コード例 #1
0
ファイル: cr4010.py プロジェクト: paulmalherbe/Tartan
 def doPrintOption(self, opt):
     if opt == "N":
         return
     state = self.df.disableButtonsTags()
     self.df.setWidget(self.df.mstFrame, state="hide")
     if opt in ("I", "B"):
         table = "crsmst"
         whr = [
             ("crm_cono", "=", self.opts["conum"]),
             ("crm_acno", "=", self.acno)]
         rp = TabPrt(self.opts["mf"], self.opts["conum"], self.opts["conam"],
             name=self.__class__.__name__, tabs=table, where=whr,
             keys=[self.acno])
         repprt = rp.repprt
         repeml = rp.repeml
         xits = rp.xits
     else:
         repprt = None
         repeml = None
         xits = False
     if opt in ("T", "B") and not xits:
         heads = ["Creditor's Transactions",
             "Account: %s  Name: %s" % (self.acno, self.name)]
         whr = [
             ("crt_cono", "=", self.opts["conum"]),
             ("crt_acno", "=", self.acno)]
         if self.paidup == "Y":
             col, recs = getTrn(self.opts["mf"].dbm, "crs", whr=whr)
         else:
             col, recs = getTrn(self.opts["mf"].dbm, "crs",
                 dte=self.curdt, whr=whr)
         cols = []
         data = []
         dic = self.sql.crstrn_dic
         for num, rec in enumerate(recs):
             dat = []
             for nam in ["crt_ref1", "crt_trdt", "crt_type",
                     "crt_tramt", "paid", "balance", "crt_desc"]:
                 if not num:
                     if nam == "paid":
                         cols.append(["paid", "SD", 13.2, "Paid"])
                     elif nam == "balance":
                         cols.append(["balance", "SD", 13.2, "Balance"])
                     else:
                         cols.append([nam, dic[nam][2], dic[nam][3],
                             dic[nam][5]])
                 dat.append(rec[col.index(nam)])
             data.append(dat)
         if repprt:
             prtdia = False
         else:
             prtdia = (("Y","V"),("Y","N"))
         rp = RepPrt(self.opts["mf"], conum=self.opts["conum"],
             conam=self.opts["conam"], name=self.__class__.__name__,
             ttype="D", tables=data, heads=heads, cols=cols,
             trtp=["crt_type", crtrtp], prtdia=prtdia, repprt=repprt,
             repeml=repeml, fromad=self.fromad)
     self.df.setWidget(self.df.mstFrame, state="show")
     self.df.enableButtonsTags(state=state)
コード例 #2
0
ファイル: cr4010.py プロジェクト: paulmalherbe/Tartan
 def doTrans2(self, frt, pag, r, c, p, i, w):
     self.paidup = w
     whr = [
         ("crt_cono", "=", self.opts["conum"]),
         ("crt_acno", "=", self.acno)]
     if self.paidup == "Y":
         col, recs = getTrn(self.opts["mf"].dbm, "crs", whr=whr)
     else:
         col, recs = getTrn(self.opts["mf"].dbm, "crs", dte=self.curdt,
             whr=whr)
     if recs:
         data = []
         for dat in recs:
             data.append([
                 dat[col.index("crt_trdt")],
                 dat[col.index("crt_curdt")],
                 dat[col.index("crt_batch")],
                 dat[col.index("crt_type")],
                 dat[col.index("crt_ref1")],
                 dat[col.index("crt_tramt")],
                 dat[col.index("paid")],
                 dat[col.index("balance")],
                 dat[col.index("crt_desc")]])
         tit = "Transactions for Account: %s - %s" % (self.acno, self.name)
         col = (
             ("crt_trdt", "Date", 10, "D1", "N"),
             ("crt_curdt", "Curr-Dt", 7, "D2", "N"),
             ("crt_batch", "Batch", 7, "Na", "N"),
             ("crt_type", "Typ", 3, ("XX", crtrtp), "N"),
             ("crt_ref1", "Reference", 9, "Na", "Y"),
             ("crt_tramt", "Amount", 13.2, "SD", "N"),
             ("alloc", "Allocated", 13.2, "SD", "N"),
             ("balan", "Balance", 13.2, "SD", "N"),
             ("crt_desc", "Details", 30, "NA", "N"))
         state = self.df.disableButtonsTags()
         while True:
             rec = SelectChoice(self.df.nb.Page4, tit, col, data)
             # Display all transaction details
             if rec.selection:
                 self.df.setWidget(self.df.mstFrame, state="hide")
                 whr = [
                     ("crt_cono", "=", self.opts["conum"]),
                     ("crt_acno", "=", self.acno),
                     ("crt_type", "=", rec.selection[4]),
                     ("crt_ref1", "=", rec.selection[5])]
                 TabPrt(self.opts["mf"], tabs="crstrn", where=whr,
                     pdia=False)
                 self.df.setWidget(self.df.mstFrame, state="show")
             else:
                 break
         self.df.enableButtonsTags(state=state)
     self.doTrans1()
