Пример #1
0
 def doTrnRef(self, frt, pag, r, c, p, i, w):
     self.trnref = w
     try:
         rs = self.df.rs.selection
     except:
         rs = None
     if not rs:
         wa = [
             ("glt_type", "=", self.opts["rtn"]),
             ("glt_refno", "=", self.trnref)]
         opt = {}
         for k in self.glt:
             if k == "where":
                 opt[k] = copyList(self.glt[k])
                 opt[k].extend(wa)
             elif type(self.glt[k]) == list:
                 opt[k] = copyList(self.glt[k])
             else:
                 opt[k] = self.glt[k]
         rs = self.df.selRecord(1, opt).selection
     if rs:
         self.df.loadEntry("C", 0, p+1, data=rs[0])
         self.df.loadEntry("C", 0, p+2, data=rs[4])
         self.df.loadEntry("C", 0, p+3, data=rs[5])
         self.seq = rs[3]
         return "nd"
     else:
         return "Invalid Transaction"
Пример #2
0
 def printReport(self, recs):
     data = []
     typ = "Generating the Report ... Please Wait"
     p = ProgressBar(self.opts["mf"].body, mxs=len(recs), typ=typ, esc=True)
     for num, dat in enumerate(recs):
         p.displayProgress(num)
         if p.quit:
             break
         data.append(self.getValues(dat))
     p.closeProgress()
     if not p.quit:
         head = ["Member's Master Report as at %s" % self.repdtd]
         colsh = []
         for n1 in self.cnums:
             for n2, d2 in enumerate(self.colsd[n1][2:]):
                 if n1 in (20, 21) and self.df.repprt[2] == "export":
                     if n1 == 20:
                         prefix = "P"
                         col = copyList(self.padcol)
                     else:
                         prefix = "S"
                         col = copyList(self.sadcol)
                     colsh.append(("name1%s_%s" % (n1, n2), "NA", col[0],
                                   "%s-Address-Line-1" % prefix, "y"))
                     colsh.append(("name2%s_%s" % (n1, n2), "NA", col[1],
                                   "%s-Address-Line-2" % prefix, "y"))
                     colsh.append(("name3%s_%s" % (n1, n2), "NA", col[2],
                                   "%s-Address-Line-3" % prefix, "y"))
                     colsh.append(("name4%s_%s" % (n1, n2), "NA", col[3],
                                   "%s-City" % prefix, "y"))
                     colsh.append(("name5%s_%s" % (n1, n2), "NA", col[4],
                                   "%s-Code" % prefix, "y"))
                     colsh.append(("name6%s_%s" % (n1, n2), "NA", col[5],
                                   "%s-Region" % prefix, "y"))
                     colsh.append(("name7%s_%s" % (n1, n2), "NA", col[6],
                                   "%s-Country" % prefix, "y"))
                 else:
                     colsh.append(
                         ("name%s_%s" % (n1, n2), d2[1], d2[2], d2[0], "y"))
         RepPrt(self.opts["mf"],
                name=self.__class__.__name__,
                heads=head,
                tables=data,
                cols=colsh,
                opts=self.getDes(),
                ttype="D",
                conum=self.opts["conum"],
                conam=self.opts["conam"],
                repprt=self.df.repprt,
                repeml=self.df.repeml,
                fromad=self.fromad,
                pbar="P")
Пример #3
0
 def doHeader(self, rtm, rmc, prm, prc, tdc):
     self.form.add_page()
     if "account_details" in self.form.tptp:
         nad = rtm[rmc.index("rtm_name")]
         add1 = rtm[rmc.index("rtm_addr1")]
         if add1:
             nad = "%1s\n%1s" % (nad, add1)
             nad = "%1s\n%1s" % (nad, rtm[rmc.index("rtm_addr2")])
             nad = "%1s\n%1s" % (nad, rtm[rmc.index("rtm_addr3")])
             nad = "%1s\n%1s" % (nad, rtm[rmc.index("rtm_pcode")])
         else:
             nad = prm[prc.index("rtp_addr1")]
             nad = "%1s\n%1s" % (nad, prm[prc.index("rtp_addr2")])
             nad = "%1s\n%1s" % (nad, prm[prc.index("rtp_addr3")])
             nad = "%1s\n%1s" % (nad, prm[prc.index("rtp_pcode")])
         self.form.newdic["account_details_C00"][tdc.index(
             "tpd_text")] = nad
     for key in self.form.newkey:
         nl = copyList(self.form.newdic[key])
         if nl[tdc.index("tpd_place")] != "A":
             continue
         if nl[tdc.index("tpd_detseq")] == "rtm_code_C00":
             nl[tdc.index("tpd_text")] = self.code
         elif nl[tdc.index("tpd_detseq")] == "rtm_acno_C00":
             nl[tdc.index("tpd_text")] = self.acno
         self.form.doDrawDetail(nl)
Пример #4
0
 def doEnd(self):
     self.df.closeProcess()
     odr = "rtc_code, rtc_acno, rtc_cnum"
     whr = [("rtc_cono", "=", self.opts["conum"]),
            ("rtc_start", "<=", self.date)]
     if self.styp in ("C", "X"):
         whr.append(("rtc_status", "=", self.styp))
     if self.cons == "Y":
         recs = []
         cols = ["rtc_code", "rtc_acno", "max(rtc_cnum)"]
         accs = self.sql.getRec("rtlcon",
                                cols=cols,
                                where=whr,
                                group="rtc_code, rtc_acno",
                                order="rtc_code, rtc_acno")
         for acc in accs:
             w = copyList(whr)
             w.append(("rtc_code", "=", acc[0]))
             w.append(("rtc_acno", "=", acc[1]))
             w.append(("rtc_cnum", "=", acc[2]))
             rec = self.sql.getRec("rtlcon", where=w, limit=1)
             recs.append(rec)
     else:
         recs = self.sql.getRec("rtlcon", where=whr, order=odr)
     if not recs:
         showError(self.opts["mf"].body, "Selection Error",
                   "No Records Selected")
     else:
         self.printReport(recs)
     self.closeProcess()
Пример #5
0
 def doPrmCod(self, frt, pag, r, c, p, i, w):
     self.code = w
     self.old = self.sql.getRec("rtlprm",
                                where=[("rtp_cono", "=",
                                        self.opts["conum"]),
                                       ("rtp_code", "=", self.code)],
                                limit=1)
     if not self.old:
         self.new = "y"
     else:
         self.new = "n"
         acc = copyList(self.old[:-1])
         acc.append("")
         acc.insert(8, "")
         for x in range(0, self.df.topq[pag]):
             self.df.loadEntry(frt, pag, p + x, data=acc[x + 1])
         if self.glint == "N":
             return
         des = self.sql.getRec("genmst",
                               cols=["glm_desc"],
                               where=[("glm_cono", "=", self.opts["conum"]),
                                      ("glm_acno", "=", acc[7])],
                               limit=1)
         if des:
             self.df.loadEntry("T", 0, 7, data=des[0])
         des = self.sql.getRec("genmst",
                               cols=["glm_desc"],
                               where=[("glm_cono", "=", self.opts["conum"]),
                                      ("glm_acno", "=", acc[9])],
                               limit=1)
         if des:
             self.df.loadEntry("T", 0, 9, data=des[0])
Пример #6
0
 def setVariables(self):
     self.sql = Sql(self.opts["mf"].dbm, ["lontrn"],
         prog=self.__class__.__name__)
     if self.sql.error:
         return
     gc = GetCtl(self.opts["mf"])
     lonctl = gc.getCtl("lonctl", self.opts["conum"])
     if not lonctl:
         return
     self.fromad = lonctl["cln_emadd"]
     t = time.localtime()
     self.sysdttm = "(Printed on: %i/%02i/%02i at %02i:%02i)" % \
         (t[0], t[1], t[2], t[3], t[4])
     self.head = "%03u %-30s" % (self.opts["conum"], self.opts["conam"])
     self.colsh = ["TP", "BatchNo", "Acc-Num", "Ln", "Reference",
         "Trans-Date", "Remarks", "Debits", "Credits"]
     self.forms = [("UI", 2), ("NA", 7), ("UA", 7), ("UI", 2),
         ("Na", 9), ("D1", 10), ("NA", 30), ("SD", 13.2), ("SD", 13.2)]
     self.sper = int(self.opts["period"][1][0] / 100)
     self.eper = int(self.opts["period"][2][0] / 100)
     self.gqt = [0,0,0,0,0]
     self.gam = [0,0,0,0,0]
     self.prtrtp = copyList(lntrtp)
     self.prtrtp[3] = ("DRI", "Debit Interest")
     self.prtrtp.append(("CRI", "Credit Interest"))
     self.totind = "N"
     return True
Пример #7
0
 def doPrint(self):
     hds = "V.A.T. Records"
     col = [
         ["vtm_code", "UA",  1,   "C"],
         ["vtm_desc", "NA", 30,   "Description"],
         ["vtm_cat", "UA",   1,   "T"],
         ["vtr_date", "d1", 10,   "Start-Date"],
         ["vtr_rate", "UD",  6.2, "Rate"]]
     recs = self.sql.getRec(tables=["ctlvmf", "ctlvrf"], cols=["vtm_code",
         "vtm_desc", "vtm_cat", "vtr_date", "vtr_rate"], where=[("vtm_cono",
         "=", self.opts["conum"]), ("vtr_cono=vtm_cono",),
         ("vtr_code=vtm_code",)], order="vtm_code, vtr_date")
     code = None
     data = copyList(recs)
     for num, rec in enumerate(recs):
         if rec[0] == code:
             data[num][0] = ""
             data[num][1] = ""
             data[num][2] = ""
         code = rec[0]
     state = self.df.disableButtonsTags()
     self.df.setWidget(self.df.mstFrame, state="hide")
     RepPrt(self.opts["mf"], name=self.__class__.__name__, tables=data,
         heads=[hds], ttype="D", cols=col, prtdia=(("Y","V"), ("Y","N")))
     self.df.setWidget(self.df.mstFrame, state="show")
     self.df.enableButtonsTags(state=state)
     self.df.focusField("T", 0, 1)
Пример #8
0
 def doCfwd(self, page):
     if "carried_forward" in self.form.tptp:
         tdc = self.form.sql.tpldet_col
         line = copyList(self.form.cfwd)
         line[tdc.index("tpd_text")] = "Continued on Page %i" % (page + 1)
         self.form.doDrawDetail(line)
     return page + 1
