コード例 #1
0
ファイル: rc2010.py プロジェクト: paulmalherbe/Tartan
 def showOwnerTrans(self):
     whr = [("rot_cono", "=", self.opts["conum"]),
            ("rot_acno", "=", self.owner)]
     tot = self.sql.getRec("rcaowt",
                           cols=["round(sum(rot_tramt),2)"],
                           where=[("rot_cono", "=", self.opts["conum"]),
                                  ("rot_acno", "=", self.owner)],
                           limit=1)
     if not tot or not tot[0]:
         self.due = 0
     else:
         self.due = float(ASD(0) - ASD(tot[0]))
     arr = self.sql.getRec("rcatnt",
                           cols=["round(sum(rtu_tramt),2)"],
                           where=[("rtu_cono", "=", self.opts["conum"]),
                                  ("rtu_owner", "=", self.owner),
                                  ("rtu_mtyp", "in", (1, 4))],
                           limit=1)
     if arr and arr[0]:
         self.due = float(ASD(self.due) - ASD(arr[0]))
     self.df.loadEntry("T", 1, 2, data=self.due)
     tab = ["rcaowt"]
     col = [
         "rot_trdt", "rot_type", "rot_refno", "rot_desc", "rot_tramt",
         "rot_taxamt"
     ]
     whr = [("rot_cono", "=", self.opts["conum"]),
            ("rot_acno", "=", self.owner)]
     odr = "rot_trdt, rot_type, rot_refno"
     dat = self.sql.getRec(tables=tab, cols=col, where=whr, order=odr)
     data = []
     bals = 0
     for d in dat:
         bals = float(ASD(bals) + ASD(d[4]))
         data.append(d + [bals])
     col = (("rot_trdt", "Trans-Date", 10, "D1",
             "N"), ("rot_type", "Typ", 3, ("XX", rctrtp),
                    "N"), ("rot_refno", "Reference", 9, "Na",
                           "N"), ("rot_desc", "Details", 39, "NA", "N"),
            ("rot_tramt", "Amount", 11.2, "SD",
             "N"), ("rot_taxamt", "VAT-Amount", 11.2, "SD",
                    "N"), ("balance", "Balance", 15.2, "SD", "N"))
     try:
         self.otrn.closeProcess()
     except:
         pass
     self.otrn = SelectChoice(self.df.topPage1,
                              None,
                              col,
                              data,
                              wait=False,
                              neww=False,
                              butt=False,
                              sort=False,
                              live=False,
                              modal=False,
                              lines=9)
コード例 #2
0
ファイル: sc2030.py プロジェクト: paulmalherbe/Tartan
 def doShow(self):
     cols = (("scod", "Skip", 6, "UI",
              "N"), ("sname", "Name", 30, "NA",
                     "N"), ("sfor", "Shots", 5, "UI", "N"), ("ocod", "Oppt",
                                                             6, "UI", "N"),
             ("oname", "Name", 30, "NA", "N"), ("sagt", "Shots", 5, "UI",
                                                "N"))
     recs = self.sql.getRec("scpgme",
                            where=[("scg_cono", "=", self.opts["conum"]),
                                   ("scg_ccod", "=", self.ccod),
                                   ("scg_ctyp", "=", self.ctyp),
                                   ("scg_snum", "=", self.snum),
                                   ("scg_subs", "=", self.subs),
                                   ("scg_rnum", "=", self.rnum)])
     done = []
     data = []
     for rec in recs:
         scod = rec[self.sql.scpgme_col.index("scg_scod")]
         ocod = rec[self.sql.scpgme_col.index("scg_ocod")]
         if scod in done or scod > 900000 or ocod in done or ocod > 900000:
             continue
         sfor = rec[self.sql.scpgme_col.index("scg_sfor")]
         sagt = rec[self.sql.scpgme_col.index("scg_sagt")]
         data.append((scod, self.getName(scod), sfor, ocod,
                      self.getName(ocod), sagt))
     SelectChoice(self.opts["mf"].window, "Results", cols, data)
     self.df.focusField(self.df.frt, self.df.pag, self.df.col)
コード例 #3
0
 def doSch(self):
     cols = [("bkno", "Number", 7, "UI", "F"),
             ("sname", "Surname", 20, "TX", "Y"),
             ("names", "Names", 20, "TX", "F"),
             ("group", "Group", 30, "TX", "F"),
             ("arrive", "Arrival-Dt", 10, "d1", "F"),
             ("state", "Status", 1, "UA", "F")]
     data = self.sql.getRec(tables=["bkmmst", "bkmcon"],
                            cols=[
                                "bkm_number", "bkc_sname", "bkc_names",
                                "bkm_group", "bkm_arrive", "bkm_state"
                            ],
                            where=[("bkm_cono", "=", self.opts["conum"]),
                                   ("bkc_cono=bkm_cono", ),
                                   ("bkc_ccode=bkm_ccode", )],
                            order="bkc_sname, bkc_names")
     sc = SelectChoice(self.cal.window,
                       "Select Booking",
                       cols,
                       data,
                       fltr=True)
     if sc.selection:
         self.number = int(sc.selection[1])
         self.opts["mf"].closeLoop()
     else:
         self.number = None
コード例 #4
0
ファイル: cr4010.py プロジェクト: paulmalherbe/Tartan
 def doTrans2(self, frt, pag, r, c, p, i, w):
     self.paidup = w
     whr = [
         ("crt_cono", "=", self.opts["conum"]),
         ("crt_acno", "=", self.acno)]
     if self.paidup == "Y":
         col, recs = getTrn(self.opts["mf"].dbm, "crs", whr=whr)
     else:
         col, recs = getTrn(self.opts["mf"].dbm, "crs", dte=self.curdt,
             whr=whr)
     if recs:
         data = []
         for dat in recs:
             data.append([
                 dat[col.index("crt_trdt")],
                 dat[col.index("crt_curdt")],
                 dat[col.index("crt_batch")],
                 dat[col.index("crt_type")],
                 dat[col.index("crt_ref1")],
                 dat[col.index("crt_tramt")],
                 dat[col.index("paid")],
                 dat[col.index("balance")],
                 dat[col.index("crt_desc")]])
         tit = "Transactions for Account: %s - %s" % (self.acno, self.name)
         col = (
             ("crt_trdt", "Date", 10, "D1", "N"),
             ("crt_curdt", "Curr-Dt", 7, "D2", "N"),
             ("crt_batch", "Batch", 7, "Na", "N"),
             ("crt_type", "Typ", 3, ("XX", crtrtp), "N"),
             ("crt_ref1", "Reference", 9, "Na", "Y"),
             ("crt_tramt", "Amount", 13.2, "SD", "N"),
             ("alloc", "Allocated", 13.2, "SD", "N"),
             ("balan", "Balance", 13.2, "SD", "N"),
             ("crt_desc", "Details", 30, "NA", "N"))
         state = self.df.disableButtonsTags()
         while True:
             rec = SelectChoice(self.df.nb.Page4, tit, col, data)
             # Display all transaction details
             if rec.selection:
                 self.df.setWidget(self.df.mstFrame, state="hide")
                 whr = [
                     ("crt_cono", "=", self.opts["conum"]),
                     ("crt_acno", "=", self.acno),
                     ("crt_type", "=", rec.selection[4]),
                     ("crt_ref1", "=", rec.selection[5])]
                 TabPrt(self.opts["mf"], tabs="crstrn", where=whr,
                     pdia=False)
                 self.df.setWidget(self.df.mstFrame, state="show")
             else:
                 break
         self.df.enableButtonsTags(state=state)
     self.doTrans1()
コード例 #5
0
ファイル: rc2010.py プロジェクト: paulmalherbe/Tartan
 def showTenantTrans(self):
     tab = ["rcatnt"]
     col = [
         "rtu_trdt", "rtu_type", "rtu_refno", "rtu_desc", "rtu_mtyp",
         "rtu_tramt", "rtu_taxamt"
     ]
     whr = [("rtu_cono", "=", self.opts["conum"]),
            ("rtu_owner", "=", self.owner), ("rtu_code", "=", self.code),
            ("rtu_acno", "=", self.acno)]
     odr = "rtu_trdt, rtu_type, rtu_refno, rtu_mtyp"
     dat = self.sql.getRec(tables=tab, cols=col, where=whr, order=odr)
     data = []
     bals = 0
     for d in dat:
         bals = float(ASD(bals) + ASD(d[5]))
         data.append(d + [bals])
     col = (("rtu_trdt", "Trans-Date", 10, "D1",
             "N"), ("rtu_type", "Typ", 3, ("XX", rctrtp),
                    "N"), ("rtu_refno", "Reference", 9, "Na",
                           "N"), ("rtu_desc", "Details", 35, "NA", "N"),
            ("rtu_mtyp", "Mov", 3, ("XX", rcmvtp),
             "N"), ("rtu_tramt", "Amount", 11.2, "SD",
                    "N"), ("rtu_taxamt", "VAT-Amount", 11.2, "SD",
                           "N"), ("balance", "Balance", 15.2, "SD", "N"))
     try:
         self.ttrn.closeProcess()
     except:
         pass
     self.ttrn = SelectChoice(self.df.topPage2,
                              None,
                              col,
                              data,
                              wait=False,
                              neww=False,
                              butt=False,
                              sort=False,
                              live=False,
                              modal=False,
                              lines=9)
コード例 #6
0
 def doTrans2(self, frt, pag, r, c, p, i, w):
     tit = "Transactions for Item: %s %s - %s" % \
         (self.group, self.code, self.desc)
     dat, atc, col = self.getTrans(hist=w)
     if dat:
         state = self.df.disableButtonsTags()
         while True:
             rec = SelectChoice(self.df.nb.Page3, tit, atc, dat)
             if rec.selection:
                 self.df.setWidget(self.df.mstFrame, state="hide")
                 whr = [("ast_seq", "=", rec.selection[len(col)])]
                 TabPrt(self.opts["mf"],
                        tabs="asstrn",
                        where=whr,
                        pdia=False)
                 self.df.setWidget(self.df.mstFrame, state="show")
             else:
                 break
         self.df.enableButtonsTags(state=state)
     self.doTrans1()
コード例 #7
0
ファイル: cr4010.py プロジェクト: paulmalherbe/Tartan
 def doOrders(self):
     col = self.sql.strpom_col
     whr = [
         ("pom_cono", "=", self.opts["conum"]),
         ("pom_acno", "=", self.acno),
         ("pom_delno", "<>", "cancel"),
         ("pom_deldt", "=", 0)]
     recs = self.sql.getRec("strpom", where=whr, order="pom_date")
     if recs:
         data = []
         for dat in recs:
             data.append([
                 dat[col.index("pom_date")],
                 dat[col.index("pom_ordno")],
                 dat[col.index("pom_cusord")],
                 dat[col.index("pom_jobnum")],
                 dat[col.index("pom_contact")]])
         tit = "Orders for Account: %s - %s" % (self.acno, self.name)
         col = (
             ("pom_date", "   Date", 10, "D1", "N"),
             ("pom_ordno", "Doc-Numbr", 9, "UI", "N"),
             ("pom_cusord", "Cust-Ord-Num", 15, "Na"),
             ("pom_jobnum", "Job-Num", 7, "Na"),
             ("pom_contact", "Contact", 30, "NA"))
         state = self.df.disableButtonsTags()
         while True:
             rec = SelectChoice(self.df.nb.Page6, tit, col, data)
             # Attempt to display the document
             if rec.selection:
                 self.df.setWidget(self.df.mstFrame, state="hide")
                 try:
                     doc = int(rec.selection[2])
                     PrintOrder(self.opts["mf"], self.opts["conum"],
                         self.opts["conam"], doc, repprt=["N", "V",
                         "view"], copy="y")
                 except:
                     pass
                 self.df.setWidget(self.df.mstFrame, state="show")
             else:
                 break
         self.df.enableButtonsTags(state=state)
コード例 #8
0
ファイル: td1010.py プロジェクト: paulmalherbe/Tartan
 def doContacts(self):
     # Display contacts and allow adding, editing etc.
     recs = self.sql.getRec("telcon",
                            cols=[
                                "tdc_contact", "tdc_desig", "tdc_telno",
                                "tdc_celno", "tdc_email"
                            ],
                            where=[("tdc_name", "=", self.name)],
                            order="tdc_contact")
     if not recs:
         recs = [["", "", "", "", ""]]
     titl = "Contacts"
     cols = (("a", "Name", 30, "NA"), ("b", "Designation", 20,
                                       "NA"), ("c", "Telephone", 20, "NA"),
             ("d", "Mobile", 20, "NA"), ("e", "Email-Address", 50, "TX"))
     butt = (("Add", self.doConAdd), ("Exit", self.doConExit))
     state = self.df.disableButtonsTags()
     self.opts["mf"].updateStatus("Select a Contact to Edit or an Action")
     self.contyp = None
     self.chg = SelectChoice(self.df.mstFrame,
                             titl=titl,
                             cols=cols,
                             data=recs,
                             butt=butt,
                             sort=False)
     self.df.enableButtonsTags(state=state)
     if not self.contyp and self.chg.selection:
         self.contyp = "chg"
         con = self.chg.selection[1].strip()
         self.conchg = self.sql.getRec("telcon",
                                       where=[("tdc_name", "=", self.name),
                                              ("tdc_contact", "=", con)],
                                       limit=1)
     if self.contyp in ("add", "chg"):
         self.doConChanges()
     self.df.focusField(self.df.frt, self.df.pag, self.df.col)
コード例 #9
0
 def doPreview(self):
     self.cols = [
         ("a", "Seq-Num", 7.2, "UD"),
         ("b", "T", 1, "UA"),
         ("c", "Grp", 3, "Na"),
         ("d", "Lvl", 3, "Na"),
         ("e", "Acc-Num", 7, "Na"),
         ("f", "Description", 30, "NA")]
     self.data = []
     self.newp = []
     recs = self.sql.getRec("genrpt", where=[("glr_cono", "=",
         self.selcoy), ("glr_repno", "=", self.repno)], order="glr_seq")
     pgp = 0
     lsq = 0
     rpc = self.sql.genrpt_col
     for num, rec in enumerate(recs):
         seq = rec[rpc.index("glr_seq")]
         rtp = rec[rpc.index("glr_type")]
         if rtp in ("B", "P", "O"):
             self.titl = rec[rpc.index("glr_desc")]
             continue
         des = rec[rpc.index("glr_desc")]
         prt = rec[rpc.index("glr_print")]
         if prt == "N":
             continue
         if rtp == "H":
             if rec[rpc.index("glr_ffeed")] == "Y":
                 self.data.append((seq, "N", "", "", "",
                     "---------- New Page ----------"))
             elif lsq:
                 ptp = recs[lsq][rpc.index("glr_type")]
                 utp = recs[lsq][rpc.index("glr_uline")]
                 if ptp == "H" or (ptp == "U" and utp == "B"):
                     pass
                 else:
                     self.data.append((seq, "", "", "", "", ""))
             self.data.append((seq, rtp, "", "", "", des))
             self.data.append((seq, "", "", "", "", ""))
         elif rtp == "L":
             frm = rec[rpc.index("glr_from")]
             too = rec[rpc.index("glr_to")]
             whr = [("glm_cono", "=", self.selcoy)]
             if too:
                 whr.append(("glm_acno", "between", frm, too))
             else:
                 whr.append(("glm_acno", "=", frm))
             accs = self.sql.getRec("genmst", cols=["glm_acno",
                 "glm_desc"], where=whr, order="glm_acno")
             for acc in accs:
                 self.data.append((seq, rtp, "", "", acc[0], acc[1]))
         elif rtp == "G":
             grp = rec[rpc.index("glr_group")]
             if not pgp or grp != pgp:
                 self.data.append((seq, rtp, grp, "", "", des))
             pgp = grp
         elif rtp == "T":
             tot = rec[rpc.index("glr_total")]
             self.data.append((seq, rtp, "", tot, "", des))
         elif rtp == "S":
             self.data.append((seq, rtp, "", "", "", des))
         elif rtp == "U":
             utp = rec[rpc.index("glr_uline")]
             if utp == "B":
                 des = ""
             elif utp == "S":
                 des = "-" * 30
             else:
                 des = "=" * 30
             self.data.append((seq, rtp, "", "", "", des))
         else:
             continue
         lsq = num
     self.pprt = False
     self.sc = SelectChoice(self.opts["mf"].window, self.titl, self.cols,
         self.data, sort=False, butt=(("Print", self.doPrePrt),))
     if self.pprt:
         cols = []
         for col in self.cols:
             cols.append([col[0], col[3], col[2], col[1], "y"])
         state = self.df.disableButtonsTags()
         self.df.setWidget(self.df.mstFrame, "hide")
         RepPrt(self.opts["mf"], name=self.__class__.__name__,
             tables=self.data, heads=[self.titl], cols=cols, ttype="D",
             prtdia=(("Y","V"),("Y","N")))
         self.df.setWidget(self.df.mstFrame, "show")
         self.df.enableButtonsTags(state=state)
         self.df.focusField("T", 1, 1)
     elif self.sc.selection:
         self.df.doKeyPressed("T", 1,  0, self.sc.selection[1])
         self.df.doKeyPressed("T", 1,  1, self.sc.selection[2])
     else:
         self.df.focusField("T", 1, 1)
