示例#1
0
 def doPremises(self, frt, pag, r, c, p, i, w):
     acc = self.sql.getRec("rtlprm",
                           cols=["rtp_desc"],
                           where=[("rtp_cono", "=", self.opts["conum"]),
                                  ("rtp_code", "=", w)],
                           limit=1)
     if not acc:
         return "Invalid Premises"
     self.code = w
     col = ["rtc_payind", "rtc_start", "rtc_period"]
     whr = [("rtc_cono", "=", self.opts["conum"]),
            ("rtc_code", "=", self.code), ("rtc_status", "=", "C")]
     chk = self.sql.getRec("rtlcon",
                           cols=col,
                           where=whr,
                           order="rtc_start desc")
     if not chk:
         self.end = 0
         return
     freq, start, period = chk[0]
     if freq == "M":
         self.end = CCD(projectDate(start, period, "months"), "D1", 10)
     elif freq == "3":
         self.end = CCD(projectDate(start, period * 3, "months"), "D1", 10)
     elif freq == "6":
         self.end = CCD(projectDate(start, period * 6, "months"), "D1", 10)
     else:
         self.end = CCD(projectDate(start, period, "years"), "D1", 10)
示例#2
0
 def doStartDate(self, frt, pag, r, c, p, i, w):
     self.start = w
     if self.period in ("D", "E"):
         if self.getStart(self.start):
             return "Invalid Start Date"
         if self.period == "D":
             self.end = projectDate(self.start, 3)
         else:
             self.end = projectDate(self.start, 2)
         self.df.loadEntry(frt, pag, p+1, data=self.end)
         return "sk1"
示例#3
0
 def doExpiredContract(self):
     tit = ("Renew Rental Contract", )
     r1s = (("Monthly", "M"), ("Quarterly", "3"), ("Bi-Annually", "6"),
            ("Annually", "A"))
     chdt = self.strt.work
     while True:
         chdt = projectDate(chdt, self.mths, typ="months")
         exdt = mthendDate(projectDate(chdt, self.mths - 1, typ="months"))
         if int(exdt / 100) > self.curdt:
             break
     self.fld = ((("T", 0, 0, 0), "OUA", 7,
                  "Owner Code"), (("T", 0, 1, 0), "OUA", 7,
                                  "Premises Code"), (("T", 0, 2, 0), "ONA",
                                                     7, "Account Code"),
                 (("T", 0, 3, 0), "ONA", 30, "Tenant Name"),
                 (("T", 0, 4, 0), ("IRB", r1s), 0, "Payment Frequency", "",
                  self.freq, "N", None, None, None,
                  None), (("T", 0, 5, 0), "ID1", 10, "Start Date", "", chdt,
                          "N", None, None, None, ("efld", )),
                 (("T", 0, 6, 0), "IUI", 3, "Number of Periods", "",
                  self.pers, "N", None, None, None, ("notzero", )),
                 (("T", 0, 7, 0), "IUD", 12.2, "Rental Amount", "",
                  self.amnt, "N", None, None, None, ("notzero", )),
                 (("T", 0, 8, 0), "IUD", 12.2, "Deposit Amount", "",
                  self.depo, "N", None, None, None, ("efld", )),
                 (("T", 0, 9, 0), "IUD", 12.2, "Basic Water Amount", "", "",
                  "N", None, None, None,
                  ("efld", )), (("T", 0, 10, 0), "IUI", 1, "Type", "", "",
                                "N", None, None, None, ("efld", )),
                 (("T", 0, 11, 0), "IUD", 12.2, "Basic Exlectricity Amount",
                  "", "", "N", None, None, None,
                  ("efld", )), (("T", 0, 12, 0), "IUI", 1, "Type", "", "",
                                "N", None, None, None, ("efld", )))
     tnd = ((self.doExpireEnd, "y"), )
     txt = (None, )
     self.na = TartanDialog(self.opts["mf"],
                            tops=True,
                            title=tit,
                            eflds=self.fld,
                            tend=tnd,
                            txit=txt,
                            focus=False)
     self.doLoadFocus(chdt)
     self.na.mstFrame.wait_window()
示例#4
0
 def getStart(self, date=None):
     if self.period == "D":
         chk = 0
     else:
         chk = 4
     if date:
         year = int(date / 10000)
         month = int(date / 100) % 100
         day = date % 100
         if datetime.date(year, month, day).weekday() != chk:
             return True
     else:
         date = projectDate(self.sysdtw, -1)
         dte = 99
         while dte != chk:
             date = projectDate(date, 1)
             year = int(date / 10000)
             month = int(date / 100) % 100
             day = date % 100
             dte = datetime.date(year, month, day).weekday()
         return date