Пример #9
0
 def setVariables(self):
     sql = Sql(self.opts["mf"].dbm, "ftable", prog=self.__class__.__name__)
     if sql.error:
         return
     self.unique = ("genbal", "genbud", "genmst", "genrcc", "genrct")
     self.tables = [("assgrp", "asg_cono", "asg_assacc"),
                    ("assgrp", "asg_cono", "asg_depacc"),
                    ("assgrp", "asg_cono", "asg_expacc"),
                    ("bkmunm", "bum_cono", "bum_slsa"),
                    ("crsctl", "ctc_cono", "ctc_bankac"),
                    ("crsmst", "crm_cono", "crm_glac"),
                    ("cshana", "can_cono", "can_code"),
                    ("ctlctl", "ctl_cono", "ctl_conacc"),
                    ("ctldep", "dep_dr_coy", "dep_dr_sal"),
                    ("ctldep", "dep_dr_coy", "dep_dr_com"),
                    ("ctldep", "dep_cr_coy", "dep_cr_sal"),
                    ("ctldep", "dep_cr_coy", "dep_cr_com"),
                    ("ctlnot", "not_cono", "not_key"),
                    ("ctlvtf", "vtt_cono", "vtt_acno", "vtt_styp"),
                    ("drsrcm", "dcm_cono", "dcm_glac"),
                    ("genbal", "glo_cono", "glo_acno"),
                    ("genbud", "glb_cono", "glb_acno"),
                    ("genint", "cti_cono", "cti_acno"),
                    ("genjlt", "gjt_cono", "gjt_acno"),
                    ("genmst", "glm_cono", "glm_acno"),
                    ("genrcc", "grc_cono", "grc_acno"),
                    ("genrcc", "grc_acoy", "grc_aacc"),
                    ("genrct", "grt_cono", "grt_acno"),
                    ("genrpt", "glr_cono", "glr_from"),
                    ("genrpt", "glr_cono", "glr_to"),
                    ("gentrn", "glt_cono", "glt_acno"),
                    ("memctc", "mcc_cono", "mcc_glac"),
                    ("rcactl", "cte_cono", "cte_glbnk"),
                    ("rtlprm", "rtp_cono", "rtp_rtlacc"),
                    ("rtlprm", "rtp_cono", "rtp_incacc"),
                    ("strgrp", "gpm_cono", "gpm_sales"),
                    ("strgrp", "gpm_cono", "gpm_costs"),
                    ("strmf1", "st1_cono", "st1_sls"),
                    ("strmf1", "st1_cono", "st1_cos"),
                    ("wagedc", "ced_eglco", "ced_eglno"),
                    ("wagedc", "ced_rglco", "ced_rglno"),
                    ("wagtf2", "wt2_gl_econo", "wt2_gl_eacno"),
                    ("wagtf2", "wt2_gl_rcono", "wt2_gl_racno")]
     tabs = []
     tables = copyList(self.tables)
     for tab in tables:
         chk = sql.getRec("ftable", where=[("ft_tabl", "=", tab[0])])
         if not chk:
             self.tables.remove(tab)
             continue
         if tab[0] not in tabs:
             tabs.append(tab[0])
     self.sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__)
     if self.sql.error:
         return
     self.doimp = False
     return True
Пример #10
0
 def doEnd(self):
     if "args" not in self.opts:
         hdr = self.tit
         prt = copyList(self.df.repprt)
         eml = copyList(self.df.repeml)
         self.df.closeProcess()
     else:
         hdr = "%03i %s - %s" % (self.opts["conum"], self.opts["conam"],
         "Competition Format")
         prt = ["Y", "V", "view"]
         eml = None
     self.drawFormat()
     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"], pdfnam=pdfnam, header=hdr,
         repprt=prt, fromad=self.fromad, repeml=eml)
     if "wait" not in self.opts:
         self.opts["mf"].closeLoop()
Пример #11
0
 def doHeader(self, page):
     self.form.add_page()
     tdc = self.form.sql.tpldet_col
     for key in self.form.newkey:
         nl = copyList(self.form.newdic[key])
         if nl[tdc.index("tpd_place")] != "A":
             continue
         if nl[tdc.index("tpd_detseq")] == "rtn_acno_C00":
             nl[tdc.index("tpd_text")] = self.acc
         self.form.doDrawDetail(nl)
     return 0
Пример #12
0
 def doHeader(self, page):
     tdc = self.form.sql.tpldet_col
     self.form.add_page()
     for key in self.form.newkey:
         nl = copyList(self.form.newdic[key])
         if nl[tdc.index("tpd_place")] != "A":
             continue
         if nl[tdc.index("tpd_detseq")] == "crm_acno_C00":
             nl[tdc.index("tpd_text")] = self.acno
         elif nl[tdc.index("tpd_detseq")] == "page_number_C00":
             nl[tdc.index("tpd_text")] = str(page)
         self.form.doDrawDetail(nl)
     return 0
Пример #13
0
 def doReadTables(self, tipe=None):
     if self.table not in tabdic:
         return "skip"
     if tipe == "idx":
         tab = "ftable"
         old = self.sql.getRec("ftable",
                               where=[("ft_tabl", "=", self.table)],
                               order="ft_seq")
     else:
         tab = "ffield"
         old = self.sql.getRec("ffield",
                               where=[("ff_tabl", "=", self.table)],
                               order="ff_seq")
         if old and self.table == "strpom":
             self.strpom = False
             tmp = copyList(old)
             for num, rec in enumerate(tmp):
                 if rec[1] == 13 and rec[2] == "pom_mess":
                     self.strpom = True
                     old[num][1] = 14
                 elif rec[1] == 14 and rec[2] == "pom_delno":
                     old[num][1] = 15
                 elif rec[1] == 15 and rec[2] == "pom_deldt":
                     old[num][1] = 16
                 elif rec[1] == 16 and rec[2] == "pom_capnm":
                     old[num][1] = 17
                 elif rec[1] == 17 and rec[2] == "pom_capdt":
                     old[num][1] = 18
     if not old:
         if self.opts["mf"] and self.opts["mf"].window:
             self.opts["mf"].updateStatus("Table %s Not Found in %s" % \
                 (self.table, tab))
         else:
             print("Table %s Not Found in %s" % (self.table, tab))
         return tipe
     if self.opts["mf"] and self.opts["mf"].window:
         self.opts["mf"].updateStatus("")
     setattr(self, "old%s" % tipe, old)
     new = []
     for t in tabdic[self.table][tipe]:
         n = copy.copy(t)
         n.insert(0, self.table)
         if tipe == "idx":
             n[2] = int(n[2])
             for _ in range(len(n), 14):
                 n.append("")
         else:
             n[1] = int(n[1])
             n[4] = float(n[4])
         new.append(n)
     setattr(self, "new%s" % tipe, new)
Пример #14
0
 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)
Пример #15
0
 def doHeader(self, mlm, dmc, tdc):
     self.form.add_page()
     if "account_details" in self.form.tptp:
         tit = mlm[dmc.index("mlm_title")]
         sur = mlm[dmc.index("mlm_surname")]
         nam = mlm[dmc.index("mlm_names")]
         ini = ""
         for n, d in enumerate(nam.split()):
             if n < 3:
                 if not ini:
                     ini = d[0].upper()
                 else:
                     ini = "%s %s" % (ini, d[0].upper())
         nad = "%s %s %s" % (tit.strip(), ini.strip(), sur.strip())
         add = self.sql.getRec("memadd",
                               where=[("mla_cono", "=", self.opts["conum"]),
                                      ("mla_memno", "=", self.memno),
                                      ("mla_type", "=", "P")],
                               limit=1)
         adc = self.sql.memadd_col
         if add:
             if add[adc.index("mla_add1")]:
                 nad = "%s\n%s" % (nad, add[adc.index("mla_add1")])
             if add[adc.index("mla_add2")]:
                 nad = "%s\n%s" % (nad, add[adc.index("mla_add2")])
             if add[adc.index("mla_add3")]:
                 nad = "%s\n%s" % (nad, add[adc.index("mla_add3")])
             if add[adc.index("mla_city")]:
                 nad = "%s\n%s" % (nad, add[adc.index("mla_city")])
             if add[adc.index("mla_country")]:
                 nad = "%s\n%-s, %-s" % (nad, add[adc.index("mla_code")],
                                         add[adc.index("mla_country")])
             else:
                 nad = "%s\n%s" % (nad, add[adc.index("mla_code")])
         else:
             nad = "\n\n\n\n\n"
         self.form.newdic["account_details_C00"][tdc.index(
             "tpd_text")] = nad
     for key in self.form.newkey:
         nl = copyList(self.form.newdic[key])
         if nl[tdc.index("tpd_place")] != "A":
             continue
         if nl[tdc.index("tpd_detseq")] == "mlm_memno_C00":
             nl[tdc.index("tpd_text")] = self.memno
         self.form.doDrawDetail(nl)
Пример #16
0
 def doEnd(self):
     svr = self.df.t_work[0][0][5]
     if svr:
         prt = self.df.t_work[0][0][8]
         sec = self.df.t_work[0][0][6]
         aut = self.df.t_work[0][0][7]
         nam = self.df.t_work[0][0][9]
         pwd = self.df.t_work[0][0][10]
         chk = sendMail([svr, prt, sec, aut, nam, pwd],
                        "",
                        "",
                        "",
                        check=True,
                        err=self.opts["mf"].body,
                        wrkdir=self.opts["mf"].rcdic["wrkdir"])
         if not chk:
             self.df.focusField("T", 0, 6)
             return
     tme = time.localtime()
     data = copyList(self.df.t_work[0][0])
     if self.new:
         self.sql.insRec("ctlsys", data=data)
     elif data != self.acc[:len(data)]:
         self.sql.updRec("ctlsys", data=data)
         dte = int("%04i%02i%02i%02i%02i%02i" % tme[:-3])
         for num, dat in enumerate(self.acc):
             if dat != data[num]:
                 self.sql.insRec("chglog",
                                 data=[
                                     "ctlsys", "U",
                                     "%03i" % 0, self.sql.ctlsys_col[num],
                                     dte, self.opts["capnm"],
                                     str(dat),
                                     str(data[num]), "", 0
                                 ])
     # Reset all password dates to current date (Temporary Fix)
     dte = (tme[0] * 10000) + (tme[1] * 100) + tme[2]
     self.sql.updRec("ctlpwu", cols=["usr_last"], data=[dte])
     self.opts["mf"].dbm.commitDbase()
     self.doExit()
Пример #17
0
 def doProcess(self, rtm):
     rmc = self.sql.rtlmst_col
     rtc = copyList(self.sql.rtltrn_col)
     tdc = self.form.sql.tpldet_col
     self.code = rtm[rmc.index("rtm_code")]
     self.acno = rtm[rmc.index("rtm_acno")]
     eml = rtm[rmc.index("rtm_email")]
     for col in rmc:
         d = "%s_00" % col
         if d in self.form.newdic:
             dat = rtm[rmc.index(col)]
             self.form.newdic[d][tdc.index("tpd_text")] = dat
     prm = self.sql.getRec("rtlprm",
                           where=[("rtp_cono", "=", self.opts["conum"]),
                                  ("rtp_code", "=", self.code)],
                           limit=1)
     if not prm:
         prm = [0, "", "", "", "", "", "", 0, 0]
     prc = self.sql.rtlprm_col
     for col in prc:
         d = "%s_00" % col
         if col in self.form.newdic:
             dat = prm[prc.index(col)]
             self.form.newdic[d][tdc.index("tpd_text")] = dat
     con = self.sql.getRec("rtlcon",
                           where=[("rtc_cono", "=", self.opts["conum"]),
                                  ("rtc_code", "=", self.code),
                                  ("rtc_acno", "=", self.acno)],
                           limit=1)
     coc = self.sql.rtlprm_col
     for col in coc:
         d = "%s_00" % col
         if col in self.form.newdic:
             dat = con[coc.index(col)]
             self.form.newdic[d][tdc.index("tpd_text")] = dat
     self.tots = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
     rtt = self.sql.getRec(
         "rtltrn",
         cols=["round(sum(rtt_tramt), 2)", "round(sum(rtt_taxamt), 2)"],
         where=[("rtt_cono", "=", self.opts["conum"]),
                ("rtt_code", "=", self.code), ("rtt_acno", "=", self.acno),
                ("rtt_trdt", "<=", self.datew),
                ("rtt_curdt", "=", self.curdt)],
         limit=1)
     if rtt[0]:
         self.tots[0] = rtt[0]
         self.tots[2] = rtt[0]
         self.tots[5] = rtt[0]
     if rtt[1]:
         self.tots[0] = float(ASD(self.tots[0]) - ASD(rtt[1]))
         self.tots[1] = rtt[1]
     arr = self.sql.getRec("rtltrn",
                           cols=["round(sum(rtt_tramt), 2)"],
                           where=[("rtt_cono", "=", self.opts["conum"]),
                                  ("rtt_code", "=", self.code),
                                  ("rtt_acno", "=", self.acno),
                                  ("rtt_curdt", "<", self.curdt)],
                           limit=1)
     if arr[0]:
         self.tots[3] = arr[0]
         self.tots[5] = float(ASD(self.tots[5]) + ASD(arr[0]))
     if self.zeros == "N" and not self.tots[5]:
         return
     if self.minus == "N" and self.tots[5] < 0:
         return
     rtc = [
         "rtt_trdt", "rtt_refno", "rtt_type", "rtt_desc", "rtt_cnum",
         "rtt_tramt"
     ]
     rtt = self.sql.getRec(
         "rtltrn",
         cols=[
             "rtt_trdt", "rtt_refno", "rtt_type", "rtt_desc", "rtt_cnum",
             "round(sum(rtt_tramt), 2)"
         ],
         where=[("rtt_cono", "=", self.opts["conum"]),
                ("rtt_code", "=", self.code), ("rtt_acno", "=", self.acno),
                ("rtt_type", "<>", 5), ("rtt_trdt", "<=", self.datew)],
         group="rtt_trdt, rtt_refno, rtt_type, rtt_desc, rtt_cnum",
         order="rtt_trdt, rtt_cnum, rtt_refno")
     if not rtt:
         rtt = []
     trans = []
     for trn in rtt:
         tramt = trn[rtc.index("rtt_tramt")]
         if tramt < 0:
             trn.extend([0, tramt])
         else:
             trn.extend([tramt, 0])
         trans.append(trn)
     rtc.extend(["line_debit", "line_credit"])
     self.doHeader(rtm, rmc, prm, prc, tdc)
     if len(trans) <= self.form.maxlines:
         self.doBody(rtc, trans, tdc)
     else:
         bal = 0
         lines = len(trans) - self.form.maxlines + 1
         for _ in range(lines):
             trn = trans.pop(0)
             bal = float(ASD(bal) + ASD(trn[5]))
         trn[rtc.index("rtt_refno")] = "B/FWD"
         trn[rtc.index("rtt_type")] = 3
         trn[rtc.index("rtt_desc")] = "Balance Brought Forward"
         trn[rtc.index("rtt_tramt")] = bal
         if bal < 0:
             trn[rtc.index("line_debit")] = 0
             trn[rtc.index("line_credit")] = bal
         else:
             trn[rtc.index("line_debit")] = bal
             trn[rtc.index("line_credit")] = 0
         trans.insert(0, trn)
         self.doBody(rtc, trans, tdc)
     self.doTotal(tdc)
     self.doTail(tdc)
     if self.df.repeml[1] == "Y" and not self.emadd:
         self.df.repeml[2] = eml
         self.doPrint()
Пример #18
0
 def doExit(self):
     if self.df.frt == "C" and self.df.col != 1:
         chk = self.sql.getRec("bwlgme", where=[("bcg_cono", "=",
             self.opts["conum"]), ("bcg_ccod", "=", self.ccod), ("bcg_game",
             "=", self.gcod), ("bcg_aflag", "in", ("", "D"))])
         for c in chk:
             scod = c[self.sql.bwlgme_col.index("bcg_scod")]
             ocod = c[self.sql.bwlgme_col.index("bcg_ocod")]
             if scod > 900000 or ocod > 900000:
                 continue
             if self.ponly == "Y":
                 fors = c[self.sql.bwlgme_col.index("bcg_points")]
                 agts = self.sql.getRec("bwlgme",
                     cols=["bcg_points"], where=[("bcg_cono", "=",
                     self.opts["conum"]), ("bcg_ccod", "=", self.ccod),
                     ("bcg_game", "=", self.gcod), ("bcg_scod",
                     "=", ocod)], limit=1)[0]
             else:
                 fors = c[self.sql.bwlgme_col.index("bcg_sfor")]
                 agts = c[self.sql.bwlgme_col.index("bcg_sagt")]
             if not fors and not agts:
                 self.df.focusField(self.df.frt, self.df.pag, self.df.col,
                     err="Missing Score Card for Skips %s and %s" % (scod,
                     ocod))
                 return
         if self.cfmat in ("D", "K") and self.gcod != self.games:
             # Delete Next Round's Records
             whr = [
                 ("bcg_cono", "=", self.opts["conum"]),
                 ("bcg_ccod", "=", self.ccod)]
             w = whr[:]
             w.append(("bcg_game", ">", self.gcod))
             self.sql.delRec("bwlgme", where=w)
             # Create Next Round's Records
             whr.append(("bcg_game", "=", self.gcod))
             odr = "bcg_group, bcg_pair, bcg_scod"
             g = self.sql.bwlgme_col
             for grp in range(1, 3):
                 w = whr[:]
                 w.append(("bcg_group", "=", grp))
                 recs = self.sql.getRec("bwlgme", where=w, order=odr)
                 for num in range(0, len(recs), 2):
                     pair = int(num / 2) + 1
                     rec1 = copyList(recs[num])
                     if len(recs) == 1:
                         w = whr[:]
                         w.append(("bcg_group", "=", 2))
                         rec2 = self.sql.getRec("bwlgme", where=w,
                             order=odr, limit=1)
                         grp = 2
                     else:
                         rec2 = copyList(recs[num + 1])
                     skp1 = rec1[g.index("bcg_scod")]
                     opp1 = rec1[g.index("bcg_ocod")]
                     for1 = rec1[g.index("bcg_sfor")]
                     agt1 = rec1[g.index("bcg_sagt")]
                     skp2 = rec2[g.index("bcg_scod")]
                     opp2 = rec2[g.index("bcg_ocod")]
                     for2 = rec2[g.index("bcg_sfor")]
                     agt2 = rec2[g.index("bcg_sagt")]
                     if opp1 > 900000:
                         pl1 = skp1
                     elif for1 > agt1:
                         pl1 = skp1
                     else:
                         pl1 = opp1
                     if opp2 > 900000:
                         pl2 = skp2
                     elif for2 > agt2:
                         pl2 = skp2
                     else:
                         pl2 = opp2
                     dat = [self.opts["conum"], self.ccod, pl1,
                         self.gcod + 1, "D", 0, pl2, "", grp, 0,
                         0, 0.0, 0, 0, 0.0, "", 0, pair]
                     self.sql.insRec("bwlgme", data=dat)
                 if len(recs) == 1:
                     break
             self.opts["mf"].dbm.commitDbase()
         if self.cfmat in ("D", "K"):
             callModule(self.opts["mf"], self.df, "bc2050",
                 coy=[self.opts["conum"], self.opts["conam"]],
                 args=self.ccod)
     self.df.closeProcess()
     self.opts["mf"].closeLoop()
Пример #19
0
 def doStatement(self, tdc, lm2):
     l2c = self.sql.lonmf2_col
     ltc = copyList(self.sql.lontrn_col)
     self.loan = lm2[l2c.index("lm2_loan")]
     for col in l2c:
         d = "%s_C00" % col
         if d in self.form.newdic:
             dat = lm2[l2c.index(col)]
             self.form.newdic[d][tdc.index("tpd_text")] = dat
     if self.pend == "Y":
         # Raise Pending Interest
         LoanInterest("L",
                      self.opts["mf"].dbm,
                      lm2,
                      update="Y",
                      tdate=self.date.work,
                      batch="Pending",
                      curdt=self.curdt,
                      capnm="")
     # Get Transactions
     whr = [("lnt_cono", "=", self.opts["conum"]),
            ("lnt_acno", "=", self.acno), ("lnt_loan", "=", self.loan),
            ("lnt_curdt", "<=", self.eperw)]
     odr = "lnt_curdt, lnt_trdt, lnt_type, lnt_refno"
     if self.itot == "Y":
         w = whr[:]
         w.append(("lnt_type", "<>", 4))
         trns = self.sql.getRec("lontrn", where=w, order=odr)
         if self.capb == "A":  # Anniversary
             fcap = [lm2[l2c.index("lm2_start")], 0]
             if self.capf == "A":
                 fcap[1] = projectDate(fcap[0], 1, typ="years")
             else:
                 fcap[1] = projectDate(fcap[0], 6, typ="months")
         else:  # Financial
             periods = self.sql.getRec(
                 "ctlynd",
                 cols=["cye_period", "cye_start", "cye_end"],
                 where=[("cye_cono", "=", self.opts["conum"])],
                 order="cye_period")
             fcap = [periods[0][1], periods[0][2]]
             if self.capf == "B":  # Bi-Annual
                 fcap[1] = projectDate(fcap[1], -6, typ="months")
         capdt = [copyList(fcap)]
         while fcap[1] < self.date.work:
             if self.capf == "A":
                 fcap[0] = projectDate(fcap[0], 1, typ="years")
                 fcap[1] = projectDate(fcap[1], 1, typ="years")
             else:
                 fcap[0] = projectDate(fcap[0], 6, typ="months")
                 fcap[1] = projectDate(fcap[1], 6, typ="months")
             if fcap[1] <= self.date.work:
                 capdt.append(copyList(fcap))
         for capd in capdt:
             w = whr[:]
             w.append(("lnt_type", "=", 4))
             w.append(("lnt_trdt", "between", capd[0], capd[1]))
             ints = self.sql.getRec("lontrn", where=w, order=odr)
             if not ints:
                 continue
             ddes = "Dr Int %s to %s"
             cdes = "Cr Int %s to %s"
             dbal = 0
             cbal = 0
             for trn in ints:
                 amt = trn[ltc.index("lnt_tramt")]
                 if amt < 0:
                     cbal = float(ASD(cbal) + ASD(amt))
                 else:
                     dbal = float(ASD(dbal) + ASD(amt))
             if dbal:
                 trn[ltc.index("lnt_tramt")] = dbal
                 trn[ltc.index("lnt_desc")] = ddes % (CCD(
                     int(capd[0] / 100), "D2",
                     7).disp, CCD(int(capd[1] / 100), "D2", 7).disp)
                 trns.append(copyList(trn))
             if cbal:
                 trn[ltc.index("lnt_tramt")] = cbal
                 trn[ltc.index("lnt_desc")] = cdes % (CCD(
                     int(capd[0] / 100), "D2",
                     7).disp, CCD(int(capd[1] / 100), "D2", 7).disp)
                 trns.append(copyList(trn))
         trns = sorted(trns, key=itemgetter(5))
     else:
         trns = self.sql.getRec("lontrn", where=whr, order=odr)
     if not trns:
         return
     self.bal = 0
     self.tots = 0
     if self.sperw:
         obal = 0
         trans = copyList(trns)
         for trn in trans:
             tramt = trn[self.sql.lontrn_col.index("lnt_tramt")]
             if trn[self.sql.lontrn_col.index("lnt_curdt")] < self.sperw:
                 obal = float(ASD(obal) + ASD(tramt))
                 trns.remove(trn)
         trn[ltc.index("lnt_type")] = 3
         trn[ltc.index("lnt_trdt")] = (self.sperw * 100) + 1
         trn[ltc.index("lnt_refno")] = "O/Bal"
         trn[ltc.index("lnt_batch")] = ""
         trn[ltc.index("lnt_tramt")] = obal
         trn[ltc.index("lnt_desc")] = "Opening Balance"
         trn[ltc.index("lnt_batind")] = ""
         trns.insert(0, trn)
     trans = []
     for trn in trns:
         tramt = trn[ltc.index("lnt_tramt")]
         self.tots = float(ASD(self.tots) + ASD(tramt))
         if tramt < 0:
             trn.extend([0, tramt])
         else:
             trn.extend([tramt, 0])
         trans.append(trn)
     ltc.extend(["line_debit", "line_credit"])
     if self.zeros == "N" and not self.tots:
         return
     self.doBody(ltc, trans, tdc)
     self.doTotal(tdc)
     self.doTail(tdc)
     if self.pend == "Y":
         self.opts["mf"].dbm.rollbackDbase()
     if self.df.repeml[1] == "Y" and not self.emadd:
         self.df.repeml[2] = self.emlto
         self.doPrint()
Пример #20
0
 def doRaiseDep(self):
     # Calculate Depreciations and check if Raised
     # else create transaction and accumulate variables
     #
     # Extract Closing Balance at lurdt
     where = [("ast_cono", "=", self.opts["conum"]),
              ("ast_group", "=", self.group.work),
              ("ast_code", "=", self.code)]
     whr = copyList(where)
     whr.append(("ast_curdt", "<=", self.lurdt))
     bal = self.sql.getRec(
         "asstrn",
         cols=["round(sum(ast_amt1), 2)", "round(sum(ast_amt2), 2)"],
         where=whr,
         limit=1)
     if bal and bal[0] <= 0:
         return
     # Get Date Purchased and Months to trdt
     self.trdt = mthendDate(self.lurdt * 100)
     acc = self.sql.getRec("asstrn",
                           cols=["min(ast_date)"],
                           where=[("ast_cono", "=", self.opts["conum"]),
                                  ("ast_group", "=", self.group.work),
                                  ("ast_code", "=", self.code),
                                  ("ast_mtyp", "=", 1)],
                           limit=1)
     years = dateDiff(acc[0], self.trdt, "years")
     if years > 6:
         # Maximum of 7 variable rates in assdep record
         years = 6
     # Extract Depreciation up to previous year end
     whr = copyList(where)
     whr.extend([("ast_mtyp", "=", 4), ("ast_curdt", "<", self.sper)])
     pmd = self.sql.getRec(
         "asstrn",
         cols=["round(sum(ast_amt1), 2)", "round(sum(ast_amt2), 2)"],
         where=whr,
         limit=1)
     if not pmd[0]:
         pmd[0] = 0
     if not pmd[1]:
         pmd[1] = 0
     #
     # Extract Depreciation for lurdt
     whr = copyList(where)
     whr.extend([("ast_mtyp", "=", 4), ("ast_curdt", "=", self.lurdt)])
     cmd = self.sql.getRec("asstrn",
                           cols=[
                               "max(ast_refno)", "round(sum(ast_amt1), 2)",
                               "round(sum(ast_amt2), 2)"
                           ],
                           where=whr,
                           limit=1)
     if not cmd[0] or cmd[0] == "Take-On":
         self.refno = CCD(1, "Na", 9).work
     else:
         self.refno = CCD(cmd[0], "Na", 9).work
     if not cmd[1]:
         cmd[1] = 0
     if not cmd[2]:
         cmd[2] = 0
     if self.dep[self.sql.assdep_col.index("asd_typec")] == "S":
         # Straight Line
         cval = self.cap
         crat = self.dep[self.sql.assdep_col.index("asd_rate1c")]
         for x in range(2, years + 2):
             n = self.dep[self.sql.assdep_col.index("asd_rate%sc" % x)]
             if n:
                 crat = n
     else:
         # Depreciating Balance
         cval = float(ASD(self.cap) + ASD(pmd[0]))
         crat = self.dep[self.sql.assdep_col.index("asd_rate1c")]
     if cval:
         if cval < 0:
             cdep = 0
         else:
             cdep = round((cval * crat / 100.0 / 12), 2)
             cdep = float(ASD(cdep) + ASD(cmd[1]))
             cbal = float(ASD(bal[0]) - ASD(cdep))
             if cbal < 0:
                 cdep = float(ASD(cdep) + ASD(cbal))
             cdep = float(ASD(0) - ASD(cdep))
     typer = self.dep[self.sql.assdep_col.index("asd_typer")]
     if self.rordp == "N" or typer == "N":
         rdep = 0
     else:
         if typer == "S":
             # Straight Line
             rval = self.cap
             rrat = self.dep[self.sql.assdep_col.index("asd_rate1r")]
             for x in range(2, years + 2):
                 n = self.dep[self.sql.assdep_col.index("asd_rate%sr" % x)]
                 if n:
                     rrat = n
         else:
             # Depreciating Balance
             rval = float(ASD(self.cap) + ASD(pmd[1]))
             rrat = self.dep[self.sql.assdep_col.index("asd_rate1r")]
         if rval:
             if rval < 0:
                 rdep = 0
             else:
                 rdep = round((rval * rrat / 100.0 / 12), 2)
                 rdep = float(ASD(rdep) + ASD(cmd[2]))
                 rbal = float(ASD(bal[1]) - ASD(rdep))
                 if rbal < 0:
                     rdep = float(ASD(rdep) + ASD(rbal))
                 rdep = float(ASD(0) - ASD(rdep))
     if cdep or rdep:
         data = [
             self.opts["conum"], self.group.work, self.code, 4, self.refno,
             "AutoDep", self.trdt, 4, cdep, rdep, 0, self.lurdt,
             "Auto Raising of Depreciation", "", "", self.opts["capnm"],
             self.sysdtw, 0
         ]
         self.sql.insRec("asstrn", data=data)
         if self.glint == "Y" and cdep:
             self.doWriteGen(self.depacc, cdep)
             cdep = float(ASD(0) - ASD(cdep))
             self.doWriteGen(self.expacc, cdep)
Пример #21
0
 def doEnd(self):
     if "args" in self.opts:
         self.whole = "S"
         self.current = "N"
         self.zeros = "Y"
         self.paid = "Y"
         self.minus = "Y"
         self.mes = None
         self.mes = self.sql.getRec("ctlmes",
                                    cols=["mss_detail"],
                                    where=[("mss_system", "=", "MEM"),
                                           ("mss_message", "=", 1)],
                                    limit=1)
         self.curdt = int(self.opts["args"][1] / 100)
         self.dated = CCD(self.opts["args"][1], "D1", 10).disp
         self.pro = False
         self.repprt = self.opts["args"][2]
         self.repeml = self.opts["args"][3]
         recs = [self.opts["args"][0]]
     else:
         self.df.closeProcess()
         self.repprt = self.df.repprt
         self.repeml = self.df.repeml
         whr = [("mlm_cono", "=", self.opts["conum"])]
         if self.status != "Z":  # Not All
             whr.append(("mlm_state", "=", self.status))
         if self.sort == "N":
             odr = "mlm_memno"
         else:
             odr = "mlm_surname"
         if self.whole == "S":
             recs = getSingleRecords(
                 self.opts["mf"],
                 "memmst", ("mlm_memno", "mlm_surname", "mlm_names"),
                 head=["X", "Number", "Surname", "Names"],
                 where=whr,
                 order=odr,
                 selcol="mlm_surname")
         else:
             if self.whole == "R":
                 whr.append(("mlm_memno", "between", self.start, self.to))
             recs = self.sql.getRec("memmst", where=whr, order=odr)
             if not recs:
                 showError(self.opts["mf"].body, "Error",
                           "No Accounts Selected")
                 if "wait" not in self.opts:
                     self.opts["mf"].closeLoop()
                 return
         # Remove all linked accounts
         col = self.sql.memmst_col
         nos = []
         for acc in recs:
             nos.append(acc[col.index("mlm_memno")])
         chk = copyList(recs)
         for acc in chk:
             whr = [("mll_cono", "=", self.opts["conum"]),
                    ("mll_lnkno", "=", acc[col.index("mlm_memno")])]
             lnk = self.sql.getRec("memlnk", where=whr, limit=1)
             if lnk and lnk[1] in nos:
                 recs.remove(acc)
     if recs:
         self.emadd = self.repeml[2]
         self.form = DrawForm(self.opts["mf"].dbm,
                              self.tname,
                              wrkdir=self.opts["mf"].rcdic["wrkdir"])
         self.doLoadStatic()
         self.form.doNewDetail()
         if self.repeml[1] == "N":
             mess = "Printing Statements"
         else:
             mess = "Printing and Emailing Statements"
         p = ProgressBar(self.opts["mf"].body,
                         typ=mess,
                         mxs=len(recs),
                         esc=True)
         for num, rec in enumerate(recs):
             p.displayProgress(num)
             if p.quit:
                 break
             if self.pro:
                 self.doProForma(rec)
             self.doProcess(rec)
         p.closeProgress()
         if self.pro:
             self.opts["mf"].dbm.rollbackDbase()
         if p.quit or not self.form.page:
             pass
         elif self.repeml[1] == "N" or self.emadd:
             self.repeml[2] = self.emadd
             self.doPrint()
     if "wait" not in self.opts:
         self.opts["mf"].closeLoop()
Пример #22
0
 def doChange(self, chgs):
     if self.doimp:
         p1 = ProgressBar(self.opts["mf"].body,
                          typ="",
                          mxs=len(self.tables))
         genrpt = "no"
     else:
         genrpt = askQuestion(
             self.opts["mf"].body,
             head="Report Generator",
             mess="Apply this Change to the Report Generator as well?",
             default="no")
     for num, tab in enumerate(self.tables):
         if tab[0] == "genrpt" and genrpt == "no":
             continue
         if self.doimp:
             p1.txtlab.configure(text="Changing %s Table" % tab[0])
             p1.displayProgress(num)
         new = []
         if self.doimp:
             p2 = ProgressBar(self.opts["mf"].body,
                              inn=p1,
                              typ="",
                              mxs=len(chgs))
         for seq, chg in enumerate(chgs):
             if self.doimp:
                 p2.txtlab.configure(text="Changing Number %s to %s" %
                                     (chg[0], chg[1]))
                 p2.displayProgress(seq)
             # Get records for this change
             oldacc, newacc = chg
             if tab[0] == "genrpt":
                 whr = [(tab[1], "in", (0, self.opts["conum"]))]
             else:
                 whr = [(tab[1], "=", self.opts["conum"])]
             if tab[0] == "ctlnot":
                 whr.extend([("not_sys", "=", "GEN"),
                             (tab[2], "=", str(oldacc))])
             elif tab[0] == "ctlvtf":
                 oldacc = CCD(oldacc, "Na", 7).work
                 newacc = CCD(newacc, "Na", 7).work
                 whr.extend([(tab[2], "=", oldacc), (tab[3], "=", "G")])
             else:
                 whr.append((tab[2], "=", oldacc))
             recs = self.sql.getRec(tables=tab[0], where=whr)
             if not recs:
                 continue
             # Delete records
             self.sql.delRec(tab[0], where=whr)
             # Make changes
             col = getattr(self.sql, "%s_col" % tab[0])
             pos = col.index(tab[2])
             cpy = copyList(recs)
             for rec in cpy:
                 rec[pos] = newacc
                 new.append(rec)
         if self.doimp:
             p2.closeProgress()
         if new:
             self.sql.insRec(tab[0], data=new)
     if self.doimp:
         p1.closeProgress()
         self.opts["mf"].dbm.commitDbase(ask=True)
Пример #23
0
 def doEnd(self):
     self.df.closeProcess()
     dat = []
     tps = []
     if self.drawn == "Y":
         tps.extend(["B", "D"])
     if self.bounce == "Y":
         tps.append("A")
     if self.teams == "Y":
         tps.append("C")
     where = [("bdt_cono", "=", self.opts["conum"]),
              ("bdt_tab", "<", self.nstart), ("bdt_flag", "in", tps)]
     if self.start.work:
         where.append(("bdt_date", ">=", self.start.work))
     if self.end.work:
         where.append(("bdt_date", "<=", self.end.work))
     whr = copyList(where)
     if self.whole == "N":
         tab = []
         rec = getSingleRecords(self.opts["mf"],
                                "bwldrt", ("bdt_tab", "bdt_name"),
                                head=["X", "Tab-No", "Name"],
                                where=whr,
                                group="bdt_tab, bdt_name",
                                order="bdt_name",
                                selcol="bdt_name")
         if not rec:
             self.opts["mf"].closeLoop()
             return
         for r in rec:
             tab.append(r[1])
         whr.append(("bdt_tab", "in", tab))
     odr = "bdt_name, bdt_date"
     rec = self.sql.getRec("bwldrt", where=whr, order=odr)
     c = self.sql.bwldrt_col
     l = ""
     self.dic = {}
     for r in rec:
         dte = CCD(r[c.index("bdt_date")], "D1", 10)
         tim = r[c.index("bdt_time")]
         bdm = self.sql.getRec("bwldrm",
                               where=[("bdm_cono", "=", self.opts["conum"]),
                                      ("bdm_date", "=", dte.work),
                                      ("bdm_time", "=", tim)],
                               limit=1)
         if bdm[self.sql.bwldrm_col.index("bdm_dhist")] == "N":
             continue
         self.clash = ""
         side = [["", ""], ["", ""], ["", ""], ["", ""]]
         self.tab = r[c.index("bdt_tab")]
         if self.tab not in self.dic:
             self.dic[self.tab] = []
         nam = self.getName(self.tab)
         pos = (0 - (r[c.index("bdt_pos")] - 4))
         side[pos] = ["", nam]
         for x in range(1, 4):
             tm = self.getName(r[c.index("bdt_team%s" % x)])
             if not tm:
                 continue
             if self.clash:
                 cl = "X"
             else:
                 cl = ""
             pos = (0 - (r[c.index("bdt_pos%s" % x)] - 4))
             side[pos] = [cl, tm]
         if self.tab != l:
             if l:
                 dat.append([])
             d = [nam]
         else:
             d = [""]
         d.extend([dte.disp, side[0], side[1], side[2], side[3]])
         dat.append(d)
         l = self.tab
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=120, auto=True)
     self.fpdf.header = self.pageHeading
     if self.tots == "N":
         # Print teams
         self.heading = "main"
         self.fpdf.add_page()
         cwth = self.fpdf.get_string_width("X")
         for d in dat:
             if not d:
                 self.fpdf.drawText(txt="", w=0, h=5, border=0, ln=1)
             else:
                 self.fpdf.cell(w=cwth * 21, h=5, txt=d[0], border=0, ln=0)
                 self.fpdf.cell(w=cwth * 11, h=5, txt=d[1], border=0, ln=0)
                 if d[2][0]:
                     self.fpdf.cell(w=cwth * 21,
                                    h=5,
                                    txt=d[2][1],
                                    border=1,
                                    ln=0)
                 else:
                     self.fpdf.cell(w=cwth * 21,
                                    h=5,
                                    txt=d[2][1],
                                    border=0,
                                    ln=0)
                 if d[3][0]:
                     self.fpdf.cell(w=cwth * 21,
                                    h=5,
                                    txt=d[3][1],
                                    border=1,
                                    ln=0)
                 else:
                     self.fpdf.cell(w=cwth * 21,
                                    h=5,
                                    txt=d[3][1],
                                    border=0,
                                    ln=0)
                 if d[4][0]:
                     self.fpdf.cell(w=cwth * 21,
                                    h=5,
                                    txt=d[4][1],
                                    border=1,
                                    ln=0)
                 else:
                     self.fpdf.cell(w=cwth * 21,
                                    h=5,
                                    txt=d[4][1],
                                    border=0,
                                    ln=0)
                 if d[5][0]:
                     self.fpdf.cell(w=cwth * 21,
                                    h=5,
                                    txt=d[5][1],
                                    border=1,
                                    ln=1)
                 else:
                     self.fpdf.cell(w=cwth * 21,
                                    h=5,
                                    txt=d[5][1],
                                    border=0,
                                    ln=1)
     if self.whole == "Y" or self.tots == "Y":
         # Print top attendees
         self.heading = "summary"
         whr = copyList(where)
         whr.append(("bdt_tab", "<", self.nstart))
         self.cnt = self.sql.getRec("bwldrt",
                                    cols=["count(*) as count", "bdt_tab"],
                                    where=whr,
                                    group="bdt_tab",
                                    order="count desc, bdt_name")
         while self.cnt:
             self.fpdf.add_page()
             if len(self.cnt) < 26:
                 left = copyList(self.cnt)
                 self.cnt = []
                 right = []
             else:
                 left = self.cnt[:25]
                 self.cnt = self.cnt[25:]
                 if len(self.cnt) < 26:
                     right = copyList(self.cnt)
                     self.cnt = []
                 else:
                     right = self.cnt[:25]
                     self.cnt = self.cnt[25:]
             left = left + (25 - len(left)) * [["", ""]]
             right = right + (25 - len(right)) * [["", ""]]
             self.fpdf.set_font("Arial", "", 15)
             cwth = self.fpdf.get_string_width("X")
             for x in range(25):
                 if left[x][1]:
                     left[x][1] = self.getName(left[x][1], cls=False)
                 if right[x][1]:
                     right[x][1] = self.getName(right[x][1], cls=False)
                 self.fpdf.cell(cwth * 5, 8, "%5s " % left[x][0], 0, 0, "R")
                 self.fpdf.cell(cwth * 24, 8, left[x][1], 0, 0, "L")
                 self.fpdf.cell(cwth * 5, 8, "%5s " % right[x][0], 0, 0,
                                "R")
                 self.fpdf.cell(cwth * 20, 8, right[x][1], 0, 1, "L")
     pdfnam = getModName(self.opts["mf"].rcdic["wrkdir"],
                         self.__class__.__name__,
                         self.opts["conum"],
                         ext="pdf")
     self.fpdf.output(pdfnam, "F")
     head = "Tabs Draw Summary for the period %s to %s" % (self.start.disp,
                                                           self.end.disp)
     doPrinter(mf=self.opts["mf"],
               conum=self.opts["conum"],
               pdfnam=pdfnam,
               header=head,
               repprt=self.df.repprt,
               fromad=self.fromad,
               repeml=self.df.repeml)
     self.opts["mf"].closeLoop()
Пример #24
0
 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()
Пример #25
0
 def doHKeeping(self):
     recs = self.sql.getRec("bkmunm", cols=["bum_btyp", "bum_code",
         "bum_desc"], where=[("bum_cono", "=", self.opts["conum"]),
         ("bum_room", "<>", 999)], order="bum_btyp, bum_code")
     for rec in recs:
         col = ["bkm_number", "bkm_btype", "bkm_group", "bkc_sname",
             "bkc_names", "bkm_arrive", "bkm_depart", "sum(brt_quant)"]
         state = ["C", "S"]
         if self.query == "Y":
             state.append("Q")
         bks = self.sql.getRec(tables=["bkmmst", "bkmrtt", "bkmcon"],
             cols=col, where=[("bkm_cono", "=", self.opts["conum"]),
             ("bkm_state", "in", tuple(state)), ("brt_cono=bkm_cono",),
             ("brt_number=bkm_number",), ("brt_utype", "=", rec[0]),
             ("brt_ucode", "=", rec[1]), ("bkc_cono=bkm_cono",),
             ("bkc_ccode=bkm_ccode",)], order="bkm_arrive, bkc_sname")
         qty = ""
         arr = ""
         dep = ""
         amt = ""
         totq = 0
         lines = []
         hh = [8, 8, 8]
         for bk in bks:
             number = bk[0]
             btype = bk[1]
             if bk[2]:
                 name = bk[2]
             elif bk[4]:
                 name = "%s %s" % (bk[4].split()[0], bk[3])
             else:
                 name = bk[3]
             name = "%s\n(%s)" % (name.strip(), number)
             arrive = bk[5]
             depart = bk[6]
             if btype == "A":
                 if depart <= self.start or arrive > self.end:
                     continue
             elif depart < self.start or arrive > self.end:
                 continue
             if arrive >= self.start:
                 yr = int(arrive / 10000)
                 mt = int(arrive / 100) % 100
                 dy = arrive % 100
                 dt = datetime.date(yr, mt, dy)
                 arrive = dt.strftime("%a")
             else:
                 arrive = "<--"
             if btype == "A":
                 td = projectDate(depart, -1)
             else:
                 td = depart
             if td <= self.end:
                 yr = int(depart / 10000)
                 mt = int(depart / 100) % 100
                 dy = depart % 100
                 dt = datetime.date(yr, mt, dy)
                 depart = dt.strftime("%a")
             else:
                 depart = "-->"
             rms = self.sql.getRec("bkmrtt",
                 cols=["brt_uroom"],
                 where=[
                     ("brt_cono", "=", self.opts["conum"]),
                     ("brt_number", "=", number),
                     ("brt_utype", "=", rec[0]),
                     ("brt_ucode", "=", rec[1])],
                 order="brt_uroom")
             rm = False
             for r in rms:
                 if not r[0]:
                     continue
                 if not rm:
                     name = "%s - R%s" % (name, r[0])
                     rm = True
                 else:
                     name = "%s & R%s" % (name, r[0])
             quant = bk[7]
             bal = self.sql.getRec("bkmtrn", cols=["sum(bkt_tramt)"],
                 where=[("bkt_cono", "=", self.opts["conum"]), ("bkt_number",
                 "=", number)], limit=1)
             namq = len(wrap(name, break_long_words=False, width=25))
             totq += namq
             hh[2] = namq * 8
             qty = CCD(quant, "UI", 3).disp
             arr = CCD(arrive, "NA", 3).disp
             dep = CCD(depart, "NA", 3).disp
             amt = CCD(bal[0], "SD", 13.2).disp
             lines.append([name, qty, arr, dep, amt, copyList(hh)])
         if not self.fpdf.page or self.fpdf.get_y() + (totq * 8) > 280:
             self.fpdf.add_page()
         untq = len(wrap(rec[2], break_long_words=False, width=25))
         if not lines:
             hh[1] = hh[2] = 8.0 * untq
             self.y = self.fpdf.get_y()
             self.printLine(rec[2], "", "", "", "", "", hh)
             self.fpdf.set_y(self.y)
             self.printLine(None, "", "", "", "", "", hh)
         else:
             if untq > totq:
                 hh[1] = hh[2] = (untq * 8.0) / totq
             elif totq > untq:
                 hh[0] = (totq * 8.0) / untq
             else:
                 hh[2] = totq * 8
             self.y = self.fpdf.get_y()
             self.printLine(rec[2], "", "", "", "", "", hh)
             self.fpdf.set_y(self.y)
             for l in lines:
                 self.printLine(None, l[0], l[1], l[2], l[3], l[4], l[5])
Пример #26
0
 def printReport(self, recs):
     p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True)
     self.head = "%03u %-145s" % (self.opts["conum"], self.opts["conam"])
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head)
     self.pglin = 999
     mst = self.sql.rtlmst_col
     con = self.sql.rtlcon_col
     self.tots = [0, 0, 0, 0, 0]
     for num, dat in enumerate(recs):
         p.displayProgress(num)
         if p.quit:
             break
         code = CCD(dat[con.index("rtc_code")], "NA", 7)
         acno = CCD(dat[con.index("rtc_acno")], "NA", 7)
         cnum = CCD(dat[con.index("rtc_cnum")], "UI", 3)
         freq = CCD(dat[con.index("rtc_payind")], "UA", 1)
         strt = CCD(dat[con.index("rtc_start")], "D1", 10)
         prds = CCD(dat[con.index("rtc_period")], "UI", 3)
         stat = CCD(dat[con.index("rtc_status")], "UA", 1)
         if self.styp != "X":
             curdt = int(self.date / 100)
             if self.months:
                 yy = int(curdt / 100)
                 mm = (curdt % 100) + self.months
                 while mm > 12:
                     yy += 1
                     mm -= 12
                 curdt = (yy * 100) + mm
             if freq.work == "M":
                 mths = 1 * prds.work
             elif freq.work == "3":
                 mths = 3 * prds.work
             elif freq.work == "6":
                 mths = 6 * prds.work
             else:
                 mths = 12 * prds.work
             yy = int(strt.work / 10000)
             mm = int((strt.work % 10000) / 100) + mths - 1
             while mm < 1:
                 yy -= 1
                 mm += 12
             while mm > 12:
                 yy += 1
                 mm -= 12
             chkmth = copyList(mthnam)
             if mm == 2:
                 if not yy % 4:
                     chkmth[2][2] = 29
                 else:
                     chkmth[2][2] = 28
             exdt = CCD(((yy * 10000) + (mm * 100) + chkmth[mm][2]), "D1",
                        10)
             if self.styp == "E" and int(exdt.work / 100) > curdt:
                 continue
         else:
             exdt = CCD(0, "d1", 10)
         acc = self.sql.getRec("rtlmst",
                               where=[("rtm_cono", "=", self.opts["conum"]),
                                      ("rtm_code", "=", code.work),
                                      ("rtm_acno", "=", acno.work)],
                               limit=1)
         name = CCD(acc[mst.index("rtm_name")], "NA", 30)
         if self.cons == "Y":
             trn = self.sql.getRec(
                 "rtltrn",
                 cols=["rtt_type", "round(sum(rtt_tramt), 2)"],
                 where=[("rtt_cono", "=", self.opts["conum"]),
                        ("rtt_code", "=", code.work),
                        ("rtt_acno", "=", acno.work),
                        ("rtt_trdt", "<=", self.date)],
                 group="rtt_type")
         else:
             trn = self.sql.getRec(
                 "rtltrn",
                 cols=["rtt_type", "round(sum(rtt_tramt), 2)"],
                 where=[("rtt_cono", "=", self.opts["conum"]),
                        ("rtt_code", "=", code.work),
                        ("rtt_acno", "=", acno.work),
                        ("rtt_cnum", "=", cnum.work),
                        ("rtt_trdt", "<=", self.date)],
                 group="rtt_type")
         rtl = CCD(0, "SD", 13.2)
         rec = CCD(0, "SD", 13.2)
         pmt = CCD(0, "SD", 13.2)
         jnl = CCD(0, "SD", 13.2)
         if trn:
             for t in trn:
                 if t[0] == 1:
                     rtl = CCD(t[1], "SD", 13.2)
                 elif t[0] == 2:
                     rec = CCD(t[1], "SD", 13.2)
                 elif t[0] == 3:
                     pmt = CCD(t[1], "SD", 13.2)
                 elif t[0] == 4:
                     jnl = CCD(t[1], "SD", 13.2)
         bal = float(ASD(rtl.work) + ASD(rec.work) + ASD(pmt.work) + \
             ASD(jnl.work))
         bal = CCD(bal, "SD", 13.2)
         if self.pglin > self.fpdf.lpp:
             self.pageHeading()
         self.fpdf.drawText("%s %s %s %s %s %s %s %s %s %s %s %s %s %s" % \
             (code.disp, acno.disp, cnum.disp, name.disp, freq.disp,
             strt.disp, prds.disp, exdt.disp, stat.disp, rtl.disp,
             rec.disp, pmt.disp, jnl.disp, bal.disp))
         self.tots[0] = float(ASD(self.tots[0]) + ASD(rtl.work))
         self.tots[1] = float(ASD(self.tots[1]) + ASD(rec.work))
         self.tots[2] = float(ASD(self.tots[2]) + ASD(pmt.work))
         self.tots[3] = float(ASD(self.tots[3]) + ASD(jnl.work))
         self.tots[4] = float(ASD(self.tots[4]) + ASD(bal.work))
         self.pglin += 1
     t = []
     for x in range(5):
         t.append(CCD(self.tots[x], "SD", 13.2).disp)
     self.fpdf.underLine(txt=self.head)
     self.fpdf.drawText("%19s %-30s %29s %-13s %-13s %-13s %-13s %-13s" % \
         ("", "Grand Totals", "", t[0], t[1], t[2], t[3], t[4]))
     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,
                   fromad=self.fromad,
                   repeml=self.df.repeml)
     self.closeProcess()
Пример #27
0
 def doEnd(self):
     self.df.closeProcess()
     chk = self.sql.getRec("bwlgme", cols=["bcg_group", "bcg_scod"],
         where=[("bcg_cono", "=", self.opts["conum"]), ("bcg_ccod", "=",
         self.ccod), ("bcg_game", "=", self.pgame)], order="bcg_group")
     if chk[0][0] and self.cfmat == "R":
         groups = "Y"
     else:
         groups = self.groups
     self.grps = {}
     for rec in chk:
         if rec[0] not in self.grps:
             self.grps[rec[0]] = [[rec[1]], [], []]
         else:
             self.grps[rec[0]][0].append(rec[1])
     self.keys = list(self.grps.keys())
     self.keys.sort()
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=65)
     self.lastg = None
     for g in self.keys:
         self.pageHeading()
         if self.gamrep == "Y":
             self.doReport("G", g)
             if g == 0 and len(chk) > 20:
                 self.pageHeading()
         self.doReport("M", g)
     if self.pgame == self.games:
         # Enter Prizes
         for key in self.keys:
             if self.cfmat == "R" and groups == "Y":
                 self.grps[key][1] = 0
             else:
                 self.doPrizes(key)
         # Match Winners & Summary
         self.gqty = len(self.keys)
         self.wins = {}
         self.allp = []
         self.swin = []
         self.where = [
             ("bcg_cono", "=", self.opts["conum"]),
             ("bcg_ccod", "=", self.ccod),
             ("bcg_game", "<=", self.pgame),
             ("btb_cono=bcg_cono",),
             ("btb_tab=bcg_scod",)]
         for grp in range(self.gqty):
             if groups == "Y":
                 gcod = grp + 1
             else:
                 gcod = grp
             whr = copyList(self.where)
             whr.append(("bcg_group", "=", gcod))
             col = [
                 "bcg_scod", "btb_surname", "btb_names",
                 "sum(bcg_a_sfor) as sfor",
                 "sum(bcg_a_sagt) as sagt",
                 "sum(bcg_a_sfor - bcg_a_sagt) as agg",
                 "sum(bcg_a_points) as pts"]
             recs = self.sql.getRec(tables=["bwlgme", "bwltab"], cols=col,
                 where=whr, group="bcg_scod, btb_surname, btb_names",
                 order="pts desc, agg desc, sagt asc")
             if not recs:
                 continue
             self.wins[gcod] = []
             for x in range(self.grps[gcod][1]):
                 self.allp.append(recs[x][0])
                 if recs[x][2]:
                     nam = "%s, %s" % (recs[x][1], recs[x][2].split()[0])
                 else:
                     nam = recs[x][1]
                 self.wins[gcod].append(nam)
             if self.cfmat == "R" and groups == "Y":
                 self.swin.append(self.grps[gcod][0][0])
         if self.sesp == "Y":
             self.pageHeading("S")
             self.doSesWin()
         else:
             for grp in self.wins:
                 if self.wins[grp]:
                     self.pageHeading("S")
                     break
         self.doMatchWin()
     pdfnam = getModName(self.opts["mf"].rcdic["wrkdir"],
         self.__class__.__name__, "report", ext="pdf")
     self.fpdf.output(pdfnam, "F")
     if self.df.repeml[1] == "Y":
         if not self.df.repeml[2]:
             col = ["btb_mail"]
             whr = [
                 ("bce_cono", "=", self.opts["conum"]),
                 ("bce_ccod", "=", self.ccod),
                 ("btb_cono=bce_cono",),
                 ("btb_tab=bce_scod",),
                 ("btb_mail", "<>", "")]
             recs = self.sql.getRec(tables=["bwlent", "bwltab"], cols=col,
                 where=whr)
             self.df.repeml[2] = []
             for rec in recs:
                 self.df.repeml[2].append(rec[0])
     head = "%s - Results after game %s" % (self.cdes, self.pgame)
     doPrinter(mf=self.opts["mf"], conum=self.opts["conum"], pdfnam=pdfnam,
         header=head, repprt=self.df.repprt, fromad=self.fromad,
         repeml=self.df.repeml)
     if self.pgame == self.lgame and self.cfmat == "R" and \
             groups == "Y" and not self.poff:
         ok = askQuestion(self.opts["mf"].body, "Play-Offs",
             "Must a Play-Off Draw be Created and/or Printed?",
             default="yes")
         if ok == "yes":
             self.doSecEnd()
     self.opts["mf"].closeLoop()
Пример #28
0
 def doBody(self, btc, bkt, tdc):
     page = 0
     count = 0
     self.tbal = 0
     for trans in bkt:
         if not count:
             page += 1
             count = self.doHeader(page)
         if count == self.form.maxlines:
             page = self.doCfwd(page)
             count = self.doHeader(page)
         ldic = {}
         for cod in self.form.body:
             if cod in ("type_code", "line_paid", "line_balance"):
                 continue
             if cod == "bkt_desc":
                 des = self.form.doSplitText("bkt_desc_C00",
                                             trans[btc.index(cod)])
                 if len(des) > 1 and not des[-1]:
                     del des[-1]
             else:
                 ldic[cod] = CCD(trans[btc.index(cod)],
                                 self.form.tptp[cod][0][1],
                                 self.form.tptp[cod][0][2])
         ldic["line_paid"] = 0
         ldic["line_balance"] = ldic["bkt_tramt"].work
         self.tbal = float(ASD(self.tbal) + ASD(ldic["bkt_tramt"].work))
         for n, l in enumerate(des):
             if count == self.form.maxlines:
                 page = self.doCfwd(page)
                 count = self.doHeader(page)
             if n == 0 and len(des) == 1:
                 include = copyList(self.form.body)
             elif n == 0:
                 include = ("bkt_date", "bkt_refno", "type_code")
             elif n + 1 == len(des):
                 include = copyList(self.form.body)
                 include.remove("bkt_date")
                 include.remove("bkt_refno")
                 include.remove("type_code")
             else:
                 include = []
             for code in self.form.body:
                 seq = "%s_C%02i" % (code, count)
                 if code == "bkt_desc":
                     data = l
                 elif code in include:
                     if code == "type_code":
                         data = bktrtp[trans[btc.index("bkt_type")] - 1][0]
                     else:
                         data = ldic[code].work
                 else:
                     data = "BLANK"
                 self.form.newdic[seq][tdc.index("tpd_text")] = data
                 self.form.doDrawDetail(self.form.newdic[seq])
             count += 1
     for x in range(count, self.form.maxlines):
         for cod in self.form.body:
             d = "%s_C%02i" % (cod, x)
             self.form.newdic[d][tdc.index("tpd_text")] = "BLANK"
             self.form.doDrawDetail(self.form.newdic[d])
Пример #29
0
 def doSesWin(self):
     # Session Winners
     sess = {}
     for gme in range(1, self.games + 1):
         col = [
             "bcg_scod", "btb_surname", "btb_names",
             "sum(bcg_sfor) as sfor",
             "sum(bcg_sagt) as sagt",
             "sum(bcg_sfor - bcg_sagt) as agg",
             "sum(bcg_points) as pts"]
         whr = copyList(self.where)
         whr.append(("bcg_game", "=", gme))
         grp = "bcg_scod, btb_surname, btb_names"
         odr = "pts desc, agg desc, sagt asc"
         if self.sesg == "Y" and gme > self.grgame:
             col.append("bcg_group")
             grp = "bcg_group, %s" % grp
             odr = "bcg_group, %s" % odr
         recs = self.sql.getRec(tables=["bwlgme", "bwltab"],
             cols=col, where=whr, group=grp, order=odr)
         done = None
         for rec in recs:
             if len(rec) == 7:
                 gpc = 0
             else:
                 gpc = rec[7]
             if gpc == done:
                 continue
             ign = False
             if self.ponly == "Y" and not rec[6]:
                 break
             if self.ponly == "N" and (not rec[3] and not rec[4]):
                 break
             for grp in range(self.gqty):
                 if rec[0] in self.allp:
                     ign = True
                     break
             if not ign:
                 self.allp.append(rec[0])
                 if gme not in sess:
                     sess[gme] = {}
                 if rec[2]:
                     nam = "%s, %s" % (rec[1], rec[2].split()[0])
                 else:
                     nam = rec[1]
                 sess[gme][gpc] = nam
                 done = gpc
     mess = "Session Winners"
     self.fpdf.setFont(style="B", size=14)
     self.fpdf.drawText(mess, align="C", border="TLRB", fill=1)
     self.fpdf.drawText("Ses", w=12, border="TLRB", fill=1, ln=0)
     if self.sesg == "Y":
         self.fpdf.drawText("Grp", w=12, border="TLRB", fill=1, ln=0)
     self.fpdf.drawText("Name", border="TLRB", fill=1)
     self.fpdf.setFont()
     for gme in range(1, self.games + 1):
         stxt = str("%3s" % gme)
         if gme not in sess:
             self.fpdf.drawText(stxt, w=12, border="TLRB", ln=0)
             if self.sesg == "Y":
                 self.fpdf.drawText("", w=12, border="TLRB", ln=0)
             self.fpdf.drawText("* No Valid Winner or Abandoned *",
                 border="TLRB")
             continue
         grps = list(sess[gme].keys())
         grps.sort()
         for grp in grps:
             gtxt = "%3s" % chr(64 + grp)
             self.fpdf.drawText(stxt, w=12, border="TLRB", ln=0)
             if self.sesg == "Y":
                 self.fpdf.drawText(gtxt, w=12, border="TLRB", ln=0)
             self.fpdf.drawText(sess[gme][grp], border="TLRB")
     self.fpdf.drawText()
Пример #30
0
    def doDropYears(self):
        """
        TABLES is a list of tables to be actioned as follows:

        [tran_table, date_column, [amount columns], mfile_table]
        """
        TABLES = [["asstrn", "ast_curdt", ["ast_amt1", "ast_amt2"], "assmst"],
                  ["bkmtrn", "bkt_curdt", ["bkt_tramt"], "bkmmst"], ["chglog"],
                  ["crspay", "cpt_date", []],
                  ["crstrn", "crt_curdt", ["crt_tramt"], "crsmst"],
                  ["ctlbat", "btm_curdt", []], ["ctllog"], ["ctlnot"],
                  ["ctlvtf", "vtt_curdt", []],
                  ["drstrn", "drt_curdt", ["drt_tramt"], "drsmst"], ["emllog"],
                  ["genbal", "glo_trdt", []], ["genbud", "glb_curdt", []],
                  ["gendtt", "gdt_curdt", []], ["genrct", "grt_date", []],
                  ["gentrn", "glt_curdt", ["glt_tramt"], "genmst"],
                  ["lontrn", "lnt_curdt", ["lnt_tramt"], "lonmf2"],
                  ["memtrn", "mlt_curdt", ["mlt_tramt"], "memmst"],
                  ["memtrs", "mst_trdt", []],
                  ["rcaowt", "rot_curdt", ["rot_tramt"], "rcaowm"],
                  ["rcatnt", "rtu_curdt", ["rtu_tramt"], "rcatnm"],
                  ["rtltrn", "rtt_curdt", ["rtt_tramt"], "rtlmst"],
                  ["slsiv1", "si1_date", []], ["strpom", "pom_date", []],
                  ["strtrn", "stt_curdt", ["stt_qty", "stt_cost"], "strmf1"],
                  ["wagltf", "wlt_curdt", ["wlt_amt"], "waglmf"],
                  ["wagtf1", "wt1_date", []], ["wagtf2", "wt2_date", []]]
        ynds = self.sql.getRec("ctlynd",
                               where=[("cye_cono", "=", self.opts["conum"])],
                               order="cye_period")
        if len(ynds) <= self.years:
            return
        last = ynds[len(ynds) - (self.years + 1)]
        sdate = last[self.sql.ctlynd_col.index("cye_start")]
        edate = last[self.sql.ctlynd_col.index("cye_end")]
        etime = (edate * 10000) + 9999
        emldt = "%04i-%02i-99 99:99" % (int(edate / 10000),
                                        (int(edate / 100) % 100))
        ecurdt = int(edate / 100)
        count = 0
        for ynd in ynds:
            if ynd[1] < last[1]:
                self.sql.delRec("ctlynd",
                                where=[("cye_cono", "=", self.opts["conum"]),
                                       ("cye_period", "=", ynd[1])])
            else:
                self.sql.updRec("ctlynd",
                                cols=["cye_period"],
                                data=[count],
                                where=[("cye_cono", "=", self.opts["conum"]),
                                       ("cye_period", "=", ynd[1])])
                count += 1
        tables = self.sql.getRec("ftable", order="ft_tabl")
        ourtab = []
        for tab in tables:
            ourtab.append(tab[0])
        tabs = list(tabdic.keys())
        if "args" not in self.opts:
            pb = ProgressBar(self.opts["mf"].body,
                             typ=("G", "Dropping Periods Older Than %s Years" %
                                  self.years))
        sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__)
        for tab in TABLES:
            if "args" not in self.opts:
                pb.displayProgress()
            if tab[0] not in ourtab:
                continue
            if tab[0] == "chglog":
                key = "%03i%s" % (self.opts["conum"], "%")
                sql.delRec(tab[0],
                           where=[("chg_key", "like", key),
                                  ("chg_dte", "<=", etime)])
                continue
            if tab[0] == "ctllog":
                sql.delRec(tab[0], where=[("clg_start", "<=", etime)])
                continue
            if tab[0] == "ctlnot":
                sql.delRec(tab[0],
                           where=[("not_cono", "=", self.opts["conum"]),
                                  ("not_date", "<=", edate)])
                continue
            if tab[0] == "emllog":
                sql.delRec(tab[0], where=[("eml_dtt", "<=", emldt)])
                continue
            ftt = self.sql.getRec("ftable", where=[("ft_tabl", "=", tab[0])])
            pfxt = ftt[0][4].split("_")[0]
            coyt = None
            for k in ftt:
                for f in k[4:]:
                    if f.count("_cono"):
                        coyt = f
                        break
                if coyt:
                    break
            if coyt:
                whrt = [(coyt, "=", self.opts["conum"])]
            else:
                whrt = []
            if tab[2]:
                ftm = self.sql.getRec("ftable",
                                      where=[("ft_tabl", "=", tab[3]),
                                             ("ft_seq=1", )],
                                      limit=1)
                pfxm = ftm[4].split("_")[0]
                keyt = []
                keym = []
                coym = None
                for c in ftm[4:]:
                    if c:
                        if c.count("_cono"):
                            coym = c
                        keym.append(c)
                        t = c.replace(pfxm, pfxt)
                        keyt.append(t)
                if coym:
                    whrm = [(coym, "=", self.opts["conum"])]
                else:
                    whrm = []
            if not tab[2]:
                if tab[1].count("_curdt"):
                    whrt.append((tab[1], "<=", ecurdt))
                    sql.delRec(tab[0], where=whrt)
                elif tab[0] == "crspay":
                    whrt.extend([("cpt_date", "<=", edate),
                                 ("cpt_flag", "=", "Y")])
                    sql.delRec(tab[0], where=whrt)
                elif tab[0] == "drsrcm":
                    whrt.append((tab[1], "<=", ecurdt))
                    recs = sql.getRec(tables=tab[0], where=whrt)
                    for num, rec in enumerate(recs):
                        if "args" not in self.opts and not num % 10:
                            pb.displayProgress()
                        sql.delRec(tab[0],
                                   where=[("dcm_cono", "=", rec[0]),
                                          ("dcm_num", "=", rec[1])])
                        sql.delRec("drsrct",
                                   where=[("dct_cono", "=", rec[0]),
                                          ("dct_num", "=", rec[1])])
                elif tab[0] == "genbal":
                    whrt.append((tab[1], "<=", sdate))
                    sql.delRec(tab[0], where=whrt)
                elif tab[0] == "genrct":
                    whrt.append((tab[1], "<=", sdate))
                    sql.delRec(tab[0], where=whrt)
                elif tab[0] == "memtrs":
                    whrt.append((tab[1], "<=", sdate))
                    sql.delRec(tab[0], where=whrt)
                elif tab[0] == "strpom":
                    whrt.append((tab[1], "<=", edate))
                    recs = sql.getRec(tables=tab[0], where=whrt)
                    for num, rec in enumerate(recs):
                        if "args" not in self.opts and not num % 10:
                            pb.displayProgress()
                        sql.delRec(tab[0],
                                   where=[("pom_cono", "=", rec[0]),
                                          ("pom_ordno", "=", rec[1])])
                        sql.delRec("strpot",
                                   where=[("pot_cono", "=", rec[0]),
                                          ("pot_ordno", "=", rec[1])])
                elif tab[0] == "slsiv1":
                    whrt.append((tab[1], "<=", edate))
                    recs = sql.getRec(tables=tab[0], where=whrt)
                    for num, rec in enumerate(recs):
                        if "args" not in self.opts and not num % 10:
                            pb.displayProgress()
                        sql.delRec(tab[0],
                                   where=[("si1_cono", "=", rec[0]),
                                          ("si1_rtn", "=", rec[1]),
                                          ("si1_docno", "=", rec[2])])
                        sql.delRec("slsiv2",
                                   where=[("si2_cono", "=", rec[0]),
                                          ("si2_rtn", "=", rec[1]),
                                          ("si2_docno", "=", rec[2])])
                        sql.delRec("slsiv3",
                                   where=[("si3_cono", "=", rec[0]),
                                          ("si3_rtn", "=", rec[1]),
                                          ("si3_docno", "=", rec[2])])
                elif tab[0] == "strpom":
                    whrt.append((tab[1], "<=", edate))
                    recs = sql.getRec(tables=tab[0], where=whrt)
                    for num, rec in enumerate(recs):
                        if "args" not in self.opts and not num % 10:
                            pb.displayProgress()
                        sql.delRec(tab[0],
                                   where=[("pom_cono", "=", rec[0]),
                                          ("pom_ordno", "=", rec[1])])
                        sql.delRec("strpot",
                                   where=[("pot_cono", "=", rec[0]),
                                          ("pot_ordno", "=", rec[1])])
                elif tab[0] == "wagtf1":
                    whrt.append((tab[1], "<=", sdate))
                    sql.delRec(tab[0], where=whrt)
                elif tab[0] == "wagtf2":
                    whrt.append((tab[1], "<=", sdate))
                    sql.delRec(tab[0], where=whrt)
            else:
                recs = sql.getRec(tables=tab[3], where=whrm)
                for num, rec in enumerate(recs):
                    if "args" not in self.opts and not num % 10:
                        pb.displayProgress()
                    whr = copyList(whrt)
                    for k in keyt:
                        if not k.count("_cono"):
                            dat = rec[getattr(sql, "%s_col" % tab[0]).index(k)]
                            whr.append((k, '=', dat))
                    if tab[0] == "asstrn":
                        whr.append(("ast_mtyp", "<>", 1))
                        col = ["ast_mtyp"]
                        grp = "ast_cono, ast_group, ast_code, ast_mtyp"
                        lim = 0
                    elif tab[0] == "rcatnt":
                        col = ["rtu_cnum", "rtu_mtyp"]
                        grp = "rtu_cono, rtu_owner, rtu_code, rtu_acno, "\
                            "rtu_cnum, rtu_mtyp"
                        lim = 0
                    elif tab[0] == "rtltrn":
                        col = ["rtt_cnum"]
                        grp = "rtt_cono, rtt_code, rtt_acno, rtt_cnum"
                        lim = 0
                    elif tab[0] == "strtrn":
                        col = ["stt_loc"]
                        grp = "stt_cono, stt_group, stt_code, stt_loc"
                        lim = 0
                    elif tab[0] == "wagltf":
                        mt = sql.getRec("wagltf",
                                        cols=["wlt_loan", "max(wlt_curdt)"],
                                        where=[("wlt_cono", "=", rec[0]),
                                               ("wlt_empno", "=", rec[1])],
                                        group="wlt_cono, wlt_empno, wlt_loan",
                                        order="wlt_cono, wlt_empno, wlt_loan")
                        for m in mt:
                            if m[1] >= ecurdt:
                                continue
                            b = sql.getRec("wagltf",
                                           cols=["sum(wlt_amt)"],
                                           where=[("wlt_cono", "=", rec[0]),
                                                  ("wlt_empno", "=", rec[1]),
                                                  ("wlt_loan", "=", m[0])],
                                           limit=1)
                            if not b[0]:
                                continue
                            sql.delRec("waglmf",
                                       where=[("wlm_cono", "=", rec[0]),
                                              ("wlm_empno", "=", rec[1]),
                                              ("wlm_loan", "=", m[0])])
                            sql.delRec("wagltf",
                                       where=[("wlt_cono", "=", rec[0]),
                                              ("wlt_empno", "=", rec[1]),
                                              ("wlt_loan", "=", m[0])])
                        continue
                    else:
                        col = []
                        grp = None
                        lim = 1
                    for c in tab[2]:
                        col.append("sum(%s)" % c)
                    whr.append((tab[1], "<=", ecurdt))
                    bals = sql.getRec(tables=tab[0],
                                      cols=col,
                                      where=whr,
                                      group=grp,
                                      order=grp,
                                      limit=lim)
                    if not bals:
                        continue
                    sql.delRec(tab[0], where=whr)
                    if tab[0] == "asstrn":
                        from tartanWork import armvtp
                        for bal in bals:
                            # Create Transactions
                            if not bal[1] and not bal[2]:
                                continue
                            data = rec[:3]
                            data.extend([
                                3, "Bal-Fwd", "Bal-Fwd", edate, bal[0], bal[1],
                                bal[2], 0, ecurdt,
                                "%s Brought Forward" % armvtp[bal[0] - 1][1],
                                "", "", self.opts["capnm"], self.sysdtw, 0
                            ])
                            sql.insRec(tab[0], data=data)
                    elif tab[0] == "bkmtrn" and bals[0]:
                        data = rec[:2]
                        data.extend([
                            5, "Bal-Fwd", "Bal-Fwd", edate, "", bals[0], 0,
                            ecurdt, "Brought Forward", "", "",
                            self.opts["capnm"], self.sysdtw, 0
                        ])
                        sql.insRec(tab[0], data=data)
                    elif tab[0] == "crstrn" and bals[0]:
                        data = rec[:2]
                        data.extend([
                            3, "Bal-Fwd", "Bal-Fwd", edate, "", bals[0], 0, 0,
                            ecurdt, self.sysdtw, "Y", bals[0],
                            "Brought Forward", "", "", self.opts["capnm"],
                            self.sysdtw, 0
                        ])
                        sql.insRec(tab[0], data=data)
                        # Re-Age Transactions
                        doAutoAge(self.opts["mf"].dbm, "crs", rec[0], rec[1])
                    elif tab[0] == "drstrn" and bals[0]:
                        data = rec[:3]
                        data.extend([
                            3, "Bal-Fwd", "Bal-Fwd", edate, "", bals[0], 0,
                            ecurdt, "Brought Forward", "", "",
                            self.opts["capnm"], self.sysdtw, 0
                        ])
                        sql.insRec(tab[0], data=data)
                        # Re-Age Transactions
                        doAutoAge(self.opts["mf"].dbm, "drs", rec[0], rec[1],
                                  rec[2])
                    elif tab[0] == "gentrn" and bals[0]:
                        continue
                    elif tab[0] == "memtrn" and bals[0]:
                        data = rec[:2]
                        data.extend([
                            3, "Bal-Fwd", "Bal-Fwd", edate, bals[0], 0, ecurdt,
                            "", 0, "Brought Forward", "", "",
                            self.opts["capnm"], self.sysdtw, 0
                        ])
                        sql.insRec(tab[0], data=data)
                        # Re-Age Transactions
                        doAutoAge(self.opts["mf"].dbm, "mem", rec[0], rec[1])
                    elif tab[0] == "rcaowt" and bals[0]:
                        data = rec[:2]
                        data.extend([
                            4, "Bal-Fwd", "Bal-Fwd", edate, bals[0], 0, ecurdt,
                            "Brought Forward", "", "", self.opts["capnm"],
                            self.sysdtw, 0
                        ])
                        sql.insRec(tab[0], data=data)
                    elif tab[0] == "rcatnt":
                        from tartanWork import rcmvtp
                        for bal in bals:
                            # Create Transactions
                            if not bal[2]:
                                continue
                            data = rec[:4]
                            data.extend([
                                bal[0], 4, "Bal-Fwd", "Bal-Fwd", edate, bal[1],
                                bal[2], 0, ecurdt,
                                "%s Brought Forward" % rcmvtp[bal[1] - 1][1],
                                "", "", self.opts["capnm"], self.sysdtw, 0
                            ])
                            sql.insRec(tab[0], data=data)
                    elif tab[0] == "rtltrn":
                        for bal in bals:
                            # Create Transactions
                            if not bal[1]:
                                continue
                            data = rec[:3]
                            data.extend([
                                bal[0], 4, "Bal-Fwd", "Bal-Fwd", edate, bal[1],
                                0, ecurdt, "Brought Forward", "", "",
                                self.opts["capnm"], self.sysdtw, 0
                            ])
                            sql.insRec(tab[0], data=data)
                    elif tab[0] == "strtrn":
                        for bal in bals:
                            # Create Transactions
                            if not bal[1] and not bal[2]:
                                continue
                            data = rec[:3]
                            if bal[1] < 0:
                                typ = 6
                            else:
                                typ = 5
                            data.extend([
                                bal[0], edate, typ, "Bal-Fwd", "Bal-Fwd", "",
                                bal[1], bal[2], 0, ecurdt, "Brought Forward",
                                0, "", "", "", 0, "", self.opts["capnm"],
                                self.sysdtw, 0
                            ])
                            sql.insRec(tab[0], data=data)
        if "args" not in self.opts:
            pb.closeProgress()