コード例 #3
0
 def dueDate(self, mst):
     txt = "Re-Calculating Due Dates"
     p = ProgressBar(self.opts["mf"].body, typ=txt, mxs=len(mst))
     for num, rec in enumerate(mst):
         p.displayProgress(num)
         acno = rec[self.sql.crsmst_col.index("crm_acno")]
         base = rec[self.sql.crsmst_col.index("crm_termsb")]
         stdt = rec[self.sql.crsmst_col.index("crm_stday")]
         term = rec[self.sql.crsmst_col.index("crm_terms")]
         col, recs = getTrn(self.opts["mf"].dbm,
                            "crs",
                            whr=[("crt_cono", "=", self.opts["conum"]),
                                 ("crt_acno", "=", acno)],
                            neg=False,
                            zer="N")
         if not recs:
             continue
         for trn in recs:
             trdt = trn[col.index("crt_trdt")]
             seq = trn[col.index("crt_seq")]
             due = paymentDate(base, stdt, term, trdt)
             self.sql.updRec("crstrn",
                             cols=["crt_paydt"],
                             data=[due],
                             where=[("crt_cono", "=", self.opts["conum"]),
                                    ("crt_acno", "=", acno),
                                    ("crt_seq", "=", seq)])
     p.closeProgress()
     self.opts["mf"].dbm.commitDbase()
コード例 #4
0
ファイル: cr3070.py プロジェクト: paulmalherbe/Tartan
 def doProcess(self, crm):
     self.pgnum = 0
     self.totbal = 0
     cmc = self.sql.crsmst_col
     self.acno = CCD(crm[cmc.index("crm_acno")], "NA", 7)
     whr = [("crt_cono", "=", self.opts["conum"]),
            ("crt_acno", "=", self.acno.work)]
     odr = "crt_curdt, crt_trdt, crt_ref1"
     self.ctc, self.crt = getTrn(self.opts["mf"].dbm,
                                 "crs",
                                 dte=self.curdt,
                                 whr=whr,
                                 odr=odr)
     if self.crt:
         if self.prnt == "N":
             self.printSetup()
         self.name = CCD(crm[cmc.index("crm_name")], "NA", 30)
         self.add1 = CCD(crm[cmc.index("crm_add1")], "NA", 30)
         self.add2 = CCD(crm[cmc.index("crm_add2")], "NA", 30)
         self.add3 = CCD(crm[cmc.index("crm_add3")], "NA", 30)
         self.pcod = CCD(crm[cmc.index("crm_pcod")], "NA", 4)
         self.terms = CCD(crm[cmc.index("crm_terms")], "UI", 3)
         self.termsb = CCD(crm[cmc.index("crm_termsb")], "NA", 1)
         self.stday = CCD(crm[cmc.index("crm_stday")], "UI", 2)
         self.pydis = CCD(crm[cmc.index("crm_pydis")], "SD", 7.2)
         self.printHeader()
         self.printBody()