示例#5
0
 def setVariables(self):
     self.gc = GetCtl(self.opts["mf"])
     assctl = self.gc.getCtl("assctl", self.opts["conum"])
     if not assctl:
         return
     self.rordp = assctl["cta_rordp"]
     tabs = ["assgrp", "assmst", "assdep", "asstrn"]
     self.sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__)
     if self.sql.error:
         return
     self.dend = projectDate(self.opts["period"][1][0], -1)
     self.todat = 0
     self.imports = False
     t = time.localtime()
     self.sysdtw = (t[0] * 10000) + (t[1] * 100) + t[2]
     return True
示例#6
0
 def doEnd(self):
     self.df.closeProcess()
     # Headings and Mail subject
     self.cdes = "%-30s" % self.opts["conam"]
     start = self.getDate(self.start)
     end = self.getDate(projectDate(self.end, 1))
     if self.period == "D":
         self.hdes = "Arrivals for Weekdays %s to %s" % (start, end)
     elif self.period == "E":
         self.hdes = "Arrivals for Weekend %s to %s" % (start, end)
     else:
         self.hdes = "Arrivals for Period %s to %s" % (start, end)
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=80, auto=True)
     self.fpdf.header = self.pageHeading
     self.rtyp = "A"
     self.doArrival()
     if self.house == "Y":
         self.rtyp = "H"
         self.hdes = self.hdes.replace("Arrivals", "Units")
         if self.fpdf.page:
             self.fpdf.add_page()
         self.doHKeeping()
     if self.fpdf.page:
         pdfnam = getModName(self.opts["mf"].rcdic["wrkdir"],
             self.__class__.__name__, self.opts["conum"], ext="pdf")
         self.fpdf.output(pdfnam, "F")
         subj = "%s - %s" % (self.cdes, self.hdes)
         doPrinter(mf=self.opts["mf"], conum=self.opts["conum"],
             pdfnam=pdfnam, header=subj, repprt=self.df.repprt,
             fromad=self.fromad, repeml=self.df.repeml)
     if self.prtinv == "Y" and self.docs:
         # Print Invoice
         self.docs.sort()
         PrintBookingInvoice(self.opts["mf"], self.opts["conum"],
             self.opts["conam"], "I", self.docs, tname=self.tname,
             repprt=self.df.repprt, repeml=self.df.repeml)
         # Print Statement
         self.book.sort()
         callModule(self.opts["mf"], None, "bk3070",
             coy=(self.opts["conum"], self.opts["conam"]),
             args=[self.book, self.df.repprt, self.df.repeml])
     if "wait" not in self.opts:
         self.opts["mf"].closeLoop()
示例#7
0
 def setVariables(self):
     tabs = [
         "ctlmst", "ctlvmf", "ctlvrf", "ctlvtf", "genmst", "gentrn",
         "rcaowm", "rcaowt", "rcaprm", "rcatnm", "rcacon", "rcatnt"
     ]
     self.sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__)
     if self.sql.error:
         return
     gc = GetCtl(self.opts["mf"])
     ctlmst = gc.getCtl("ctlmst", self.opts["conum"])
     if not ctlmst:
         return
     self.taxdf = ctlmst["ctm_taxdf"]
     rcactl = gc.getCtl("rcactl", self.opts["conum"])
     if not rcactl:
         return
     self.glint = rcactl["cte_glint"]
     self.ch1 = ((rcactl["cte_lme"] // 100) * 100) + 1
     self.ch2 = projectDate(self.ch1, 2, typ="months")
     if self.glint == "Y":
         self.glbnk = rcactl["cte_glbnk"]
         ctlctl = gc.getCtl("ctlctl", self.opts["conum"])
         if not ctlctl:
             return
         ctls = [
             "rca_com", "rca_dep", "rca_fee", "rca_orx", "rca_own",
             "rca_tnt", "rca_trx", "vat_ctl"
         ]
         if gc.chkRec(self.opts["conum"], ctlctl, ctls):
             return
         self.rcacom = ctlctl["rca_com"]
         self.rcadep = ctlctl["rca_dep"]
         self.rcafee = ctlctl["rca_fee"]
         self.rcaorx = ctlctl["rca_orx"]
         self.rcaown = ctlctl["rca_own"]
         self.rcatnt = ctlctl["rca_tnt"]
         self.rcatrx = ctlctl["rca_trx"]
         self.convat = ctlctl["vat_ctl"]
     t = time.localtime()
     self.sysdtw = (t[0] * 10000) + (t[1] * 100) + t[2]
     self.batno = "R%04i%02i" % (t[0], t[1])
     return True
示例#8
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])
示例#9
0
 def doArrival(self):
     state = ["C", "S"]
     if self.query == "Y":
         state.append("Q")
     recs = self.sql.getRec("bkmmst", where=[("bkm_cono", "=",
         self.opts["conum"]), ("bkm_state", "in", tuple(state))],
         order="bkm_ccode")
     self.book = []
     self.docs = []
     last = 0
     for rec in recs:
         number = rec[self.sql.bkmmst_col.index("bkm_number")]
         ccode = rec[self.sql.bkmmst_col.index("bkm_ccode")]
         btype = rec[self.sql.bkmmst_col.index("bkm_btype")]
         arrive = rec[self.sql.bkmmst_col.index("bkm_arrive")]
         depart = rec[self.sql.bkmmst_col.index("bkm_depart")]
         if btype == "A":
             if depart <= self.start or arrive > self.end:
                 continue
         elif depart < self.start or arrive > self.end:
             continue
         if self.geninv == "Y":
             self.doRaiseInvoice(number, arrive)
         con = self.sql.getRec("bkmcon", where=[("bkc_cono", "=",
             self.opts["conum"]), ("bkc_ccode", "=", ccode)], limit=1)
         sname = con[self.sql.bkmcon_col.index("bkc_sname")].strip()
         names = con[self.sql.bkmcon_col.index("bkc_names")].strip()
         if names:
             name = "%s %s (%s)" % (names.split()[0], sname, number)
         else:
             name = "%s (%s)" % (sname, number)
         bal = self.sql.getRec("bkmtrn", cols=["sum(bkt_tramt)"],
             where=[("bkt_cono", "=", self.opts["conum"]), ("bkt_number",
             "=", number)], limit=1)
         rtts = self.sql.getRec("bkmrtt", cols=["brt_udesc",
             "brt_uroom", "sum(brt_quant)"], where=[("brt_cono", "=",
             self.opts["conum"]), ("brt_number", "=", number)],
             group="brt_utype, brt_ucode, brt_udesc, brt_uroom",
             order="brt_utype, brt_ucode, brt_uroom")
         if not rtts:
             continue
         units = []
         unt = None
         for rtt in rtts:
             if rtt[1]:
                 if not unt:
                     unt = ["%s - R%s" % (rtt[0], rtt[1]), rtt[2]]
                 else:
                     unt = ["%s & R%s" % (unt[0], rtt[1]), rtt[2]]
             else:
                 unt = (rtt[0], rtt[2])
             units.append(unt)
         namq = len(wrap(name, break_long_words=False, width=25))
         untq = 0
         for unit in units:
             untq += len(wrap(unit[0], break_long_words=False, width=25))
         if namq and untq > namq:
             hh = [(untq * 8.0) / namq, 8, untq * 8]
         elif untq and namq > untq:
             hh = [8, (namq * 8.0) / untq, namq * 8]
         elif namq:
             hh = [8, 8, namq * 8]
         else:
             hh = [8, 8, untq * 8]
         if not self.fpdf.page or self.fpdf.get_y() + hh[0] > 280:
             self.fpdf.add_page()
         oldnm = None
         for unit in units:
             if name == oldnm:
                 name = ""
             else:
                 oldnm = name
             if arrive >= self.start:
                 yr = int(arrive / 10000)
                 mt = int(arrive / 100) % 100
                 dy = arrive % 100
                 d = datetime.date(yr, mt, dy)
                 arr = d.strftime("%a")
             else:
                 arr = "<--"
             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
                 e = datetime.date(yr, mt, dy)
                 dep = e.strftime("%a")
             else:
                 dep = "-->"
             if last != number and bal[0]:
                 amt = CCD(bal[0], "SD", 13.2).disp
             else:
                 amt = CCD(0, "SD", 13.2).disp
             self.printLine(name, unit[0], unit[1], arr, dep, amt, hh)
             last = number
     self.opts["mf"].dbm.commitDbase()
