def doEnd(self): self.df.closeProcess() if self.opts["period"][0] == 1: self.sql.updRec("ctlynd", cols=["cye_start", "cye_end"], data=[self.s0, self.e0], where=[("cye_cono", "=", self.opts["conum"]), ("cye_period", "=", 0)]) for per in self.pers: num = per[self.sql.ctlynd_col.index("cye_period")] if num == self.opts["period"][0]: self.start = self.s_per self.end = self.e_per else: self.start = self.getStartDate(self.end) self.end = self.getEndDate(self.start) self.sql.updRec("ctlynd", cols=["cye_start", "cye_end"], data=[self.start, self.end], where=[("cye_cono", "=", self.opts["conum"]), ("cye_period", "=", num)]) spl = SplashScreen(self.opts["mf"].body, text="Running Year End Routine for Period %s" % num) per = getPeriods(self.opts["mf"], self.opts["conum"], num - 1) per = (num - 1, (per[0].work, per[0].disp), (per[1].work, per[1].disp)) callModule(self.opts["mf"], None, "msy010", coy=(self.opts["conum"], self.opts["conam"]), period=per, user=self.opts["capnm"], args="N") spl.closeSplash() self.opts["mf"].dbm.commitDbase(ask=True) self.opts["mf"].closeLoop()
def setVariables(self): self.sql = Sql(self.opts["mf"].dbm, ["genmst", "genbal", "genbud", "gentrn"], prog=self.__class__.__name__) if self.sql.error: return t = time.localtime() self.sysdtd = "%i/%02i/%02i" % (t[0], t[1], t[2]) self.i_per = int(self.opts["period"][1][0] / 100) self.e_per = int(self.opts["period"][2][0] / 100) df = self.e_per - self.i_per - 87 if df > 12: self.d_per = df - 12 yr = int(self.i_per / 100) mt = int(self.i_per % 100) for _ in range(self.d_per): mt += 1 if mt > 12: mt -= 12 yr += 1 self.s_per = (yr * 100) + mt else: self.d_per = 0 self.s_per = self.i_per self.d_pyr = 0 if self.opts["period"][0]: s, e, f = getPeriods(self.opts["mf"], self.opts["conum"], (self.opts["period"][0] - 1)) if (s, e, f) == (None, None, None): return self.s_lyr = s.work self.i_pyr = int(s.work / 100) self.e_pyr = int(e.work / 100) df = self.e_pyr - self.i_pyr - 87 if df > 12: self.d_pyr = df - 12 yr = int(self.i_pyr / 100) mt = self.i_pyr % 100 for _ in range(self.d_pyr): mt += 1 if mt > 12: mt -= 12 yr += 1 self.s_pyr = (yr * 100) + mt else: self.s_pyr = self.i_pyr self.trnper = 0 return True
def setVariables(self): self.sql = Sql(self.opts["mf"].dbm, ["ctlynd", "wagmst", "waglmf", "wagltf"], prog=self.__class__.__name__) if self.sql.error: return gc = GetCtl(self.opts["mf"]) wagctl = gc.getCtl("wagctl", self.opts["conum"]) if not wagctl: return t = time.localtime() self.sysdtw = (t[0] * 10000) + (t[1] * 100) + t[2] self.sysdtd = "%i/%02i/%02i" % (t[0], t[1], t[2]) # Get the current period starting date period = self.sql.getRec("ctlynd", cols=["max(cye_period)"], where=[("cye_cono", "=", self.opts["conum"])], limit=1)[0] self.opts["period"] = getPeriods(self.opts["mf"], self.opts["conum"], period)[0].work return True
def doEnd(self): self.df.closeProcess() tabels = [("genmst", "glm")] if self.df.t_work[0][0][1] == "Y": tabels.append(("ctlctl", "ctl")) if self.df.t_work[0][0][2] == "Y": tabels.append(("genbal", "glo")) if self.df.t_work[0][0][3] == "Y": tabels.append(("gentrn", "glt")) if self.df.t_work[0][0][4] == "Y": tabels.append(("genbud", "glb")) if self.df.t_work[0][0][5] == "Y": tabels.append(("genjlm", "gjm")) tabels.append(("genjlt", "gjt")) if self.df.t_work[0][0][6] == "Y": tabels.append(("genrpt", "glr")) if self.df.t_work[0][0][7] == "Y": tabels.append(("gendtm", "gdm")) tabels.append(("gendtt", "gdt")) if self.df.t_work[0][0][8] == "Y": tabels.append(("genstr", "gls")) for tab, ref in tabels: self.sql.delRec(tab, where=[("%s_cono" % ref, "=", self.opts["conum"])]) recs = self.sql.getRec(tables=tab, where=[("%s_cono" % ref, "=", self.oldco)]) if recs: p = ProgressBar(self.opts["mf"].body, mxs=len(recs), typ="Copying %s" % tab) for num, acc in enumerate(recs): p.displayProgress(num) coy = "%s_cono" % ref col = getattr(self.sql, "%s_col" % tab) acc[col.index(coy)] = self.opts["conum"] self.sql.insRec(tab, data=acc) p.closeProgress() if self.df.t_work[0][0][9] == "Y": self.sql.delRec("ctlynd", where=[("cye_cono", "=", self.opts["conum"])]) ynds = self.sql.getRec("ctlynd", where=[("cye_cono", "=", self.oldco), ("cye_period", "in", (0, 1))], order="cye_period") for ynd in ynds: ynd[0] = self.opts["conum"] self.sql.insRec("ctlynd", data=ynd) mxp = self.sql.getRec("ctlynd", cols=["max(cye_period)"], where=[("cye_cono", "=", self.oldco)], limit=1) for p in range(1, mxp[0]): pr = getPeriods(self.opts["mf"], self.oldco, p) per = (p, (pr[0].work, pr[0].disp), (pr[1].work, pr[1].disp)) callModule(self.opts["mf"], None, "msy010", coy=(self.opts["conum"], self.opts["conam"]), period=per, user=self.opts["capnm"], args=pr[2]) self.opts["mf"].dbm.commitDbase(ask=True) self.opts["mf"].closeLoop()
def doYearEnd(self, per): self.sql.updRec("ctlynd", cols=["cye_last", "cye_final"], data=[self.sysdtw, self.final], where=[("cye_cono", "=", self.opts["conum"]), ("cye_period", "=", per)]) if per == self.c_per: start_c = self.start end_c = self.end if (per + 1) > self.l_per: newy = int(end_c / 10000) newm = (int(end_c / 100) % 100) + 1 if newm > 12: newy += 1 newm -= 12 news = (newy * 10000) + (newm * 100) + 1 newy = int(end_c / 10000) + 1 newm = int(end_c / 100) % 100 newe = (newy * 10000) + (newm * 100) + 1 newe = mthendDate(newe) self.sql.insRec( "ctlynd", data=[self.opts["conum"], (per + 1), news, newe, 0, "N"]) else: s, e, f = getPeriods(self.opts["mf"], self.opts["conum"], per) if s is None or e is None: return start_c = s.work end_c = e.work sp = int(start_c / 100) ep = int(end_c / 100) s, e, f = getPeriods(self.opts["mf"], self.opts["conum"], (per + 1)) start_n = s.work if "GL" not in self.mod: return self.sql.delRec("genbal", where=[("glo_cono", "=", self.opts["conum"]), ("glo_trdt", "=", start_n)]) gm = self.sql.getRec("genmst", cols=["glm_acno, glm_type"], where=[("glm_cono", "=", self.opts["conum"])]) if gm: for ac in gm: ov = self.sql.getRec("genbal", cols=["glo_cyr"], where=[("glo_cono", "=", self.opts["conum"]), ("glo_acno", "=", ac[0]), ("glo_trdt", "=", start_c)], limit=1) if not ov: ov = CCD(0, "SD", 13.2) else: ov = CCD(ov[0], "SD", 13.2) cy = self.sql.getRec("gentrn", cols=["round(sum(glt_tramt), 2)"], where=[("glt_cono", "=", self.opts["conum"]), ("glt_acno", "=", ac[0]), ("glt_curdt", "between", sp, ep)], limit=1) if not cy[0]: cy = CCD(0, "SD", 13.2) else: cy = CCD(cy[0], "SD", 13.2) bal = float(ASD(ov.work) + ASD(cy.work)) if ac[1] == "P": self.retinc = float(ASD(self.retinc) + ASD(bal)) bal = 0.00 self.sql.insRec("genbal", data=[self.opts["conum"], ac[0], start_n, bal]) ri_bal = self.sql.getRec("genbal", cols=["glo_cyr"], where=[("glo_cono", "=", self.opts["conum"]), ("glo_acno", "=", self.ri_acc), ("glo_trdt", "=", start_n)], limit=1) if not ri_bal: self.sql.insRec("genbal", data=[ self.opts["conum"], self.ri_acc, start_n, self.retinc ]) else: bal = float(ASD(ri_bal[0]) + ASD(self.retinc)) self.sql.updRec("genbal", cols=["glo_cyr"], data=[bal], where=[("glo_cono", "=", self.opts["conum"]), ("glo_acno", "=", self.ri_acc), ("glo_trdt", "=", start_n)])
for o, v in opts: if o == "-c": coy = int(v) elif o == "-p": num = int(v) elif o == "-f": fin = v.upper() elif o == "-r": rcf = v if not num: num = 0 mf = MainFrame(xdisplay=False) mf.dbm = Dbase(rcdic=loadRcFile(rcfile=rcf)) if not mf.dbm.err: mf.dbm.openDbase() per = getPeriods(mf, coy, num) if per[1] and per[2]: per = (num, (per[0].work, per[0].disp), (per[1].work, per[1].disp)) ex = msy010( **{ "mf": mf, "conum": coy, "period": per, "capnm": "paul", "args": fin }) else: print("Invalid Period %s for Company %s" % (num, coy)) mf.dbm.closeDbase() # vim:set ts=4 sw=4 sts=4 expandtab: