def doGetBalTrn(self): if self.paid == "Y": trans = "A" else: trans = "Y" bals = Balances(self.opts["mf"], "MEM", self.opts["conum"], self.curdt, (self.memno, )) self.obal, self.tbal, self.ages, self.mlt = bals.doAllBals(trans=trans) lnk = self.sql.getRec("memlnk", cols=["mll_lnkno"], where=[("mll_cono", "=", self.opts["conum"]), ("mll_memno", "=", self.memno)]) if not lnk: return for l in lnk: bals = Balances(self.opts["mf"], "MEM", self.opts["conum"], self.curdt, (l[0], )) obal, tbal, ages, mlt = bals.doAllBals(trans=trans) for n, d in enumerate(mlt[1]): mlt[1][n][mlt[0].index("mlt_desc")] = "%s (%s)" % \ (d[mlt[0].index("mlt_desc")][:30], d[mlt[0].index("mlt_memno")]) self.obal = float(ASD(self.obal) + ASD(obal)) self.tbal = float(ASD(self.tbal) + ASD(tbal)) for x in range(5): self.ages[x] = float(ASD(self.ages[x]) + ASD(ages[x])) self.mlt[1].extend(mlt[1]) self.mlt[2] += mlt[2] # Sort Transaction by Date self.mlt[1].sort(key=lambda x: x[mlt[0].index("mlt_trdt")])
def getValues(self, data): acc = CCD(data[0], "UI", 6) name = CCD("%s, %s %s" % (data[3], data[1], data[2]), "NA", 30) bals = Balances(self.opts["mf"], "MEM", self.opts["conum"], self.cutoff, keys=(acc.work, )) obal, cbal, ages = bals.doAllBals() bal = CCD(cbal, "SD", 13.2) if self.limit and bal.work < self.limit: return if self.zero == "Y" and not bal.work: return if self.credit == "N" and bal.work < 0: return if self.onlycr == "Y" and bal.work >= 0: return cur = CCD(ages[0], "SD", 13.2) d30 = CCD(ages[1], "SD", 13.2) d60 = CCD(ages[2], "SD", 13.2) d90 = CCD(ages[3], "SD", 13.2) d120 = CCD(ages[4], "SD", 13.2) if bal.work < 0: deb = CCD(bal.work, "SD", 13.2) else: deb = CCD(0, "SD", 13.2) self.gtots[0] = float(ASD(self.gtots[0]) + ASD(deb.work)) self.gtots[1] = float(ASD(self.gtots[1]) + ASD(bal.work)) self.gtots[2] = float(ASD(self.gtots[2]) + ASD(cur.work)) self.gtots[3] = float(ASD(self.gtots[3]) + ASD(d30.work)) self.gtots[4] = float(ASD(self.gtots[4]) + ASD(d60.work)) self.gtots[5] = float(ASD(self.gtots[5]) + ASD(d90.work)) self.gtots[6] = float(ASD(self.gtots[6]) + ASD(d120.work)) return (acc, name, deb, bal, cur, d30, d60, d90, d120)
def printReport(self, recs): p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True) self.head = "%03u %-95s" % (self.opts["conum"], self.opts["conam"]) self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head) self.tots = [0, 0] self.pglin = 999 for num, dat in enumerate(recs): p.displayProgress(num) if p.quit: break chn = CCD(dat[self.col.index("drm_chain")], "UI", 3) acno = CCD(dat[self.col.index("drm_acno")], "NA", 7) name = CCD(dat[self.col.index("drm_name")], "NA", 30) rft = CCD(dat[self.col.index("drm_rfterms")], "UI", 3) per = CCD(dat[self.col.index("drm_int_per")], "UD", 5.2) if not per.work: if not self.defrte: continue per = CCD(self.defrte, "UD", 5.2) bals = Balances(self.opts["mf"], "DRS", self.opts["conum"], int(self.cutoff / 100), (chn.work, acno.work)) obal, tbal, ages = bals.doAllBals() if tbal <= 0: continue bal = CCD(tbal, "SD", 13.2) tm = int(rft.work / 30) if tm > 4: tm = 4 od = 0 for x in range(tm, 5): od = float(ASD(od) + ASD(ages[x])) odu = CCD(od, "SD", 13.2) if odu.work <= 0 or (self.minbal and odu.work < self.minbal): continue b = round((odu.work * per.work / 1200), 2) amt = CCD(b, "SD", 13.2) if self.pglin > self.fpdf.lpp: self.pageHeading() self.fpdf.drawText("%s %s %s %s %s %s %s %s" % \ (chn.disp, acno.disp, name.disp, rft.disp, bal.disp, odu.disp, per.disp, amt.disp)) self.pglin += 1 self.tots[0] = float(ASD(self.tots[0]) + ASD(odu.work)) self.tots[1] = float(ASD(self.tots[1]) + ASD(amt.work)) p.closeProgress() if self.fpdf.page and not p.quit: self.grandTotal() 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)
def doProcess(self): self.df.closeProcess() recs = self.sql.getRec("drsmst", where=[("drm_cono", "=", self.opts["conum"]), ("drm_stat", "<>", "X")], order="drm_chain, drm_name") if recs: col = self.sql.drsmst_col p = ProgressBar(self.opts["mf"].body, typ="Calculating Ratings", mxs=len(recs)) for num, rec in enumerate(recs): p.displayProgress(num) chn = rec[col.index("drm_chain")] acc = rec[col.index("drm_acno")] rft = int(rec[col.index("drm_rfterms")] / 30) rjt = int(rec[col.index("drm_rjterms")] / 30) lim = rec[col.index("drm_limit")] stp = rec[col.index("drm_stop")] rte = rec[col.index("drm_rating")] if rte == "B" or stp == "Y": rating = "B" else: rating = None bal = Balances(self.opts["mf"], "DRS", self.opts["conum"], self.curdt, [chn, acc]) obal, cbal, age = bal.doAllBals() if cbal > 0: if lim and cbal > lim: rating = "P" if not rating and rft > 0: bal = 0 for y in range(rft - 1, 5): bal = float(ASD(bal) + ASD(age[y])) if bal > 0: rating = "F" if not rating and rjt > 0: bal = 0 for y in range(rjt - 1, 5): bal = float(ASD(bal) + ASD(age[y])) if bal > 0: rating = "B" if not rating and rte in ("", "N"): rating = "G" elif self.ignore == "N" and cbal == 0 and rte in ("", "N"): rating = "G" if rating: self.sql.updRec("drsmst", cols=["drm_rating"], data=[rating], where=[("drm_cono", "=", self.opts["conum"]), ("drm_chain", "=", chn), ("drm_acno", "=", acc)]) p.closeProgress() self.opts["mf"].dbm.commitDbase(ask=True) self.opts["mf"].closeLoop()
def loadBalances(self): bals = Balances(self.opts["mf"], "DRS", self.opts["conum"], int(self.sysdtw / 100), (self.chain, self.acno)) obal, tbal, ages = bals.doAllBals() this, hist = bals.doCrsDrsHist() self.sale = hist[0] self.pays = hist[1] last = self.sql.getRec("drstrn", cols=["max(drt_trdt)"], where=[("drt_cono", "=", self.opts["conum"]), ("drt_chain", "=", self.chain), ("drt_acno", "=", self.acno), ("drt_type", "=", 1)], limit=1) if not last or not last[0]: lastsald = 0 else: lastsald = last[0] last = self.sql.getRec("drstrn", cols=["max(drt_trdt)"], where=[("drt_cono", "=", self.opts["conum"]), ("drt_chain", "=", self.chain), ("drt_acno", "=", self.acno), ("drt_type", "=", 5)], limit=1) if not last or not last[0]: lastpayd = 0 else: lastpayd = last[0] for x in range(0, 8): if x == 0: data = lastsald elif x == 1: data = lastpayd elif x == 2: data = tbal else: data = ages[x - 3] self.df.loadEntry("T", 3, x, data=data) p = 0 for x in range(0, 13): i = 0 self.df.loadEntry("C", 4, p, data=self.sale[x]) p = p + 1 i = i + 1 pay = float(ASD(0) - ASD(self.pays[x])) self.df.loadEntry("C", 4, p, data=pay) p = p + 1 i = i + 1
def getValues(self, data): chn = CCD(data[0], "UI", 3) acc = CCD(data[1], "NA", 7) name = CCD(data[2], "NA", 30) if self.base == "A": bals = Balances(self.opts["mf"], "DRS", self.opts["conum"], self.cutoff, keys=(data[0], data[1])) obal, cbal, ages = bals.doAllBals() else: pers = [] yr = int(self.cutoff / 100) mt = int(self.cutoff % 100) for x in range(4): pers.append((yr * 100) + mt) mt -= 1 if not mt: yr -= 1 mt = 12 cbal = 0 ages = [0, 0, 0, 0, 0] bals = self.sql.getRec("drstrn", cols=["drt_curdt", "sum(drt_tramt)"], where=[("drt_cono", "=", self.opts["conum"]), ("drt_chain", "=", chn.work), ("drt_acno", "=", acc.work), ("drt_curdt", "<=", pers[0])], group="drt_curdt", order="drt_curdt") for bal in bals: try: idx = pers.index(bal[0]) except: idx = 4 ages[idx] = float(ASD(ages[idx]) + ASD(bal[1])) cbal = float(ASD(cbal) + ASD(bal[1])) bal = CCD(cbal, "SD", 13.2) if self.limit and bal.work < self.limit: return if self.zero == "Y" and not bal.work: return if self.credit == "N" and bal.work < 0: return if self.credit == "O" and bal.work >= 0: return cur = CCD(ages[0], "SD", 13.2) d30 = CCD(ages[1], "SD", 13.2) d60 = CCD(ages[2], "SD", 13.2) d90 = CCD(ages[3], "SD", 13.2) d120 = CCD(ages[4], "SD", 13.2) if bal.work < 0: deb = CCD(bal.work, "SD", 13.2) else: deb = CCD(0, "SD", 13.2) self.gtots[0] = float(ASD(self.gtots[0]) + ASD(deb.work)) self.gtots[1] = float(ASD(self.gtots[1]) + ASD(bal.work)) self.gtots[2] = float(ASD(self.gtots[2]) + ASD(cur.work)) self.gtots[3] = float(ASD(self.gtots[3]) + ASD(d30.work)) self.gtots[4] = float(ASD(self.gtots[4]) + ASD(d60.work)) self.gtots[5] = float(ASD(self.gtots[5]) + ASD(d90.work)) self.gtots[6] = float(ASD(self.gtots[6]) + ASD(d120.work)) return (chn, acc, name, deb, bal, cur, d30, d60, d90, d120)
def doProcess(self, drm): dmc = self.sql.drsmst_col dtc = self.sql.drstrn_col tdc = self.form.sql.tpldet_col self.chn = drm[dmc.index("drm_chain")] self.acc = drm[dmc.index("drm_acno")] eml = drm[dmc.index("drm_acc_email")] self.form.account_details("drm", dmc, drm, 1) if drm[dmc.index("drm_stames")]: self.mesno = drm[dmc.index("drm_stames")] else: self.mesno = self.mess for col in dmc: d = "%s_C00" % col if d in self.form.newdic: dat = drm[dmc.index(col)] self.form.newdic[d][tdc.index("tpd_text")] = dat bals = Balances(self.opts["mf"], "DRS", self.opts["conum"], self.curdt, (self.chn, self.acc)) if self.alloc == "Y": tt = "A" else: tt = "Y" obal, self.tbal, self.ages, trns = bals.doAllBals(trans=tt) if not trns[1]: return if self.sttyp == "O": self.tots = [0.0, 0.0, 0.0] cmth = False tran = copyList(trns[1]) for t in tran: if t[dtc.index("drt_type")] not in (2, 6) and \ t[dtc.index("drt_curdt")] == self.curdt: self.tots[1] = float(ASD(self.tots[1]) + \ ASD(t[dtc.index("drt_tramt")])) if t[dtc.index("drt_taxamt")]: self.tots[1] = float(ASD(self.tots[1]) - \ ASD(t[dtc.index("drt_taxamt")])) self.tots[2] = float(ASD(self.tots[2]) + \ ASD(t[dtc.index("drt_taxamt")])) else: self.tots[0] = float(ASD(self.tots[0]) + \ ASD(t[dtc.index("drt_tramt")])) if t[dtc.index("drt_curdt")] == self.curdt: cmth = True elif self.oitem == "N": trns[1].remove(t) if self.zeros == "N" and not self.tbal and not cmth: return if self.minus == "N" and self.tbal < 0: return if self.oitem == "N" and obal: t[trns[0].index("drt_type")] = 3 t[trns[0].index("drt_ref1")] = "O/Bal" t[trns[0].index("drt_batch")] = "" t[trns[0].index("drt_trdt")] = (self.curdt * 100) + 1 t[trns[0].index("drt_ref2")] = "" t[trns[0].index("drt_tramt")] = obal t[trns[0].index("drt_taxamt")] = 0 t[trns[0].index("drt_desc")] = "Opening Balance" t[trns[0].index("drt_taxind")] = "" t[trns[0].index("drt_batind")] = "" trns[1].insert(0, t) if len(trns[1]) <= self.form.maxlines: self.doBody(trns[0], trns[1], tdc) else: pages = int(len(trns[1]) / self.form.maxlines) if len(trns[1]) % self.form.maxlines: pages += 1 if pages <= self.pages: self.doBody(trns[0], trns[1], tdc) else: bal = 0 lines = len( trns[1]) - (self.pages * self.form.maxlines) + 1 for _ in range(lines): trn = trns[1].pop(0) bal = float( ASD(bal) + ASD(trn[dtc.index("drt_tramt")])) trn[trns[0].index("drt_type")] = 3 trn[trns[0].index("drt_ref1")] = "B/FWD" trn[trns[0].index("drt_batch")] = "" trn[trns[0].index("drt_ref2")] = "" trn[trns[0].index("drt_tramt")] = bal trn[trns[0].index("drt_taxamt")] = 0 trn[trns[0].index("drt_desc")] = "Balance Brought Forward" trn[trns[0].index("drt_taxind")] = "" trn[trns[0].index("drt_batind")] = "" trns[1].insert(0, trn) self.doBody(trns[0], trns[1], tdc) else: if self.zeros == "N" and not self.tbal: return if self.minus == "N" and self.tbal < 0: return self.doBody(trns[0], trns[1], tdc) self.doTotal(tdc) self.doTail(tdc) if self.df.repeml[1] == "Y" and not self.emadd: self.df.repeml[2] = eml self.doPrint()