def loadBalances(self): bals = Balances(self.opts["mf"], "ASS", self.opts["conum"], self.sper, keys=(self.group, self.code)) asset = bals.doAssBals(start=self.sper, end=self.eper, trans="C") if not asset: return cap, cdp, rdp, cbl, rbl, mov, trn = asset dte = self.sql.getRec("asstrn", cols=["min(ast_date)"], where=[("ast_cono", "=", self.opts["conum"]), ("ast_group", "=", self.group), ("ast_code", "=", self.code), ("ast_mtyp", "=", 1)], limit=1) if dte[0]: val = self.sql.getRec("asstrn", cols=["ast_amt1"], where=[("ast_cono", "=", self.opts["conum"]), ("ast_group", "=", self.group), ("ast_code", "=", self.code), ("ast_mtyp", "=", 1), ("ast_date", "=", dte[0])], limit=1) self.df.loadEntry("T", 2, 0, data=dte[0]) self.df.loadEntry("T", 2, 1, data=val[0]) self.df.loadEntry("C", 2, 0, data=cbl) if self.rordp == "Y": self.df.loadEntry("C", 2, 1, data=rbl) else: self.df.loadEntry("C", 2, 1, data=0) if mov: for n, c, r in mov: if self.rordp == "Y": p = n * 2 else: p = n cbl = float(ASD(cbl) + ASD(c)) if self.rordp == "Y": rbl = float(ASD(rbl) + ASD(r)) self.df.loadEntry("C", 2, p, data=c) if self.rordp == "Y": self.df.loadEntry("C", 2, p + 1, data=r) if self.rordp == "Y": self.df.loadEntry("C", 2, 12, data=cbl) self.df.loadEntry("C", 2, 13, data=rbl) else: self.df.loadEntry("C", 2, 6, data=cbl)
def getValues(self, data): bals = Balances(self.opts["mf"], "ASS", self.opts["conum"], self.sper, keys=(data[0], data[1])) asset = bals.doAssBals(start=self.sper, end=self.endper) if not asset: return cap, cdp, rdp, cbl, rbl, mov = asset vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] vals[0] = cap if self.rtype == "C": vals[1] = cdp vals[2] = cbl vals[9] = cbl else: vals[1] = rdp vals[2] = rbl vals[9] = rbl woff = False sold = False if mov: for m in mov: if m[0] == 3: woff = True if m[0] == 5: sold = True if self.rtype == "C": idx = 1 else: idx = 2 vals[m[0] + 2] = float(ASD(vals[m[0] + 2]) + ASD(m[idx])) vals[9] = float(ASD(vals[9]) + ASD(m[idx])) if woff or sold: vals[8] = vals[9] vals[9] = 0 if self.zero == "Y" and all(v == 0 for v in vals[2:10]): return return vals
def doRaiseAll(self, recs): if not self.args: p = ProgressBar(self.opts["mf"].body, mxs=len(recs), typ="Raising Depreciation ... Please Wait") for num, dat in enumerate(recs): if not self.args: p.displayProgress(num) self.group = CCD(dat[self.sql.assmst_col.index("asm_group")], "UA", 3) grp = self.sql.getRec("assgrp", where=[("asg_cono", "=", self.opts["conum"]), ("asg_group", "=", self.group.work)], limit=1) if not grp: if not self.args: showError(self.opts["mf"].body, "Group Error", "Missing Group (%s) Record" % self.group.disp) abort = True break self.depacc = grp[self.sql.assgrp_col.index("asg_depacc")] self.expacc = grp[self.sql.assgrp_col.index("asg_expacc")] self.code = dat[self.sql.assmst_col.index("asm_code")] depcod = dat[self.sql.assmst_col.index("asm_depcod")] # Get Depreciation Record self.dep = self.sql.getRec(tables="assdep", where=[("asd_cono", "=", self.opts["conum"]), ("asd_code", "=", depcod)], limit=1) if not self.dep: showError(self.opts["mf"].body, "Error", "Depreciation Code %s Does Not Exist.\n\n"\ "Aborting." % depcod) abort = True break bals = Balances(self.opts["mf"], "ASS", self.opts["conum"], self.sper, keys=(self.group.work, self.code)) asset = bals.doAssBals() if not asset: continue self.cap, cdp, rdp, cbl, rbl, mov = asset # Raise depreciation from start period to curdt or sale date self.lurdt = self.sper sales = False while not sales and self.lurdt <= self.curdt: trans = self.sql.getRec( "asstrn", cols=["ast_mtyp", "round(sum(ast_amt1), 2)"], where=[("ast_cono", "=", self.opts["conum"]), ("ast_group", "=", self.group.work), ("ast_code", "=", self.code), ("ast_curdt", "=", self.lurdt), ("ast_mtyp", "<>", 4)], group="ast_mtyp") if trans: for mov, amt in trans: if mov == 5: sales = True self.cap = 0 break self.cap = float(ASD(self.cap) + ASD(amt)) if self.cap: self.doRaiseDep() self.lurdt = self.doIncrCurdt() if not self.args: p.closeProgress() if abort: self.opts["mf"].dbm.rollbackDbase() else: self.sql.updRec("assctl", cols=["cta_lastp"], data=[self.curdt], where=[("cta_cono", "=", self.opts["conum"])]) self.opts["mf"].dbm.commitDbase()
def printReport(self, recs): p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True) if self.rordp == "Y": self.head = "%03u %-118s" % (self.opts["conum"], self.opts["conam"]) else: self.head = "%03u %-91s" % (self.opts["conum"], self.opts["conam"]) self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head) oldgrp = "" oldcod = "" self.pglin = 999 mc = self.sql.assmst_col for num, dat in enumerate(recs): p.displayProgress(num) if p.quit: break self.grp = CCD(dat[mc.index("asm_group")], "UA", 3) self.cod = CCD(dat[mc.index("asm_code")], "Na", 7) self.desc = CCD(dat[mc.index("asm_desc")], "NA", 30) bals = Balances(self.opts["mf"], "ASS", self.opts["conum"], self.sper, keys=(self.grp.work, self.cod.work)) asset = bals.doAssBals(start=self.sdate, end=self.edate, trans="C") if not asset: continue cap, cdp, rdp, cbl, rbl, mov, trn = asset self.bal1 = cbl self.bal2 = rbl if trn[0]: for z in trn[0]: dt = CCD(z[trn[1].index("ast_date")], "d1", 10) rf = CCD(z[trn[1].index("ast_refno")], "Na", 9) tp = CCD(z[trn[1].index("ast_type")], "UI", 1) bt = CCD(z[trn[1].index("ast_batch")], "Na", 7) mv = CCD(z[trn[1].index("ast_mtyp")], "UI", 1) m1 = CCD(z[trn[1].index("ast_amt1")], "SD", 13.2) m2 = CCD(z[trn[1].index("ast_amt2")], "SD", 13.2) ds = CCD(z[trn[1].index("ast_desc")], "NA", 30) if self.pglin > (self.fpdf.lpp - 10): self.pageHeading() if (oldgrp and self.grp.work != oldgrp) or \ (oldcod and self.cod.work != oldcod): if self.npag == "Y": self.pageHeading() else: self.accountHeading() self.bal1 = float(ASD(self.bal1) + ASD(m1.work)) self.bal2 = float(ASD(self.bal2) + ASD(m2.work)) b1 = CCD(self.bal1, "SD", 13.2) if self.rordp == "Y": b2 = CCD(self.bal2, "SD", 13.2) self.fpdf.drawText("%s %s %s %s %s %s %s %s %s %s" % \ (dt.disp, rf.disp, artrtp[tp.work-1][0], bt.disp, armvtp[mv.work-1][0], m1.disp, b1.disp, m2.disp, b2.disp, ds.disp)) else: self.fpdf.drawText("%s %s %s %s %s %s %s %s" % \ (dt.disp, rf.disp, artrtp[tp.work-1][0], bt.disp, armvtp[mv.work-1][0], m1.disp, b1.disp, ds.disp)) self.pglin += 1 oldgrp = self.grp.work oldcod = self.cod.work p.closeProgress() if self.fpdf.page and not p.quit: 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, repeml=self.df.repeml, fromad=self.fromad)