def last_report_elem(elem, supply_point, year, month, format=True): cell_template = '<%(elem)s class="%(classes)s">%(msg)s</%(elem)s>' state = soh_reported_on_time(supply_point, year, month) classes = "insufficient_data" msg = _("Waiting for reply") if state == OnTimeStates.NO_DATA or state == OnTimeStates.INSUFFICIENT_DATA: if format: return cell_template % { "classes": classes, "msg": msg, "elem": elem } else: return msg # check from business day to business day last_bd_of_the_month = get_business_day_of_month(year, month, -1) last_report = last_stock_on_hand_before(supply_point, last_bd_of_the_month) msg = defaultfilters.date(last_report.report_date, "d M Y") if not format: return msg if state == OnTimeStates.LATE: classes = "warning_icon iconified" elif state == OnTimeStates.ON_TIME: classes = "good_icon iconified" return cell_template % {"classes": classes, "msg": msg, "elem": elem}
def _ontime_class(cell): state = soh_reported_on_time(cell.object, cell.row.table.year, cell.row.table.month) if state == OnTimeStates.LATE: return "last_reported warning_icon iconified" elif state == OnTimeStates.ON_TIME: return "last_reported good_icon iconified"
def last_report_elem(elem, supply_point, year, month, format=True): cell_template = '<%(elem)s class="%(classes)s">%(msg)s</%(elem)s>' state = soh_reported_on_time(supply_point, year, month) classes = "insufficient_data" msg = _("Waiting for reply") if state == OnTimeStates.NO_DATA or state == OnTimeStates.INSUFFICIENT_DATA: if format: return cell_template % {"classes": classes, "msg": msg, "elem": elem} else: return msg # check from business day to business day last_bd_of_the_month = get_business_day_of_month(year, month, -1) last_report = last_stock_on_hand_before(supply_point, last_bd_of_the_month) msg = defaultfilters.date(last_report.report_date, "d M Y") if not format: return msg if state == OnTimeStates.LATE: classes = "warning_icon iconified" elif state == OnTimeStates.ON_TIME: classes = "good_icon iconified" return cell_template % {"classes": classes, "msg": msg, "elem": elem}
def soh_not_responding(self): return filter( lambda sp: soh_reported_on_time(sp, self.year, self.month) in (OnTimeStates.NO_DATA, OnTimeStates.INSUFFICIENT_DATA), self.facilities)
def soh_late(self): return filter( lambda sp: soh_reported_on_time(sp, self.year, self.month) == OnTimeStates.LATE, self.facilities)
def soh_not_responding(self): return filter(lambda sp: soh_reported_on_time(sp, self.year, self.month) in (OnTimeStates.NO_DATA, OnTimeStates.INSUFFICIENT_DATA), self.facilities)
def soh_late(self): return filter(lambda sp: soh_reported_on_time(sp, self.year, self.month) == OnTimeStates.LATE, self.facilities)