示例#10
0
 def printReport(self, recs):
     p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True)
     self.head = "%03u %-167s" % (self.opts["conum"], self.opts["conam"])
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head)
     self.pglin = 999
     mst = self.sql.rcatnm_col
     con = self.sql.rcacon_col
     self.tots = [0, 0, 0, 0, 0, 0]
     self.cred = [0, 0, 0, 0, 0, 0]
     for num, dat in enumerate(recs):
         p.displayProgress(num)
         if p.quit:
             break
         ownr = CCD(dat[con.index("rcc_owner")], "NA", 7)
         code = CCD(dat[con.index("rcc_code")], "NA", 7)
         acno = CCD(dat[con.index("rcc_acno")], "NA", 7)
         cnum = CCD(dat[con.index("rcc_cnum")], "UI", 3)
         freq = CCD(dat[con.index("rcc_payind")], "UA", 1)
         strt = CCD(dat[con.index("rcc_start")], "D1", 10)
         prds = CCD(dat[con.index("rcc_period")], "UI", 3)
         stat = CCD(dat[con.index("rcc_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
             exdt = projectDate(strt.work, mths - 1, typ="months")
             exdt = CCD(mthendDate(exdt), "D1", 10)
             if self.styp == "E" and int(exdt.work / 100) > curdt:
                 continue
         else:
             exdt = CCD(0, "d1", 10)
         acc = self.sql.getRec("rcatnm", where=[("rtn_cono", "=",
             self.opts["conum"]), ("rtn_owner", "=", ownr.work),
             ("rtn_code", "=", code.work), ("rtn_acno", "=", acno.work)],
             limit=1)
         name = CCD(acc[mst.index("rtn_name")], "NA", 30)
         if self.cons == "Y":
             trn = self.sql.getRec("rcatnt", cols=["rtu_mtyp",
                 "round(sum(rtu_tramt), 2)"], where=[("rtu_cono", "=",
                 self.opts["conum"]), ("rtu_owner", "=", ownr.work),
                 ("rtu_code", "=", code.work), ("rtu_acno", "=", acno.work),
                 ("rtu_trdt", "<=", self.date)], group="rtu_mtyp")
         else:
             trn = self.sql.getRec("rcatnt", cols=["rtu_mtyp",
                 "round(sum(rtu_tramt), 2)"], where=[("rtu_cono", "=",
                 self.opts["conum"]), ("rtu_owner", "=", ownr.work),
                 ("rtu_code", "=", code.work), ("rtu_acno", "=", acno.work),
                 ("rtu_cnum", "=", cnum.work), ("rtu_trdt", "<=",
                 self.date)], group="rtu_mtyp")
         rtl = CCD(0, "SD", 13.2)
         dep = CCD(0, "SD", 13.2)
         fee = CCD(0, "SD", 13.2)
         sv1 = CCD(0, "SD", 13.2)
         sv2 = CCD(0, "SD", 13.2)
         rep = 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:
                     dep = CCD(t[1], "SD", 13.2)
                 elif t[0] == 3:
                     fee = CCD(t[1], "SD", 13.2)
                 elif t[0] == 4:
                     sv1 = CCD(t[1], "SD", 13.2)
                 elif t[0] == 5:
                     sv2 = CCD(t[1], "SD", 13.2)
                 elif t[0] == 6:
                     rep = CCD(t[1], "SD", 13.2)
         srv = CCD(float(ASD(sv1.work) + ASD(sv2.work)), "SD", 13.2)
         bal = float(ASD(rtl.work) + ASD(fee.work) + ASD(srv.work) + \
             ASD(rep.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 %s %s" % (ownr.disp, code.disp, acno.disp, cnum.disp,
             name.disp, freq.disp, strt.disp, prds.disp, exdt.disp,
             stat.disp, dep.disp, rtl.disp, fee.disp, srv.disp, rep.disp,
             bal.disp))
         self.tots[0] = float(ASD(self.tots[0]) + ASD(dep.work))
         if dep.work < 0:
             self.cred[0] = float(ASD(self.cred[0]) + ASD(dep.work))
         self.tots[1] = float(ASD(self.tots[1]) + ASD(rtl.work))
         if rtl.work < 0:
             self.cred[1] = float(ASD(self.cred[1]) + ASD(rtl.work))
         self.tots[2] = float(ASD(self.tots[2]) + ASD(fee.work))
         if fee.work < 0:
             self.cred[2] = float(ASD(self.cred[2]) + ASD(fee.work))
         self.tots[3] = float(ASD(self.tots[3]) + ASD(srv.work))
         if srv.work < 0:
             self.cred[3] = float(ASD(self.cred[3]) + ASD(srv.work))
         self.tots[4] = float(ASD(self.tots[4]) + ASD(rep.work))
         if rep.work < 0:
             self.cred[4] = float(ASD(self.cred[4]) + ASD(rep.work))
         self.tots[5] = float(ASD(self.tots[5]) + ASD(bal.work))
         if bal.work < 0:
             self.cred[5] = float(ASD(self.cred[5]) + ASD(bal.work))
         self.pglin += 1
     t = []
     for x in range(6):
         t.append(CCD(self.tots[x], "SD", 13.2).disp)
     self.fpdf.underLine(txt=self.head)
     self.fpdf.drawText("%27s %-30s %29s %-13s %-13s %-13s %-13s "\
         "%-13s %-13s" % ("", "Grand Totals", "", t[0], t[1], t[2],
         t[3], t[4], t[5]))
     t = []
     for x in range(6):
         t.append(CCD(self.cred[x], "SD", 13.2).disp)
     self.fpdf.underLine(txt=self.head)
     self.fpdf.drawText("%27s %-30s %29s %-13s %-13s %-13s %-13s "\
         "%-13s %-13s" % ("", "Credits", "", t[0], t[1], t[2],
         t[3], t[4], t[5]))
     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()
示例#11
0
 def doLeeway(self, frt, pag, r, c, p, i, w):
     self.leeway = w
     if self.leeway:
         self.pdatw = projectDate(self.pdatw, self.leeway)
示例#12
0
 def doCalendar(self):
     self.number = 0
     self.ptyp = None
     self.newb = False
     udics = {}
     self.start = projectDate(self.sysdtw, -7)
     bkm = self.sql.getRec("bkmmst",
                           cols=["max(bkm_depart)"],
                           where=[("bkm_cono", "=", self.opts["conum"]),
                                  ("bkm_state", "<>", "X")],
                           limit=1)
     if not bkm or bkm[0] is None:
         days = 15
     else:
         days = dateDiff(self.start, bkm[0], "days") + 1
         if days < 15:
             days = 15
     bkmunm = self.sql.getRec("bkmunm",
                              where=[("bum_cono", "=", self.opts["conum"]),
                                     ("bum_maxg", "<>", 999)],
                              order="bum_btyp, bum_code")
     if not bkmunm:
         showError(self.opts["mf"].body, "Units",
                   "No Units in the Database")
         self.quit = True
         return
     col = self.sql.bkmunm_col
     for num, unit in enumerate(bkmunm):
         t = unit[col.index("bum_btyp")]
         c = unit[col.index("bum_code")]
         d = unit[col.index("bum_desc")]
         m = unit[col.index("bum_maxg")]
         if t == "A" and c == "ALL":
             continue
         udics["%s-%s" % (t, c)] = [d, CCD(m, "UI", 3).disp] + [""] * days
     for x in range(num, 10):
         t = "X"
         c = x - num
         d = ""
         m = "   "
         udics["%s-%s" % (t, c)] = [d, m] + [""] * days
     books = self.sql.getRec(tables="bkmmst",
                             cols=[
                                 "bkm_number", "bkm_btype", "bkm_arrive",
                                 "bkm_depart", "bkm_state"
                             ],
                             where=[("bkm_cono", "=", self.opts["conum"]),
                                    ("bkm_depart", ">=", self.start),
                                    ("bkm_state", "<>", "X")])
     for book in books:
         if book[2] < self.start:
             book[2] = self.start
         sday = dateDiff(self.start, book[2], "days")
         eday = dateDiff(self.start, book[3], "days")
         if book[1] == "O":
             eday += 1
         bkmrtt = self.sql.getRec("bkmrtt",
                                  cols=["brt_utype", "brt_ucode"],
                                  where=[("brt_cono", "=",
                                          self.opts["conum"]),
                                         ("brt_number", "=", book[0])])
         units = []
         for rtt in bkmrtt:
             units.append("%s-%s" % tuple(rtt))
         if "A-ALL" in units:
             units.remove("A-ALL")
             for unit in udics:
                 if unit[0] == "A":
                     units.append(unit)
         for unit in units:
             if unit not in udics:
                 continue
             for d in range(sday, eday):
                 if book[4] == "Q":
                     udics[unit][d + 2] = "Query|%s" % book[0]
                 elif book[4] == "C":
                     udics[unit][d + 2] = "Confirmed|%s" % book[0]
                 elif book[4] == "S":
                     udics[unit][d + 2] = "Settled|%s" % book[0]
     titl = ("%03i %s" % (self.opts["conum"], self.opts["conam"]),
             "Lodging and Function Bookings Calendar (bk1010)")
     labs = (("Code", 8), ("Description", 30), ("Qty", 4))
     tags = [("blank", ("black", "white")),
             ("label", ("black", "lightgray")),
             ("query", (self.opts["mf"].rcdic["qfg"],
                        self.opts["mf"].rcdic["qbg"])),
             ("confirm", (self.opts["mf"].rcdic["cfg"],
                          self.opts["mf"].rcdic["cbg"])),
             ("settle", (self.opts["mf"].rcdic["sfg"],
                         self.opts["mf"].rcdic["sbg"]))]
     cols = [[]]
     for x in range(days):
         d1 = CCD(projectDate(self.start, x), "D1", 10)
         d2 = time.strftime("%A", time.strptime(str(d1.work), "%Y%m%d"))
         txt = "%s\n%s" % ("{:^10}".format(d2), d1.disp)
         cols[0].append((txt, 10))
     keys = list(udics.keys())
     keys.sort()
     data = []
     for row, key in enumerate(keys):
         cod = ("%s" % key, "label")
         des = ("%s" % udics[key][0], "label")
         qty = ("%-s" % udics[key][1], "label")
         lab = (cod, des, qty)
         col = []
         lst = None
         tag = ""
         spn = 1
         for c, d in enumerate(udics[key][2:]):
             if d == lst:
                 spn += 1
                 continue
             if lst is not None:
                 col.append((txt, tag, spn))
                 spn = 1
             lst = d
             if not d:
                 num = 0
                 txt = "\n"
                 tag = "blank"
             else:
                 sta, num = d.split("|")
                 txt = "%s\n%s" % (num, sta)
                 if sta == ("Query"):
                     tag = "query"
                 elif sta == ("Confirmed"):
                     tag = "confirm"
                 elif sta == ("Settled"):
                     tag = "settle"
         if spn > 300:
             col.append((txt, tag, 300))
             col.append((txt, tag, spn - 300))
         else:
             col.append((txt, tag, spn))
         data.append((lab, col))
     butt = [("New Booking", self.doNew), ("Search Bookings", self.doSch),
             ("Deposits List", (self.doRep, "D")),
             ("Arrivals List", (self.doRep, "L")), ("Quit", self.doQuit)]
     cmds = [("<Double-1>", self.doBkm), ("<Button-3>", self.doEnq)]
     self.cal = ScrollGrid(
         **{
             "mf":
             self.opts["mf"],
             "titl":
             titl,
             "chgt":
             2,
             "tags":
             tags,
             "labs":
             labs,
             "cols":
             cols,
             "data":
             data,
             "butt":
             butt,
             "cmds":
             cmds,
             "font": (self.opts["mf"].rcdic["mft"],
                      self.opts["mf"].rcdic["dfs"]),
             "wait":
             False,
             "minc":
             14
         })
     self.opts["mf"].startLoop(deicon=False)
     if self.tt:
         self.tt.hideTip()
         self.tt = None
     self.cal.window.destroy()
     self.opts["mf"].setThemeFont()
     self.opts["mf"].window.deiconify()
     if not self.ptyp and not self.quit:
         callModule(self.opts["mf"],
                    None,
                    "bk1020",
                    coy=(self.opts["conum"], self.opts["conam"]),
                    user=self.opts["capnm"],
                    args=self.number)
     elif self.ptyp == "D":
         callModule(self.opts["mf"],
                    None,
                    "bk3010",
                    coy=(self.opts["conum"], self.opts["conam"]),
                    args=True)
     elif self.ptyp == "L":
         callModule(self.opts["mf"],
                    None,
                    "bk3030",
                    coy=(self.opts["conum"], self.opts["conam"]),
                    user=self.opts["capnm"],
                    args=True)
示例#13
0
 def doEnd(self):
     self.df.closeProcess()
     whr = [("rcc_cono", "=", self.opts["conum"]), ("rtn_cono=rcc_cono", ),
            ("rtn_owner=rcc_owner", ), ("rtn_code=rcc_code", ),
            ("rtn_acno=rcc_acno", ), ("rcc_status", "<>", "X")]
     recs = self.sql.getRec(
         tables=["rcacon", "rcatnm"],
         cols=[
             "rcc_cono", "rcc_owner", "rcc_code", "rcc_acno", "rcc_cnum",
             "rcc_payind", "rcc_start", "rcc_period", "rcc_rtlamt",
             "rcc_deposit", "rcc_wamt", "rcc_wtyp", "rcc_eamt", "rcc_etyp",
             "rtn_name"
         ],
         where=whr,
     )
     if recs:
         for num, self.con in enumerate(recs):
             own = self.sql.getRec("rcaowm",
                                   cols=["rom_vatdf"],
                                   where=[("rom_cono", "=",
                                           self.opts["conum"]),
                                          ("rom_acno", "=", self.con[1])],
                                   limit=1)
             if not own:
                 showError(
                     self.opts["mf"].body, "Missing Owner",
                     "This Owner's Record (%s) Could Not Be Found!" %
                     self.con[1])
                 continue
             self.vatdf = own[0]
             self.prm = self.sql.getRec("rcaprm",
                                        cols=["rcp_crate"],
                                        where=[
                                            ("rcp_cono", "=",
                                             self.opts["conum"]),
                                            ("rcp_owner", "=", self.con[1]),
                                            ("rcp_code", "=", self.con[2])
                                        ],
                                        limit=1)
             if not self.prm:
                 showError(
                     self.opts["mf"].body, "Missing Premises",
                     "This Premises's Record (%s %s) Could Not Be Found!" %
                     (self.con[1], self.con[2]))
                 continue
             self.freq = self.con[5]
             self.strt = CCD(self.con[6], "D1", 10)
             self.pers = self.con[7]
             self.amnt = self.con[8]
             self.depo = self.con[9]
             self.wamt = self.con[10]
             self.wtyp = self.con[11]
             self.eamt = self.con[12]
             self.etyp = self.con[13]
             if self.freq == "M":
                 self.mths = 1 * self.pers
             elif self.freq == "3":
                 self.mths = 3 * self.pers
             elif self.freq == "6":
                 self.mths = 6 * self.pers
             else:
                 self.mths = 12 * self.pers
             exdt = projectDate(self.strt.work, self.mths - 1, typ="months")
             exdt = CCD(mthendDate(exdt), "D1", 10)
             if int(exdt.work / 100) <= self.curdt:
                 self.sql.updRec("rcacon",
                                 cols=["rcc_status"],
                                 data=["X"],
                                 where=[("rcc_cono", "=", self.con[0]),
                                        ("rcc_owner", "=", self.con[1]),
                                        ("rcc_code", "=", self.con[2]),
                                        ("rcc_acno", "=", self.con[3]),
                                        ("rcc_cnum", "=", self.con[4])])
                 ok = askQuestion(self.opts["mf"].body, "Expired Contract",
                     "This contract has Expired, would you like to "\
                     "Renew it?\n\nOwner: %s\nPremises: %s\nAccount: %s\n"\
                     "Name: %s\nStart: %s\nEnd:   %s" % (self.con[1],
                     self.con[2], self.con[3], self.con[14], self.strt.disp,
                     exdt.disp))
                 if ok == "no":
                     continue
                 self.doExpiredContract()
             self.doRaiseRental(num)
             self.doRaiseExtra(num)
     self.sql.updRec("rcactl",
                     cols=["cte_lme"],
                     data=[self.tme],
                     where=[("cte_cono", "=", self.opts["conum"])])
     self.opts["mf"].dbm.commitDbase(ask=True, mess="Do You Want To Save "\
         "All Changes?\n\nPlease Note That Once The Changes Have Been "\
         "Saved, There Is No Going Back Without Restoring From Backup!")
     self.opts["mf"].closeLoop()
示例#14
0
 def doLeeway(self, frt, pag, r, c, p, i, w):
     self.lway = w
     self.validw = projectDate(self.cutoff, self.lway)
     f = CCD(self.validw, "D1", 10)
     self.repdate = f.disp
示例#15
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()
示例#16
0
 def doEnder(self):
     self.df.closeProcess()
     recs = self.sql.getRec("memmst",
                            cols=["mlm_memno"],
                            where=[("mlm_cono", "=", self.opts["conum"]),
                                   ("mlm_state", "=", "A")])
     if self.ynd:
         p = ProgressBar(self.opts["mf"].body,
                         typ="Checking Member Categories",
                         mxs=len(recs))
         for num, acc in enumerate(recs):
             p.displayProgress(num)
             self.memno = acc[0]
             data = doChkCatChg(self.opts["mf"], self.opts["conum"],
                                self.memno, self.nxtdt)
             if data:
                 if not data[3]:
                     self.doRaiseCharge("B",
                                        data[0],
                                        data[1],
                                        data[2],
                                        data[3],
                                        data[4],
                                        data[5],
                                        data[6],
                                        skip=True)
                 dte = int("%04i%02i%02i%02i%02i%02i" % \
                     time.localtime()[:-3])
                 self.sql.delRec("memcat",
                                 where=[("mlc_cono", "=",
                                         self.opts["conum"]),
                                        ("mlc_memno", "=", self.memno),
                                        ("mlc_type", "=", "B"),
                                        ("mlc_code", "=", data[0])])
                 self.sql.insRec(
                     "chglog",
                     data=[
                         "memcat", "D",
                         "%03i%06i%1s%02i" %
                         (self.opts["conum"], self.memno, "B", data[0]), "",
                         dte, self.opts["capnm"],
                         str(data[1]),
                         str(data[2]), "", 0
                     ])
                 self.sql.insRec("memcat",
                                 data=[
                                     self.opts["conum"], self.memno, "B",
                                     data[7], "", self.nxtdt, 0, 0
                                 ])
                 self.sql.insRec(
                     "chglog",
                     data=[
                         "memcat", "N",
                         "%03i%06i%1s%02i" %
                         (self.opts["conum"], self.memno, "B", data[7]), "",
                         dte, self.opts["capnm"],
                         str(self.nxtdt),
                         str(0), "", 0
                     ])
         p.closeProgress()
         ok = askQuestion(self.opts["mf"].body,
                          "Category Changes",
                          "Would You Like to Display Category Changes?",
                          default="yes")
         if ok == "yes":
             callModule(self.opts["mf"],
                        None,
                        "ml3060",
                        coy=(self.opts["conum"], self.opts["conam"]),
                        args=(projectDate(self.lme, 1), self.nxtdt))
             ok = askQuestion(
                 self.opts["mf"].body,
                 "Continue",
                 "Would You Like to Continue with the Month End?",
                 default="yes")
             if ok == "no":
                 self.opts["mf"].closeLoop()
                 return
     p = ProgressBar(self.opts["mf"].body, typ="F", mxs=len(recs))
     for num, acc in enumerate(recs):
         p.displayProgress(num)
         self.memno = acc[0]
         if self.penalty == "Y":
             amount = 0
             join = "left outer join memage on mta_cono=mlt_cono and "\
                 "mta_memno=mlt_memno and mta_type=mlt_type and "\
                 "mta_refno=mlt_refno"
             cols = ["mlt_ctyp", "mlt_ccod", "sum(mlt_tramt)"]
             wher = [("mlt_cono", "=", self.opts["conum"]),
                     ("mlt_memno", "=", self.memno),
                     ("mlt_trdt", "<=", self.cutoff)]
             grps = "mlt_ctyp, mlt_ccod"
             ordr = "mlt_trdt"
             recs = self.sql.getRec("memtrn",
                                    join=join,
                                    cols=cols,
                                    where=wher,
                                    group=grps,
                                    order=ordr)
             for rec in recs:
                 key = "%s%02i" % (rec[0], rec[1])
                 if key in self.pcodes:
                     amt = round(rec[2] * self.pcodes[key] / 100.0, 2)
                     if amt > 0:
                         amount = float(ASD(amount) + ASD(amt))
             if amount:
                 self.doUpdateTables("", "", "Penalty on Overdue Amounts",
                                     self.penctl, self.tme, amount)
         cols = [
             "mlc_type", "mlc_code", "mcc_desc", "mcc_freq", "mlc_start",
             "mlc_end", "mlc_last", "mcc_glac"
         ]
         wher = [("mlc_cono", "=", self.opts["conum"]),
                 ("mlc_memno", "=", self.memno), ("mlc_start", ">", 0),
                 ("mlc_start", "<=", self.nxtdt), ("mcc_cono=mlc_cono", ),
                 ("mcc_type=mlc_type", ), ("mcc_code=mlc_code", ),
                 ("mcc_freq", "<>", "N")]
         cats = self.sql.getRec(tables=["memcat", "memctc"],
                                cols=cols,
                                where=wher,
                                order="mlc_type, mlc_code")
         for ctyp, code, desc, freq, start, end, last, glac in cats:
             if start > self.nxtdt:
                 # Not yet Started
                 continue
             if last and end and end < self.nxtdt:
                 # Ended
                 continue
             if last and freq == "O":
                 # Once Off
                 continue
             if not self.ynd and last and freq == "A" and \
                     last >= self.opts["period"][1][0] and \
                     last <= self.opts["period"][2][0]:
                 # Out of Period
                 continue
             self.doRaiseCharge(ctyp, code, start, end, last, freq, desc,
                                glac)
     p.closeProgress()
     self.sql.updRec("memctl",
                     cols=["mcm_lme"],
                     data=[self.tme],
                     where=[("mcm_cono", "=", self.opts["conum"])])
     ok = askQuestion(self.opts["mf"].body,
                      "Audit Trail",
                      "Would You Like to Display an Audit Trail?",
                      default="yes")
     if ok == "yes":
         callModule(self.opts["mf"],
                    None,
                    "ml3020",
                    coy=(self.opts["conum"], self.opts["conam"]),
                    args=("F", 0, self.nxtcd, 1, self.batch))
     self.opts["mf"].dbm.commitDbase(ask=True,
         mess="Do You Want To Save All Entries?\n\nPlease Note That "\
         "Once The Entries Have Been Saved, There Is No Going Back "\
         "Without Restoring From Backup!")
     if self.ynd and self.opts["mf"].dbm.commit == "yes":
         callModule(self.opts["mf"],
                    None,
                    "msy010",
                    coy=(self.opts["conum"], self.opts["conam"]),
                    period=self.opts["period"],
                    user=self.opts["capnm"],
                    args="N")
     self.opts["mf"].closeLoop()