コード例 #5
0
ファイル: cr3080.py プロジェクト: paulmalherbe/Tartan
 def doProcess(self, crm):
     cmc = self.sql.crsmst_col
     tdc = self.form.sql.tpldet_col
     self.acno = crm[cmc.index("crm_acno")]
     eml = crm[cmc.index("crm_acc_email")]
     self.form.account_details("crm", cmc, crm, 1)
     for col in cmc:
         d = "%s_C00" % col
         if d in self.form.newdic:
             dat = crm[cmc.index(col)]
             self.form.newdic[d][tdc.index("tpd_text")] = dat
     jon = "cra_curdt <= %s" % self.curdt
     whr = [("crt_cono", "=", self.opts["conum"]),
            ("crt_acno", "=", self.acno), ("crt_payind", "=", "Y"),
            ("crt_paydt", "<=", self.duedtw)]
     ctc, crt = getTrn(self.opts["mf"].dbm,
                       "crs",
                       jon=jon,
                       whr=whr,
                       zer="N")
     if not crt:
         return
     bal = 0
     self.pay = 0
     for d in crt:
         if d[ctc.index("balance")] < 0:
             d[ctc.index("crt_payamt")] = d[ctc.index("balance")]
         bal = float(ASD(bal) + ASD(d[ctc.index("balance")]))
         self.pay = float(ASD(self.pay) + ASD(d[ctc.index("crt_payamt")]))
     if self.pay > bal:
         self.pay = bal
     if self.pay > 0:
         self.bname = crm[cmc.index("crm_bname")]
         self.bibt = crm[cmc.index("crm_bibt")]
         self.bacc = crm[cmc.index("crm_bacc")]
         if self.bname and self.bibt and self.bacc:
             self.ptype = "E"  # Electronic
             test = False
             while not test:
                 self.cats += 1
                 self.refno = "EFT%06i" % self.cats
                 # Check if Reference Number Already Exists
                 chk = self.sql.getRec("crstrn",
                                       where=[("crt_cono", "=",
                                               self.opts["conum"]),
                                              ("crt_acno", "=", self.acno),
                                              ("crt_type", "=", 5),
                                              ("crt_ref1", "=", self.refno)
                                              ])
                 if not chk:
                     test = True
         else:
             self.ptype = "C"  # Cheque
         self.doBody(ctc, crt, tdc)
         self.doTotal(tdc)
         self.doTail(tdc)
         if self.df.repeml[1] == "Y" and not self.emadd:
             self.df.repeml[2] = eml
             self.doPrint()
コード例 #6
0
ファイル: ml6010.py プロジェクト: paulmalherbe/Tartan
 def doReAge(self):
     self.opts["mf"].updateStatus("")
     for b in range(2):
         wid = getattr(self.df, "B%s" % b)
         self.df.setWidget(wid, "disabled")
     col = [
         "mlt_trdt", "mlt_refno", "mlt_type", "mlt_tramt", "paid", "balance"
     ]
     whr = [("mlt_cono", "=", self.opts["conum"]),
            ("mlt_memno", "=", self.memno)]
     if self.key == "normal":
         dtc, recs = getTrn(self.opts["mf"].dbm, "mem", whr=whr, zer="N")
     else:
         dtc, recs = getTrn(self.opts["mf"].dbm, "mem", whr=whr)
     if recs:
         data = []
         for rec in recs:
             dat = []
             for c in col:
                 dat.append(rec[dtc.index(c)])
             data.append(dat)
         age = AgeTrans(self.opts["mf"], "mem", data, 0, xits=False)
         if not age.ccl and age.data:
             if age.total.work:
                 while not age.ccl:
                     age.doAllocate()
                     if age.ccl or not age.total.work:
                         break
             if age.ccl:
                 self.key = "cancel"
                 age.data = []
             for tr in age.data:
                 if tr[6]:
                     w = copyList(whr)
                     w.extend([("mlt_type", "=", tr[2]),
                               ("mlt_refno", "=", tr[1])])
                     self.sql.insRec("memage",
                                     data=[
                                         self.opts["conum"], self.memno,
                                         tr[2], tr[1], self.curdt, tr[2],
                                         tr[1], tr[6], 0
                                     ])
         else:
             self.key = "cancel"
     self.agevar.set(False)
コード例 #7
0
ファイル: cr3080.py プロジェクト: paulmalherbe/Tartan
 def doExTrnRef(self, frt, pag, r, c, p, i, w):
     col = ["crt_trdt", "balance", "crt_payind", "crt_paydt", "crt_payamt"]
     whr = [("crt_cono", "=", self.opts["conum"]),
            ("crt_acno", "=", self.exacc), ("crt_type", "=", self.extyp),
            ("crt_ref1", "=", w)]
     c, d = getTrn(self.opts["mf"].dbm, "crs", whr=whr, lim=1)
     if not d:
         return "Invalid Transaction Number"
     if not d[0][c.index("balance")]:
         return "Transaction Has No Balance"
     self.exref = w
     self.exdte = d[0][c.index("crt_paydt")]
     self.examt = d[0][c.index("crt_payamt")]
     for pos, fld in enumerate(col):
         self.ex.loadEntry(frt, pag, p + 1 + pos, data=d[0][c.index(fld)])