コード例 #10
0
ファイル: rc2010.py プロジェクト: paulmalherbe/Tartan
class rc2010(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.drawDialog()
            self.opts["mf"].startLoop()

    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

    def drawDialog(self):
        # Transaction Types
        typ = {
            "stype": "C",
            "titl": "Select the Required Type",
            "head": ("C", "Type"),
            "data": []
        }
        # Movement Types
        data = []
        for x in range(1, len(rcmvtp) + 1):
            data.append((x, rcmvtp[x - 1][1]))
        mov = {
            "stype": "C",
            "titl": "Select the Required Type",
            "head": ("C", "Type"),
            "data": data
        }
        # Premises
        prm = {
            "stype":
            "R",
            "tables": ("rcaprm", "rcaowm"),
            "cols":
            (("rcp_owner", "", 0, "Owner"), ("rom_name", "", 0, "Owner"),
             ("rcp_code", "", 0, "Prm-Cod"), ("rcp_addr1", "", 0,
                                              "Address-Line-1")),
            "where": [("rcp_cono", "=", self.opts["conum"]),
                      ("rom_cono=rcp_cono", ), ("rom_acno=rcp_owner", )],
            "index":
            2
        }
        # Tenant
        tnm = {
            "stype":
            "R",
            "tables": ("rcatnm", ),
            "cols": (("rtn_acno", "", 0, "Acc-Num"), ("rtn_name", "", 0,
                                                      "Description", "Y")),
            "where": [("rtn_cono", "=", self.opts["conum"])],
            "whera": [("T", "rtn_owner", 0, 1)]
        }
        # Contract
        con = {
            "stype":
            "R",
            "tables": ("rcacon", ),
            "cols": (("rcc_cnum", "", 0, "Seq"), ("rcc_payind", "", 0, "F"),
                     ("rcc_start", "", 0, "Start-Date"),
                     ("rcc_period", "", 0, "Per"), ("rcc_status", "", 0, "S")),
            "where": [("rcc_cono", "=", self.opts["conum"])],
            "whera": [("T", "rcc_owner", 0, 1), ("T", "rcc_code", 0, 0),
                      ("T", "rcc_acno", 0, 2)]
        }
        # VAT Records
        vtm = {
            "stype":
            "R",
            "tables": ("ctlvmf", ),
            "cols": (("vtm_code", "", 0, "C"), ("vtm_desc", "", 0,
                                                "Description", "Y")),
            "where": [("vtm_cono", "=", self.opts["conum"])]
        }
        tag = (
            (
                "Owner",
                None,
                (("T", 2, 1), ("C", 2, 1)),  # On
                (("C", 1, 1), ("T", 2, 2), ("C", 2, 2))),  # Off
            (
                "Tenant",
                None,
                ("C", 1, 1),  # On
                (("C", 1, 2), ("T", 2, 1), ("C", 2, 1))),  # Off
            ("Allocation", self.doAllocation, None, None))
        fld = [
            (("T", 0, 0, 0), "INA", 7, "Prm-Cod", "Premises Code", "", "Y",
             self.doPrmCod, prm, None, None),
            (("T", 0, 0, 0), "ONA", 30, "Description"),
            (("T", 1, 0, 0), "ONA", 7, "Acc-Num"),
            (("T", 1, 0, 0), "ONA", 30, "Name"),
            (("T", 1, 0, 0), "OSD", 11.2, "Payable"),
            (("C", 1, 0, 0), "INa", 9, "Reference", "Reference Number", "i",
             "Y", self.doOwnRef, None, None, ("notblank", )),
            (("C", 1, 0, 1), "ID1", 10, "Date", "Transaction Date", "r", "N",
             self.doOwnDat, None, None, ("efld", )),
            (("C", 1, 0, 2), "IUI", 1, "T", "Transaction Type", "r", "N",
             self.doOwnTyp, typ, None, ("notzero", )),
            (("C", 1, 0, 3), "ISD", 11.2, "Amount", "Transaction Amount", "",
             "N", self.doOwnAmt, None, None, None),
            (("C", 1, 0, 4), "IUA", 1, "V", "V.A.T Code", "N", "N",
             self.doOwnCod, vtm, None, ("efld", )),
            (("C", 1, 0, 5), "ISD", 11.2, "V.A.T", "V.A.T Amount", "", "N",
             self.doOwnVat, None, None, None),
            (("C", 1, 0, 6), "INA", 47, "Details", "Transaction Details", "",
             "N", self.doOwnDet, None, None, None),
            (("T", 2, 0, 0), "INA", 7, "Acc-Num", "Account Number", "", "Y",
             self.doAccNum, tnm, None, None),
            (("T", 2, 0, 0), "ONA", 30, "Name"),
            (("T", 2, 0, 0), "IUI", 3, "Seq", "Contract Number", "", "N",
             self.doConSeq, con, None, None),
            (("T", 2, 0, 0), "OSD", 11.2, "Balance"),
            (("C", 2, 0, 0), "INa", 9, "Reference", "Reference Number", "i",
             "Y", self.doTntRef, None, None, ("notblank", )),
            (("C", 2, 0, 1), "ID1", 10, "Date", "Transaction Date", "r", "N",
             self.doTntDat, None, None, ("efld", )),
            (("C", 2, 0, 2), "IUI", 1, "T", "Transaction Type", "r", "N",
             self.doTntTyp, typ, None, ("notzero", )),
            (("C", 2, 0, 3), "ISD", 11.2, "Amount", "Transaction Amount", "",
             "N", self.doTntAmt, None, None, None),
            (("C", 2, 0, 4), "INA", (60, 30), "Details", "Transaction Details",
             "", "N", self.doTntDet, None, None, None),
            (("T", 3, 0, 0), "OSD", 11.2, "Rentals     "),
            (("T", 3, 0, 0), "OSD", 11.2, "Deposit     "),
            (("T", 3, 0, 0), "OSD", 11.2, "Fees        "),
            (("T", 3, 1, 0), "OSD", 11.2, "Services (O)"),
            (("T", 3, 1, 0), "OSD", 11.2, "Services (A)"),
            (("T", 3, 1, 0), "OSD", 11.2, "Repairs     "),
            (("T", 3, 2, 0), "OSD", 11.2, "Allocation"),
            (("C", 3, 0, 0), "IUI", 1, "M", "Movement Type", "", "Y",
             self.doAllMov, mov, None, ("between", 1, 6)),
            (("C", 3, 0, 1), "ISD", 11.2, "Amount", "Allocation Amount", "",
             "N", self.doAllAmt, None, None, None),
            (("C", 3, 0, 2), "IUA", 1, "V", "V.A.T Code", "N", "N",
             self.doAllCod, vtm, None, ("efld", )),
            (("C", 3, 0, 3), "ISD", 11.2, "V.A.T", "V.A.T Amount", "", "N",
             self.doAllVat, None, None, None),
            (("C", 3, 0, 4), "INA", (50, 30), "Details", "Transaction Details",
             "", "N", self.doAllDet, None, None, None)
        ]
        row = [0, 4, 4, 10]
        tnd = [(self.endPage, "y"), (self.endPage, "y"), (self.endPage, "y"),
               (self.endPage, "y")]
        txt = [self.exitPage, self.exitPage, self.exitPage, self.exitPage]
        cnd = [(None, "n"), (self.endPage, "y"), (self.endPage, "y"),
               (self.endPage, "y")]
        cxt = [None, self.exitPage, self.exitPage, self.exitPage]
        but = (("Notes", None, self.allNotes, 0, ("T", 0, 0), ("T", 0, 1)),
               ("Statement", None, self.allStmnt, 0,
                (("C", 1, 1), ("C", 2, 1)), (("T", 0, 1), ("T", 2, 1))),
               ("Cancel", None, self.doAllCancel, 0, ("C", 3, 1), ("C", 2, 1)))
        self.df = TartanDialog(self.opts["mf"],
                               tags=tag,
                               eflds=fld,
                               rows=row,
                               tend=tnd,
                               txit=txt,
                               cend=cnd,
                               cxit=cxt,
                               butt=but)

    def doPrmCod(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec(
            "rcaprm",
            cols=["rcp_desc", "rcp_owner", "rcp_crate", "rcp_addr1"],
            where=[("rcp_cono", "=", self.opts["conum"]),
                   ("rcp_code", "=", w)],
            limit=1)
        if not acc:
            return "Invalid Premises Code"
        self.code = w
        desc, self.owner, self.crate, addr1 = acc
        if desc:
            self.df.loadEntry(frt, pag, p + 1, data=desc)
        else:
            self.df.loadEntry(frt, pag, p + 1, data=addr1)
        acc = self.sql.getRec("rcaowm",
                              cols=["rom_name", "rom_vatdf"],
                              where=[("rom_cono", "=", self.opts["conum"]),
                                     ("rom_acno", "=", self.owner)],
                              limit=1)
        if not acc:
            return "Missing Owner Record (%s)" % self.owner
        self.df.loadEntry("T", 1, 0, data=self.owner)
        self.df.loadEntry("T", 1, 1, data=acc[0])
        self.vatdf = acc[1]
        self.acno = None

    def doAccNum(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("rcatnm",
                              cols=["rtn_name"],
                              where=[("rtn_cono", "=", self.opts["conum"]),
                                     ("rtn_owner", "=", self.owner),
                                     ("rtn_code", "=", self.code),
                                     ("rtn_acno", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid Account Number"
        self.acno = w
        self.name = acc[0]
        self.df.loadEntry(frt, pag, p + 1, data=self.name)
        con = self.sql.getRec("rcacon",
                              where=[("rcc_cono", "=", self.opts["conum"]),
                                     ("rcc_owner", "=", self.owner),
                                     ("rcc_code", "=", self.code),
                                     ("rcc_acno", "=", self.acno)],
                              order="rcc_cnum")
        if not con:
            return "No Valid Contracts"
        self.cnum = con[-1:][0][self.sql.rcacon_col.index("rcc_cnum")]
        self.df.topf[2][2][5] = self.cnum

    def doConSeq(self, frt, pag, r, c, p, i, w):
        con = self.sql.getRec("rcacon",
                              where=[("rcc_cono", "=", self.opts["conum"]),
                                     ("rcc_code", "=", self.code),
                                     ("rcc_acno", "=", self.acno),
                                     ("rcc_cnum", "=", w)],
                              order="rcc_cnum")
        if not con:
            return "Invalid Contract Sequence"
        self.cnum = w
        self.showTenantBalance()

    def doOwnRef(self, frt, pag, r, c, p, i, w):
        self.trnref = w

    def doOwnDat(self, frt, pag, r, c, p, i, w):
        if w < self.ch1 or w > self.ch2:
            ov = PwdConfirm(self.opts["mf"],
                            conum=self.opts["conum"],
                            system="RCA",
                            code="DateOver")
            if ov.flag == "no":
                return "Invalid Date (< %s or > %s)" % (self.ch1, self.ch2)
        self.trndat = w
        data = []
        for x in range(2, len(rctrtp) + 1):
            data.append((x, rctrtp[x - 1][1]))
        self.df.colf[1][2][8]["data"] = data

    def doOwnTyp(self, frt, pag, r, c, p, i, w):
        if w not in (2, 3, 4):
            return "Invalid Transaction Type"
        self.trntyp = w

    def doOwnAmt(self, frt, pag, r, c, p, i, w):
        if self.trntyp == 3 and w > self.due:
            op = PwdConfirm(self.opts["mf"],
                            conum=self.opts["conum"],
                            system="RCA",
                            code="Overpaid")
            if op.flag == "no":
                return "Overpaid"
        self.trnamt = w
        # Ignore VAT at this stage
        self.vatcode = ""
        self.trnvat = 0
        self.df.loadEntry(frt, pag, p + 1, data=self.vatcode)
        self.df.loadEntry(frt, pag, p + 2, data=self.trnvat)
        return "sk2"

    def doOwnCod(self, frt, pag, r, c, p, i, w):
        pass

    #    vrte = getVatRate(self.sql, self.opts["conum"], w, self.trndat)
    #    if vrte is None:
    #        return "Invalid V.A.T Code"
    #    self.vatcode = w
    #    self.trnvat = round((self.trnamt * vrte / (vrte + 100)), 2)
    #    self.df.loadEntry(frt, pag, p+1, data=self.trnvat)
    #    if not self.trnvat:
    #        return "sk1"

    def doOwnVat(self, frt, pag, r, c, p, i, w):
        pass

    #    if self.trnamt < 0 and w > 0:
    #        self.trnvat = float(ASD(0) - ASD(w))
    #    elif self.trnamt > 0 and w < 0:
    #        self.trnvat = float(ASD(0) - ASD(w))
    #    else:
    #        self.trnvat = w
    #    self.df.loadEntry(frt, pag, p, data=self.trnvat)

    def doOwnDet(self, frt, pag, r, c, p, i, w):
        self.trndet = w

    def doTntRef(self, frt, pag, r, c, p, i, w):
        self.trnref = w

    def doTntDat(self, frt, pag, r, c, p, i, w):
        if w < self.ch1 or w > self.ch2:
            ov = PwdConfirm(self.opts["mf"],
                            conum=self.opts["conum"],
                            system="RCA",
                            code="DateOver")
            if ov.flag == "no":
                return "Invalid Date (< %s or > %s)" % (self.ch1, self.ch2)
        self.trndat = w
        data = []
        for x in range(1, len(rctrtp) + 1):
            data.append((x, rctrtp[x - 1][1]))
        self.df.colf[2][2][8]["data"] = data

    def doTntTyp(self, frt, pag, r, c, p, i, w):
        if w not in (1, 2, 3, 4):
            return "Invalid Transaction Type"
        self.trntyp = w

    def doTntAmt(self, frt, pag, r, c, p, i, w):
        self.trnamt = w
        if self.trntyp == 1:
            # Rental Raised
            self.vatcode = self.vatdf
            vrte = getVatRate(self.sql, self.opts["conum"], self.vatcode,
                              self.trndat)
            if vrte is None:
                vrte = 0.0
            self.trnvat = round((w * vrte / (vrte + 100)), 2)
            self.df.loadEntry(frt, pag, p + 1, data="Rental Raised")
        else:
            # Ignore VAT at this stage
            self.vatcode = ""
            self.trnvat = 0

    def doTntDet(self, frt, pag, r, c, p, i, w):
        self.trndet = w

    def doAllocation(self):
        self.df.setWidget(self.df.B1, state="normal")

    def doAllMov(self, frt, pag, r, c, p, i, w):
        if w == 2 and self.trntyp not in (2, 3):
            return "Deposits Only Allowed for Receipts and Payments"
        self.allmov = w

    def doAllAmt(self, frt, pag, r, c, p, i, w):
        if not w:
            self.allamt = float(ASD(self.trnamt) - ASD(self.alltot))
            self.df.loadEntry(frt, pag, p, data=self.allamt)
        else:
            self.allamt = w
        if self.allmov == 2:
            # Deposit
            self.allcod = ""
            self.df.loadEntry(frt, pag, p + 1, data=self.allcod)
            self.allvat = 0
            self.df.loadEntry(frt, pag, p + 2, data=self.allvat)
            return "sk2"
        if self.trntyp in (2, 3):
            # Receipt or Payment
            self.df.loadEntry(frt, pag, p + 1, self.vatdf)
        if self.trntyp == 4 and self.allmov == 3:
            # Journal Fee
            self.df.loadEntry(frt, pag, p + 1, self.taxdf)
        else:
            self.allcod = ""
            self.allvat = 0

    def doAllCod(self, frt, pag, r, c, p, i, w):
        vrte = getVatRate(self.sql, self.opts["conum"], w, self.trndat)
        if vrte is None:
            return "Invalid V.A.T Code"
        self.allcod = w
        self.allvat = round((self.allamt * vrte / (vrte + 100)), 2)
        self.df.loadEntry(frt, pag, p + 1, data=self.allvat)
        if not self.allvat:
            self.df.loadEntry(frt, pag, p + 2, data=self.trndet)
            return "sk1"

    def doAllVat(self, frt, pag, r, c, p, i, w):
        if self.allamt < 0 and w > 0:
            self.allvat = float(ASD(0) - ASD(w))
        elif self.allamt > 0 and w < 0:
            self.allvat = float(ASD(0) - ASD(w))
        else:
            self.allvat = w
        self.df.loadEntry(frt, pag, p, data=self.allvat)
        self.df.loadEntry(frt, pag, p + 1, data=self.trndet)

    def doAllDet(self, frt, pag, r, c, p, i, w):
        self.trndet = w

    def doAllCancel(self):
        self.allocs = []
        self.df.clearFrame("C", 3)
        self.df.setWidget(self.df.B1, state="disabled")
        self.df.selPage("Tenant")
        self.df.clearLine(2, int((self.df.last[2][1] - 1) / self.df.colq[2]),
                          "Y")

    def endPage(self):
        if self.df.frt == "T" and self.df.pag == 0:
            self.df.focusField("C", 1, 1)
        elif self.df.frt == "C" and self.df.pag == 1:
            # Owners
            self.updateTables()
            self.df.advanceLine(self.df.pag)
        elif self.df.frt == "T" and self.df.pag == 2:
            self.df.focusField("C", 2, 1)
        elif self.df.frt == "C" and self.df.pag == 2:
            # Tenants
            self.allocs = []
            self.alltot = 0.0
            if self.trntyp == 1:
                self.movtyp = 1
                self.updateTables()
                self.df.advanceLine(self.df.pag)
            else:
                self.df.selPage("Allocation")
                dpp = 0.0
                acc = self.sql.getRec("rcacon",
                                      cols=["rcc_deposit"],
                                      where=[("rcc_cono", "=",
                                              self.opts["conum"]),
                                             ("rcc_owner", "=", self.owner),
                                             ("rcc_code", "=", self.code),
                                             ("rcc_acno", "=", self.acno)],
                                      order="rcc_cnum")
                if acc:
                    dpo = acc[-1:][0][0]
                else:
                    dpo = 0.0
                dat = self.sql.getRec(
                    "rcatnt",
                    cols=["rtu_mtyp", "round(sum(rtu_tramt), 2)"],
                    where=[("rtu_cono", "=", self.opts["conum"]),
                           ("rtu_owner", "=", self.owner),
                           ("rtu_code", "=", self.code),
                           ("rtu_acno", "=", self.acno)],
                    group="rtu_mtyp",
                    order="rtu_mtyp")
                if dat:
                    for d in dat:
                        if d[0] == 2:
                            dpp = d[1]
                        else:
                            self.df.loadEntry("T", 3, d[0] - 1, data=d[1])
                dpo = float(ASD(dpo) + ASD(dpp))
                if dpo:
                    self.df.loadEntry("T", 3, 1, data=dpo)
                self.df.loadEntry("T", 3, 6, data=self.trnamt)
                self.df.focusField("C", 3, 1)
        else:
            # Allocations
            self.allocs.append(
                [self.allmov, self.allamt, self.allcod, self.allvat])
            self.alltot = float(ASD(self.alltot) + ASD(self.allamt))
            bal = float(ASD(self.trnamt) - ASD(self.alltot))
            if bal:
                pos = self.allmov - 1
                if self.trntyp == 2:
                    a = float(
                        ASD(self.df.t_work[3][0][pos]) - ASD(self.allamt))
                else:
                    a = float(
                        ASD(self.df.t_work[3][0][pos]) + ASD(self.allamt))
                self.df.loadEntry("T", 3, pos, data=a)
                self.df.loadEntry("T", 3, 6, data=bal)
                self.df.advanceLine(3)
            else:
                for line in self.allocs:
                    self.movtyp, self.trnamt, self.vatcode, self.trnvat = line
                    self.updateTables()
                self.df.clearFrame("C", 3)
                self.df.selPage("Tenant")
                self.df.advanceLine(2)
        self.showOwnerTrans()
        if self.acno:
            self.showTenantTrans()

    def showOwnerTrans(self):
        whr = [("rot_cono", "=", self.opts["conum"]),
               ("rot_acno", "=", self.owner)]
        tot = self.sql.getRec("rcaowt",
                              cols=["round(sum(rot_tramt),2)"],
                              where=[("rot_cono", "=", self.opts["conum"]),
                                     ("rot_acno", "=", self.owner)],
                              limit=1)
        if not tot or not tot[0]:
            self.due = 0
        else:
            self.due = float(ASD(0) - ASD(tot[0]))
        arr = self.sql.getRec("rcatnt",
                              cols=["round(sum(rtu_tramt),2)"],
                              where=[("rtu_cono", "=", self.opts["conum"]),
                                     ("rtu_owner", "=", self.owner),
                                     ("rtu_mtyp", "in", (1, 4))],
                              limit=1)
        if arr and arr[0]:
            self.due = float(ASD(self.due) - ASD(arr[0]))
        self.df.loadEntry("T", 1, 2, data=self.due)
        tab = ["rcaowt"]
        col = [
            "rot_trdt", "rot_type", "rot_refno", "rot_desc", "rot_tramt",
            "rot_taxamt"
        ]
        whr = [("rot_cono", "=", self.opts["conum"]),
               ("rot_acno", "=", self.owner)]
        odr = "rot_trdt, rot_type, rot_refno"
        dat = self.sql.getRec(tables=tab, cols=col, where=whr, order=odr)
        data = []
        bals = 0
        for d in dat:
            bals = float(ASD(bals) + ASD(d[4]))
            data.append(d + [bals])
        col = (("rot_trdt", "Trans-Date", 10, "D1",
                "N"), ("rot_type", "Typ", 3, ("XX", rctrtp),
                       "N"), ("rot_refno", "Reference", 9, "Na",
                              "N"), ("rot_desc", "Details", 39, "NA", "N"),
               ("rot_tramt", "Amount", 11.2, "SD",
                "N"), ("rot_taxamt", "VAT-Amount", 11.2, "SD",
                       "N"), ("balance", "Balance", 15.2, "SD", "N"))
        try:
            self.otrn.closeProcess()
        except:
            pass
        self.otrn = SelectChoice(self.df.topPage1,
                                 None,
                                 col,
                                 data,
                                 wait=False,
                                 neww=False,
                                 butt=False,
                                 sort=False,
                                 live=False,
                                 modal=False,
                                 lines=9)

    def showTenantTrans(self):
        tab = ["rcatnt"]
        col = [
            "rtu_trdt", "rtu_type", "rtu_refno", "rtu_desc", "rtu_mtyp",
            "rtu_tramt", "rtu_taxamt"
        ]
        whr = [("rtu_cono", "=", self.opts["conum"]),
               ("rtu_owner", "=", self.owner), ("rtu_code", "=", self.code),
               ("rtu_acno", "=", self.acno)]
        odr = "rtu_trdt, rtu_type, rtu_refno, rtu_mtyp"
        dat = self.sql.getRec(tables=tab, cols=col, where=whr, order=odr)
        data = []
        bals = 0
        for d in dat:
            bals = float(ASD(bals) + ASD(d[5]))
            data.append(d + [bals])
        col = (("rtu_trdt", "Trans-Date", 10, "D1",
                "N"), ("rtu_type", "Typ", 3, ("XX", rctrtp),
                       "N"), ("rtu_refno", "Reference", 9, "Na",
                              "N"), ("rtu_desc", "Details", 35, "NA", "N"),
               ("rtu_mtyp", "Mov", 3, ("XX", rcmvtp),
                "N"), ("rtu_tramt", "Amount", 11.2, "SD",
                       "N"), ("rtu_taxamt", "VAT-Amount", 11.2, "SD",
                              "N"), ("balance", "Balance", 15.2, "SD", "N"))
        try:
            self.ttrn.closeProcess()
        except:
            pass
        self.ttrn = SelectChoice(self.df.topPage2,
                                 None,
                                 col,
                                 data,
                                 wait=False,
                                 neww=False,
                                 butt=False,
                                 sort=False,
                                 live=False,
                                 modal=False,
                                 lines=9)

    def showTenantBalance(self):
        bal = self.sql.getRec("rcatnt",
                              cols=["round(sum(rtu_tramt),2)"],
                              where=[("rtu_cono", "=", self.opts["conum"]),
                                     ("rtu_owner", "=", self.owner),
                                     ("rtu_code", "=", self.code),
                                     ("rtu_acno", "=", self.acno),
                                     ("rtu_cnum", "=", self.cnum),
                                     ("rtu_mtyp", "<>", 2)],
                              limit=1)
        self.df.loadEntry("T", 2, 3, data=bal[0])

    def updateTables(self):
        curdt = int(self.trndat / 100)
        amt = self.trnamt
        vat = self.trnvat
        if self.trntyp in (1, 4):
            # Rental and Journal
            gltyp = 4
        elif self.trntyp == 2:
            # Receipt
            gltyp = 6
            bnk = amt
            amt = float(ASD(0) - ASD(amt))
            vat = float(ASD(0) - ASD(vat))
        elif self.trntyp == 3:
            # Payment
            gltyp = 2
            bnk = float(ASD(0) - ASD(amt))
        if self.df.pag == 1:
            # Owners Transaction
            accod = self.owner
            data = [
                self.opts["conum"], self.owner, self.trntyp, self.trnref,
                self.batno, self.trndat, amt, vat, curdt, self.trndet,
                self.vatcode, "", self.opts["capnm"], self.sysdtw, 0
            ]
            self.sql.insRec("rcaowt", data=data)
            if self.glint == "Y":
                # General Ledger Transaction for Owner Control
                gld = "%7s %s" % (self.owner, self.trndet[:22])
                data = [
                    self.opts["conum"], self.rcaown, curdt, self.trndat, gltyp,
                    self.trnref, self.batno, amt, 0, gld, "", "", 0,
                    self.opts["capnm"], self.sysdtw, 0
                ]
                self.sql.insRec("gentrn", data=data)
        else:
            # Tenants Transaction
            accod = self.code
            data = [
                self.opts["conum"], self.owner, self.code, self.acno,
                self.cnum, self.trntyp, self.trnref, self.batno, self.trndat,
                self.movtyp, amt, vat, curdt, self.trndet, self.vatcode, "",
                self.opts["capnm"], self.sysdtw, 0
            ]
            self.sql.insRec("rcatnt", data=data)
            if self.glint == "Y":
                gld = "%7s %7s %7s" % (self.owner, self.code, self.acno)
                if self.df.pag == 3 and self.movtyp == 2:
                    # General Ledger Transaction for Deposit Control
                    acc = self.rcadep
                else:
                    # General Ledger Transaction for Tenant Control
                    acc = self.rcatnt
                data = [
                    self.opts["conum"], acc, curdt, self.trndat, gltyp,
                    self.trnref, self.batno, amt, 0, gld, "", "", 0,
                    self.opts["capnm"], self.sysdtw, 0
                ]
                self.sql.insRec("gentrn", data=data)
            self.showTenantBalance()
        if self.trntyp in (2, 3):
            if self.glint == "Y":
                # General Ledger Transaction for Bank Account
                data = [
                    self.opts["conum"], self.glbnk, curdt, self.trndat, gltyp,
                    self.trnref, self.batno, bnk, 0, gld, "", "", 0,
                    self.opts["capnm"], self.sysdtw, 0
                ]
                self.sql.insRec("gentrn", data=data)
            return
        if self.df.pag == 1 and self.df.pag == 1:
            # Owners Journal Entries (Unallocated)
            if self.glint == "Y":
                amt = float(ASD(0) - ASD(amt))
                data = [
                    self.opts["conum"], self.rcaorx, curdt, self.trndat, gltyp,
                    self.trnref, self.batno, amt, 0, gld, "", "", 0,
                    self.opts["capnm"], self.sysdtw, 0
                ]
                self.sql.insRec("gentrn", data=data)
            return
        if self.df.pag == 2 and self.movtyp == 1:
            # Rental and Commission Raised
            rta = float(ASD(0) - ASD(amt))
            rtv = float(ASD(0) - ASD(vat))
            des = "Rental on %s Premises" % self.code
            data = [
                self.opts["conum"], self.owner, self.trntyp, self.trnref,
                self.batno, self.trndat, rta, rtv, curdt, des, self.vatcode,
                "", self.opts["capnm"], self.sysdtw, 0
            ]
            self.sql.insRec("rcaowt", data=data)
            if self.glint == "Y":
                # General Ledger Transaction for Owner Control
                gld = "%7s Rental on %7s" % (self.owner, self.code)
                data = [
                    self.opts["conum"], self.rcaown, curdt, self.trndat, gltyp,
                    self.trnref, self.batno, rta, 0, gld, "", "", 0,
                    self.opts["capnm"], self.sysdtw, 0
                ]
                self.sql.insRec("gentrn", data=data)
            if self.crate:
                # If there is a Commission Rate on the Premises Record
                cma = float(ASD(0) - ASD(round((rta * self.crate / 100.0), 2)))
                vrte = getVatRate(self.sql, self.opts["conum"], self.taxdf,
                                  self.trndat)
                if vrte is None:
                    vrte = 0.0
                cmv = round((cma * vrte / 100.0), 2)
                cmt = float(ASD(cma) + ASD(cmv))
                cma = float(ASD(0) - ASD(cma))
                tax = float(ASD(0) - ASD(cmv))
                des = "Commission @ %3.5s%s Inclusive" % (self.crate, "%")
                data = [
                    self.opts["conum"], self.owner, 4, self.trnref, self.batno,
                    self.trndat, cmt, cmv, curdt, des, self.vatdf, "",
                    self.opts["capnm"], self.sysdtw, 0
                ]
                self.sql.insRec("rcaowt", data=data)
                if self.glint == "Y":
                    # Update Owner Control
                    gld = "%7s Commission Raised" % self.owner
                    data = [
                        self.opts["conum"], self.rcaown, curdt, self.trndat,
                        gltyp, self.trnref, self.batno, cmt, 0, gld, "", "", 0,
                        self.opts["capnm"], self.sysdtw, 0
                    ]
                    self.sql.insRec("gentrn", data=data)
                    # Update Commission Account
                    data = [
                        self.opts["conum"], self.rcacom, curdt, self.trndat,
                        gltyp, self.trnref, self.batno, cma, tax, gld, "", "",
                        0, self.opts["capnm"], self.sysdtw, 0
                    ]
                    self.sql.insRec("gentrn", data=data)
                if self.taxdf:
                    # VAT Transaction (ctlvtf)
                    data = [
                        self.opts["conum"], self.taxdf, "O", curdt, "R",
                        self.trntyp, self.batno, self.trnref, self.trndat,
                        self.acno, self.name, cma, tax, 0, self.opts["capnm"],
                        self.sysdtw, 0
                    ]
                    self.sql.insRec("ctlvtf", data=data)
                    if self.glint == "Y" and tax:
                        # Update VAT Control
                        data = [
                            self.opts["conum"], self.convat, curdt,
                            self.trndat, gltyp, self.trnref, self.batno, tax,
                            0, gld, "", "", 0, self.opts["capnm"], self.sysdtw,
                            0
                        ]
                        self.sql.insRec("gentrn", data=data)
            return
        if self.df.pag == 3 and self.movtyp == 3:
            # Contract Fees
            amt = float(ASD(0) - ASD(amt) + ASD(vat))
            vat = float(ASD(0) - ASD(vat))
            if self.glint == "Y":
                # Update Contract Fee Account
                data = [
                    self.opts["conum"], self.rcafee, curdt, self.trndat, gltyp,
                    self.trnref, self.batno, amt, vat, gld, "", "", 0,
                    self.opts["capnm"], self.sysdtw, 0
                ]
                self.sql.insRec("gentrn", data=data)
            if self.taxdf:
                # VAT Transaction (ctlvtf)
                data = (self.opts["conum"], self.vatcode, "O", curdt, "R",
                        self.trntyp, self.batno, self.trnref, self.trndat,
                        accod, self.trndet, amt, vat, 0, self.opts["capnm"],
                        self.sysdtw, 0)
                self.sql.insRec("ctlvtf", data=data)
                if self.glint == "Y":
                    # Update VAT Control
                    data = [
                        self.opts["conum"], self.convat, curdt, self.trndat,
                        gltyp, self.trnref, self.batno, vat, 0, gld, "", "", 0,
                        self.opts["capnm"], self.sysdtw, 0
                    ]
                    self.sql.insRec("gentrn", data=data)
            return
        if self.df.pag == 3 and self.movtyp == 4:
            # Services - Owner Recovery
            rta = float(ASD(0) - ASD(amt))
            rtv = float(ASD(0) - ASD(vat))
            des = "Services Recovery on %s" % self.code
            data = [
                self.opts["conum"], self.owner, self.trntyp, self.trnref,
                self.batno, self.trndat, rta, rtv, curdt, des, self.vatcode,
                "", self.opts["capnm"], self.sysdtw, 0
            ]
            self.sql.insRec("rcaowt", data=data)
            if self.glint == "Y":
                # General Ledger Transaction for Owner Control
                gld = "%7s Services Recovery" % self.owner
                data = [
                    self.opts["conum"], self.rcaown, curdt, self.trndat, gltyp,
                    self.trnref, self.batno, rta, 0, gld, "", "", 0,
                    self.opts["capnm"], self.sysdtw, 0
                ]
                self.sql.insRec("gentrn", data=data)
            return
        # Tenants Journal Entries (Unallocated)
        if self.glint == "Y":
            amt = float(ASD(0) - ASD(amt))
            data = [
                self.opts["conum"], self.rcatrx, curdt, self.trndat, gltyp,
                self.trnref, self.batno, amt, 0, gld, "", "", 0,
                self.opts["capnm"], self.sysdtw, 0
            ]
            self.sql.insRec("gentrn", data=data)

    def exitPage(self):
        if self.df.frt == "T" and self.df.pag == 0:
            self.df.closeProcess()
            self.opts["mf"].closeLoop()
        elif self.df.frt == "C" and self.df.pag == 3:
            self.df.focusField("C", 3, self.df.col)
        else:
            self.opts["mf"].dbm.commitDbase(ask=True)
            try:
                self.otrn.closeProcess()
            except:
                pass
            try:
                self.ttrn.closeProcess()
            except:
                pass
            self.df.selPage("Owner")
            self.df.focusField("T", 0, 1)

    def allNotes(self):
        if self.df.frt == "C":
            state = self.df.disableButtonsTags()
            self.df.setWidget(self.df.mstFrame, state="hide")
            if self.df.pag == 1:
                key = "%s" % self.owner
            else:
                key = "%7s%7s%s" % (self.owner, self.code, self.acno)
            NotesCreate(self.opts["mf"],
                        self.opts["conum"],
                        self.opts["conam"],
                        self.opts["capnm"],
                        "RCA",
                        key,
                        commit=False)
            self.df.setWidget(self.df.mstFrame, state="show")
            self.df.enableButtonsTags(state=state)
        self.df.focusField(self.df.frt, self.df.pag, self.df.col)

    def allStmnt(self):
        if self.df.frt == "C" and self.df.pag == 1:
            self.sargs = [self.owner]
            self.repModule("rc3050")
        elif self.df.frt == "C" and self.df.pag == 2:
            self.sargs = [self.owner, self.code, self.acno]
            self.repModule("rc3060")
        else:
            self.df.focusField(self.df.frt, self.df.pag, self.df.col)

    def repModule(self, mod):
        self.exit = False
        state = self.df.disableButtonsTags()
        self.df.setWidget(self.df.mstFrame, state="hide")
        tit = ("Date and Printer Selection", )
        fld = ((("T", 0, 0, 0), "ID1", 10, "Statement Date", "", self.sysdtw,
                "N", self.doPrtDate, None, None, ("efld", )), )
        self.st = TartanDialog(self.opts["mf"],
                               tops=True,
                               title=tit,
                               eflds=fld,
                               tend=((self.doPrtEnd, "y"), ),
                               txit=(self.doPrtExit, ),
                               view=("N", "V"),
                               mail=("B", "Y"))
        self.st.mstFrame.wait_window()
        if not self.exit:
            self.sargs.extend(
                [self.stdtw, self.stdtd, self.st.repprt, self.st.repeml])
            popt = {
                "mf": self.opts["mf"],
                "conum": self.opts["conum"],
                "conam": self.opts["conam"],
                "capnm": self.opts["capnm"],
                "args": self.sargs
            }
            runModule(mod, **popt)
        self.df.setWidget(self.df.mstFrame, state="show")
        self.df.enableButtonsTags(state=state)
        self.df.focusField(self.df.frt, self.df.pag, self.df.col)

    def doPrtDate(self, frt, pag, r, c, p, i, w):
        self.stdtw = w
        self.stdtd = self.st.t_disp[0][0][0]

    def doPrtEnd(self):
        self.doPrtClose()

    def doPrtExit(self):
        self.exit = True
        self.doPrtClose()

    def doPrtClose(self):
        self.st.closeProcess()
コード例 #11
0
 def doEnd(self):
     self.df.closeProcess()
     if not self.new:
         self.sql.delRec("rptstm", where=[("rsm_cono", "=",
             self.opts["conum"]), ("rsm_rgrp", "=", self.rgrp)])
         self.sql.delRec("rptstr", where=[("rsr_cono", "=",
             self.opts["conum"]), ("rsr_rgrp", "=", self.rgrp)])
     self.sql.insRec("rptstm", data=[self.opts["conum"], self.rgrp,
         self.tadd])
     titl = "Report Stream"
     cols = (
         ("a", "", 0, "CB", "N"),
         ("b", "R-Code", 6, "NA", "N"),
         ("c", "System", 25, "NA", "N"),
         ("d", "Report", 30, "NA", "N"))
     data = []
     for mod in self.mods:
         if mod[0] in self.smod:
             data.append(["X", mod[0], mod[1], mod[2]])
         else:
             data.append(["", mod[0], mod[1], mod[2]])
     sc = SelectChoice(self.opts["mf"].body, titl, cols, data)
     if sc.selection:
         self.count = 1
         self.fles = []
         self.tmp = os.path.join(self.opts["mf"].rcdic["wrkdir"], "temp")
         if os.path.exists(self.tmp):
             shutil.rmtree(self.tmp)
         os.mkdir(self.tmp)
         if self.styp == "E":
             self.mess = "Attached please find the following reports:\n"
         else:
             self.mess = "Reports to Print:\n"
         for mod in sc.selection:
             if mod[1] == "gl3050":
                 self.doGetStream()
             if self.strm:
                 self.strm = None
                 continue
             self.opts["mf"].head.configure(text="")
             try:
                 if mod[1] in self.smod:
                     work = eval(self.smod[mod[1]])
                 else:
                     raise Exception
             except:
                 work = self.vars[mod[1]]
             var = callModule(self.opts["mf"], None, mod[1],
                 coy=(self.opts["conum"], self.opts["conam"]),
                 period=self.opts["period"], user=self.opts["capnm"],
                 args={"noprint": True, "work": work}, ret=["fpdf",
                 "t_work"])
             if var:
                 nam = os.path.join(self.tmp, "report%s.pdf" % self.count)
                 self.fles.append(nam)
                 var["fpdf"].output(nam)
                 self.mess = "%s\n%2s) %s - %s" % (self.mess, self.count,
                     mod[2], mod[3])
                 self.sql.insRec("rptstr", data=[self.opts["conum"],
                     self.rgrp, mod[1], str(var["t_work"])])
                 self.count += 1
         if self.fles:
             if self.styp == "E":
                 self.mess = "%s\n\nRegards" % self.mess
                 ok = askQuestion(self.opts["mf"].body, "Mail Reports",
                     self.mess, default="yes")
                 if ok == "yes":
                     self.doEmailReps()
             else:
                 ok = askQuestion(self.opts["mf"].body, "Print Reports",
                     self.mess, default="yes")
                 if ok == "yes":
                     self.doPrintReps()
             for fle in self.fles:
                 os.remove(fle)
     self.opts["mf"].dbm.commitDbase(True)
     self.closeProcess()
コード例 #12
0
ファイル: dr4010.py プロジェクト: paulmalherbe/Tartan
 def doOthers(self):
     si1 = self.sql.slsiv1_col
     wh1 = [("si1_cono", "=", self.opts["conum"]),
            ("si1_rtn", "in", ("Q", "O", "W")),
            ("si1_chain", "=", self.chain), ("si1_acno", "=", self.acno),
            ("si1_invno", "=", "")]
     recs = self.sql.getRec("slsiv1", where=wh1, order="si1_date")
     if recs:
         data = []
         for dat in recs:
             wh2 = [("si2_cono", "=", self.opts["conum"]),
                    ("si2_rtn", "=", dat[si1.index("si1_rtn")]),
                    ("si2_docno", "=", dat[si1.index("si1_docno")])]
             si2 = self.sql.getRec("slsiv2",
                                   cols=[
                                       "si2_disc_per", "si2_qty",
                                       "si2_price", "si2_vat_rate"
                                   ],
                                   where=wh2)
             incamt = 0
             for dis, qty, pri, vat in si2:
                 incrat = float(ASD(100.0) + ASD(vat))
                 incpri = round((pri * incrat / 100.0), 4)
                 net = float(ASD(100.0) - ASD(dis))
                 inc = round((qty * incpri * net / 100.0), 2)
                 incamt = float(ASD(incamt) + ASD(inc))
             data.append([
                 dat[si1.index("si1_date")], dat[si1.index("si1_rtn")],
                 dat[si1.index("si1_docno")], dat[si1.index("si1_cus_ord")],
                 dat[si1.index("si1_jobno")], dat[si1.index("si1_contact")],
                 incamt
             ])
         tit = "Quotes and Orders for Account: %s - %s" % \
             (self.acno, self.name)
         col = (("si1_date", "   Date", 10, "D1",
                 "N"), ("si1_rtn", "T", 1, "UA",
                        "N"), ("si1_docno", "Doc-Numbr", 9, "UI", "N"),
                ("si1_cus_ord", "Cust-Ord-Num", 14,
                 "Na"), ("si1_jobno", "Job-Num", 7,
                         "Na"), ("si1_contact", "Contact", 30, "NA"),
                ("incamt", "Total-Value", 12.2, "SD"))
         state = self.df.disableButtonsTags()
         while True:
             rec = SelectChoice(self.df.nb.Page6, tit, col, data)
             # Attempt to display the document
             if rec.selection:
                 self.df.setWidget(self.df.mstFrame, state="hide")
                 typ = rec.selection[2]
                 try:
                     doc = int(rec.selection[3])
                     PrintInvoice(self.opts["mf"],
                                  self.opts["conum"],
                                  self.opts["conam"],
                                  typ,
                                  doc,
                                  repprt=["N", "V", "view"],
                                  copy="y")
                 except:
                     pass
                 self.df.setWidget(self.df.mstFrame, state="show")
             else:
                 break
         self.df.enableButtonsTags(state=state)
コード例 #13
0
ファイル: dr4010.py プロジェクト: paulmalherbe/Tartan
 def doTrans2(self, frt, pag, r, c, p, i, w):
     self.paidup = w
     whr = [("drt_cono", "=", self.opts["conum"]),
            ("drt_chain", "=", self.chain), ("drt_acno", "=", self.acno)]
     if self.paidup == "Y":
         col, recs = getTrn(self.opts["mf"].dbm, "drs", whr=whr)
     else:
         col, recs = getTrn(self.opts["mf"].dbm,
                            "drs",
                            dte=self.curdt,
                            whr=whr)
     if recs:
         data = []
         for dat in recs:
             data.append([
                 dat[col.index("drt_trdt")], dat[col.index("drt_curdt")],
                 dat[col.index("drt_batch")], dat[col.index("drt_type")],
                 dat[col.index("drt_ref1")],
                 self.getRef2(col, dat), dat[col.index("drt_tramt")],
                 dat[col.index("paid")], dat[col.index("balance")],
                 dat[col.index("drt_desc")]
             ])
         if self.chains == "Y":
             tit = "Transactions for Account: %s %s - %s" % \
                 (self.chain, self.acno, self.name)
         else:
             tit = "Transactions for Account: %s - %s" % \
                 (self.acno, self.name)
         col = (("drt_trdt", "   Date", 10, "D1",
                 "N"), ("drt_curdt", "Curr-Dt", 7, "D2",
                        "N"), ("drt_batch", "Batch", 7, "Na", "N"),
                ("drt_type", "Typ", 3, ("XX", drtrtp),
                 "N"), ("drt_ref1", "Reference", 9, "Na",
                        "Y"), ("drt_ref2", "Ref-Number-Two", 14, "Na", "Y"),
                ("drt_tramt", "    Amount", 13.2, "SD",
                 "N"), ("alloc", " Allocated", 13.2, "SD",
                        "N"), ("balan", "   Balance", 13.2, "SD",
                               "N"), ("drt_desc", "Details", 30, "NA", "N"))
         state = self.df.disableButtonsTags()
         while True:
             rec = SelectChoice(self.df.nb.Page5, tit, col, data)
             # If Invoice or Credit Note, attempt to display the document
             # else display all transaction details
             if rec.selection:
                 self.df.setWidget(self.df.mstFrame, state="hide")
                 if rec.selection[4] in (1, 4):
                     if rec.selection[4] == 1:
                         typ = "I"
                     else:
                         typ = "C"
                     try:
                         doc = int(rec.selection[5])
                         inv = self.sql.getRec("slsiv1",
                                               where=[("si1_cono", "=",
                                                       self.opts["conum"]),
                                                      ("si1_rtn", "=", typ),
                                                      ("si1_docno", "=",
                                                       doc)],
                                               limit=1)
                     except:
                         inv = []
                 else:
                     inv = []
                 if inv:
                     PrintInvoice(self.opts["mf"],
                                  self.opts["conum"],
                                  self.opts["conam"],
                                  typ,
                                  doc,
                                  repprt=["N", "V", "view"],
                                  copy="y")
                 else:
                     whr = [("drt_cono", "=", self.opts["conum"]),
                            ("drt_chain", "=", self.chain),
                            ("drt_acno", "=", self.acno),
                            ("drt_type", "=", rec.selection[4]),
                            ("drt_ref1", "=", rec.selection[5])]
                     TabPrt(self.opts["mf"],
                            tabs="drstrn",
                            where=whr,
                            pdia=False)
                 self.df.setWidget(self.df.mstFrame, state="show")
             else:
                 break
         self.df.enableButtonsTags(state=state)
     self.doTrans1()
コード例 #14
0
ファイル: td1010.py プロジェクト: paulmalherbe/Tartan
 def doPrint(self):
     titl = "Select the Required Print Options"
     cols = (("a", "C", 1, "UA", "N"), ("b", "Description", 30, "NA", "N"))
     if self.df.last[0][0] != 1:
         data = [("A", "Print Card")]
     else:
         data = []
     data.extend([("B", "Print Directory"), ("C", "Print Contacts"),
                  ("D", "Print Notes")])
     ss = SelectChoice(self.df.mstFrame, titl, cols, data, sort=False)
     self.opts["mf"].updateStatus("")
     if not ss.selection:
         self.df.focusField(self.df.frt, self.df.pag, self.df.col)
         return
     state = self.df.disableButtonsTags()
     self.df.setWidget(self.df.mstFrame, state="hide")
     if ss.selection[1] == "A":
         head = ["Card for %s" % self.name]
         whr = [("tdm_name", "=", self.name)]
         TabPrt(self.opts["mf"],
                name=self.__class__.__name__,
                tabs="telmst",
                head=head,
                where=whr)
     elif ss.selection[1] == "D":
         self.notes = NotesPrint(self.opts["mf"], 0, "", "TEL", loop=False)
         if not self.notes.data:
             pass
         else:
             data = []
             p = ProgressBar(self.opts["mf"].body,
                             typ="Generating the Report",
                             mxs=len(self.notes.data),
                             esc=True)
             for num, dat in enumerate(self.notes.data):
                 p.displayProgress(num)
                 if p.quit:
                     break
                 desc = textFormat(dat[5], width=50)
                 for n, d in enumerate(desc):
                     if not n:
                         data.append([
                             dat[2], dat[4],
                             CCD(dat[3], "d1", 10).disp, dat[6],
                             CCD(dat[7], "d1", 10).disp, d
                         ])
                     else:
                         data.append(["", "", "", "", "", d])
             p.closeProgress()
             if not p.quit:
                 name = self.__class__.__name__
                 head = ["Telephone Directory Notes Listing"]
                 cols = [["a", "NA", 30, "Name", "y"],
                         ["b", "NA", 20, "User-Name", "y"],
                         ["c", "NA", 10, "Cap-Date", "y"],
                         ["d", "UA", 1, "F", "y"],
                         ["e", "NA", 10, "Act-Date", "y"],
                         ["f", "NA", 50, "Details", "y"]]
                 RepPrt(self.opts["mf"],
                        name=name,
                        tables=data,
                        heads=head,
                        cols=cols,
                        ttype="D",
                        repprt=self.notes.df.repprt,
                        repeml=self.notes.df.repeml)
     else:
         tit = ["Telephone Directory"]
         grp = {
             "stype":
             "R",
             "tables": ("telgrp", ),
             "cols": (("tdg_group", "UA", 3, "Grp"), ("tdg_desc", "NA", 30,
                                                      "Description")),
             "order":
             "tdg_desc"
         }
         fld = ((("T", 0, 0, 0), "IUA", 3, "Group", "", "", "N", self.prGrp,
                 grp, None, ("efld", )), )
         self.pr = TartanDialog(self.opts["mf"],
                                tops=True,
                                title=tit,
                                eflds=fld,
                                tend=((self.prEnd, "y"), ),
                                txit=(self.prExit, ))
         self.pr.mstFrame.wait_window()
         if not self.prxit:
             if self.prgrp:
                 if ss.selection[1] == "B":
                     head = ["Details for Group %s" % self.prgrp]
                     whr = [("tdm_group", "=", self.prgrp)]
                 else:
                     head = ["Contacts for Group %s" % self.prgrp]
                     whr = [("tdm_group", "=", self.prgrp),
                            ("tdc_name=tdm_name", )]
             else:
                 if ss.selection[1] == "B":
                     head = ["Cards for All Groups"]
                     whr = []
                 else:
                     head = ["Contacts for All Groups"]
                     whr = []
             if ss.selection[1] == "B":
                 tab = ["telmst"]
                 col = [
                     "tdm_name", "tdm_telno", "tdm_faxno", "tdm_mobile",
                     "tdm_email"
                 ]
             else:
                 tab = ["telmst", "telcon"]
                 col = [
                     "tdm_name", "tdc_contact", "tdc_desig", "tdc_telno",
                     "tdc_celno", "tdc_email"
                 ]
             prtdia = (("Y", "V"), ("Y", "N"))
             RepPrt(self.opts["mf"],
                    name=self.__class__.__name__,
                    tables=tab,
                    heads=head,
                    cols=col,
                    where=whr,
                    order="tdm_name",
                    prtdia=prtdia)
     self.df.setWidget(self.df.mstFrame, state="show")
     self.df.enableButtonsTags(state=state)
     self.df.focusField(self.df.frt, self.df.pag, self.df.col)