def getValues(self, data): self.grp = CCD(data[0], "UA", 3) if self.df.repprt[2] != "export": if self.lstgrp and self.lstgrp != self.grp.work: self.groupTotal() cod = CCD(data[1], "NA", 20) dsc = CCD(data[2], "NA", 30) uoi = CCD(data[3], "NA", 10) bals = Balances(self.opts["mf"], "STR", self.opts["conum"], self.coffw, keys=(self.grp.work, cod.work, self.loc, ("S", self.start))) more = [] if self.chain: more.append(("stt_chain", "=", self.chain)) if self.acno: more.append(("stt_acno", "in", tuple(self.acno))) this, hist = bals.doStrHist(more=more) bals = hist[2] purchd = "" purchw = [] tot = 0 for x in range(11, -1, -1): if self.rtype == "Q": amt = float(ASD(0) - ASD(bals[x][0])) elif self.rtype == "V": amt = float(ASD(0) - ASD(bals[x][2])) else: amt = float(ASD(0) - ASD(bals[x][2]) + ASD(bals[x][1])) amt = CCD(round(amt, 0), "SI", 10) tot = float(ASD(tot) + ASD(amt.work)) self.stots[x] = float(ASD(self.stots[x]) + ASD(amt.work)) self.gtots[x] = float(ASD(self.gtots[x]) + ASD(amt.work)) purchd = purchd + amt.disp purchw.append(amt.work) if tot == 0: return return (cod, dsc, uoi, amt, purchd, purchw)
def printReport(self, recs): p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True) self.head = "%03u %-169s" % (self.opts["conum"], self.opts["conam"]) self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head) self.stots = [0] * 13 self.ctots = [0] * 13 self.pglin = 999 for x1, r1 in enumerate(recs): p.displayProgress(x1) if p.quit: break rep = CCD(r1[0], "Na", 3) name = CCD(r1[1], "NA", 30) bals = Balances(self.opts["mf"], "STR", self.opts["conum"], self.end, (rep.work,)) this, hist = bals.doStrHist(self.start) if this == 0: continue costsd = "" salesd = "" proftd = "" prperd = "" prt = False mchart = ["T", name.work] for x2 in range(11,-1,-1): c = float(ASD(0) - ASD(hist[2][x2][1])) c = CCD(round(c, 0), "SL", 11) s = float(ASD(0) - ASD(hist[2][x2][2])) s = CCD(round(s, 0), "SL", 11) if c.work or s.work: prt = True prf = float(ASD(s.work) - ASD(c.work)) prf = CCD(round(prf, 0), "SL", 11) if s.work == 0: pcn = 0 else: pcn = round((prf.work * 100.0 / s.work), 2) pcn = CCD(pcn, "SD", 11.2) self.ctots[x2] = self.ctots[x2] + c.work self.stots[x2] = self.stots[x2] + s.work costsd = costsd + c.disp salesd = salesd + s.disp proftd = proftd + prf.disp prperd = prperd + pcn.disp mchart.append(s.work) if not prt: continue self.mchart.append(mchart) if self.pglin > (self.fpdf.lpp - 5): self.pageHeading() self.fpdf.drawText("%s %s %-6s %s" % (rep.disp, name.disp, "Sales", salesd)) self.fpdf.drawText("%-34s %-6s %s" % ("", "Costs ", costsd)) self.fpdf.drawText("%-34s %-6s %s" % ("", "Profit", proftd)) self.fpdf.drawText("%-34s %-6s %s" % ("", "Prf-% ", prperd)) self.fpdf.underLine(txt=self.head) self.pglin += 5 p.closeProgress() if self.fpdf.page and not p.quit: self.grandTotal() if "args" not in self.opts or "noprint" not in self.opts["args"]: pdfnam = getModName(self.opts["mf"].rcdic["wrkdir"], self.__class__.__name__, self.opts["conum"], ext="pdf") self.fpdf.output(pdfnam, "F") doPrinter(mf=self.opts["mf"], conum=self.opts["conum"], pdfnam=pdfnam, header=self.tit, repprt=self.df.repprt, fromad=self.fromad, repeml=self.df.repeml) CreateChart(self.opts["mf"], self.opts["conum"], self.opts["conam"], [self.start, self.end], [[self.opts["conam"], "Saleman's Sales History"], "Values"], None, self.mchart)
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