コード例 #8
0
ファイル: cr3080.py プロジェクト: paulmalherbe/Tartan
 def doExTrnTyp(self, frt, pag, r, c, p, i, w):
     self.extyp = w
     data = []
     # Build the data for the F1 choice selection
     col, dat = getTrn(self.opts["mf"].dbm,
                       "crs",
                       whr=[("crt_cono", "=", self.opts["conum"]),
                            ("crt_acno", "=", self.exacc),
                            ("crt_type", "=", w)],
                       zer="N")
     if dat:
         cols = ("crt_ref1", "crt_type", "crt_trdt", "crt_tramt", "paid",
                 "balance", "crt_paydt", "crt_payind", "crt_payamt")
         for d in dat:
             rec = []
             for cc in cols:
                 rec.append(d[col.index(cc)])
             data.append(rec)
     self.ex.colf[0][1][8]["where"] = data
コード例 #9
0
 def printReport(self, mst):
     p = ProgressBar(self.opts["mf"].body, mxs=len(mst), esc=True)
     self.head = "%03u %-71s" % (self.opts["conum"], self.opts["conam"])
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head)
     self.ctots = [0, 0, 0]
     self.gtots = [0, 0, 0]
     self.pglin = 999
     for seq, rec in enumerate(mst):
         p.displayProgress(seq)
         if p.quit:
             break
         chn = CCD(rec[0], "UI", 3)
         acno = CCD(rec[1], "NA", 7)
         name = CCD(rec[2], "NA", 30)
         col, trns = getTrn(self.opts["mf"].dbm,
                            "drs",
                            whr=[("drt_cono", "=", self.opts["conum"]),
                                 ("drt_chain", "=", chn.work),
                                 ("drt_acno", "=", acno.work),
                                 ("drt_trdt", "<=", self.pdatw)],
                            neg=False,
                            zer="N")
         if not trns:
             continue
         if self.pglin == 999:
             self.pageHeading(chn.disp, acno.disp, name.disp)
         else:
             self.newAccount(chn.disp, acno.disp, name.disp)
         for trn in trns:
             ref1 = CCD(trn[col.index("drt_ref1")], "Na", 9)
             ref2 = CCD(trn[col.index("drt_ref2")], "Na", 9)
             trtp = CCD(trn[col.index("drt_type")], "UI", 1)
             trdt = CCD(trn[col.index("drt_trdt")], "d1", 10)
             tramt = CCD(trn[col.index("drt_tramt")], "SD", 13.2)
             paid = CCD(trn[col.index("paid")], "SD", 13.2)
             trbal = CCD(trn[col.index("balance")], "SD", 13.2)
             if self.pglin > self.fpdf.lpp:
                 self.pageHeading(chn.disp, acno.disp, name.disp)
             self.fpdf.drawText(
                 "%s %s %s %s %s %s %s" %
                 (ref1.disp, ref2.disp, drtrtp[trtp.work - 1][0], trdt.disp,
                  tramt.disp, paid.disp, trbal.disp))
             self.pglin += 1
             self.ctots[0] = float(ASD(self.ctots[0]) + ASD(tramt.work))
             self.ctots[1] = float(ASD(self.ctots[1]) + ASD(paid.work))
             self.ctots[2] = float(ASD(self.ctots[2]) + ASD(trbal.work))
             self.gtots[0] = float(ASD(self.gtots[0]) + ASD(tramt.work))
             self.gtots[1] = float(ASD(self.gtots[1]) + ASD(paid.work))
             self.gtots[2] = float(ASD(self.gtots[2]) + ASD(trbal.work))
         if self.fpdf.page:
             self.accountTotal()
     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)
コード例 #10
0
 def printReport(self, mst):
     p = ProgressBar(self.opts["mf"].body, mxs=len(mst), esc=True)
     self.head = "%03u %-107s" % (self.opts["conum"], self.opts["conam"])
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head)
     self.ctots = [0, 0, 0, 0, 0]
     self.gtots = [0, 0, 0, 0, 0]
     self.pglin = 999
     for num, rec in enumerate(mst):
         p.displayProgress(num)
         if p.quit:
             break
         acno = CCD(rec[self.sql.crsmst_col.index("crm_acno")], "NA", 7)
         name = CCD(rec[self.sql.crsmst_col.index("crm_name")], "NA", 30)
         bnam = rec[self.sql.crsmst_col.index("crm_bname")]
         bibt = rec[self.sql.crsmst_col.index("crm_bibt")]
         bacc = rec[self.sql.crsmst_col.index("crm_bacc")]
         if bnam and bibt and bacc:
             ptyp = "E"
         else:
             ptyp = "C"
         col, trns = getTrn(self.opts["mf"].dbm,
                            "crs",
                            whr=[("crt_cono", "=", self.opts["conum"]),
                                 ("crt_acno", "=", acno.work),
                                 ("crt_paydt", "<=", self.pdatw),
                                 ("crt_payind", "=", "Y")],
                            neg=False,
                            zer="N")
         if not trns:
             continue
         if self.pglin == 999:
             self.pageHeading(acno.disp, name.disp, ptyp)
         else:
             self.newAccount(acno.disp, name.disp, ptyp)
         for trn in trns:
             ref1 = CCD(trn[col.index("crt_ref1")], "Na", 9)
             ref2 = CCD(trn[col.index("crt_ref2")], "Na", 9)
             trtp = CCD(trn[col.index("crt_type")], "UI", 1)
             trdt = CCD(trn[col.index("crt_trdt")], "d1", 10)
             disper = CCD(trn[col.index("crt_disper")], "SD", 7.2)
             tramt = CCD(trn[col.index("crt_tramt")], "SD", 13.2)
             paid = CCD(trn[col.index("paid")], "SD", 13.2)
             trbal = CCD(trn[col.index("balance")], "SD", 13.2)
             sett = round((trbal.work * disper.work / 100), 2)
             sett = CCD(sett, "SD", 13.2)
             nett = float(ASD(trbal.work) - ASD(sett.work))
             nett = CCD(nett, "SD", 13.2)
             if self.pglin > self.fpdf.lpp:
                 self.pageHeading(acno.disp, name.disp, ptyp)
             self.fpdf.drawText("%s %s %s %s %s %s %s %s %s %s" % \
                 (ref1.disp, ref2.disp, crtrtp[trtp.work-1][0], trdt.disp,
                 disper.disp, tramt.disp, paid.disp, trbal.disp, sett.disp,
                 nett.disp))
             self.pglin += 1
             self.ctots[0] = float(ASD(self.ctots[0]) + ASD(tramt.work))
             self.ctots[1] = float(ASD(self.ctots[1]) + ASD(paid.work))
             self.ctots[2] = float(ASD(self.ctots[2]) + ASD(trbal.work))
             self.ctots[3] = float(ASD(self.ctots[3]) + ASD(sett.work))
             self.ctots[4] = float(ASD(self.ctots[4]) + ASD(nett.work))
             self.gtots[0] = float(ASD(self.gtots[0]) + ASD(tramt.work))
             self.gtots[1] = float(ASD(self.gtots[1]) + ASD(paid.work))
             self.gtots[2] = float(ASD(self.gtots[2]) + ASD(trbal.work))
             self.gtots[3] = float(ASD(self.gtots[3]) + ASD(sett.work))
             self.gtots[4] = float(ASD(self.gtots[4]) + ASD(nett.work))
         if self.fpdf.page:
             self.accountTotal()
     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)
コード例 #11
0
ファイル: dr4010.py プロジェクト: paulmalherbe/Tartan
 def doTrans2(self, frt, pag, r, c, p, i, w):
     self.paidup = w
     whr = [("drt_cono", "=", self.opts["conum"]),
            ("drt_chain", "=", self.chain), ("drt_acno", "=", self.acno)]
     if self.paidup == "Y":
         col, recs = getTrn(self.opts["mf"].dbm, "drs", whr=whr)
     else:
         col, recs = getTrn(self.opts["mf"].dbm,
                            "drs",
                            dte=self.curdt,
                            whr=whr)
     if recs:
         data = []
         for dat in recs:
             data.append([
                 dat[col.index("drt_trdt")], dat[col.index("drt_curdt")],
                 dat[col.index("drt_batch")], dat[col.index("drt_type")],
                 dat[col.index("drt_ref1")],
                 self.getRef2(col, dat), dat[col.index("drt_tramt")],
                 dat[col.index("paid")], dat[col.index("balance")],
                 dat[col.index("drt_desc")]
             ])
         if self.chains == "Y":
             tit = "Transactions for Account: %s %s - %s" % \
                 (self.chain, self.acno, self.name)
         else:
             tit = "Transactions for Account: %s - %s" % \
                 (self.acno, self.name)
         col = (("drt_trdt", "   Date", 10, "D1",
                 "N"), ("drt_curdt", "Curr-Dt", 7, "D2",
                        "N"), ("drt_batch", "Batch", 7, "Na", "N"),
                ("drt_type", "Typ", 3, ("XX", drtrtp),
                 "N"), ("drt_ref1", "Reference", 9, "Na",
                        "Y"), ("drt_ref2", "Ref-Number-Two", 14, "Na", "Y"),
                ("drt_tramt", "    Amount", 13.2, "SD",
                 "N"), ("alloc", " Allocated", 13.2, "SD",
                        "N"), ("balan", "   Balance", 13.2, "SD",
                               "N"), ("drt_desc", "Details", 30, "NA", "N"))
         state = self.df.disableButtonsTags()
         while True:
             rec = SelectChoice(self.df.nb.Page5, tit, col, data)
             # If Invoice or Credit Note, attempt to display the document
             # else display all transaction details
             if rec.selection:
                 self.df.setWidget(self.df.mstFrame, state="hide")
                 if rec.selection[4] in (1, 4):
                     if rec.selection[4] == 1:
                         typ = "I"
                     else:
                         typ = "C"
                     try:
                         doc = int(rec.selection[5])
                         inv = self.sql.getRec("slsiv1",
                                               where=[("si1_cono", "=",
                                                       self.opts["conum"]),
                                                      ("si1_rtn", "=", typ),
                                                      ("si1_docno", "=",
                                                       doc)],
                                               limit=1)
                     except:
                         inv = []
                 else:
                     inv = []
                 if inv:
                     PrintInvoice(self.opts["mf"],
                                  self.opts["conum"],
                                  self.opts["conam"],
                                  typ,
                                  doc,
                                  repprt=["N", "V", "view"],
                                  copy="y")
                 else:
                     whr = [("drt_cono", "=", self.opts["conum"]),
                            ("drt_chain", "=", self.chain),
                            ("drt_acno", "=", self.acno),
                            ("drt_type", "=", rec.selection[4]),
                            ("drt_ref1", "=", rec.selection[5])]
                     TabPrt(self.opts["mf"],
                            tabs="drstrn",
                            where=whr,
                            pdia=False)
                 self.df.setWidget(self.df.mstFrame, state="show")
             else:
                 break
         self.df.enableButtonsTags(state=state)
     self.doTrans1()
コード例 #12
0
 def doEnd(self):
     self.df.closeProcess()
     col = [
         "mlm_memno", "mlm_surname", "mlm_names", "mlm_payplan", "mlc_code"
     ]
     whr = [("mlm_cono", "=", self.opts["conum"]), ("mlm_state", "=", "A")]
     if self.plan == "N":
         whr.append(("mlm_payplan", "=", "N"))
     whr.extend([("mlc_cono=mlm_cono", ), ("mlc_memno=mlm_memno", ),
                 ("mlc_type", "=", "B")])
     grp = "mlm_memno, mlm_surname, mlm_names, mlm_payplan, mlc_code"
     if self.sort == "N":
         odr = "mlm_memno"
     else:
         odr = "mlm_surname"
     sp = SplashScreen(self.opts["mf"].body,
                       "Preparing Report ... Please Wait")
     recs = self.sql.getRec(tables=["memmst", "memcat"],
                            cols=col,
                            where=whr,
                            group=grp,
                            order=odr)
     sp.closeSplash()
     if not recs:
         self.opts["mf"].closeLoop()
         return
     p = ProgressBar(self.opts["mf"].body,
                     typ="Generating the Report",
                     mxs=len(recs),
                     esc=True)
     data = []
     for num, rec in enumerate(recs):
         p.displayProgress(num)
         if p.quit:
             break
         whr = [("mlt_cono", "=", self.opts["conum"]),
                ("mlt_memno", "=", rec[0])]
         trn = getTrn(self.opts["mf"].dbm, "mem", whr=whr, zer="N")
         bal = 0
         inv = 0
         for t in trn[1]:
             c = trn[0]
             bal = float(ASD(bal) + ASD(t[c.index("mlt_tramt")]))
             if t[c.index("mlt_type")] == 1 and \
                     t[c.index("mlt_curdt")] >= self.s_per:
                 inv = float(ASD(inv) + ASD(t[c.index("mlt_tramt")]))
         if not bal or bal < inv:
             continue
         cat = self.sql.getRec(tables=["memctc", "memctp"],
                               cols=["mcc_desc", "mcp_rate_01"],
                               where=[("mcc_cono", "=", self.opts["conum"]),
                                      ("mcc_type", "=", "B"),
                                      ("mcc_code", "=", rec[4]),
                                      ("mcp_cono=mcc_cono", ),
                                      ("mcp_type=mcc_type", ),
                                      ("mcp_code=mcc_code", )],
                               order="mcp_date desc",
                               limit=1)
         if not cat or bal < cat[1]:
             continue
         rec[1] = "%s, %s" % (rec[1], rec[2])
         del rec[2]
         rec[3] = cat[0]
         rec.append(cat[1])
         rec.append(inv)
         rec.append(bal)
         data.append(rec)
     p.closeProgress()
     if p.quit:
         self.opts["mf"].closeLoop()
         return
     name = self.__class__.__name__
     head = ["Members Suspension Report"]
     cols = [["a", "NA", 7, "Mem-No", "y"], ["b", "NA", 50, "Name", "y"],
             ["d", "UA", 1, "P", "y"],
             ["c", "NA", 30, "Active-Category", "y"],
             ["e", "SD", 13.2, "Subscription", "y"],
             ["f", "SD", 13.2, "Tot-Invoiced", "y"],
             ["g", "SD", 13.2, "Tot-Balance", "y"]]
     rep = RepPrt(self.opts["mf"],
                  conum=self.opts["conum"],
                  conam=self.opts["conam"],
                  name=name,
                  tables=data,
                  heads=head,
                  cols=cols,
                  gtots=("e", "f", "g"),
                  ttype="D",
                  repprt=self.df.repprt,
                  repeml=self.df.repeml,
                  fromad=self.fromad)
     if not rep.xits:
         ask = askChoice(self.opts["mf"].body,
                         "Suspend Members",
                         "Select Members to Suspend",
                         butt=(("All", "A"), ("Some", "S"), ("None", "N")),
                         default="None")
         if ask in ("A", "S"):
             if ask == "S":
                 cols = ["memno", "name"]
                 dics = {
                     "memno": ("", 0, "UI", 6, "Member Number", "Mem-No"),
                     "name": ("", 1, "NA", 50, "Member Name", "Name")
                 }
                 newd = []
                 for dat in data:
                     newd.append((dat[0], dat[1]))
                 data = getSingleRecords(self.opts["mf"],
                                         "",
                                         cols,
                                         where=newd,
                                         ttype="D",
                                         dic=dics)
             if data:
                 p = ProgressBar(self.opts["mf"].body,
                                 typ="Suspending Members",
                                 mxs=len(data))
                 for num, rec in enumerate(data):
                     p.displayProgress(num)
                     self.sql.updRec("memmst",
                                     cols=["mlm_state", "mlm_sdate"],
                                     data=["S", self.sysdtw],
                                     where=[("mlm_cono", "=",
                                             self.opts["conum"]),
                                            ("mlm_memno", "=", rec[0])])
                     self.sql.insRec("memsta",
                                     data=[
                                         self.opts["conum"], rec[0], "S",
                                         self.sysdtw, self.opts["capnm"],
                                         self.sysdtw, 0
                                     ])
                 self.opts["mf"].dbm.commitDbase()
     p.closeProgress()
     self.opts["mf"].closeLoop()