def getValues(self, data): grp = CCD(data[0], "UA", 3) code = CCD(data[1], "NA", 20) desc = CCD(data[2], "UA", 30) uoi = CCD(data[3], "NA", 10) whr = [("st2_cono", "=", self.opts["conum"]), ("st2_group", "=", grp.work), ("st2_code", "=", code.work)] if self.loc: whr.append(("st2_loc", "=", self.loc)) st2 = self.sql.getRec( "strmf2", cols=["st2_reord_ind", "st2_reord_level", "st2_reord_qty"], where=whr, limit=1) if not st2: return if self.zero == "N" and not st2[1]: return req = CCD(st2[1], "SD", 12.2) bals = Balances(self.opts["mf"], "STR", self.opts["conum"], int(self.repdtw / 100), keys=(grp.work, code.work, self.loc)) cbal, obal, bbal = bals.doStrOrds() tbal = float(ASD(cbal.work) + ASD(obal.work) - ASD(bbal.work)) if req.work < tbal: if self.zero == "N": return tbal = CCD(0, "SD", 12.2) return (grp, code, desc, uoi, cbal, obal, bbal, tbal) tbal = float(ASD(req.work) - ASD(tbal)) if tbal < st2[2]: tbal = st2[2] tbal = CCD(tbal, "SD", 12.2) if self.zero == "N" and not tbal.work: return if self.zero == "Y" and not cbal.work and not obal.work and not \ bbal.work and not tbal.work: return return (grp, code, desc, uoi, cbal, obal, bbal, tbal)
def loadBalances(self): bals = Balances(self.opts["mf"], "STR", self.opts["conum"], int(self.sysdtw / 100), keys=(self.group, self.code, self.loc, ("P", self.opts["period"][0]))) m_ob, m_mv, m_cb, y_ob, y_mv, y_cb, ac, lc, ls = bals.doStrBals() cb, oo, bo = bals.doStrOrds() this, hist = bals.doStrHist() rec = hist[0] rec.append(this[0]) iss = hist[1] iss.append(this[1]) lrec = self.sql.getRec("strtrn", cols=["max(stt_trdt)"], where=[("stt_cono", "=", self.opts["conum"]), ("stt_group", "=", self.group), ("stt_code", "=", self.code), ("stt_loc", "=", self.loc), ("stt_type", "in", (1, 3))]) if not lrec[0][0]: lastrec = 0 else: lastrec = lrec[0][0] liss = self.sql.getRec("strtrn", cols=["max(stt_trdt)"], where=[("stt_cono", "=", self.opts["conum"]), ("stt_group", "=", self.group), ("stt_code", "=", self.code), ("stt_loc", "=", self.loc), ("stt_type", "in", (2, 4, 7, 8))]) if not liss or not liss[0][0]: lastiss = 0 else: lastiss = liss[0][0] qbal = float(y_cb[0]) vbal = float(y_cb[1]) if qbal: cost = round((vbal / qbal), 2) else: cost = 0.0 cst = CCD(cost, "SD", 10.2) self.df.loadEntry("T", 2, 0, data=lastrec) self.df.loadEntry("T", 2, 1, data=lastiss) self.df.loadEntry("T", 2, 2, data=qbal) self.df.loadEntry("T", 2, 3, data=vbal) self.df.loadEntry("T", 2, 4, data=cst.disp) self.df.loadEntry("T", 2, 5, data=oo.disp) self.df.loadEntry("T", 2, 6, data=bo.disp) p = 0 for x in range(0, 13): i = 0 self.df.loadEntry("C", 3, p, data=rec[x][0]) p = p + 1 i = i + 1 self.df.loadEntry("C", 3, p, data=rec[x][1]) p = p + 1 i = i + 1 amt = float(ASD(0) - ASD(iss[x][0])) self.df.loadEntry("C", 3, p, data=amt) p = p + 1 i = i + 1 amt = float(ASD(0) - ASD(iss[x][1])) self.df.loadEntry("C", 3, p, data=amt) p = p + 1 i = i + 1