Пример #1
0
class mlc410(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm, ["chglog", "memctk", "memkon"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        chk = self.sql.getRec("memctk")
        if not chk:
            self.sql.insRec("memctk", data=[1, "H", "Home Telephone Number"])
            self.sql.insRec("memctk", data=[2, "W", "Work Telephone Number"])
            self.sql.insRec("memctk", data=[3, "M", "Mobile Telephone Number"])
            self.sql.insRec("memctk", data=[4, "F", "Facsimile Number"])
            self.sql.insRec("memctk", data=[5, "E", "E-Mail Address"])
            self.opts["mf"].dbm.commitDbase()
        return True

    def mainProcess(self):
        cod = {
            "stype":
            "R",
            "tables": ("memctk", ),
            "cols": (("mck_code", "", 0, "CD"), ("mck_desc", "", 0,
                                                 "Description", "Y"))
        }
        typ = {
            "stype":
            "C",
            "title":
            "Available Types",
            "head": ("C", "Description"),
            "data": (("E", "E-Mail"), ("F", "Facsimile"), ("H", "Home Phone"),
                     ("M", "Mobile"), ("W", "Work Phone"))
        }
        fld = ((("T", 0, 0, 0), "I@mck_code", 0, "", "", "", "N", self.doCode,
                cod, None, ("notzero", )),
               (("T", 0, 1, 0), "I@mck_type", 0, "", "", "", "N", self.doType,
                typ, None, ("in", ("E", "F", "H", "M", "W"))),
               (("T", 0, 2, 0), "I@mck_desc", 0, "", "", "", "N", self.doDesc,
                None, self.doDelete, ("notblank", )))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doCode(self, frt, pag, r, c, p, i, w):
        self.code = w
        self.old = self.sql.getRec("memctk",
                                   where=[("mck_code", "=", self.code)],
                                   limit=1)
        if self.old:
            self.new = False
            self.ktyp = self.old[self.sql.memctk_col.index("mck_type")]
            self.df.loadEntry(frt, pag, p + 1, data=self.ktyp)
            self.desc = self.old[self.sql.memctk_col.index("mck_desc")]
            self.df.loadEntry(frt, pag, p + 2, data=self.desc)
        else:
            self.new = True

    def doType(self, frt, pag, r, c, p, i, w):
        self.ktyp = w

    def doDesc(self, frt, pag, r, c, p, i, w):
        self.desc = w

    def doDelete(self):
        if self.code in (1, 2, 3, 4, 5):
            return "Static Code, Not Deleted"
        chk = self.sql.getRec("memkon",
                              cols=["count(*)"],
                              where=[("mlk_code", "=", self.code)],
                              limit=1)
        if chk[0]:
            return "Code in Use (memkon), Not Deleted"
        self.sql.delRec("memctk", where=[("mck_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        data = [self.code, self.ktyp, self.desc]
        if self.new:
            self.sql.insRec("memctk", data=data)
        elif data != self.old[:len(data)]:
            col = self.sql.memctk_col
            data.append(self.old[col.index("mck_xflag")])
            self.sql.updRec("memctk",
                            data=data,
                            where=[("mck_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #2
0
class gl1010(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            if "wait" in self.opts:
                self.df.mstFrame.wait_window()
            else:
                self.opts["mf"].startLoop()

    def setVariables(self):
        gc = GetCtl(self.opts["mf"])
        ctlsys = gc.getCtl("ctlsys")
        if not ctlsys:
            return
        self.gldep = ctlsys["sys_gl_dep"]
        self.gldig = ctlsys["sys_gl_dig"]
        ctlmst = gc.getCtl("ctlmst", self.opts["conum"])
        if not ctlmst:
            return
        self.taxdf = ctlmst["ctm_taxdf"]
        if not self.taxdf:
            self.taxdf = "N"
        self.mods = []
        for x in range(0, len(ctlmst["ctm_modules"].rstrip()), 2):
            self.mods.append(ctlmst["ctm_modules"][x:x + 2])
        tabs = [
            "ctlctl", "ctldep", "ctlvmf", "genmst", "genbal", "genbud",
            "genrpt", "gentrn", "chglog"
        ]
        if "CR" in self.mods:
            tabs.append("crsctl")
        if "DR" in self.mods:
            tabs.append("drsctl")
        if "ST" in self.mods:
            tabs.extend(["strctl", "strloc"])
        if "SI" in self.mods:
            tabs.append("slsctl")
        self.sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__)
        if self.sql.error:
            return
        chk = self.sql.getRec("genmst",
                              cols=["count(*)"],
                              where=[("glm_cono", "=", self.opts["conum"])],
                              limit=1)
        if chk[0]:
            self.newgen = False
        else:
            self.newgen = True
        if "args" in self.opts:
            self.acno = None
        return True

    def mainProcess(self):
        glm = {
            "stype":
            "R",
            "tables": ("genmst", ),
            "cols": (("glm_acno", "", 0, "Acc-Num"), ("glm_desc", "", 0,
                                                      "Description", "Y")),
            "where": [("glm_cono", "=", self.opts["conum"])]
        }
        vat = {
            "stype":
            "R",
            "tables": ("ctlvmf", ),
            "cols": (("vtm_code", "", 0, "Acc-Num"), ("vtm_desc", "", 0,
                                                      "Description", "Y")),
            "where": [("vtm_cono", "=", self.opts["conum"])]
        }
        r1s = (("Profit & Loss", "P"), ("Balance Sheet", "B"))
        r2s = (("Yes", "Y"), ("No", "N"))
        fld = [(("T", 0, 0, 0), "IUI", 7, "Acc-Num", "Account Number", "", "Y",
                self.doAccNum, glm, None, ("notzero", )),
               (("T", 0, 1, 0), ("IRB", r1s), 0, "Account Type", "", "P", "N",
                self.doTypCod, None, self.doDelete, None),
               (("T", 0, 2,
                 0), "INA", 30, "Description", "Account Description", "", "N",
                None, None, None, ("notblank", )),
               (("T", 0, 3, 0), ("IRB", r2s), 0, "Allow Postings", "", "Y",
                "N", None, None, None, None),
               [("T", 0, 4, 0), "IUA", 1, "Tax Default", "", "", "N",
                self.doVatCod, vat, None, ("notblank", )]]
        but = [
            ("Import",None,self.doImport,0,("T",0,1),("T",0,2),
                "Import a Chart of Accounts from a CSV or XLS file "\
                "having the following fields: Account Number, "\
                "Account Type (P/B), Description, Direct Postings (Y/N), "\
                "VAT Code"),
            ["Populate",None,self.doPopulate,0,("T",0,1),("T",0,2),
                "Generate a Chart of Accounts with Accompanying Control "\
                "Records and Financial Statement Report. This Only Applies "\
                "to Unpopulated (NEW) Ledgers."],
            ("Accept",None,self.doAccept,0,(("T",0,2),("T",0,5)),
                (("T",0,0),("T",0,1))),
            ("Cancel",None,self.doCancel,0,(("T",0,2),("T",0,5)),
                (("T",0,0),("T",0,1))),
            ("Quit",None,self.doQuit,1,None,None,"",1,4)]
        tnd = ((self.doEnd, "y"), )
        txt = (self.doQuit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)
        if not self.newgen:
            self.df.butt[1][4] = None
            self.df.butt[1][5] = None
            self.df.setWidget(self.df.B1, state="disabled")

    def doAccNum(self, frt, pag, r, c, p, i, w):
        self.acno = w
        self.old = self.sql.getRec("genmst",
                                   where=[("glm_cono", "=",
                                           self.opts["conum"]),
                                          ("glm_acno", "=", self.acno)],
                                   limit=1)
        if not self.old:
            self.new = True
            if self.gldep == "Y":
                err = self.doCheckDep(self.acno)
                if err:
                    return err
        elif "args" in self.opts:
            showError(self.opts["mf"].body, "Error",
                      "Only a New Account is Allowed")
            return "rf"
        else:
            self.new = False
            for x in range(0, self.df.topq[pag]):
                self.df.loadEntry(frt, pag, p + x, data=self.old[x + 1])

    def doTypCod(self, frt, pag, r, c, p, i, w):
        if self.new:
            if w == "P":
                self.df.topf[pag][4][5] = self.taxdf
            else:
                self.df.topf[pag][4][5] = "N"
        elif not self.df.topf[pag][4][5]:
            self.df.topf[pag][4][5] = "N"

    def doVatCod(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("ctlvmf",
                              cols=["vtm_desc"],
                              where=[("vtm_cono", "=", self.opts["conum"]),
                                     ("vtm_code", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid VAT Code"

    def doDelete(self):
        t = self.sql.getRec("gentrn",
                            cols=["count(*)"],
                            where=[("glt_cono", "=", self.opts["conum"]),
                                   ("glt_acno", "=", self.acno)],
                            limit=1)
        if t[0]:
            return "Transactions Exist, Not Deleted"
        self.sql.delRec("genmst",
                        where=[("glm_cono", "=", self.opts["conum"]),
                               ("glm_acno", "=", self.acno)])
        self.sql.delRec("genbal",
                        where=[("glo_cono", "=", self.opts["conum"]),
                               ("glo_acno", "=", self.acno)])
        self.sql.delRec("genbud",
                        where=[("glb_cono", "=", self.opts["conum"]),
                               ("glb_acno", "=", self.acno)])
        dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
        self.sql.insRec("chglog",
                        data=[
                            "genmst", "D",
                            "%03i%07i" % (self.opts["conum"], self.acno), "",
                            dte, self.opts["capnm"], "", "", "", 0
                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        if self.newgen:
            self.df.butt[1][4] = None
            self.df.butt[1][5] = None
        data = [
            self.opts["conum"], self.acno, self.df.t_work[0][0][1],
            self.df.t_work[0][0][2], self.df.t_work[0][0][3],
            self.df.t_work[0][0][4]
        ]
        if self.new:
            self.sql.insRec("genmst", data=data)
        elif data != self.old[:len(data)]:
            col = self.sql.genmst_col
            data.append(self.old[col.index("glm_xflag")])
            self.sql.updRec("genmst",
                            data=data,
                            where=[("glm_cono", "=", self.opts["conum"]),
                                   ("glm_acno", "=", self.acno)])
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.old):
                if dat != data[num]:
                    self.sql.insRec(
                        "chglog",
                        data=[
                            "genmst", "U",
                            "%03i%07i" % (self.opts["conum"], self.acno),
                            col[num], dte, self.opts["capnm"],
                            str(dat),
                            str(data[num]), "", 0
                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.setWidget(self.df.B3, state="disabled")
        if "args" in self.opts:
            self.doQuit()
        else:
            self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doImport(self):
        self.df.setWidget(self.df.B3, state="disabled")
        self.df.setWidget(self.df.mstFrame, state="hide")
        fi = FileImport(self.opts["mf"], imptab="genmst", impskp=["glm_cono"])
        sp = ProgressBar(self.opts["mf"].body,
                         typ="Importing Chart of Accounts",
                         mxs=len(fi.impdat))
        err = None
        for num, line in enumerate(fi.impdat):
            sp.displayProgress(num)
            chk = self.sql.getRec("genmst",
                                  where=[("glm_cono", "=", self.opts["conum"]),
                                         ("glm_acno", "=", line[0])],
                                  limit=1)
            if chk:
                err = "%s %s Already Exists" % (fi.impcol[0][0], line[0])
                break
            if self.gldep == "Y":
                err = self.doCheckDep(line[0])
                if err:
                    break
            if line[1] not in ("B", "P"):
                err = "Invalid %s %s, Only B or P" % (fi.impcol[1][0], line[1])
                break
            if not line[2]:
                err = "Blank Description"
                break
            if line[3] not in ("Y", "N"):
                err = "Invalid %s %s" % (fi.impcol[3][0], line[3])
                break
            chk = self.sql.getRec("ctlvmf",
                                  where=[("vtm_cono", "=", self.opts["conum"]),
                                         ("vtm_code", "=", line[4])],
                                  limit=1)
            if not chk:
                err = "%s %s Does Not Exist" % (fi.impcol[4][0], line[4])
                break
            line.insert(0, self.opts["conum"])
            self.sql.insRec("genmst", data=line)
        sp.closeProgress()
        if err:
            err = "Line %s: %s" % ((num + 1), err)
            showError(
                self.opts["mf"].body, "Import Error", """%s

Please Correct your Import File and then Try Again.""" % err)
            self.opts["mf"].dbm.rollbackDbase()
        else:
            self.opts["mf"].dbm.commitDbase()
        self.df.setWidget(self.df.mstFrame, state="show")
        self.df.focusField(self.df.frt, self.df.pag, self.df.col)

    def doCheckDep(self, acno):
        dep = int(acno / (10**(7 - self.gldig)))
        acc = int(acno % (10**(7 - self.gldig)))
        if dep:
            chk = self.sql.getRec("ctldep",
                                  where=[("dep_cono", "=", self.opts["conum"]),
                                         ("dep_code", "=", dep)],
                                  limit=1)
            if not chk:
                return "Invalid Department Number (%s)" % dep
            chk = self.sql.getRec("genmst",
                                  where=[("glm_cono", "=", self.opts["conum"]),
                                         ("glm_acno", "=", acc)],
                                  limit=1)
            if chk:
                return "This Account Number (%s) is in Use" % acc

    def doPopulate(self):
        if not self.newgen:
            showError(self.opts["mf"].body, "Populate Error",
                      "You Cannot Populate with Existing Accounts")
            self.df.focusField(self.df.frt, self.df.pag, self.df.col)
            return
        if self.gldep == "Y":
            showError(self.opts["mf"].body, "Populate Error",
                      "You Cannot Populate with Departments Enabled")
            self.df.focusField(self.df.frt, self.df.pag, self.df.col)
            return
        self.igcrs = "N"
        self.igdrs = "N"
        self.igstr = "N"
        self.df.setWidget(self.df.B3, state="disabled")
        self.df.setWidget(self.df.mstFrame, state="hide")
        tit = ("Integrate Subsiduary Ledgers", )
        r1s = (("Yes", "Y"), ("No", "N"))
        fld = []
        col = 0
        if "CR" in self.mods:
            fld.append((("T", 0, col, 0), ("IRB", r1s), 0, "Creditor's Ledger",
                        "Creditor's Ledger", "N", "N", self.doIgCrs, None,
                        None, None, None))
            col += 1
        if "DR" in self.mods:
            fld.append((("T", 0, col, 0), ("IRB", r1s), 0, "Debtor's Ledger",
                        "Debtor's Ledger", "N", "N", self.doIgDrs, None, None,
                        None, None))
            col += 1
        if "ST" in self.mods:
            fld.append((("T", 0, col, 0), ("IRB", r1s), 0, "Stores's Ledger",
                        "Stores's Ledger", "N", "N", self.doIgStr, None, None,
                        None, None))
        if fld:
            self.ig = TartanDialog(self.opts["mf"],
                                   title=tit,
                                   tops=True,
                                   eflds=fld,
                                   tend=((self.doIgEnd, "y"), ),
                                   txit=(self.doIgExit, ))
            self.ig.mstFrame.wait_window()
            if self.igexit:
                self.doQuit()
                return
        sp = SplashScreen(self.opts["mf"].body,
                          "Populating Records\n\nPlease Wait ...")
        # genmst
        genmst = datdic["genmst"]
        for dat in genmst:
            dat.insert(0, self.opts["conum"])
            dat.append("Y")
            if dat[2] == "B":
                dat.append("N")
            else:
                dat.append(self.taxdf)
            self.sql.insRec("genmst", data=dat)
        # genrpt
        genrpt = datdic["genrpt"]
        for dat in genrpt:
            dat.insert(0, self.opts["conum"])
            self.sql.insRec("genrpt", data=dat)
        # ctlctl
        crsctl = 0
        drsctl = 0
        stksoh = 0
        ctlctl = datdic["ctlctl"]
        for dat in ctlctl:
            if dat[0] in ("crs_ctl", "dis_rec"):
                if self.igcrs != "Y":
                    continue
                if dat[0] == "crs_ctl":
                    crsctl = int(dat[2])
            elif dat[0] in ("drs_ctl", "dis_all"):
                if self.igdrs != "Y":
                    continue
                if dat[0] == "drs_ctl":
                    drsctl = int(dat[2])
            elif dat[0] in ("stk_soh", "stk_susp"):
                if self.igstr != "Y":
                    continue
                if dat[0] == "stk_soh":
                    stksoh = int(dat[2])
            elif dat[0] in ("wag_ctl", "wag_slc", "wag_sli"):
                continue
            dat.insert(0, self.opts["conum"])
            self.sql.insRec("ctlctl", data=dat)
        if "CR" in self.mods:
            chk = self.sql.getRec("crsctl",
                                  where=[("ctc_cono", "=", self.opts["conum"])
                                         ])
            if not chk:
                self.sql.insRec("crsctl",
                                data=[
                                    self.opts["conum"], self.igcrs, "E", "", 0,
                                    0, "remittance_advice", ""
                                ])
            else:
                self.sql.updRec("crsctl",
                                cols=["ctc_glint"],
                                data=[self.igcrs],
                                where=[("ctc_cono", "=", self.opts["conum"])])
            if self.igcrs == "Y" and crsctl:
                self.sql.updRec("genmst",
                                cols=["glm_ind"],
                                data=["N"],
                                where=[("glm_cono", "=", self.opts["conum"]),
                                       ("glm_acno", "=", crsctl)])
        if "DR" in self.mods:
            chk = self.sql.getRec("drsctl",
                                  where=[("ctd_cono", "=", self.opts["conum"])
                                         ])
            if not chk:
                self.sql.insRec("drsctl",
                                data=[
                                    self.opts["conum"], self.igdrs, "E", "N",
                                    "statement_normal", "Y", ""
                                ])
            else:
                self.sql.updRec("drsctl",
                                cols=["ctd_glint"],
                                data=[self.igdrs],
                                where=[("ctd_cono", "=", self.opts["conum"])])
            if self.igdrs == "Y" and drsctl:
                self.sql.updRec("genmst",
                                cols=["glm_ind"],
                                data=["N"],
                                where=[("glm_cono", "=", self.opts["conum"]),
                                       ("glm_acno", "=", drsctl)])
        if "ST" in self.mods:
            chk = self.sql.getRec("strctl",
                                  where=[("cts_cono", "=", self.opts["conum"])
                                         ])
            if not chk:
                self.sql.insRec("strctl",
                                data=[
                                    self.opts["conum"], self.igstr, "N", 1,
                                    "N", "purchase_order", ""
                                ])
            else:
                self.sql.updRec("strctl",
                                cols=["cts_glint"],
                                data=[self.igstr],
                                where=[("cts_cono", "=", self.opts["conum"])])
            chk = self.sql.getRec("strloc",
                                  where=[("srl_cono", "=", self.opts["conum"])
                                         ])
            if not chk:
                self.sql.insRec("strloc",
                                data=[
                                    self.opts["conum"], "1",
                                    "Location Number One", "", "", "", ""
                                ])
            if self.igstr == "Y" and stksoh:
                self.sql.updRec("genmst",
                                cols=["glm_ind"],
                                data=["N"],
                                where=[("glm_cono", "=", self.opts["conum"]),
                                       ("glm_acno", "=", stksoh)])
        if "SI" in self.mods:
            chk = self.sql.getRec("slsctl",
                                  where=[("ctv_cono", "=", self.opts["conum"])
                                         ])
            if not chk:
                self.sql.insRec(
                    "slsctl",
                    data=[self.opts["conum"], "Y", "Y", "sales_document", ""])
        sp.closeSplash()
        self.df.butt[1][4] = None
        self.df.butt[1][5] = None
        self.opts["mf"].dbm.commitDbase()
        self.df.setWidget(self.df.mstFrame, state="show")
        self.df.focusField(self.df.frt, self.df.pag, self.df.col)

    def doIgCrs(self, frt, pag, r, c, p, i, w):
        self.igcrs = w

    def doIgDrs(self, frt, pag, r, c, p, i, w):
        self.igdrs = w

    def doIgStr(self, frt, pag, r, c, p, i, w):
        self.igstr = w

    def doIgEnd(self):
        self.igexit = False
        self.ig.closeProcess()

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.last[0] = [0, 0]
        self.df.focusField("T", 0, 1)

    def doIgExit(self):
        self.igexit = True
        self.ig.closeProcess()

    def doQuit(self):
        self.df.closeProcess()
        if "wait" not in self.opts:
            self.opts["mf"].closeLoop()
Пример #3
0
class drc410(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            if "wait" in self.opts:
                self.df.mstFrame.wait_window()
            else:
                self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       "drsdel",
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        return True

    def mainProcess(self):
        dlm = {
            "stype":
            "R",
            "tables": ("drsdel", ),
            "cols":
            (("del_code", "", 0, "Del-Cod"), ("del_add1", "", 0, "Address"))
        }
        self.fld = [[("T", 0, 0, 0), "INa", 7, "Code", "Address Code", "", "N",
                     self.doCode, dlm, None, ("notblank", )],
                    (("T", 0, 1, 0), "INA", 30, "Address Line 1", "", "", "N",
                     None, None, self.doDelete, ("notblank", )),
                    (("T", 0, 2, 0), "INA", 30, "Address Line 2", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, 3, 0), "INA", 30, "Address Line 3", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, 4, 0), "INA", 30, "Address Line 4", "", "", "N",
                     None, None, None, ("efld", ))]
        if "args" in self.opts:
            self.fld[0][1] = "ONa"
            self.fld[0][5] = self.opts["args"]
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doCode(self, frt, pag, r, c, p, i, w):
        self.code = w
        self.acc = self.sql.getRec("drsdel",
                                   where=[("del_code", "=", self.code)],
                                   limit=1)
        if not self.acc:
            self.new = "Y"
        else:
            self.new = "N"
            for x in range(0, self.df.topq[pag]):
                self.df.loadEntry(frt, pag, p + x, data=self.acc[x])

    def doDelete(self):
        self.sql.delRec("drsdel", where=[("del_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        dat = []
        for x in range(0, len(self.df.t_work[0][0])):
            dat.append(self.df.t_work[0][0][x])
        if self.new == "Y":
            self.sql.insRec("drsdel", data=dat)
        elif dat != self.acc[:len(dat)]:
            col = self.sql.drsdel_col
            dat.append(self.acc[col.index("del_xflag")])
            self.sql.updRec("drsdel",
                            data=dat,
                            where=[("del_code", "=", self.code)])
        if "args" in self.opts:
            self.doExit()
        else:
            self.opts["mf"].dbm.commitDbase()
            self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        if "wait" not in self.opts:
            self.opts["mf"].closeLoop()
Пример #4
0
class wgc210(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       "wagrcv",
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        return True

    def mainProcess(self):
        rcv = {
            "stype": "R",
            "tables": ("wagrcv", ),
            "cols":
            (("rcv_code", "", 0, "Code"), ("rcv_desc", "", 0, "Details"))
        }
        self.fld = ((("T", 0, 0, 0), "IUI", 4, "Item Code", "", "", "N",
                     self.doCode, rcv, None, ("notzero", )),
                    (("T", 0, 1, 0), "INA", 50, "Description", "", "", "N",
                     None, None, self.doDelete, ("notblank", )))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doCode(self, frt, pag, r, c, p, i, w):
        self.code = w
        acc = self.sql.getRec("wagrcv",
                              where=[("rcv_code", "=", self.code)],
                              limit=1)
        if not acc:
            self.new = "Y"
        else:
            self.new = "N"
            for x in range(1, self.df.topq[pag]):
                self.df.loadEntry(frt, pag, p + x, data=acc[x])

    def doDelete(self):
        self.sql.delRec("wagrcv", where=[("rcv_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        dat = []
        for x in range(0, len(self.df.t_work[0][0])):
            dat.append(self.df.t_work[0][0][x])
        if self.new == "Y":
            self.sql.insRec("wagrcv", data=dat)
        else:
            self.sql.updRec("wagrcv",
                            data=dat,
                            where=[("rcv_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #5
0
class bs1010(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        gc = GetCtl(self.opts["mf"])
        ctlsys = gc.getCtl("ctlsys")
        if not ctlsys:
            return
        ctlmst = gc.getCtl("ctlmst", self.opts["conum"])
        if not ctlmst:
            return
        tabs = ["bksmst", "bksown", "bksaut", "chglog"]
        self.sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__)
        if self.sql.error:
            return
        return True

    def mainProcess(self):
        bmf = {
            "stype":
            "R",
            "tables": ("bksmst", "bksown"),
            "cols":
            (("bmf_stat", "", 0, "S"), ("bmf_code", "", 0, "Code"),
             ("bmf_titl", "", 0, "Title", "Y"), ("bmf_ownr", "", 0, "Ownr"),
             ("bof_fnam", "", 0, "Name"), ("bmf_mnth", "", 0, "Mth-Rec")),
            "where": [("bmf_cono", "=", self.opts["conum"]),
                      ("bof_cono=bmf_cono", ), ("bof_code=bmf_ownr", )],
            "order":
            "bmf_stat, bmf_titl",
            "index":
            1
        }
        amf = {
            "stype":
            "R",
            "tables": ("bksaut", ),
            "cols":
            (("baf_code", "", 0, "Code"), ("baf_snam", "", 0, "Surname", "Y"),
             ("baf_fnam", "", 0, "Names")),
            "order":
            "baf_code"
        }
        omf = {
            "stype":
            "R",
            "tables": ("bksown", ),
            "cols":
            (("bof_code", "", 0, "Code"), ("bof_snam", "", 0, "Surname", "Y"),
             ("bof_fnam", "", 0, "Names")),
            "where": [("bof_cono", "=", self.opts["conum"])],
            "order":
            "bof_code"
        }
        r1s = (("Current", "C"), ("Removed", "X"))
        fld = ((("T", 0, 0,
                 0), "IUI", 4, "Code", "", "", "Y", self.doCode, bmf, None,
                ("efld", )), (("T", 0, 1, 0), "ITX", 30, "Title", "", "", "N",
                              self.doTitle, None, None, ("notblank", )),
               (("T", 0, 2, 0), "IUI", 4, "Author", "", "", "N", self.doAuthor,
                amf, None, ("efld", )), (("T", 0, 2, 0), "ONA", 30, ""),
               (("T", 0, 3, 0), "IUI", 4, "Owner", "", "", "N", self.doOwner,
                omf, None, ("efld", )), (("T", 0, 3, 0), "ONA", 30, ""),
               (("T", 0, 4,
                 0), "ID2", 7, "Month", "", "", "N", self.doMonth, None, None,
                ("efld", )), (("T", 0, 5, 0), ("IRB", r1s), 0, "Status", "",
                              "C", "N", self.doStatus, None, None, None))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2),
                (("T", 0, 0), ("T", 0, 1))), ("Exit", None, self.doExit, 0,
                                              ("T", 0, 1), None))
        tnd = ((self.doEnd, "y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doCode(self, frt, pag, r, c, p, i, w):
        self.bcode = w
        if not self.bcode:
            ok = askQuestion(self.opts["mf"].body,
                             "New Book",
                             "Is This a New Book?",
                             default="no")
            if ok == "no":
                return "Invalid Code"
            self.newbk = True
            self.bcode = getNextCode(self.sql,
                                     "bksmst",
                                     "bmf_code",
                                     start=1,
                                     last=9999)
            self.df.loadEntry(frt, pag, p, data=self.bcode)
        else:
            self.old = self.sql.getRec("bksmst",
                                       where=[("bmf_cono", "=",
                                               self.opts["conum"]),
                                              ("bmf_code", "=", self.bcode)],
                                       limit=1)
            if not self.old:
                ok = askQuestion(self.opts["mf"].body,
                                 "Code",
                                 "Is This a Manual Code?",
                                 default="no")
                if ok == "no":
                    return "Invalid Code"
                self.newbk = True
                return
            col = 0
            self.newbk = False
            for num, dat in enumerate(self.old[1:-1]):
                self.df.loadEntry(frt, pag, col, data=dat)
                if num == 2:
                    col += 1
                    self.df.loadEntry(frt, pag, col, data=self.getAuthor(dat))
                elif num == 3:
                    col += 1
                    self.df.loadEntry(frt, pag, col, data=self.getOwner(dat))
                col += 1

    def doDelete(self):
        self.sql.delRec("bksmst",
                        where=[("bmf_cono", "=", self.opts["conum"]),
                               ("bmf_code", "=", self.bcode)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doTitle(self, frt, pag, r, c, p, i, w):
        self.title = w

    def doAuthor(self, frt, pag, r, c, p, i, w):
        self.acode = w
        if not self.acode:
            ok = askQuestion(self.opts["mf"].body,
                             "New Author",
                             "Is This a New Author?",
                             default="no")
            if ok == "no":
                return "Invalid Code"
            self.doNewAuthor()
            if not self.aend:
                return "rf"
            self.df.loadEntry(frt, pag, p, data=self.acode)
        acc = self.sql.getRec("bksaut",
                              where=[("baf_code", "=", self.acode)],
                              limit=1)
        if not acc:
            return "Invalid Code"
        self.df.loadEntry(frt, pag, p + 1, data=self.getAuthor(self.acode))

    def doNewAuthor(self):
        state = self.df.disableButtonsTags()
        self.df.setWidget(self.df.mstFrame, state="hide")
        tit = ("Author's Details", )
        fld = ((("T", 0, 0, 0), "ITX", 30, "Surname", "", "", "Y", None, None,
                None, ("notblank", )), (("T", 0, 1, 0), "ITX", 30, "Names", "",
                                        "", "Y", None, None, None, ("efld", )))
        self.aa = TartanDialog(self.opts["mf"],
                               title=tit,
                               tops=True,
                               eflds=fld,
                               tend=((self.doAutEnd, "y"), ),
                               txit=(self.doAutExit, ))
        self.aa.mstFrame.wait_window()
        self.df.setWidget(self.df.mstFrame, state="show")
        self.df.enableButtonsTags(state=state)

    def doAutEnd(self):
        self.aend = True
        self.acode = getNextCode(self.sql,
                                 "bksaut",
                                 "baf_code",
                                 start=1,
                                 last=9999)
        data = [self.acode, self.aa.t_work[0][0][0], self.aa.t_work[0][0][1]]
        self.sql.insRec("bksaut", data=data)
        self.aa.closeProcess()

    def doAutExit(self):
        self.aend = False
        self.aa.closeProcess()

    def getAuthor(self, code):
        acc = self.sql.getRec("bksaut",
                              where=[("baf_code", "=", code)],
                              limit=1)
        if acc:
            return "%s, %s" % (acc[1], acc[2])
        else:
            return ""

    def doOwner(self, frt, pag, r, c, p, i, w):
        self.ocode = w
        if not self.ocode:
            ok = askQuestion(self.opts["mf"].body,
                             "New Member",
                             "Is This a New Member?",
                             default="no")
            if ok == "no":
                return "Invalid Code"
            self.doNewOwner()
            if not self.oend:
                return "rf"
            self.df.loadEntry(frt, pag, p, data=self.ocode)
        acc = self.sql.getRec("bksown",
                              where=[("bof_cono", "=", self.opts["conum"]),
                                     ("bof_code", "=", self.ocode)],
                              limit=1)
        if not acc:
            return "Invalid Code"
        self.df.loadEntry(frt, pag, p + 1, data=self.getOwner(self.ocode))

    def doNewOwner(self):
        state = self.df.disableButtonsTags()
        self.df.setWidget(self.df.mstFrame, state="hide")
        tit = ("Owner's Details", )
        fld = ((("T", 0, 0, 0), "ITX", 30, "Surname", "", "", "Y", None, None,
                None, ("notblank", )), (("T", 0, 1, 0), "ITX", 30, "Names", "",
                                        "", "Y", None, None, None, ("efld", )))
        self.oo = TartanDialog(self.opts["mf"],
                               title=tit,
                               tops=True,
                               eflds=fld,
                               tend=((self.doOwnEnd, "y"), ),
                               txit=(self.doOwnExit, ))
        self.oo.mstFrame.wait_window()
        self.df.setWidget(self.df.mstFrame, state="show")
        self.df.enableButtonsTags(state=state)

    def doOwnEnd(self):
        self.oend = True
        self.ocode = getNextCode(self.sql,
                                 "bksown",
                                 "bof_code",
                                 start=1,
                                 last=9999)
        data = [
            self.opts["conum"], self.acode, self.oo.t_work[0][0][0],
            self.oo.t_work[0][0][1], "", "", "", "", "", "", "", ""
        ]
        self.sql.insRec("bksown", data=data)
        self.oo.closeProcess()

    def doOwnExit(self):
        self.oend = False
        self.oo.closeProcess()

    def getOwner(self, code):
        acc = self.sql.getRec("bksown",
                              where=[("bof_cono", "=", self.opts["conum"]),
                                     ("bof_code", "=", code)],
                              limit=1)
        if acc:
            return "%s, %s" % (acc[2], acc[3])
        else:
            return ""

    def doMonth(self, frt, pag, r, c, p, i, w):
        self.month = w

    def doStatus(self, frt, pag, r, c, p, i, w):
        self.status = w

    def doEnd(self):
        data = [self.opts["conum"]]
        for num, dat in enumerate(self.df.t_work[0][0]):
            if num in (3, 5):
                continue
            data.append(dat)
        if self.newbk:
            self.sql.insRec("bksmst", data=data)
        elif data != self.old[:len(data)]:
            col = self.sql.bksmst_col
            data.append(self.old[col.index("bmf_xflag")])
            self.sql.updRec("bksmst",
                            data=data,
                            where=[("bmf_cono", "=", self.opts["conum"]),
                                   ("bmf_code", "=", self.bcode)])
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.old):
                if dat != data[num]:
                    self.sql.insRec(
                        "chglog",
                        data=[
                            "bksmst", "U",
                            "%03i%04i" % (self.opts["conum"], self.bcode),
                            col[num], dte, self.opts["capnm"],
                            str(dat),
                            str(data[num]), "", 0
                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #6
0
class mlc210(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(
            self.opts["mf"].dbm,
            ["chglog", "genmst", "memctc", "memcat", "memtrn", "memctp"],
            prog=self.__class__.__name__)
        if self.sql.error:
            return
        gc = GetCtl(self.opts["mf"])
        memctl = gc.getCtl("memctl", self.opts["conum"])
        if not memctl:
            return
        self.glint = memctl["mcm_glint"]
        return True

    def mainProcess(self):
        cod = {
            "stype":
            "R",
            "tables": ("memctc", ),
            "cols": (("mcc_code", "", 0, "CD"), ("mcc_freq", "", 0, "F"),
                     ("mcc_desc", "", 0, "Description", "Y"), ("mcc_rgrp", "",
                                                               0, "RG")),
            "where": [("mcc_cono", "=", self.opts["conum"])],
            "whera": [["T", "mcc_type", 0, 0]]
        }
        glm = {
            "stype":
            "R",
            "tables": ("genmst", ),
            "cols": (("glm_acno", "", 0, "Acc-Num"), ("glm_desc", "", 0,
                                                      "Description", "Y")),
            "where": [("glm_cono", "=", self.opts["conum"])]
        }
        prc = {
            "stype":
            "R",
            "tables": ("memctp", ),
            "cols":
            (("mcp_date", "", 0, "CD"), ("mcp_penalty", "", 0, "P-Rte"),
             ("mcp_prorata", "", 0, "P"), ("mcp_rate_01", "", 0, "Month-01")),
            "where": [("mcp_cono", "=", self.opts["conum"])],
            "whera": [["T", "mcp_type", 0, 0], ["T", "mcp_code", 1, 0]],
            "order":
            "mcp_date"
        }
        r1s = (("Fees", "A"), ("Category", "B"), ("Sports", "C"),
               ("Debentures", "D"))
        r2s = (("Annually", "A"), ("Monthly", "M"), ("Once Off", "O"),
               ("Never", "N"))
        r3s = (("No", "N"), ("1M", "1"), ("3M", "3"), ("6M", "6"), ("Manual",
                                                                    "M"))
        fld = [(("T", 0, 0, 0), ("IRB", r1s), 0, "Category Type", "", "A", "Y",
                self.doCatType, None, None, None),
               (("T", 0, 1, 0), "I@mcc_code", 0, "", "", "", "N",
                self.doCatCode, cod, None, ("notzero", )),
               (("T", 0, 2, 0), "I@mcc_desc", 0, "", "", "", "N", self.doDesc,
                None, self.doDelete, ("notblank", )),
               (("T", 0, 3, 0), "I@mcc_rgrp", 0, "", "", "", "N", self.doRgrp,
                None, None, ("notblank", )),
               (("T", 0, 4, 0), ("IRB", r2s), 0, "Frequency", "", "A", "N",
                self.doCatFreq, None, None, None),
               (("T", 0, 5, 0), "I@mcc_age_l", 0, "", "", "", "N",
                self.doCatLimit, None, None, ("efld", )),
               (("T", 0, 5,
                 0), "I@mcc_and_s", 0, "And Mship", "And Length of Service",
                "", "N", self.doCatLimit, None, None, ("efld", )),
               (("T", 0, 5,
                 0), "I@mcc_or_s", 0, "Or Mship", "Or Length of Service", "",
                "N", self.doCatLimit, None, None, ("efld", )),
               (("T", 0, 6, 0), "I@mcc_ncode", 0, "Next Code", "", "", "N",
                self.doCatNcode, cod, None, None)]
        idx = 7
        if self.glint == "Y":
            fld.extend([(("T", 0, idx, 0), "I@mcc_glac", 0, "", "", "", "N",
                         self.doGlac, glm, None, ("efld", )),
                        (("T", 0, idx, 0), "ONA", 30, "")])
            idx += 1
        fld.extend([(("T", 0, idx, 0), "I@mcp_date", 0, "", "", "", "N",
                     self.doDate, prc, None, ("efld", )),
                    (("T", 0, idx + 1, 0), "I@mcp_penalty", 0, "", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, idx + 2, 0), ("IRB", r3s), 0, "Pro-Rata",
                     "Pro-Rata", "N", "N", self.doProRata, None, None, None),
                    (("T", 0, idx + 3, 0), "I@mcp_rate_01", 0, "", "", "", "N",
                     self.doMonth, None, None, ("efld", )),
                    (("T", 0, idx + 3, 34, 46), "I@mcp_rate_02", 0, "", "", "",
                     "N", None, None, None, ("efld", )),
                    (("T", 0, idx + 4, 0), "I@mcp_rate_03", 0, "", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, idx + 4, 34, 46), "I@mcp_rate_04", 0, "", "", "",
                     "N", None, None, None, ("efld", )),
                    (("T", 0, idx + 5, 0), "I@mcp_rate_05", 0, "", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, idx + 5, 34, 46), "I@mcp_rate_06", 0, "", "", "",
                     "N", None, None, None, ("efld", )),
                    (("T", 0, idx + 6, 0), "I@mcp_rate_07", 0, "", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, idx + 6, 34, 46), "I@mcp_rate_08", 0, "", "", "",
                     "N", None, None, None, ("efld", )),
                    (("T", 0, idx + 7, 0), "I@mcp_rate_09", 0, "", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, idx + 7, 34, 46), "I@mcp_rate_10", 0, "", "", "",
                     "N", None, None, None, ("efld", )),
                    (("T", 0, idx + 8, 0), "I@mcp_rate_11", 0, "", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, idx + 8, 34, 46), "I@mcp_rate_12", 0, "", "", "",
                     "N", None, None, None, ("efld", ))])
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doCatType(self, frt, pag, r, c, p, i, w):
        self.ctyp = w

    def doCatCode(self, frt, pag, r, c, p, i, w):
        self.code = w
        self.oldcat = self.sql.getRec("memctc",
                                      where=[("mcc_cono", "=",
                                              self.opts["conum"]),
                                             ("mcc_type", "=", self.ctyp),
                                             ("mcc_code", "=", self.code)],
                                      limit=1)
        if self.oldcat:
            self.desc = self.oldcat[self.sql.memctc_col.index("mcc_desc")]
            self.rgrp = self.oldcat[self.sql.memctc_col.index("mcc_rgrp")]
            self.freq = self.oldcat[self.sql.memctc_col.index("mcc_freq")]
            self.age_l = self.oldcat[self.sql.memctc_col.index("mcc_age_l")]
            self.and_s = self.oldcat[self.sql.memctc_col.index("mcc_and_s")]
            self.or_s = self.oldcat[self.sql.memctc_col.index("mcc_or_s")]
            self.ncode = self.oldcat[self.sql.memctc_col.index("mcc_ncode")]
            self.df.loadEntry(frt, pag, p + 1, data=self.desc)
            self.df.loadEntry(frt, pag, p + 2, data=self.rgrp)
            self.df.loadEntry(frt, pag, p + 3, data=self.freq)
            self.df.loadEntry(frt, pag, p + 4, data=self.age_l)
            self.df.loadEntry(frt, pag, p + 5, data=self.and_s)
            self.df.loadEntry(frt, pag, p + 6, data=self.or_s)
            self.df.loadEntry(frt, pag, p + 7, data=self.ncode)
            if self.glint == "Y":
                self.glno = self.oldcat[self.sql.memctc_col.index("mcc_glac")]
                self.df.loadEntry(frt, pag, p + 8, data=self.glno)
                des = self.sql.getRec("genmst",
                                      cols=["glm_desc"],
                                      where=[("glm_cono", "=",
                                              self.opts["conum"]),
                                             ("glm_acno", "=", self.glno)],
                                      limit=1)
                if des:
                    self.df.loadEntry("T", 0, p + 9, data=des[0])
                idx = 11
            else:
                idx = 9
            if self.freq == "N":
                self.date = 0
                self.oldprc = []
                for x in range(idx, len(self.df.t_work[0][0])):
                    self.df.loadEntry("T", 0, x, data="")
            else:
                self.oldprc = self.sql.getRec("memctp",
                                              where=[
                                                  ("mcp_cono", "=",
                                                   self.opts["conum"]),
                                                  ("mcp_type", "=", self.ctyp),
                                                  ("mcp_code", "=", self.code)
                                              ],
                                              order="mcp_date desc",
                                              limit=1)
                self.date = self.oldprc[self.sql.memctp_col.index("mcp_date")]
                for n, d in enumerate(self.oldprc[3:-1]):
                    self.df.loadEntry("T", 0, idx + n, data=d)

    def doDesc(self, frt, pag, r, c, p, i, w):
        self.desc = w
        if self.ctyp != "C":
            self.rgrp = "NA"
            return "sk1"

    def doRgrp(self, frt, pag, r, c, p, i, w):
        self.rgrp = w

    def doCatFreq(self, frt, pag, r, c, p, i, w):
        self.freq = w
        if self.freq == "N":
            self.age_l = 0
            self.and_s = 0
            self.or_s = 0
            self.ncode = 0
            self.glno = 0
            for x in range(p + 1, len(self.df.t_work[0][0])):
                self.df.loadEntry("T", 0, x, data="")
            return "nd"
        if self.ctyp != "B":
            self.age_l = 0
            self.and_s = 0
            self.or_s = 0
            self.ncode = 0
            self.df.loadEntry(frt, pag, p + 1, data=0)
            self.df.loadEntry(frt, pag, p + 2, data=0)
            self.df.loadEntry(frt, pag, p + 3, data=0)
            self.df.loadEntry(frt, pag, p + 4, data=0)
            return "sk4"

    def doCatLimit(self, frt, pag, r, c, p, i, w):
        if p == 5:
            self.age_l = w
        elif p == 6:
            self.and_s = w
        else:
            self.or_s = w
            if not self.age_l and not self.and_s and not self.or_s:
                self.ncode = 0
                self.df.loadEntry(frt, pag, p + 1, data=0)
                return "sk1"

    def doCatNcode(self, frt, pag, r, c, p, i, w):
        self.ncode = w

    def doGlac(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("genmst",
                              cols=["glm_desc"],
                              where=[("glm_cono", "=", self.opts["conum"]),
                                     ("glm_acno", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid G/L Account"
        self.glno = w
        self.df.loadEntry("T", 0, p + 1, data=acc[0])

    def doDate(self, frt, pag, r, c, p, i, w):
        self.date = w
        if not self.oldcat:
            self.oldprc = []
        else:
            self.oldprc = self.sql.getRec("memctp",
                                          where=[("mcp_cono", "=",
                                                  self.opts["conum"]),
                                                 ("mcp_code", "=", self.code),
                                                 ("mcp_type", "=", self.ctyp),
                                                 ("mcp_date", "=", self.date)],
                                          limit=1)
        if self.oldprc:
            for n, d in enumerate(self.oldprc[4:-1]):
                self.df.loadEntry(frt, pag, p + 1 + n, data=d)
        else:
            for n in range(14):
                self.df.clearEntry(frt, pag, c + 1 + n)

    def doProRata(self, frt, pag, r, c, p, i, w):
        self.prorata = w

    def doMonth(self, frt, pag, r, c, p, i, w):
        if self.oldprc or self.prorata == "M":
            return
        if self.prorata == "N":
            mths = [w] * 12
        elif self.prorata == "1":
            mths = [w]
            for x in range(11, 0, -1):
                mths = mths + [round(w / 12.0 * x, 0)]
        elif self.prorata == "3":
            mths = [w, w, w]
            for x in range(3, 0, -1):
                for _ in range(3):
                    mths = mths + [round(w / 4.0 * x, 0)]
        elif self.prorata == "6":
            mths = [w, w, w, w, w, w]
            for x in range(6):
                mths = mths + [round(w / 2.0, 0)]
        for n, d in enumerate(mths):
            self.df.loadEntry(frt, pag, p + n, data=d)
        if self.prorata == "N":
            return "sk11"

    def doDelete(self):
        mst = self.sql.getRec("memcat",
                              cols=["count(*)"],
                              where=[("mlc_cono", "=", self.opts["conum"]),
                                     ("mlc_type", "=", self.ctyp),
                                     ("mlc_code", "=", self.code)],
                              limit=1)
        if mst[0]:
            return "Code in Use (memcat), Not Deleted"
        trn = self.sql.getRec("memtrn",
                              cols=["count(*)"],
                              where=[("mlt_cono", "=", self.opts["conum"]),
                                     ("mlt_ctyp", "=", self.ctyp),
                                     ("mlt_ccod", "=", self.code)],
                              limit=1)
        if trn[0]:
            return "Code in Use (memtrn), Not Deleted"
        dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
        self.sql.delRec("memctc",
                        where=[("mcc_cono", "=", self.opts["conum"]),
                               ("mcc_type", "=", self.ctyp),
                               ("mcc_code", "=", self.code)])
        self.sql.insRec("chglog", data=["memctc", "D", "%03i%1s%02i" % \
            (self.opts["conum"], self.ctyp, self.code), "", dte,
            self.opts["capnm"], "", "", "", 0])
        prc = self.sql.getRec("memctp",
                              cols=["mcp_date"],
                              where=[("mcp_cono", "=", self.opts["conum"]),
                                     ("mcp_type", "=", self.ctyp),
                                     ("mcp_code", "=", self.code)])
        for date in prc:
            self.sql.delRec("memctp",
                            where=[("mcp_cono", "=", self.opts["conum"]),
                                   ("mcp_code", "=", self.code),
                                   ("mcp_code", "=", self.code),
                                   ("mcp_date", "=", date)])
            self.sql.insRec("chglog", data=["memctp", "D", "%03i%1s%02i%8s" % \
                (self.opts["conum"], self.ctyp, self.code, date), "", dte,
                self.opts["capnm"], "", "", "", 0])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
        data = [
            self.opts["conum"], self.ctyp, self.code, self.desc, self.rgrp,
            self.freq, self.age_l, self.and_s, self.or_s, self.ncode
        ]
        if self.glint == "N":
            data.append(0)
        else:
            data.append(self.glno)
        if not self.oldcat:
            self.sql.insRec("memctc", data=data)
        elif data != self.oldcat[:len(data)]:
            col = self.sql.memctc_col
            data.append(self.oldcat[col.index("mcc_xflag")])
            self.sql.updRec("memctc",
                            data=data,
                            where=[("mcc_cono", "=", self.opts["conum"]),
                                   ("mcc_type", "=", self.ctyp),
                                   ("mcc_code", "=", self.code)])
            for num, dat in enumerate(self.oldcat):
                if dat != data[num]:
                    self.sql.insRec(
                        "chglog",
                        data=[
                            "memctc", "U",
                            "%03i%1s%02i" %
                            (self.opts["conum"], self.ctyp, self.code),
                            col[num], dte, self.opts["capnm"],
                            str(dat),
                            str(data[num]), "", 0
                        ])
        if self.freq != "N":
            data = [self.opts["conum"], self.ctyp, self.code]
            if self.glint == "Y":
                idx = 11
            else:
                idx = 9
            for x in range(idx, idx + 15):
                data.append(self.df.t_work[0][0][x])
            if not self.oldprc:
                self.sql.insRec("memctp", data=data)
            elif data != self.oldprc[:len(data)]:
                col = self.sql.memctp_col
                data.append(self.oldcat[col.index("mcp_xflag")])
                self.sql.updRec("memctp",
                                data=data,
                                where=[("mcp_cono", "=", self.opts["conum"]),
                                       ("mcp_type", "=", self.ctyp),
                                       ("mcp_code", "=", self.code),
                                       ("mcp_date", "=", self.date)])
                for num, dat in enumerate(self.oldprc):
                    if dat != data[num]:
                        self.sql.insRec("chglog",
                                        data=[
                                            "memctp", "U",
                                            "%03i%1s%02i%8s" %
                                            (self.opts["conum"], self.ctyp,
                                             self.code, str(self.date)),
                                            col[num], dte, self.opts["capnm"],
                                            str(dat),
                                            str(data[num]), "", 0
                                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #7
0
class drc310(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       "ctlrep",
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        return True

    def mainProcess(self):
        rpm = {
            "stype": "R",
            "tables": ("ctlrep", ),
            "cols":
            (("rep_code", "", 0, "Rep"), ("rep_name", "", 0, "Name", "Y")),
            "where": [("rep_cono", "=", self.opts["conum"])]
        }
        self.fld = ((("T", 0, 0, 0), "INa", 3, "Rep", "Rep Number", "", "N",
                     self.doRep, rpm, None, ("notblank", )),
                    (("T", 0, 1, 0), "INA", 30, "Name", "", "", "N", None,
                     None, self.doDelete, ("notblank", )))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doRep(self, frt, pag, r, c, p, i, w):
        self.rep = w
        self.acc = self.sql.getRec("ctlrep",
                                   where=[("rep_cono", "=",
                                           self.opts["conum"]),
                                          ("rep_code", "=", w)],
                                   limit=1)
        if not self.acc:
            self.new = "Y"
        else:
            self.new = "N"
            name = self.acc[self.sql.ctlrep_col.index("rep_name")]
            self.df.loadEntry(frt, pag, p + 1, data=name)

    def doDelete(self):
        self.sql.delRec("ctlrep",
                        where=[("rep_cono", "=", self.opts["conum"]),
                               ("rep_code", "=", self.rep)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        data = [self.opts["conum"]]
        for x in range(0, len(self.df.t_work[0][0])):
            data.append(self.df.t_work[0][0][x])
        if self.new == "Y":
            self.sql.insRec("ctlrep", data=data)
        elif data != self.acc[:len(data)]:
            col = self.sql.ctlrep_col
            data.append(self.acc[col.index("rep_xflag")])
            self.sql.updRec("ctlrep",
                            data=data,
                            where=[("rep_cono", "=", self.opts["conum"]),
                                   ("rep_code", "=", self.rep)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #8
0
class drc610(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm, ["drsact", "drsmst"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        return True

    def mainProcess(self):
        act = {
            "stype":
            "R",
            "tables": ("drsact", ),
            "cols": (("dac_code", "", 0, "Cod"), ("dac_desc", "", 0,
                                                  "Description", "Y"))
        }
        self.fld = ((("T", 0, 0,
                      0), "IUA", 3, "Code", "Business Activity Code", "", "N",
                     self.doAct, act, None, ("notblank", )),
                    (("T", 0, 1, 0), "INA", 30, "Description", "", "", "N",
                     None, None, self.doDelete, ("notblank", )))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doAct(self, frt, pag, r, c, p, i, w):
        self.code = w
        self.acc = self.sql.getRec("drsact",
                                   where=[("dac_code", "=", self.code)],
                                   limit=1)
        if not self.acc:
            self.new = "Y"
        else:
            self.new = "N"
            desc = self.acc[self.sql.drsact_col.index("dac_desc")]
            self.df.loadEntry(frt, pag, p + 1, data=desc)

    def doDelete(self):
        acc = self.sql.getRec("drsmst",
                              cols=["count(*)"],
                              where=[("drm_bus_activity", "=", self.code)],
                              limit=1)
        if acc[0]:
            return "Code in Use, Not Deleted"
        self.sql.delRec("drsact", where=[("dac_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        data = []
        for x in range(0, len(self.df.t_work[0][0])):
            data.append(self.df.t_work[0][0][x])
        if self.new == "Y":
            self.sql.insRec("drsact", data=data)
        elif data != self.acc[:len(data)]:
            col = self.sql.drsact_col
            data.append(self.acc[col.index("dac_xflag")])
            self.sql.updRec("drsact",
                            data=data,
                            where=[("dac_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #9
0
class arc310(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       ["assdep", "assgrp", "assmst", "genmst"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        gc = GetCtl(self.opts["mf"])
        assctl = gc.getCtl("assctl", self.opts["conum"])
        if not assctl:
            return
        self.glint = assctl["cta_glint"]
        return True

    def mainProcess(self):
        grp = {
            "stype":
            "R",
            "tables": ("assgrp", ),
            "cols": (("asg_group", "", 0, "Grp"), ("asg_desc", "", 0,
                                                   "Description", "Y")),
            "where": [("asg_cono", "=", self.opts["conum"])]
        }
        dep = {
            "stype":
            "R",
            "tables": ("assdep", ),
            "cols": (("asd_code", "", 0, "Cod"), ("asd_desc", "", 0,
                                                  "Description", "Y")),
            "where": [("asd_cono", "=", self.opts["conum"])]
        }
        glm = {
            "stype":
            "R",
            "tables": ("genmst", ),
            "cols": (("glm_acno", "", 0, "Acc-Num"), ("glm_desc", "", 0,
                                                      "Description", "Y")),
            "where": [("glm_cono", "=", self.opts["conum"])],
            "order":
            "glm_acno"
        }
        fld = [(("T", 0, 0, 0), "IUA", 3, "Asset Group", "", "", "N",
                self.doGroup, grp, None, ("notblank", )),
               (("T", 0, 1, 0), "INA", 30, "Description", "", "", "N", None,
                None, self.doDelete, ("notblank", )),
               (("T", 0, 2, 0), "INa", 3, "Depreciation Code", "", "", "N",
                self.doDepCode, dep, None, None),
               (("T", 0, 2, 0), "ONA", 34, "")]
        if self.glint == "Y":
            fld.extend([(("T", 0, 3, 0), "IUI", 7, "Asset Account", "", "",
                         "N", self.doAsset, glm, None, ("notzero", )),
                        (("T", 0, 3, 0), "ONA", 30, ""),
                        (("T", 0, 4, 0), "IUI", 7, "Accum Account", "", "",
                         "N", self.doAccum, glm, None, ("notzero", )),
                        (("T", 0, 4, 0), "ONA", 30, ""),
                        (("T", 0, 5, 0), "IUI", 7, "Expense Account", "", "",
                         "N", self.doExpense, glm, None, ("notzero", )),
                        (("T", 0, 5, 0), "ONA", 30, "")])
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doGroup(self, frt, pag, r, c, p, i, w):
        self.group = w
        self.acc = self.sql.getRec("assgrp",
                                   where=[("asg_cono", "=",
                                           self.opts["conum"]),
                                          ("asg_group", "=", self.group)],
                                   limit=1)
        if not self.acc:
            self.new = "Y"
        else:
            self.new = "N"
            self.df.loadEntry(frt, pag, p + 1, data=self.acc[2])
            self.df.loadEntry(frt, pag, p + 2, data=self.acc[3])
            dep = self.sql.getRec("assdep",
                                  cols=["asd_desc"],
                                  where=[("asd_cono", "=", self.opts["conum"]),
                                         ("asd_code", "=", self.acc[3])],
                                  limit=1)
            if dep:
                self.df.loadEntry(frt, pag, p + 3, data=dep[0])
            if self.glint == "N":
                return
            self.df.loadEntry(frt, pag, p + 4, data=self.acc[4])
            des = self.sql.getRec("genmst",
                                  cols=["glm_desc"],
                                  where=[("glm_cono", "=", self.opts["conum"]),
                                         ("glm_acno", "=", self.acc[4])],
                                  limit=1)
            if des:
                self.df.loadEntry("T", pag, p + 5, data=des[0])
            self.df.loadEntry(frt, pag, p + 6, data=self.acc[5])
            des = self.sql.getRec("genmst",
                                  cols=["glm_desc"],
                                  where=[("glm_cono", "=", self.opts["conum"]),
                                         ("glm_acno", "=", self.acc[5])],
                                  limit=1)
            if des:
                self.df.loadEntry("T", pag, p + 7, data=des[0])
            self.df.loadEntry(frt, pag, p + 8, data=self.acc[6])
            des = self.sql.getRec("genmst",
                                  cols=["glm_desc"],
                                  where=[("glm_cono", "=", self.opts["conum"]),
                                         ("glm_acno", "=", self.acc[6])],
                                  limit=1)
            if des:
                self.df.loadEntry("T", pag, p + 9, data=des[0])

    def doDepCode(self, frt, pag, r, c, p, i, w):
        chk = self.sql.getRec("assdep",
                              cols=["asd_desc"],
                              where=[("asd_cono", "=", self.opts["conum"]),
                                     ("asd_code", "=", w)],
                              limit=1)
        if not chk:
            return "Invalid Depreciation Code"
        self.df.loadEntry(frt, pag, p + 1, data=chk[0])

    def doAsset(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("genmst",
                              cols=["glm_desc"],
                              where=[("glm_cono", "=", self.opts["conum"]),
                                     ("glm_acno", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid G/L Account"
        self.df.loadEntry("T", pag, p + 1, data=acc[0])

    def doAccum(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("genmst",
                              cols=["glm_desc"],
                              where=[("glm_cono", "=", self.opts["conum"]),
                                     ("glm_acno", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid G/L Account"
        self.df.loadEntry("T", pag, p + 1, data=acc[0])

    def doExpense(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("genmst",
                              cols=["glm_desc"],
                              where=[("glm_cono", "=", self.opts["conum"]),
                                     ("glm_acno", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid G/L Account"
        self.df.loadEntry("T", pag, p + 1, data=acc[0])

    def doDelete(self):
        chk = self.sql.getRec("assmst",
                              where=[("asm_cono", "=", self.opts["conum"]),
                                     ("asm_group", "=", self.group)])
        if chk:
            return "Group in Use, Not Deleted"
        self.sql.delRec("assgrp",
                        where=[("asg_cono", "=", self.opts["conum"]),
                               ("asg_group", "=", self.group)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        data = [self.opts["conum"]]
        for x in range(0, len(self.df.t_work[0][0])):
            if x == 3 or (self.glint == "Y" and x in (5, 7, 9)):
                continue
            data.append(self.df.t_work[0][0][x])
        if self.glint == "N":
            data.extend([0, 0, 0])
        if self.new == "Y":
            self.sql.insRec("assgrp", data=data)
        elif data != self.acc[:len(data)]:
            col = self.sql.assgrp_col
            data.append(self.acc[col.index("asg_xflag")])
            self.sql.updRec("assgrp",
                            data=data,
                            where=[("asg_cono", "=", self.opts["conum"]),
                                   ("asg_group", "=", self.group)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #10
0
class rc1030(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm, [
            "ctlmst", "rcaprm", "rcaowm", "rcatnm", "rcacon", "rcatnt",
            "chglog"
        ],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        return True

    def mainProcess(self):
        own = {
            "stype":
            "R",
            "tables": ("rcaowm", ),
            "cols":
            (("rom_acno", "", 0, "Acc-Num"), ("rom_name", "", 0, "Name", "Y")),
            "where": [("rom_cono", "=", self.opts["conum"])]
        }
        prm = {
            "stype":
            "R",
            "tables": ("rcaprm", ),
            "cols": (("rcp_code", "", 0, "Prm-Code"), ("rcp_addr1", "", 0,
                                                       "Address-Line-1")),
            "where": [("rcp_cono", "=", self.opts["conum"])],
            "whera": (("T", "rcp_owner", 0, 0), )
        }
        acc = {
            "stype":
            "R",
            "tables": ("rcatnm", ),
            "cols":
            (("rtn_acno", "", 0, "Acc-Num"), ("rtn_name", "", 0, "Name", "Y")),
            "where": [("rtn_cono", "=", self.opts["conum"])],
            "whera": (("T", "rtn_owner", 0, 0), ("T", "rtn_code", 1, 0))
        }
        typ = {
            "stype": "C",
            "titl": "Select the Required Type",
            "head": ("C", "Type"),
            "data": ((4, "Services (Owner)"), (5, "Services (Agency)"))
        }
        r1s = (("Monthly", "M"), ("Quarterly", "3"), ("Bi-Annually", "6"),
               ("Annually", "A"))
        self.fld = ((("T", 0, 0, 0), "INA", 7, "Owners Code", "", "", "Y",
                     self.doOwner, own, None, ("notblank", )),
                    (("T", 0, 1, 0), "INA", 7, "Premises Code", "", "", "Y",
                     self.doPremises, prm, None, ("notblank", )),
                    (("T", 0, 2, 0), "INA", 7, "Account Code", "", "", "N",
                     self.doAccount, acc, None, ("notblank", )),
                    (("T", 0, 3, 0), "INA", 30, "Tenant Name", "", "", "N",
                     None, None, self.doDelete, ("notblank", )),
                    (("T", 0, 4, 0), "INA", 30, "Address Line 1", "", "", "N",
                     self.doAddr, None, None,
                     ("efld", )), (("T", 0, 5, 0), "INA", 30, "Address Line 2",
                                   "", "", "N", None, None, None, ("efld", )),
                    (("T", 0, 6, 0), "INA", 30, "Address Line 3", "", "", "N",
                     None, None, None,
                     ("efld", )), (("T", 0, 7, 0), "INA", 4, "Postal Code", "",
                                   "", "N", None, None, None, ("efld", )),
                    (("T", 0, 8, 0), "INA", 20, "Telephone Number", "", "",
                     "N", None, None, None,
                     ("efld", )), (("T", 0, 9, 0), "ITX", 50, "E-Mail Address",
                                   "", "", "N", None, None, None, ("email", )),
                    (("T", 0, 10, 0), "INA", 10, "VAT Number", "", "", "N",
                     self.doVatNum, None, None, ("efld", )),
                    (("T", 0, 11, 0), ("IRB", r1s), 0, "Payment Frequency", "",
                     "M", "N", None, None, None,
                     None), (("T", 0, 12, 0), "ID1", 10, "Start Date", "", "",
                             "N", None, None, None, ("notzero", )),
                    (("T", 0, 13, 0), "IUI", 3, "Number of Periods", "Periods",
                     "", "N", None, None, None, ("notzero", )),
                    (("T", 0, 14, 0), "IUD", 12.2, "Rental Amount", "",
                     "", "N", None, None, None,
                     ("notzero", )), (("T", 0, 15, 0), "IUD", 12.2,
                                      "Deposit Amount", "", "", "N", None,
                                      None, None, ("efld", )),
                    (("T", 0, 16, 0), "IUD", 12.2, "Basic Water Amount", "",
                     "", "N", self.doBWater, None, None,
                     ("efld", )), (("T", 0, 16, 0), "IUI", 1, "Type", "", "",
                                   "N", None, typ, None, ("efld", )),
                    (("T", 0, 17, 0), "IUD", 12.2, "Basic Exlectricity Amount",
                     "", "", "N", self.doBElec, None, None,
                     ("efld", )), (("T", 0, 17, 0), "IUI", 1, "Type", "", "",
                                   "N", self.doEType, typ, None,
                                   ("efld", )), (("T", 0, 18, 0), "IUA", 1,
                                                 "Status", "", "", "N", None,
                                                 None, None, ("in", ("C",
                                                                     "X"))))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doOwner(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("rcaowm",
                              cols=["rom_name"],
                              where=[("rom_cono", "=", self.opts["conum"]),
                                     ("rom_acno", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid Owner"
        self.owner = w

    def doPremises(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("rcaprm",
                              cols=["rcp_desc"],
                              where=[("rcp_cono", "=", self.opts["conum"]),
                                     ("rcp_owner", "=", self.owner),
                                     ("rcp_code", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid Premises"
        self.code = w

    def doAccount(self, frt, pag, r, c, p, i, w):
        self.acno = w
        self.oldm = self.sql.getRec("rcatnm",
                                    where=[("rtn_cono", "=",
                                            self.opts["conum"]),
                                           ("rtn_owner", "=", self.owner),
                                           ("rtn_code", "=", self.code),
                                           ("rtn_acno", "=", self.acno)],
                                    limit=1)
        if not self.oldm:
            self.new = "y"
            for num in range(4, self.df.topq[0]):
                self.df.clearEntry(frt, pag, num + 1)
            con = self.sql.getRec("rcacon",
                                  cols=["count(*)"],
                                  where=[("rcc_cono", "=", self.opts["conum"]),
                                         ("rcc_owner", "=", self.owner),
                                         ("rcc_code", "=", self.code),
                                         ("rcc_acno", "=", self.acno)],
                                  limit=1)
            if not con[0]:
                self.cnum = 1
            else:
                self.cnum = con[0] + 1
        else:
            self.new = "n"
            for num, fld in enumerate(self.oldm[3:]):
                self.df.loadEntry(frt, pag, p + num, data=fld)
            oldc = 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")
            self.oldc = oldc[-1:][0]
            self.cnum = self.oldc[4]
            for num, fld in enumerate(self.oldc[5:-1]):
                self.df.loadEntry(frt, pag, num + 11, data=fld)
            trn = self.sql.getRec("rcatnt",
                                  cols=["count(*)"],
                                  where=[("rtu_cono", "=", self.opts["conum"]),
                                         ("rtu_owner", "=", self.owner),
                                         ("rtu_code", "=", self.code),
                                         ("rtu_acno", "=", self.acno)],
                                  limit=1)
            if trn[0]:
                self.trn = True
            else:
                self.trn = False

    def doAddr(self, frt, pag, r, c, p, i, w):
        if not w:
            self.df.loadEntry(frt, pag, p + 1, data="")
            self.df.loadEntry(frt, pag, p + 2, data="")
            self.df.loadEntry(frt, pag, p + 3, data="")
            return "sk3"

    def doVatNum(self, frt, pag, r, c, p, i, w):
        if self.new == "n" and self.trn:
            return "sk1"

    def doBWater(self, frt, pag, r, c, p, i, w):
        if not w:
            self.df.loadEntry(frt, pag, p + 1, data=0)
            return "sk1"

    def doBElec(self, frt, pag, r, c, p, i, w):
        if not w:
            self.df.loadEntry(frt, pag, p + 1, data=0)
            return "sk1"

    def doEType(self, frt, pag, r, c, p, i, w):
        if self.new == "y":
            self.df.loadEntry(frt, pag, p + 1, data="C")

    def doDelete(self):
        if self.trn:
            return "Transactions Exist, Not Deleted"
        self.sql.delRec("rcatnm",
                        where=[("rtn_cono", "=", self.opts["conum"]),
                               ("rtn_owner", "=", self.owner),
                               ("rtn_code", "=", self.code),
                               ("rtn_acno", "=", self.acno)])
        self.sql.delRec("rcacon",
                        where=[("rcc_cono", "=", self.opts["conum"]),
                               ("rcc_owner", "=", self.owner),
                               ("rcc_code", "=", self.code),
                               ("rcc_acno", "=", self.acno)])
        dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
        self.sql.insRec("chglog", data=["rcatnm", "D", "%03i%-7s" % \
            (self.opts["conum"], self.code), "", dte, self.opts["capnm"],
            "", "", "", 0])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        datm = [self.opts["conum"]]
        datc = [
            self.opts["conum"], self.owner, self.code, self.acno, self.cnum
        ]
        for num, fld in enumerate(self.df.t_work[0][0]):
            if num < 11:
                datm.append(fld)
            if num > 10:
                datc.append(fld)
        if self.new == "y":
            self.sql.insRec("rcatnm", data=datm)
            self.sql.insRec("rcacon", data=datc)
        else:
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            if datm != self.oldm[:len(datm)]:
                col = self.sql.rcatnm_col
                datm.append(self.oldm[col.index("rtn_xflag")])
                self.sql.updRec("rcatnm",
                                data=datm,
                                where=[("rtn_cono", "=", self.opts["conum"]),
                                       ("rtn_owner", "=", self.owner),
                                       ("rtn_code", "=", self.code),
                                       ("rtn_acno", "=", self.acno)])
                for num, dat in enumerate(self.oldm):
                    if dat != datm[num]:
                        self.sql.insRec(
                            "chglog",
                            data=[
                                "rcatnm", "U",
                                "%03i%-7s%-7s" %
                                (self.opts["conum"], self.owner, self.code),
                                col[num], dte, self.opts["capnm"],
                                str(dat),
                                str(datm[num]), "", 0
                            ])
            if datc != self.oldc[:len(datc)]:
                col = self.sql.rcacon_col
                datc.append(self.oldc[col.index("rcc_xflag")])
                self.sql.updRec("rcacon",
                                data=datc,
                                where=[("rcc_cono", "=", self.opts["conum"]),
                                       ("rcc_owner", "=", self.owner),
                                       ("rcc_code", "=", self.code),
                                       ("rcc_acno", "=", self.acno),
                                       ("rcc_cnum", "=", self.cnum)])
                for num, dat in enumerate(self.oldc):
                    if dat != datc[num]:
                        self.sql.insRec("chglog",
                                        data=[
                                            "rcacon", "U",
                                            "%03i%-7s%-7s%-7s%03i" %
                                            (self.opts["conum"], self.owner,
                                             self.code, self.acno, self.cnum),
                                            col[num], dte, self.opts["capnm"],
                                            str(dat),
                                            str(datc[num]), "", 0
                                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #11
0
class sic110(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.drawDialog()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm, ["slsctl", "tplmst", "chglog"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        self.acc = self.sql.getRec("slsctl",
                                   where=[("ctv_cono", "=", self.opts["conum"])
                                          ],
                                   limit=1)
        if not self.acc:
            self.new = True
            self.acc = [self.opts["conum"], "Y", "Y", "sales_document", "", ""]
        else:
            self.new = False
        return True

    def drawDialog(self):
        tpl = {
            "stype":
            "R",
            "tables": ("tplmst", ),
            "cols": (("tpm_tname", "", 0, "Template"),
                     ("tpm_title", "", 0, "Title"), ("tpm_type", "", 0, "T")),
            "where": [("tpm_type", "=", "I"), ("tpm_system", "=", "INV")],
            "order":
            "tpm_tname"
        }
        r1s = (("Yes", "Y"), ("No", "N"))
        self.fld = ((("T", 0, 0, 0), ("IRB", r1s), 0, "Delivery Notes", "",
                     self.acc[1], "N", self.doDelNo, None, None, None, None,
                     "Generate Delivery Notes as well as the Sales Document"),
                    (("T", 0, 1, 0), ("IRB", r1s), 0, "Print Values", "",
                     self.acc[2], "N", None, None, None, None, None,
                     "Whether to Print Values on the Delivery Note."),
                    (("T", 0, 2, 0), "INA", 20, "Invoice Template", "",
                     self.acc[3], "N", self.doTplNam, tpl, None,
                     None), (("T", 0, 3, 0), "ITX", 50, "Email Address", "",
                             self.acc[4], "N", None, None, None, ("email", )))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 1), ("T", 0, 0)),
               ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)
        if not self.new:
            for n, f in enumerate(self.acc[1:-1]):
                self.df.loadEntry("T", 0, n, data=f)

    def doDelNo(self, frt, pag, r, c, p, i, w):
        if w == "N":
            self.df.loadEntry(frt, pag, p + 1, data="N")
            return "sk1"

    def doTplNam(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("tplmst",
                              where=[("tpm_tname", "=", w),
                                     ("tpm_type", "=", "I"),
                                     ("tpm_system", "=", "INV")],
                              limit=1)
        if not acc:
            return "Invalid Template Name"

    def doEnd(self):
        data = [self.opts["conum"]]
        for x in range(0, len(self.df.t_work[0][0])):
            data.append(self.df.t_work[0][0][x])
        if self.new:
            self.sql.insRec("slsctl", data=data)
        elif data != self.acc[:len(data)]:
            col = self.sql.slsctl_col
            data.append(self.acc[col.index("ctv_xflag")])
            self.sql.updRec("slsctl",
                            data=data,
                            where=[("ctv_cono", "=", self.opts["conum"])])
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.acc):
                if dat != data[num]:
                    self.sql.insRec("chglog",
                                    data=[
                                        "slsctl", "U",
                                        "%03i" % self.opts["conum"], col[num],
                                        dte, self.opts["capnm"],
                                        str(dat),
                                        str(data[num]), "", 0
                                    ])
        self.opts["mf"].dbm.commitDbase()
        self.doExit()

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #12
0
class ms1010(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       ["ctlmst", "ctlynd", "ctlvmf", "ctlvrf", "chglog"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        cnt = self.sql.getRec("ctlmst", cols=["count(*)"], limit=1)
        if not cnt[0]:
            self.first = True
        else:
            self.first = False
        self.img = None
        return True

    def mainProcess(self):
        self.tit = ("Company Records File Maintenance", )
        ctm = {
            "stype": "R",
            "tables": ("ctlmst", ),
            "cols":
            (("ctm_cono", "", 0, "Num"), ("ctm_name", "", 0, "Name", "Y"))
        }
        log = {"stype": "F", "types": "fle", "ftype": (("Image", "*"), )}
        r1s = (("Yes", "Y"), ("No", "N"))
        tag = (("General", None, ("T", 1, 2),
                ("T", 1, 1)), ("Banking", None, ("T", 1, 2), ("T", 1, 1)),
               ("Systems", None, ("T", 1, 2),
                ("T", 1, 1)), ("Logo", None, ("T", 1, 2), ("T", 1, 1)))
        fld = [[("T", 1, 0, 0), "IUI", 3, "Company Number", "Number", "", "Y",
                self.doCoyNum, ctm, None, ("notzero", )],
               (("T", 1, 1, 0), "INA", 30, "Name", "Company Name", "", "N",
                self.doCoyNam, None, self.doDelete, ("notblank", )),
               (("T", 1, 2, 0), "INA", 30, "Postal Address Line-1",
                "Address Line-1", "", "N", None, None, None, None),
               (("T", 1, 3, 0), "INA", 30, "               Line-2",
                "Address Line-2", "", "N", None, None, None, None),
               (("T", 1, 4, 0), "INA", 30, "               Line-3",
                "Address Line-3", "", "N", None, None, None, None),
               (("T", 1, 5, 0), "INA", 4, "Postal Code", "", "", "N", None,
                None, None, None),
               (("T", 1, 6, 0), "INA", 30, "Street Address Line-1",
                "Street Address Line-1", "", "N", None, None, None, None),
               (("T", 1, 7, 0), "INA", 30, "               Line-2",
                "Address Line-2", "", "N", None, None, None, None),
               (("T", 1, 8, 0), "INA", 30, "               Line-3",
                "Address Line-3", "", "N", None, None, None, None),
               (("T", 1, 9, 0), "INA", 4, "Street Code", "", "", "N", None,
                None, None, None),
               (("T", 1, 10, 0), "INA", 30, "Contact Name", "", "", "N", None,
                None, None, None),
               (("T", 1, 11, 0), "INA", 15, "Telephone", "Telephone No", "",
                "N", None, None, None, None),
               (("T", 1, 12, 0), "INA", 15, "Facsimile", "Facsimile No", "",
                "N", None, None, None, None),
               (("T", 1, 13, 0), "INA", 15, "Mobile", "Mobile Number", "", "N",
                None, None, None, None),
               (("T", 1, 14, 0), "ITX", 50, "E-Mail Address", "", "", "N",
                None, None, None, ("email", )),
               (("T", 1, 15, 0), "ITX", 50, "Internet URL", "", "", "N", None,
                None, None, ("efld", )),
               (("T", 1, 16, 0), "INA", 20, "Registration No", "", "", "N",
                None, None, None, None),
               (("T", 1, 17, 0), "INA", 20, "V.A.T. Number", "", "", "N",
                self.doVatNum, None, None, None),
               (("T", 1, 18, 0), "IUA", 1, "V.A.T. Default", "", "", "N",
                self.doVatCod, None, None, ("notblank", )),
               (("T", 2, 0, 0), "INA", 30, "Bank Name", "", "", "N", None,
                None, None, None),
               (("T", 2, 1, 0), "INA", 30, "Bank Branch", "", "", "N", None,
                None, None, None),
               (("T", 2, 2, 0), "INA", 8, "Bank IBT", "Bank IBT Number", "",
                "N", None, None, None, None),
               (("T", 2, 3, 0), "INA", 16, "Bank Account",
                "Bank Account Number", "", "N", None, None, None, None)]
        pos = 1
        self.sys = []
        for x in range(len(allsys)):
            for sss in allsys:
                if allsys[sss][3] == pos:
                    self.sys.append(allsys[sss][1])
                    fld.append(
                        (("T", 3, pos, 0), ("IRB", r1s), 0, allsys[sss][0], "",
                         "N", "N", None, None, None, None))
                    pos += 1
        fld.append((("T", 4, 0, 0), "IFF", 75, "Letterhead Image", "", "", "N",
                    self.doLogo, log, None, ("fle", "blank")))
        but = (("Accept", None, self.doAccept, 0, ("T", 1, 2),
                (("T", 1, 1), ("T", 4, 0))), ("Print", None, self.doPrint, 0,
                                              ("T", 1, 2), (("T", 1, 1),
                                                            ("T", 4, 0))),
               ("Cancel", None, self.doCancel, 0, ("T", 1, 2),
                (("T", 1, 1), ("T", 4, 0))), ("Quit", None, self.doExit1, 1,
                                              None, None))
        tnd = (None, (self.doEnd, "n"), (self.doEnd, "n"), (self.doEnd, "n"),
               (self.doEnd, "y"))
        txt = (None, self.doExit1, self.doExit2, self.doExit3, self.doExit4)
        self.df = TartanDialog(self.opts["mf"],
                               title=self.tit,
                               tags=tag,
                               eflds=fld,
                               butt=but,
                               tend=tnd,
                               txit=txt,
                               clicks=self.doClick)
        if self.first:
            self.opts["conum"] = 1
            self.new = True
            self.df.topf[1][0][1] = "OUI"
            self.df.loadEntry("T", 1, 0, data=self.opts["conum"])
            self.df.focusField("T", 1, 2)

    def doClick(self, *opts):
        if self.df.pag == 1 and self.df.col == 1:
            return
        self.df.focusField("T", opts[0][0], opts[0][1] + 1)

    def doCoyNum(self, frt, pag, r, c, p, i, w):
        if w == 0:
            return "Invalid Company Number"
        elif w != 1:
            chk = self.sql.getRec("ctlmst",
                                  where=[("ctm_cono", "=", 1)],
                                  limit=1)
            if not chk:
                return "Company 1 Must First Exist"
        self.opts["conum"] = w
        self.old = self.sql.getRec("ctlmst",
                                   where=[("ctm_cono", "=", self.opts["conum"])
                                          ],
                                   limit=1)
        if not self.old:
            self.new = True
        else:
            self.new = False
            self.opts["conam"] = self.old[self.sql.ctlmst_col.index(
                "ctm_name")]
            for x in range(1, self.df.topq[pag]):
                data = self.old[x]
                self.df.loadEntry(frt, pag, x, data=data)
            for x in range(0, self.df.topq[pag + 1]):
                data = self.old[x + self.df.topq[pag]]
                self.df.loadEntry(frt, pag + 1, x, data=data)
            for x in range(0, self.df.topq[pag + 2]):
                self.df.loadEntry(frt, pag + 2, x, data="N")
            mods = self.old[self.sql.ctlmst_col.index("ctm_modules")].rstrip()
            for x in range(0, len(mods), 2):
                idx = self.sys.index(mods[x:x + 2])
                self.df.loadEntry(frt, pag + 2, idx, data="Y")
            self.logo = self.old[self.sql.ctlmst_col.index("ctm_logo")]
            self.df.loadEntry(frt, pag + 3, 0, data=self.logo)
            if self.logo:
                self.displayLogo(self.logo)

    def doDelete(self):
        if self.opts["conum"] == 1:
            showError(self.opts["mf"].body, "Deletion Error",
                      "Company 1 Cannot be Deleted")
            return
        err = False
        skp = {
            "ctlmst": "ctm_cono",
            "ctlynd": "cye_cono",
            "ctlvmf": "vtm_cono",
            "ctlvrf": "vtr_cono"
        }
        for tab in tabdic:
            if tab in skp:
                continue
            chk = tabdic[tab]["fld"][0][1]
            if chk.count("_cono"):
                sql = Sql(self.opts["mf"].dbm,
                          tab,
                          prog=self.__class__.__name__)
                err = sql.getRec(tables=tab,
                                 where=[(chk, "=", self.opts["conum"])])
                if err:
                    break
        if err:
            showError(self.opts["mf"].body, "Deletion Error",
                      "%s Records Exist for This Company, Cannot Delete" % tab)
            return
        for tab in skp:
            self.sql.delRec(tab, where=[(skp[tab], "=", self.opts["conum"])])
        self.opts["mf"].dbm.commitDbase(ask=True)

    def doCoyNam(self, frt, pag, r, c, p, i, w):
        self.opts["conam"] = w
        chk = self.sql.getRec("ctlvmf",
                              where=[("vtm_cono", "=", self.opts["conum"])],
                              limit=1)
        if not chk:
            self.sql.insRec("ctlvmf",
                            data=[self.opts["conum"], "N", "No VAT", "N"])
            self.sql.insRec("ctlvrf", data=[self.opts["conum"], "N", 0, 0])

    def doVatNum(self, frt, pag, r, c, p, i, w):
        self.vatnum = w
        if not self.vatnum:
            self.vat = "N"
            self.df.loadEntry(frt, pag, p + 1, data=self.vat)
            return "sk1"

    def doVatCod(self, frt, pag, r, c, p, i, w):
        self.vat = w
        acc = self.doReadVat(self.vat)
        if not acc:
            ok = askQuestion(
                self.opts["mf"].body, "VAT Code",
                "This Code Does Not Exist, Do You Want to Create It?")
            if ok == "no":
                return "Invalid Code"
            state = self.df.disableButtonsTags()
            self.df.setWidget(self.df.mstFrame, state="hide")
            callModule(self.opts["mf"],
                       None,
                       "ms1040",
                       coy=(self.opts["conum"], self.opts["conam"]),
                       user=self.opts["capnm"],
                       args=self.vat)
            self.df.setWidget(self.df.mstFrame, state="show")
            self.df.enableButtonsTags(state=state)
            acc = self.doReadVat(self.vat)
            if not acc:
                self.df.loadEntry(frt, pag, p, data="")
                return "Invalid Code"

    def doLogo(self, frt, pag, r, c, p, i, w):
        if not w:
            if self.img:
                self.img.destroyImage()
        else:
            self.logo = os.path.normpath(w)
            if self.displayLogo(self.logo):
                return "Invalid Logo Image"
            self.df.loadEntry(frt, pag, p, data=self.logo)

    def displayLogo(self, logo):
        try:
            if self.img:
                try:
                    self.img.destroyImage()
                except:
                    pass
            self.img = ShowImage(self.df.nb.Page4,
                                 logo,
                                 wrkdir=self.opts["mf"].rcdic["wrkdir"],
                                 msiz=640)
        except:
            return "error"

    def doReadVat(self, w):
        acc = self.sql.getRec("ctlvmf",
                              cols=["vtm_desc"],
                              where=[("vtm_cono", "=", self.opts["conum"]),
                                     ("vtm_code", "=", w)],
                              limit=1)
        return acc

    def doEnd(self):
        if self.df.pag == 1:
            self.df.selPage("Banking")
            self.df.focusField("T", 2, 1)
        elif self.df.pag == 2:
            self.df.selPage("Systems")
            self.df.focusField("T", 3, 1)
        elif self.df.pag == 3:
            self.df.selPage("Logo")
            self.df.focusField("T", 4, 1)
        else:
            data = []
            mods = ""
            for x in range(0, len(self.df.t_work[1][0])):
                data.append(self.df.t_work[1][0][x])
            for x in range(0, len(self.df.t_work[2][0])):
                data.append(self.df.t_work[2][0][x])
            fin = False
            for x in range(0, len(self.df.t_work[3][0])):
                if self.df.t_work[3][0][x] == "Y":
                    mod = self.sys[x]
                    if mod not in ("BC", "BS", "SC"):
                        fin = True
                    mods = mods + mod
            data.append(mods)
            data.extend(self.df.t_work[4][0][0:2])
            if self.new:
                self.sql.insRec("ctlmst", data=data)
            elif data != self.old[:len(data)]:
                col = self.sql.ctlmst_col
                data.append(self.old[col.index("ctm_xflag")])
                self.sql.updRec("ctlmst",
                                data=data,
                                where=[("ctm_cono", "=", self.opts["conum"])])
                dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
                for num, dat in enumerate(self.old):
                    if dat != data[num]:
                        self.sql.insRec("chglog",
                                        data=[
                                            "ctlmst", "U",
                                            "%03i" % self.opts["conum"],
                                            col[num], dte, self.opts["capnm"],
                                            str(dat),
                                            str(data[num]), "", 0
                                        ])
            if fin:
                # Financial Systems
                ynd = self.sql.getRec("ctlynd",
                                      cols=["count(*)"],
                                      where=[("cye_cono", "=",
                                              self.opts["conum"])],
                                      limit=1)
                if not ynd[0]:
                    self.doFinPeriod()
                    if self.xits == "y":
                        self.doCancel()
                        return True
            self.opts["mf"].dbm.commitDbase()
            if self.first:
                self.doExit1()
            else:
                self.df.selPage("General")
                self.df.focusField("T", 1, 1)

    def doFinPeriod(self):
        tit = ("Initial Financial Period", )
        fld = ((("T", 0, 0, 0), "ID1", 10, "Period Start Date", "", "", "N",
                self.doStartPer, None, None, ("efld", )),
               (("T", 0, 1, 0), "ID1", 10, "Period End Date", "", "", "N",
                self.doEndPer, None, None, ("efld", )))
        tnd = ((self.doPerEnd, "y"), )
        txt = (self.doPerExit, )
        state = self.df.disableButtonsTags()
        self.df.setWidget(self.df.mstFrame, state="hide")
        self.pf = TartanDialog(self.opts["mf"],
                               title=tit,
                               tops=True,
                               eflds=fld,
                               tend=tnd,
                               txit=txt)
        self.pf.mstFrame.wait_window()
        self.df.setWidget(self.df.mstFrame, state="show")
        self.df.enableButtonsTags(state=state)
        self.opts["mf"].head.configure(text=self.tit[0])

    def doStartPer(self, frt, pag, r, c, p, i, w):
        y = int(w / 10000) - 1
        m = int((w % 10000) / 100)
        if m == 2:
            if not y % 4:
                d = 29
            else:
                d = 28
        else:
            d = w % 100
        self.s0 = (y * 10000) + (m * 100) + d
        self.s1 = w
        y = int(w / 10000) + 1
        m -= 1
        if not m:
            m = 12
            y -= 1
        self.pf.t_work[0][0][1] = mthendDate((y * 10000) + (m * 100) + 1)

    def doEndPer(self, frt, pag, r, c, p, i, w):
        if w <= self.s1:
            return "Invalid End Period"
        y = int(w / 10000) - 1
        m = int((w % 10000) / 100)
        if m == 2:
            if not y % 4:
                d = 29
            else:
                d = 28
        else:
            d = w % 100
        self.e0 = (y * 10000) + (m * 100) + d
        self.e1 = w

    def doPerEnd(self):
        self.sql.insRec("ctlynd",
                        data=[self.opts["conum"], 0, self.s0, self.e0, 0, "N"])
        self.sql.insRec("ctlynd",
                        data=[self.opts["conum"], 1, self.s1, self.e1, 0, "N"])
        self.xits = "n"
        self.closeProcess()

    def doPerExit(self):
        self.xits = "y"
        self.closeProcess()

    def closeProcess(self):
        self.pf.closeProcess()

    def doAccept(self):
        for page in range(4):
            frt, pag, col, mes = self.df.doCheckFields(("T", page + 1, None))
            if mes:
                break
        if mes:
            self.df.last[pag][0] = col + 1
            self.df.selPage(self.df.tags[pag - 1][0])
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            mod = False
            for x in range(len(self.df.t_work[3][0])):
                if self.df.t_work[3][0][x] == "Y":
                    mod = True
                    break
            if not mod:
                self.df.selPage("Systems")
                self.df.focusField("T", 3, 1, err="Missing System Module")
            else:
                if self.img:
                    self.img.destroyImage()
                self.df.selPage("Logo")
                self.df.doEndFrame("T", 4, cnf="N")

    def doPrint(self):
        state = self.df.disableButtonsTags()
        self.df.setWidget(self.df.mstFrame, state="hide")
        TabPrt(self.opts["mf"],
               self.opts["conum"],
               name=self.__class__.__name__,
               tabs="ctlmst",
               where=[("ctm_cono", "=", self.opts["conum"])])
        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 doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.selPage("General")
        self.df.focusField("T", 1, 1)

    def doExit1(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()

    def doExit2(self):
        self.df.selPage("General")

    def doExit3(self):
        self.df.selPage("Banking")

    def doExit4(self):
        self.df.selPage("Systems")
Пример #13
0
class sl1010(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       ["chglog", "wagedc", "wagmst", "waglmf"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        return True

    def mainProcess(self):
        wgm = {
            "stype":
            "R",
            "tables": ("wagmst", ),
            "cols": (("wgm_empno", "", 0, "EmpNo"),
                     ("wgm_sname", "", 0, "Surname", "Y"), ("wgm_fname", "", 0,
                                                            "Names")),
            "where": [("wgm_cono", "=", self.opts["conum"])]
        }
        lnm = {
            "stype":
            "R",
            "tables": ("waglmf", ),
            "cols": (("wlm_empno", "", 0, "EmpNo"), ("wlm_loan", "", 0, "Ln"),
                     ("wlm_desc", "", 0, "Description", "Y")),
            "where": [("wlm_cono", "=", self.opts["conum"])],
            "whera": [["T", "wlm_empno", 0]],
            "index":
            1
        }
        ced = {
            "stype":
            "R",
            "tables": ("wagedc", ),
            "cols": (("ced_type", "", 0, "T"), ("ced_code", "", 0, "Cde"),
                     ("ced_desc", "", 0, "Description", "Y")),
            "where": [("ced_cono", "=", self.opts["conum"]),
                      ("ced_type", "=", "D")],
            "index":
            1
        }
        fld = ((("T", 0, 0, 0), "IUI", 5, "Emp-Num", "Employee Number", "",
                "Y", self.doEmp, wgm, None, ("notzero", )), (("T", 0, 0, 0),
                                                             "ONA", 30, ""),
               (("T", 0, 1, 0), "IUI", 3, "Loan-Num", "Loan Number", "", "N",
                self.doLoan, lnm, None,
                ("notzero", )), (("T", 0, 2, 0), "INA", 30, "Description", "",
                                 "", "N", None, None, None, ("notblank", )),
               (("T", 0, 3, 0), "IUI", 3, "Deduction Code", "", "", "N",
                self.doDed, ced, None, ("notzero", )),
               (("T", 0, 4, 0), "IUD", 6.2, "Interest Percentage", "", "", "N",
                None, None, None, ("efld", )),
               (("T", 0, 5,
                 0), "ID1", 10, "Start Date", "", "", "N", None, None, None,
                ("efld", )), (("T", 0, 6, 0), "IUD", 10.2, "Deduction Amount",
                              "", "", "N", None, None, None, ("efld", )))
        tnd = ((self.doEnd, "n"), (self.doEnd, "y"))
        txt = (self.doExit, self.doExit)
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 4), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 4),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        self.df = TartanDialog(self.opts["mf"],
                               eflds=fld,
                               tend=tnd,
                               txit=txt,
                               butt=but)

    def doEmp(self, frt, pag, r, c, p, i, w):
        self.empno = w
        acc = self.sql.getRec("wagmst",
                              cols=["wgm_sname", "wgm_fname"],
                              where=[("wgm_cono", "=", self.opts["conum"]),
                                     ("wgm_empno", "=", self.empno)],
                              limit=1)
        if not acc:
            return "Invalid Employee Number"
        self.name = "%s, %s" % (acc[0], acc[1].split()[0])
        self.df.loadEntry("T", pag, p + 1, data=self.name)

    def doLoan(self, frt, pag, r, c, p, i, w):
        self.loan = w
        self.rec = self.sql.getRec("waglmf",
                                   where=[("wlm_cono", "=",
                                           self.opts["conum"]),
                                          ("wlm_empno", "=", self.empno),
                                          ("wlm_loan", "=", self.loan)],
                                   limit=1)
        if not self.rec:
            return "Invalid Loan Number"
        wlc = self.sql.waglmf_col
        self.df.loadEntry(frt,
                          pag,
                          p + 1,
                          data=self.rec[wlc.index("wlm_desc")])
        self.df.loadEntry(frt,
                          pag,
                          p + 2,
                          data=self.rec[wlc.index("wlm_code")])
        self.df.loadEntry(frt,
                          pag,
                          p + 3,
                          data=self.rec[wlc.index("wlm_rate")])
        self.df.loadEntry(frt,
                          pag,
                          p + 4,
                          data=self.rec[wlc.index("wlm_start")])
        self.df.loadEntry(frt,
                          pag,
                          p + 5,
                          data=self.rec[wlc.index("wlm_repay")])

    def doDed(self, frt, pag, r, c, p, i, w):
        self.code = w
        desc = self.sql.getRec("wagedc",
                               cols=["ced_desc"],
                               where=[("ced_cono", "=", self.opts["conum"]),
                                      ("ced_type", "=", "D"),
                                      ("ced_code", "=", w)],
                               limit=1)
        if not desc:
            return "Invalid Code"

    def doEnd(self):
        data = [self.opts["conum"]]
        for p in range(0, len(self.df.t_work[0][0])):
            if p == 1:
                continue
            data.append(self.df.t_work[0][0][p])
        if data != self.rec[:len(data)]:
            col = self.sql.waglmf_col
            data.append(self.rec[col.index("wlm_xflag")])
            self.sql.updRec("waglmf",
                            data=data,
                            where=[("wlm_cono", "=", self.opts["conum"]),
                                   ("wlm_empno", "=", self.empno),
                                   ("wlm_loan", "=", self.loan)])
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.rec):
                if dat != data[num]:
                    self.sql.insRec(
                        "chglog",
                        data=[
                            "waglmf", "U",
                            "%03i%05i%02i" %
                            (self.opts["conum"], self.empno, self.loan),
                            col[num], dte, self.opts["capnm"],
                            str(dat),
                            str(data[num]), "", 0
                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.last[0] = [0, 0]
        self.df.focusField("T", 0, 1)

    def doExit(self):
        if not self.df.pag:
            self.doCloseProcess()
        elif self.df.pag == 1:
            self.df.focusField("T", 0, 2)

    def doCloseProcess(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #14
0
class cs1010(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            if "wait" in self.opts:
                self.df.mstFrame.wait_window()
            else:
                self.opts["mf"].startLoop()

    def setVariables(self):
        gc = GetCtl(self.opts["mf"])
        cshctl = gc.getCtl("cshctl", self.opts["conum"])
        if not cshctl:
            return
        glint = cshctl["ccc_glint"]
        if glint == "Y":
            showError(self.opts["mf"].window, "Error",
                "Cash Analysis is Integrated with General Ledger.")
            return
        ctlmst = gc.getCtl("ctlmst", self.opts["conum"])
        if not ctlmst:
            return
        self.taxdf = ctlmst["ctm_taxdf"]
        if not self.taxdf:
            self.taxdf = "N"
        self.mods = []
        for x in range(0, len(ctlmst["ctm_modules"].rstrip()), 2):
            self.mods.append(ctlmst["ctm_modules"][x:x+2])
        tabs = ["ctlvmf", "cshmst", "genbal", "genbud",
                "genrpt", "gentrn", "chglog"]
        if "CR" in self.mods:
            tabs.append("crsctl")
        if "DR" in self.mods:
            tabs.append("drsctl")
        if "ST" in self.mods:
            tabs.extend(["strctl", "strloc"])
        if "SI" in self.mods:
            tabs.append("slsctl")
        self.sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__)
        if self.sql.error:
            return
        chk = self.sql.getRec("cshmst", cols=["count(*)"],
            where=[("ccm_cono", "=", self.opts["conum"])], limit=1)
        if chk[0]:
            self.newgen = False
        else:
            self.newgen = True
        if "args" in self.opts:
            self.acno = None
        return True

    def mainProcess(self):
        glm = {
            "stype": "R",
            "tables": ("cshmst",),
            "cols": (
                ("ccm_acno", "", 0, "Acc-Num"),
                ("ccm_desc", "", 0, "Description", "Y")),
            "where": [("ccm_cono", "=", self.opts["conum"])]}
        vat = {
            "stype": "R",
            "tables": ("ctlvmf",),
            "cols": (
                ("vtm_code", "", 0, "Acc-Num"),
                ("vtm_desc", "", 0, "Description", "Y")),
            "where": [("vtm_cono", "=", self.opts["conum"])]}
        fld = (
            (("T",0,0,0),"IUI",7,"Acc-Num","Account Number",
                "","Y",self.doAccNum,glm,None,("notzero",)),
            (("T",0,1,0),"INA",30,"Description","Account Description",
                "","N",None,None,None,("notblank",)),
            (("T",0,2,0),"IUA",1,"Tax Default","",
                self.taxdf,"N",self.doVatCod,vat,None,("notblank",)))
        but = (
            ("Accept",None,self.doAccept,0,("T",0,2),(("T",0,0),("T",0,1))),
            ("Cancel",None,self.doCancel,0,("T",0,2),(("T",0,0),("T",0,1))),
            ("Quit",None,self.doQuit,1,None,None))
        tnd = ((self.doEnd,"y"), )
        txt = (self.doQuit, )
        self.df = TartanDialog(self.opts["mf"], eflds=fld, butt=but,
            tend=tnd, txit=txt)

    def doAccNum(self, frt, pag, r, c, p, i, w):
        self.acno = w
        self.old = self.sql.getRec("cshmst", where=[("ccm_cono", "=",
            self.opts["conum"]), ("ccm_acno", "=", self.acno)], limit=1)
        if not self.old:
            self.new = True
        elif "args" in self.opts:
            showError(self.opts["mf"].body, "Error",
                "Only a New Account is Allowed")
            return "rf"
        else:
            self.new = False
            for x in range(0, self.df.topq[pag]):
                self.df.loadEntry(frt, pag, p+x, data=self.old[x+1])

    def doTypCod(self, frt, pag, r, c, p, i, w):
        if self.new:
            if w == "P":
                self.df.topf[pag][4][5] = self.taxdf
            else:
                self.df.topf[pag][4][5] = "N"
        elif not self.df.topf[pag][4][5]:
            self.df.topf[pag][4][5] = "N"

    def doVatCod(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("ctlvmf", cols=["vtm_desc"], where=[("vtm_cono",
            "=", self.opts["conum"]), ("vtm_code", "=", w)], limit=1)
        if not acc:
            return "Invalid VAT Code"

    def doDelete(self):
        t = self.sql.getRec("cshana", cols=["count(*)"], where=[("can_cono",
            "=", self.opts["conum"]), ("can_code", "=", self.acno)], limit=1)
        if t[0]:
            return "Transactions Exist, Not Deleted"
        self.sql.delRec("cshmst", where=[("ccm_cono", "=", self.opts["conum"]),
            ("ccm_code", "=", self.acno)])
        dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
        self.sql.insRec("chglog", data=["cshmst", "D", "%03i%07i" %
            (self.opts["conum"], self.acno), "", dte, self.opts["capnm"],
            "", "", "", 0])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        if self.newgen:
            self.df.butt[1][4] = None
            self.df.butt[1][5] = None
        data = [self.opts["conum"], self.acno,
            self.df.t_work[0][0][1], self.df.t_work[0][0][2]]
        if self.new:
            self.sql.insRec("cshmst", data=data)
        elif data != self.old[:len(data)]:
            col = self.sql.cshmst_col
            data.append(self.old[col.index("ccm_xflag")])
            self.sql.updRec("cshmst", data=data, where=[("ccm_cono", "=",
                self.opts["conum"]), ("ccm_acno", "=", self.acno)])
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.old):
                if dat != data[num]:
                    self.sql.insRec("chglog", data=["cshmst", "U",
                        "%03i%07i" % (self.opts["conum"], self.acno),
                        col[num], dte, self.opts["capnm"], str(dat),
                        str(data[num]), "", 0])
        self.opts["mf"].dbm.commitDbase()
        if "args" in self.opts:
            self.doQuit()
        else:
            self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col+1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.last[0] = [0, 0]
        self.df.focusField("T", 0, 1)

    def doIgExit(self):
        self.igexit = True
        self.ig.closeProcess()

    def doQuit(self):
        self.df.closeProcess()
        if "wait" not in self.opts:
            self.opts["mf"].closeLoop()
Пример #15
0
class stc110(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.drawDialog()
            self.opts["mf"].startLoop()

    def setVariables(self):
        gc = GetCtl(self.opts["mf"])
        ctlmst = gc.getCtl("ctlmst", self.opts["conum"])
        if not ctlmst:
            return
        mods = ctlmst["ctm_modules"]
        self.genleg = False
        self.slspos = False
        for x in range(0, len(mods), 2):
            if mods[x:x + 2] == "GL":
                self.genleg = True
            elif mods[x:x + 2] == "PS":
                self.slspos = True
        tabs = [
            "strctl", "strloc", "strgmu", "strcmu", "strprc", "tplmst",
            "chglog"
        ]
        if self.genleg:
            tabs.extend(["ctlctl", "genmst"])
        self.sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__)
        if self.sql.error:
            return
        self.acc = self.sql.getRec("strctl",
                                   where=[("cts_cono", "=", self.opts["conum"])
                                          ],
                                   limit=1)
        if not self.acc:
            self.new = True
            self.acc = [
                self.opts["conum"], "N", "N", 1, "N", "purchase_order", "", ""
            ]
        else:
            self.new = False
        if self.genleg:
            self.ctl = [["stk_soh", "Stock on Hand", 0],
                        ["stk_susp", "Stock Reconciliation", 0]]
            if self.slspos:
                self.ctl.extend([["pos_cash", "Cash Takings", 0],
                                 ["pos_card", "Card Takings", 0],
                                 ["pos_vchr", "Vouchers", 0]])
            ctlctl = gc.getCtl("ctlctl", self.opts["conum"])
            if not ctlctl:
                return
            for num, ctl in enumerate(self.ctl):
                if ctl[0] in ctlctl:
                    self.ctl[num][2] = ctlctl[ctl[0]]
        self.locs = self.acc[self.sql.strctl_col.index("cts_locs")]
        return True

    def drawDialog(self):
        tpm = {
            "stype":
            "R",
            "tables": ("tplmst", ),
            "cols": (("tpm_tname", "", 0, "Template"),
                     ("tpm_title", "", 0, "Title"), ("tpm_type", "", 0, "T")),
            "where": [("tpm_type", "=", "O"), ("tpm_system", "=", "STR")],
            "order":
            "tpm_tname"
        }
        r1s = (("Yes", "Y"), ("No", "N"))
        r2s = (("No", "N"), ("Last Cost", "L"), ("Average Cost", "A"))
        if self.genleg:
            glm = {
                "stype":
                "R",
                "tables": ("genmst", ),
                "cols": (("glm_acno", "", 0, "G/L-Num"), ("glm_desc", "", 30,
                                                          "Description")),
                "where": [("glm_cono", "=", self.opts["conum"])]
            }
            fld = [(("T", 0, 0, 0), ("IRB", r1s), 0, "G/L Integration", "",
                    self.acc[1], "N", self.doGlint, None, None, None),
                   (("T", 0, 1, 0), "IUI", 7, self.ctl[0][1], "",
                    self.ctl[0][2], "N", self.doGenAcc, glm, None, ("efld", )),
                   (("T", 0, 1, 0), "ONA", 30, ""),
                   (("T", 0, 2, 0), "IUI", 7, self.ctl[1][1], "",
                    self.ctl[1][2], "N", self.doGenAcc, glm, None, ("efld", )),
                   (("T", 0, 2, 0), "ONA", 30, "")]
            if self.slspos:
                fld.extend([(("T", 0, 3,
                              0), "IUI", 7, self.ctl[2][1], "", self.ctl[2][2],
                             "N", self.doGenAcc, glm, None, ("efld", )),
                            (("T", 0, 3, 0), "ONA", 30, ""),
                            (("T", 0, 4,
                              0), "IUI", 7, self.ctl[3][1], "", self.ctl[3][2],
                             "N", self.doGenAcc, glm, None, ("efld", )),
                            (("T", 0, 4, 0), "ONA", 30, ""),
                            (("T", 0, 5,
                              0), "IUI", 7, self.ctl[4][1], "", self.ctl[4][2],
                             "N", self.doGenAcc, glm, None, ("efld", )),
                            (("T", 0, 5, 0), "ONA", 30, "")])
                seq = 6
            else:
                seq = 3
        else:
            fld = []
            seq = 0
        fld.extend([(("T", 0, seq, 0), ("IRB", r1s), 0, "Multiple Locations",
                     "", self.acc[2], "N", self.doLocs, None, None, None),
                    (("T", 0, seq + 1, 0), "IUI", 1, "Number of Price Levels",
                     "", self.acc[3], "N", None, None, None, ("between", 1,
                                                              5)),
                    (("T", 0, seq + 2, 0), ("IRB", r2s), 0, "Automatic Markup",
                     "", self.acc[4], "N", None, None, None, None, None,
                     "Calculate Selling Prices Based on Markup Percentages"),
                    (("T", 0, seq + 3, 0), "INA", 20, "Orders Template", "",
                     self.acc[5], "N", self.doTplNam, tpm, None, None),
                    (("T", 0, seq + 4, 0), "ITX", 50, "Email Address", "",
                     self.acc[6], "N", None, None, None, ("email", ))])
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 1), ("T", 0, 0)),
               ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)
        if not self.new:
            s = 0
            for n, f in enumerate(self.acc[1:-1]):
                if not self.genleg and not n:
                    continue
                self.df.loadEntry("T", 0, s, data=f)
                s += 1
                if not n:
                    for c in self.ctl:
                        self.df.loadEntry("T", 0, s, data=c[2])
                        s += 1
                        self.df.loadEntry("T", 0, s, data=self.getDes(c[2]))
                        s += 1
            self.df.focusField("T", 0, 1, clr=False)

    def doGlint(self, frt, pag, r, c, p, i, w):
        if self.slspos:
            idx = 11
            skp = "sk10"
        else:
            idx = 5
            skp = "sk4"
        if w == "N":
            for x in range(1, idx):
                self.df.loadEntry(frt, pag, p + x, data="")
            return skp

    def doGenAcc(self, frt, pag, r, c, p, i, w):
        des = self.getDes(w)
        if not des:
            return "Invalid Account Number"
        self.df.loadEntry(frt, pag, p + 1, data=des)

    def getDes(self, acno):
        acc = self.sql.getRec("genmst",
                              cols=["glm_desc"],
                              where=[("glm_cono", "=", self.opts["conum"]),
                                     ("glm_acno", "=", acno)],
                              limit=1)
        if acc:
            return acc[0]
        else:
            return ""

    def doLocs(self, frt, pag, r, c, p, i, w):
        self.locs = w

    def doTplNam(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("tplmst",
                              where=[("tpm_tname", "=", w),
                                     ("tpm_type", "=", "O"),
                                     ("tpm_system", "=", "STR")],
                              limit=1)
        if not acc:
            return "Invalid Template Name"

    def doEnd(self):
        data = [self.opts["conum"]]
        if not self.genleg:
            data.append("N")
        if self.genleg:
            if self.slspos:
                idx = 11
                pos = (1, 3, 5, 7, 9)
            else:
                idx = 5
                pos = (1, 3)
        for x, d in enumerate(self.df.t_work[0][0]):
            if x and self.genleg and x < idx:
                if x in pos:
                    y = int((x - 1) / 2)
                    chk = self.sql.getRec("ctlctl",
                                          where=[("ctl_cono", "=",
                                                  self.opts["conum"]),
                                                 ("ctl_code", "=",
                                                  self.ctl[y][0])],
                                          limit=1)
                    if chk:
                        self.sql.updRec("ctlctl",
                                        cols=["ctl_conacc"],
                                        data=[d],
                                        where=[("ctl_cono", "=",
                                                self.opts["conum"]),
                                               ("ctl_code", "=",
                                                self.ctl[y][0])])
                    else:
                        self.sql.insRec("ctlctl",
                                        data=[
                                            self.opts["conum"], self.ctl[y][0],
                                            self.ctl[y][1], d, "", "N", "N"
                                        ])
                else:
                    continue
            else:
                data.append(d)
        if self.new:
            self.sql.insRec("strctl", data=data)
        elif data != self.acc[:len(data)]:
            col = self.sql.strctl_col
            data.append(self.acc[col.index("cts_xflag")])
            self.sql.updRec("strctl",
                            data=data,
                            where=[("cts_cono", "=", self.opts["conum"])])
            # Check and Fix Markup prices
            plevs = data[self.sql.strctl_col.index("cts_plevs")]
            automu = data[self.sql.strctl_col.index("cts_automu")]
            if automu in ("A", "L"):
                grps = self.sql.getRec("strgrp",
                                       cols=["gpm_group"],
                                       where=[("gpm_cono", "=",
                                               self.opts["conum"])])
                for grp in grps:
                    for lvl in range(1, plevs + 1):
                        self.sql.delRec("strcmu",
                                        where=[("smc_cono", "=",
                                                self.opts["conum"]),
                                               ("smc_group", "=", grp[0]),
                                               ("smc_level", "=", lvl),
                                               ("smc_markup", "=", 0)])
                        gmu = self.sql.getRec("strgmu",
                                              cols=["smg_markup"],
                                              where=[("smg_cono", "=",
                                                      self.opts["conum"]),
                                                     ("smg_group", "=",
                                                      grp[0]),
                                                     ("smg_level", "=", lvl)],
                                              limit=1)
                        if gmu:
                            if not gmu[0]:
                                self.sql.delRec("strgmu",
                                                where=[
                                                    ("smg_cono", "=",
                                                     self.opts["conum"]),
                                                    ("smg_group", "=", grp[0]),
                                                    ("smg_level", "=", lvl)
                                                ])
                            self.sql.delRec("strcmu",
                                            where=[("smc_cono", "=",
                                                    self.opts["conum"]),
                                                   ("smc_group", "=", grp[0]),
                                                   ("smc_level", "=", lvl),
                                                   ("smc_markup", "=", gmu[0])
                                                   ])
                self.sql.delRec("strprc",
                                where=[("stp_cono", "=", self.opts["conum"])])
            # Chglog
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.acc):
                if dat != data[num]:
                    self.sql.insRec("chglog",
                                    data=[
                                        "strctl", "U",
                                        "%03i" % self.opts["conum"], col[num],
                                        dte, self.opts["capnm"],
                                        str(dat),
                                        str(data[num]), "", 0
                                    ])
        if self.locs == "N":
            acc = self.sql.getRec("strloc",
                                  cols=["srl_desc"],
                                  where=[("srl_cono", "=", self.opts["conum"]),
                                         ("srl_loc", "=", "1")],
                                  limit=1)
            if not acc:
                self.sql.insRec("strloc",
                                data=[
                                    self.opts["conum"], "1",
                                    "Location Number One", "", "", "", ""
                                ])
        self.opts["mf"].dbm.commitDbase()
        self.doExit()

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #16
0
class stc410(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       "strloc",
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        gc = GetCtl(self.opts["mf"])
        strctl = gc.getCtl("strctl", self.opts["conum"])
        if not strctl:
            return
        self.locs = strctl["cts_locs"]
        if self.locs == "N":
            showError(self.opts["mf"].body, "Error",
                      "Multiple Locations Are Not Enabled")
            return
        return True

    def mainProcess(self):
        loc = {
            "stype":
            "R",
            "tables": ("strloc", ),
            "cols":
            (("srl_loc", "", 0, "L"), ("srl_desc", "", 0, "Description", "Y")),
            "where": [("srl_cono", "=", self.opts["conum"])]
        }
        self.fld = ((("T", 0, 0, 0), "IUA", 1, "Location Code", "", "", "N",
                     self.doLoc, loc, None, ("notblank", )),
                    (("T", 0, 1, 0), "INA", 30, "Description", "", "", "N",
                     None, None, self.doDelete, ("notblank", )),
                    (("T", 0, 2,
                      0), "INA", 30, "Address Line 1", "", "", "N", None, None,
                     None, None), (("T", 0, 3, 0), "INA", 30, "Address Line 2",
                                   "", "", "N", None, None, None, None),
                    (("T", 0, 4, 0), "INA", 30, "Address Line 3", "", "", "N",
                     None, None, None, None), (("T", 0, 5, 0), "INA", 30,
                                               "Address Line 4", "", "", "N",
                                               None, None, None, None))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2), ("T", 0, 0)))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doCloseProcess, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doLoc(self, frt, pag, r, c, p, i, w):
        if w == "0":
            return "Invalid Location"
        self.loc = w
        self.acc = self.sql.getRec("strloc",
                                   where=[("srl_cono", "=",
                                           self.opts["conum"]),
                                          ("srl_loc", "=", self.loc)],
                                   limit=1)
        if not self.acc:
            self.new = "Y"
        else:
            self.new = "N"
            for x in range(1, self.df.topq[pag]):
                self.df.loadEntry(frt, pag, p + x, data=self.acc[x + 1])

    def doDelete(self):
        self.sql.delRec("strloc",
                        where=[("srl_cono", "=", self.opts["conum"]),
                               ("srl_loc", "=", self.loc)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        data = [self.opts["conum"]]
        for x in range(0, len(self.df.t_work[0][0])):
            data.append(self.df.t_work[0][0][x])
        if self.new == "Y":
            self.sql.insRec("strloc", data=data)
        elif data != self.acc[:len(data)]:
            col = self.sql.strloc_col
            data.append(self.acc[col.index("srl_xflag")])
            self.sql.updRec("strloc",
                            data=data,
                            where=[("srl_cono", "=", self.opts["conum"]),
                                   ("srl_loc", "=", self.loc)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doCloseProcess(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #17
0
class wgc410(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       "ctlmes",
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        self.system = "WAG"
        return True

    def mainProcess(self):
        mss = {
            "stype":
            "R",
            "tables": ("ctlmes", ),
            "cols": (("mss_message", "", 0, "Mss"), ("mss_detail", "NA", 50,
                                                     "Details")),
            "where": [("mss_system", "=", self.system)],
            "order":
            "mss_message"
        }
        self.fld = ((("T", 0, 0, 0), "IUI", 3, "Message Number", "", "", "N",
                     self.doMes, mss, None, ("notzero", )),
                    (("T", 0, 1, 0), "ITv", (30, 6), "Details", "", "", "N",
                     self.doDetail, None, self.doDelete, None))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doMes(self, frt, pag, r, c, p, i, w):
        self.message = w
        self.acc = self.sql.getRec("ctlmes",
                                   where=[("mss_system", "=", self.system),
                                          ("mss_message", "=", self.message)],
                                   order="mss_message",
                                   limit=1)
        if not self.acc:
            self.new = "Y"
            self.df.loadEntry(frt, pag, p + 1, data="")
        else:
            self.new = "N"
            self.detail = self.acc[self.sql.ctlmes_col.index("mss_detail")]
            self.df.loadEntry(frt, pag, p + 1, data=self.detail)

    def doDetail(self, frt, pag, r, c, p, i, w):
        if len(w) > 150:
            return "Invalid Message Length, Maximum 150 Characters"

    def doDelete(self):
        self.sql.delRec("ctlmes",
                        where=[("mss_system", "=", self.system),
                               ("mss_message", "=", self.message)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        wid, self.detail = self.df.getEntry("T", 0, 1)
        if len(self.detail) > 150:
            self.df.focusField(
                "T",
                0,
                2,
                err="Invalid Message Length, Maximum 150 Characters")
        else:
            data = [self.system, self.message, self.detail]
            if self.new == "Y":
                self.sql.insRec("ctlmes", data=data)
            elif data != self.acc[:len(data)]:
                col = self.sql.ctlmes_col
                data.append(self.acc[col.index("mss_xflag")])
                self.sql.updRec("ctlmes",
                                data=data,
                                where=[("mss_system", "=", self.system),
                                       ("mss_message", "=", self.message)])
            self.opts["mf"].dbm.commitDbase()
            self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #18
0
class drc210(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        gc = GetCtl(self.opts["mf"])
        drsctl = gc.getCtl("drsctl", self.opts["conum"])
        if not drsctl:
            return
        if drsctl["ctd_chain"] == "N":
            showError(self.opts["mf"].body, "Error",
                      "Chain Stores are Not Enabled")
            return
        self.sql = Sql(self.opts["mf"].dbm, ["ctlvmf", "drschn"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        return True

    def mainProcess(self):
        chm = {
            "stype": "R",
            "tables": ("drschn", ),
            "cols":
            (("chm_chain", "", 0, "Chn"), ("chm_name", "", 0, "Name", "Y")),
            "where": [("chm_cono", "=", self.opts["conum"])]
        }
        vtm = {
            "stype":
            "R",
            "tables": ("ctlvmf", ),
            "cols": (("vtm_code", "", 0, "C"), ("vtm_desc", "", 0,
                                                "Description", "Y")),
            "where": [("vtm_cono", "=", self.opts["conum"])]
        }
        self.fld = ((("T", 0, 0, 0), "IUI", 3, "Chn", "Chainstore Number", "",
                     "N", self.doChain, chm, None, ("notzero", )),
                    (("T", 0, 1, 0), "INA", 30, "Name", "", "", "N", None,
                     None, self.doDelete, ("notblank", )),
                    (("T", 0, 2, 0), "INA", 30, "Address Line 1", "", "", "N",
                     None, None, None, ("notblank", )),
                    (("T", 0, 3, 0), "INA", 30, "Address Line 2", "", "", "N",
                     None, None, None,
                     ("efld", )), (("T", 0, 4, 0), "INA", 30, "Address Line 3",
                                   "", "", "N", None, None, None, ("efld", )),
                    (("T", 0, 5, 0), "INA", 4, "Postal Code", "", "", "N",
                     None, None, None,
                     ("efld", )), (("T", 0, 6, 0), "INA", 20, "Telephone", "",
                                   "", "N", None, None, None, ("efld", )),
                    (("T", 0, 7,
                      0), "INA", 20, "Fax", "", "", "N", None, None, None,
                     ("efld", )), (("T", 0, 8, 0), "ITX", 50, "E-Mail Address",
                                   "", "", "N", None, None, None, ("email", )),
                    (("T", 0, 9,
                      0), "INA", 30, "Contact", "", "", "N", None, None, None,
                     ("efld", )), (("T", 0, 10, 0), "IUA", 1, "Vat Code", "",
                                   "", "N", self.doVat, vtm, None,
                                   ("notblank", )), (("T", 0, 10, 0), "ONA",
                                                     30, ""))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doChain(self, frt, pag, r, c, p, i, w):
        self.chain = w
        self.acc = self.sql.getRec("drschn",
                                   where=[("chm_cono", "=",
                                           self.opts["conum"]),
                                          ("chm_chain", "=", self.chain)],
                                   limit=1)
        if not self.acc:
            self.new = "Y"
        else:
            self.new = "N"
            vat = self.sql.getRec(
                "ctlvmf",
                cols=["vtm_desc"],
                where=[("vtm_cono", "=", self.opts["conum"]),
                       ("vtm_code", "=",
                        self.acc[self.sql.drschn_col.index("chm_vatind")])],
                limit=1)
            if not vat:
                txt = "Invalid Vat Record"
            else:
                txt = vat[0]
            for x in range(0, self.df.topq[pag]):
                if x == (self.df.topq[pag] - 1):
                    self.df.loadEntry(frt, pag, p + x, data=txt)
                else:
                    self.df.loadEntry(frt, pag, p + x, data=self.acc[x + 1])

    def doVat(self, frt, pag, r, c, p, i, w):
        vat = self.sql.getRec("ctlvmf",
                              cols=["vtm_desc"],
                              where=[("vtm_cono", "=", self.opts["conum"]),
                                     ("vtm_code", "=", w)],
                              limit=1)
        if not vat:
            return "Invalid Vat Record"
        self.df.loadEntry(frt, pag, p + 1, data=vat[0])

    def doDelete(self):
        self.sql.delRec("drschn",
                        where=[("chm_cono", "=", self.opts["conum"]),
                               ("chm_chain", "=", self.chain)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        dat = [self.opts["conum"]]
        for x in range(0, len(self.df.t_work[0][0])):
            if x == 11:
                continue
            dat.append(self.df.t_work[0][0][x])
        if self.new == "Y":
            self.sql.insRec("drschn", data=dat)
        elif dat != self.acc[:len(dat)]:
            col = self.sql.drschn_col
            dat.append(self.acc[col.index("chm_xflag")])
            self.sql.updRec("drschn",
                            data=dat,
                            where=[("chm_cono", "=", self.opts["conum"]),
                                   ("chm_chain", "=", self.chain)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #19
0
class wgc110(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.drawDialog()
            self.opts["mf"].startLoop()

    def setVariables(self):
        gc = GetCtl(self.opts["mf"])
        ctlmst = gc.getCtl("ctlmst", self.opts["conum"])
        if not ctlmst:
            return
        mods = ctlmst["ctm_modules"]
        self.genleg = False
        for x in range(0, len(mods), 2):
            if mods[x:x + 2] == "GL":
                self.genleg = True
                break
        tabs = ["wagctl", "tplmst", "chglog"]
        if self.genleg:
            tabs.extend(["ctlctl", "genmst"])
        self.sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__)
        if self.sql.error:
            return
        self.acc = self.sql.getRec("wagctl",
                                   where=[("ctw_cono", "=", self.opts["conum"])
                                          ],
                                   limit=1)
        if not self.acc:
            self.new = True
            self.acc = [
                self.opts["conum"], "N", 0, "", "", 0, 0, 0, 0, "N", 0, 0, "",
                61, "payslip", "", ""
            ]
        else:
            self.new = False
        if self.genleg:
            self.ctl = [["wag_ctl", "Salaries Control", 0],
                        ["wag_slc", "Staff Loans Control", 0],
                        ["wag_sli", "Staff Loans Interest", 0]]
            ctlctl = gc.getCtl("ctlctl", self.opts["conum"])
            if not ctlctl:
                return
            for num, ctl in enumerate(self.ctl):
                if ctl[0] in ctlctl:
                    self.ctl[num][2] = ctlctl[ctl[0]]
        return True

    def drawDialog(self):
        tpm = {
            "stype":
            "R",
            "tables": ("tplmst", ),
            "cols": (("tpm_tname", "", 0, "Template"),
                     ("tpm_title", "", 0, "Title"), ("tpm_type", "", 0, "T")),
            "where": [("tpm_type", "=", "P"), ("tpm_system", "=", "WAG")],
            "order":
            "tpm_tname"
        }
        r1s = (("Yes", "Y"), ("No", "N"))
        if self.genleg:
            glm = {
                "stype":
                "R",
                "tables": ("genmst", ),
                "cols": (("glm_acno", "", 0, "G/L-Num"), ("glm_desc", "", 30,
                                                          "Description")),
                "where": [("glm_cono", "=", self.opts["conum"])]
            }
            fld = [(("T", 0, 0, 0), ("IRB", r1s), 0, "G/L Integration", "",
                    self.acc[1], "N", self.doGlint, None, None, None),
                   (("T", 0, 1, 0), "IUI", 7, self.ctl[0][1], "",
                    self.ctl[0][2], "N", self.doGenAcc, glm, None, ("efld", )),
                   (("T", 0, 1, 0), "ONA", 30, ""),
                   (("T", 0, 2, 0), "IUI", 7, self.ctl[1][1], "",
                    self.ctl[1][2], "N", self.doGenAcc, glm, None, ("efld", )),
                   (("T", 0, 2, 0), "ONA", 30, ""),
                   (("T", 0, 3, 0), "IUI", 7, self.ctl[2][1], "",
                    self.ctl[2][2], "N", self.doGenAcc, glm, None, ("efld", )),
                   (("T", 0, 3, 0), "ONA", 30, "")]
            seq = 4
        else:
            fld = []
            seq = 0
        fld.extend([(("T", 0, seq, 0), "IUI", 10, "Registration Number", "",
                     self.acc[2], "N", None, None, None, ("notzero", )),
                    (("T", 0, seq + 1, 0), "INA", 10, "SDL Number", "",
                     self.acc[3], "N", None, None, None, ("notblank", )),
                    (("T", 0, seq + 2, 0), "INA", 10, "UIF Number", "",
                     self.acc[4], "N", None, None, None, ("notblank", )),
                    (("T", 0, seq + 3, 0), "IUI", 4, "Trade Number", "",
                     self.acc[5], "N", None, None, None, ("notzero", )),
                    (("T", 0, seq + 4, 0), "IUD", 6.2, "Daily Hours", "",
                     self.acc[6], "N", None, None, None, ("notzero", )),
                    (("T", 0, seq + 5, 0), "IUD", 6.2, "Weekly Hours", "",
                     self.acc[7], "N", self.doHrs, None, None, ("notzero", )),
                    (("T", 0, seq + 6, 0), "IUD", 6.2, "Monthly Hours", "",
                     self.acc[8], "N", None, None, None, ("notzero", )),
                    (("T", 0, seq + 7, 0), ("IRB",
                                            r1s), 0, "Diplomatic Immunity", "",
                     self.acc[9], "N", None, None, None, None),
                    (("T", 0, seq + 8, 0), "IUD", 6.2, "S/L Interest Rate", "",
                     self.acc[10], "N", None, None, None, ("efld", )),
                    (("T", 0, seq + 9, 0), "Id1", 10, "Last Interest Date", "",
                     self.acc[11], "N", None, None, None, ("efld", )),
                    (("T", 0, seq + 10, 0), "INA", 4, "Best Account Code", "",
                     self.acc[12], "N", None, None, None, ("efld", )),
                    (("T", 0, seq + 11, 0), "IUI", 2, "Best Account Type", "",
                     self.acc[13], "N", None, None, None, ("efld", )),
                    (("T", 0, seq + 12, 0), "INA", 20, "Payslip Template", "",
                     self.acc[14], "N", self.doTplNam, tpm, None, ("efld", )),
                    (("T", 0, seq + 13, 0), "ITX", 50, "Email Address", "",
                     self.acc[15], "N", None, None, None, ("email", ))])
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 1), ("T", 0, 0)),
               ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)
        if not self.new:
            s = 0
            for n, f in enumerate(self.acc[1:-1]):
                if not self.genleg and not n:
                    continue
                self.df.loadEntry("T", 0, s, data=f)
                s += 1
                if n == 0:
                    for c in self.ctl:
                        self.df.loadEntry("T", 0, s, data=c[2])
                        s += 1
                        self.df.loadEntry("T", 0, s, data=self.getDes(c[2]))
                        s += 1
            self.df.focusField("T", 0, 1, clr=False)

    def doHrs(self, frt, pag, r, c, p, i, w):
        mhrs = round(w * 4.33333, 5)
        self.df.loadEntry(frt, pag, p + 1, data=mhrs)

    def doGlint(self, frt, pag, r, c, p, i, w):
        if w == "N":
            for x in range(1, 7):
                self.df.loadEntry(frt, pag, p + x, data="")
            return "sk6"

    def doGenAcc(self, frt, pag, r, c, p, i, w):
        des = self.getDes(w)
        if not des:
            return "Invalid Account Number"
        self.df.loadEntry(frt, pag, p + 1, data=des)

    def getDes(self, acno):
        acc = self.sql.getRec("genmst",
                              cols=["glm_desc"],
                              where=[("glm_cono", "=", self.opts["conum"]),
                                     ("glm_acno", "=", acno)],
                              limit=1)
        if acc:
            return acc[0]
        else:
            return ""

    def doTplNam(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("tplmst",
                              where=[("tpm_tname", "=", w),
                                     ("tpm_type", "=", "P"),
                                     ("tpm_system", "=", "WAG")],
                              limit=1)
        if not acc:
            return "Invalid Template Name"

    def doEnd(self):
        data = [self.opts["conum"]]
        if not self.genleg:
            data.append("N")
        for x, d in enumerate(self.df.t_work[0][0]):
            if self.genleg and x < 7:
                if x in (1, 3, 5):
                    y = int((x - 1) / 2)
                    chk = self.sql.getRec("ctlctl",
                                          where=[("ctl_cono", "=",
                                                  self.opts["conum"]),
                                                 ("ctl_code", "=",
                                                  self.ctl[y][0])],
                                          limit=1)
                    if chk:
                        self.sql.updRec("ctlctl",
                                        cols=["ctl_conacc"],
                                        data=[d],
                                        where=[("ctl_cono", "=",
                                                self.opts["conum"]),
                                               ("ctl_code", "=",
                                                self.ctl[y][0])])
                    else:
                        self.sql.insRec("ctlctl",
                                        data=[
                                            self.opts["conum"], self.ctl[y][0],
                                            self.ctl[y][1], d, "", "N", "N"
                                        ])
                elif x in (2, 4, 6):
                    continue
                else:
                    data.append(d)
            else:
                data.append(d)
        if self.new:
            self.sql.insRec("wagctl", data=data)
        elif data != self.acc[:len(data)]:
            col = self.sql.wagctl_col
            data.append(self.acc[col.index("ctw_xflag")])
            self.sql.updRec("wagctl",
                            data=data,
                            where=[("ctw_cono", "=", self.opts["conum"])])
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.acc):
                if dat != data[num]:
                    self.sql.insRec("chglog",
                                    data=[
                                        "wagctl", "U",
                                        "%03i" % self.opts["conum"], col[num],
                                        dte, self.opts["capnm"],
                                        str(dat),
                                        str(data[num]), "", 0
                                    ])
        self.opts["mf"].dbm.commitDbase()
        self.doExit()

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #20
0
class rc1010(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       ["ctlmst", "rcaowm", "rcaowt", "chglog"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        self.gc = GetCtl(self.opts["mf"])
        ctlmst = self.gc.getCtl("ctlmst", self.opts["conum"])
        if not ctlmst:
            return
        self.taxdf = ctlmst["ctm_taxdf"]
        return True

    def mainProcess(self):
        own = {
            "stype":
            "R",
            "tables": ("rcaowm", ),
            "cols":
            (("rom_acno", "", 0, "Acc-Num"), ("rom_name", "", 0, "Name", "Y")),
            "where": [("rom_cono", "=", self.opts["conum"])]
        }
        self.fld = ((("T", 0, 0, 0), "INA", 7, "Account Number", "", "", "Y",
                     self.doOwner, own, None, ("notblank", )),
                    (("T", 0, 1, 0), "INA", 30, "Name", "", "", "N", None,
                     None, self.doDelete, ("notblank", )),
                    (("T", 0, 2, 0), "INA", 30, "Address Line 1", "", "", "N",
                     None, None, None, ("notblank", )),
                    (("T", 0, 3, 0), "INA", 30, "Address Line 2", "", "", "N",
                     None, None, None,
                     ("efld", )), (("T", 0, 4, 0), "INA", 30, "Address Line 3",
                                   "", "", "N", None, None, None, ("efld", )),
                    (("T", 0, 5, 0), "INA", 4, "Postal Code", "PCod", "", "N",
                     None, None, None, ("notblank", )),
                    (("T", 0, 6, 0), "INA", 20, "Home Number", "", "", "N",
                     None, None, None,
                     ("efld", )), (("T", 0, 7, 0), "INA", 20, "Office Number",
                                   "", "", "N", None, None, None, ("efld", )),
                    (("T", 0, 8, 0), "INA", 20, "Mobile Number", "", "", "N",
                     None, None, None,
                     ("efld", )), (("T", 0, 9, 0), "INA", 20, "Fax Number", "",
                                   "", "N", None, None, None, ("efld", )),
                    (("T", 0, 10, 0), "ITX", 50, "E-Mail Address", "", "", "N",
                     None, None, None, ("email", )),
                    (("T", 0, 11, 0), "INA", 10, "VAT Number",
                     "VAT-Number", "", "N", None, None, None,
                     ("efld", )), (("T", 0, 12, 0), "IUA", 1, "VAT Default",
                                   "V", "", "N", None, None, None, ("efld", )),
                    (("T", 0, 13, 0), "INA", 20, "Bank Name", "Bank-Name", "",
                     "N", None, None, None,
                     ("efld", )), (("T", 0, 14, 0), "IUI", 8, "Bank Branch",
                                   "Bank-IBT", "", "N", None, None, None,
                                   ("efld", )), (("T", 0, 15, 0), "INA", 16,
                                                 "Bank Account",
                                                 "Bank-Account-Num", "", "N",
                                                 None, None, None, ("efld", )))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doOwner(self, frt, pag, r, c, p, i, w):
        self.acno = w
        self.oldm = self.sql.getRec("rcaowm",
                                    where=[("rom_cono", "=",
                                            self.opts["conum"]),
                                           ("rom_acno", "=", self.acno)],
                                    limit=1)
        if not self.oldm:
            self.new = "y"
            for num in range(2, self.df.topq[0]):
                self.df.clearEntry(frt, pag, num + 1)
        else:
            self.new = "n"
            for num, fld in enumerate(self.oldm[1:-1]):
                self.df.loadEntry(frt, pag, p + num, data=fld)
            trn = self.sql.getRec("rcaowt",
                                  cols=["count(*)"],
                                  where=[("rot_cono", "=", self.opts["conum"]),
                                         ("rot_acno", "=", self.acno)],
                                  limit=1)
            if trn[0]:
                self.trn = True
            else:
                self.trn = False

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

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

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

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

    def doVatNum(self, frt, pag, r, c, p, i, w):
        if self.new == "n" and self.trn:
            return "sk1"

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

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

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

    def doAmount(self, frt, pag, r, c, p, i, w):
        if self.new == "y":
            self.df.loadEntry(frt, pag, p + 1, data="C")

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

    def doDelete(self):
        if self.trn:
            return "Transactions Exist, Not Deleted"
        self.sql.delRec("rcaowm",
                        where=[("rom_cono", "=", self.opts["conum"]),
                               ("rom_acno", "=", self.acno)])
        dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
        self.sql.insRec("chglog", data=["rcaowm", "D", "%03i%-7s" % \
            (self.opts["conum"], self.acno), "", dte, self.opts["capnm"],
            "", "", "", 0])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        datm = [self.opts["conum"]]
        for num, fld in enumerate(self.df.t_work[0][0]):
            datm.append(fld)
        if self.new == "y":
            self.sql.insRec("rcaowm", data=datm)
        elif datm != self.oldm[:len(datm)]:
            col = self.sql.rcaowm_col
            datm.append(self.oldm[col.index("rom_xflag")])
            self.sql.updRec("rcaowm",
                            data=datm,
                            where=[("rom_cono", "=", self.opts["conum"]),
                                   ("rom_acno", "=", self.acno)])
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.oldm):
                if dat != datm[num]:
                    self.sql.insRec(
                        "chglog",
                        data=[
                            "rcaowm", "U",
                            "%03i%-7s" % (self.opts["conum"], self.acno),
                            col[num], dte, self.opts["capnm"],
                            str(dat),
                            str(datm[num]), "", 0
                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #21
0
class crc110(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.drawDialog()
            self.opts["mf"].startLoop()

    def setVariables(self):
        gc = GetCtl(self.opts["mf"])
        ctlmst = gc.getCtl("ctlmst", self.opts["conum"])
        if not ctlmst:
            return
        mods = ctlmst["ctm_modules"]
        self.genleg = False
        for x in range(0, len(mods), 2):
            if mods[x:x + 2] == "GL":
                self.genleg = True
                break
        tabs = ["crsctl", "tplmst", "chglog"]
        if self.genleg:
            tabs.extend(["ctlctl", "genmst"])
        self.sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__)
        if self.sql.error:
            return
        self.acc = self.sql.getRec("crsctl", where=[("ctc_cono", "=",
            self.opts["conum"])], limit=1)
        if not self.acc:
            self.new = True
            self.acc = [self.opts["conum"], "N", "E", "", 0, 0,
                "remittance_advice", "", ""]
        else:
            self.new = False
        if self.genleg:
            self.ctl = [
                ["crs_ctl", "Creditors Control", 0],
                ["dis_rec", "Discount Received", 0]]
            ctlctl = gc.getCtl("ctlctl", self.opts["conum"])
            if not ctlctl:
                return
            for num, ctl in enumerate(self.ctl):
                if ctl[0] in ctlctl:
                    self.ctl[num][2] = ctlctl[ctl[0]]
        return True

    def drawDialog(self):
        ctl = {
            "stype": "R",
            "tables": ("ctlctl", "genmst"),
            "cols": (
                ("ctl_code", "", 0, "Ctl-Code"),
                ("ctl_conacc", "", 0, "G/L-Num"),
                ("glm_desc", "", 30, "Description")),
            "where": [
                ("ctl_cono", "=", self.opts["conum"]),
                ("ctl_code", "like", "bank_%"),
                ("glm_cono=ctl_cono",),
                ("glm_acno=ctl_conacc",)],
            "index": 1}
        tpm = {
            "stype": "R",
            "tables": ("tplmst",),
            "cols": (
                ("tpm_tname", "", 0, "Template"),
                ("tpm_title", "", 0, "Title"),
                ("tpm_type", "", 0, "T")),
            "where": [
                ("tpm_type", "=", "R"),
                ("tpm_system", "=", "CRS")],
            "order": "tpm_tname"}
        r1s = (("Yes","Y"),("No","N"))
        r2s = (("Exclusive","E"),("Inclusive","I"))
        if self.genleg:
            glm = {
                "stype": "R",
                "tables": ("genmst",),
                "cols": (
                    ("glm_acno", "", 0, "G/L-Num"),
                    ("glm_desc", "", 30, "Description")),
                "where": [
                    ("glm_cono", "=", self.opts["conum"])]}
            fld = [
                (("T",0,0,0),("IRB",r1s),0,"G/L Integration","",
                    self.acc[1],"N",self.doGlint,None,None,None),
                (("T",0,1,0),"IUI",7,self.ctl[0][1],"",
                    self.ctl[0][2],"N",self.doGenAcc,glm,None,("efld",)),
                (("T",0,1,0),"ONA",30,""),
                (("T",0,2,0),"IUI",7,self.ctl[1][1],"",
                    self.ctl[1][2],"N",self.doGenAcc,glm,None,("efld",)),
                (("T",0,2,0),"ONA",30,""),
                (("T",0,3,0),("IRB",r2s),0,"G/L Input Method","",
                    self.acc[2],"N",None,None,None,None),
                (("T",0,4,0),"INA",4,"Best Account Code","Best",
                    self.acc[3],"N",self.doBestAcc,None,None,("efld",)),
                (("T",0,5,0),"IUI",2,"Best Account Type","BT",
                    self.acc[4],"N",None,None,None,("efld",)),
                (("T",0,6,0),"IUI",7,"Bank Account Code","Bank-Ac",
                    self.acc[5],"N",self.doBankAcc,ctl,None,("efld",))]
            seq = 7
        else:
            fld = []
            seq = 0
        fld.extend([
            (("T",0,seq,0),"INA",20,"Remittance Template","",
                self.acc[6],"N",self.doTplNam,tpm,None,("efld",)),
            (("T",0,seq + 1,0),"ITX",50,"Email Address","",
                self.acc[7],"N",None,None,None,("email",))])
        but = (
            ("Accept",None,self.doAccept,0,("T",0,1),("T",0,0)),
            ("Quit",None,self.doExit,1,None,None))
        tnd = ((self.doEnd,"Y"),)
        txt = (self.doExit,)
        self.df = TartanDialog(self.opts["mf"], eflds=fld,
            butt=but, tend=tnd, txit=txt)
        if not self.new:
            s = 0
            for n, f in enumerate(self.acc[1:-1]):
                if not self.genleg and n < 5:
                    continue
                self.df.loadEntry("T", 0, s, data=f)
                s += 1
                if not n:
                    for c in self.ctl:
                        self.df.loadEntry("T", 0, s, data=c[2])
                        s += 1
                        self.df.loadEntry("T", 0, s, data=self.getDes(c[2]))
                        s += 1
            self.df.focusField("T", 0, 1, clr=False)

    def doGlint(self, frt, pag, r, c, p, i, w):
        self.glint = w
        if self.glint == "N":
            for x in range(1, 5):
                self.df.loadEntry(frt, pag, p+x, data="")
            self.df.loadEntry(frt, pag, p+5, data="E")
            return "sk5"

    def doGenAcc(self, frt, pag, r, c, p, i, w):
        des = self.getDes(w)
        if not des:
            return "Invalid Account Number"
        self.df.loadEntry(frt, pag, p+1, data=des)

    def getDes(self, acno):
        acc = self.sql.getRec("genmst", cols=["glm_desc"],
            where=[("glm_cono", "=", self.opts["conum"]),
            ("glm_acno", "=", acno)], limit=1)
        if acc:
            return acc[0]
        else:
            return ""

    def doBestAcc(self, frt, pag, r, c, p, i, w):
        if not w or self.glint == "N":
            self.df.loadEntry(frt, pag, p+1, data="")
            self.df.loadEntry(frt, pag, p+2, data=0)
            return "sk2"

    def doBankAcc(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec(tables=["genmst", "ctlctl"], cols=["glm_desc"],
            where=[("glm_cono", "=", self.opts["conum"]), ("glm_acno", "=", w),
                ("ctl_code", "like", "bank_%"), ("ctl_cono=glm_cono",),
                ("ctl_conacc=glm_acno",)], limit=1)
        if not acc:
            return "Invalid Bank Account"

    def doTplNam(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("tplmst", where=[("tpm_tname", "=", w),
            ("tpm_type", "=", "R"), ("tpm_system", "=", "CRS")], limit=1)
        if not acc:
            return "Invalid Template"

    def doEnd(self):
        data = [self.opts["conum"]]
        if not self.genleg:
            data.extend(["N", "E", "", 0, 0])
        for x, d in enumerate(self.df.t_work[0][0]):
            if self.genleg and x < 9:
                if x in (1, 3):
                    y = int((x - 1) / 2)
                    chk = self.sql.getRec("ctlctl", where=[("ctl_cono",
                        "=", self.opts["conum"]), ("ctl_code", "=",
                        self.ctl[y][0])], limit=1)
                    if chk:
                        self.sql.updRec("ctlctl", cols=["ctl_conacc"], data=[d],
                            where=[("ctl_cono", "=", self.opts["conum"]),
                            ("ctl_code", "=", self.ctl[y][0])])
                    else:
                        self.sql.insRec("ctlctl", data=[self.opts["conum"],
                            self.ctl[y][0], self.ctl[y][1], d, "", "N", "N"])
                elif x in (2, 4):
                    continue
                else:
                    data.append(d)
            else:
                data.append(d)
        if self.new:
            self.sql.insRec("crsctl", data=data)
        elif data != self.acc[:len(data)]:
            col = self.sql.crsctl_col
            data.append(self.acc[col.index("ctc_xflag")])
            self.sql.updRec("crsctl", data=data, where=[("ctc_cono", "=",
                self.opts["conum"])])
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.acc):
                if dat != data[num]:
                    self.sql.insRec("chglog", data=["crsctl", "U",
                        "%03i" % self.opts["conum"], col[num], dte,
                        self.opts["capnm"], str(dat), str(data[num]),
                        "", 0])
        self.opts["mf"].dbm.commitDbase()
        self.doExit()

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col+1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #22
0
class stc310(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm, ["ctlvmf", "genmst", "strmf1",
            "strgrp", "strgmu"], prog=self.__class__.__name__)
        if self.sql.error:
            return
        gc = GetCtl(self.opts["mf"])
        strctl = gc.getCtl("strctl", self.opts["conum"])
        if not strctl:
            return
        self.glint = strctl["cts_glint"]
        self.plevs = strctl["cts_plevs"]
        self.automu = strctl["cts_automu"]
        return True

    def mainProcess(self):
        gpm = {
            "stype": "R",
            "tables": ("strgrp",),
            "cols": (
                ("gpm_group", "", 0, "Grp"),
                ("gpm_desc", "", 0, "Description", "Y")),
            "where": [("gpm_cono", "=", self.opts["conum"])]}
        vtm = {
            "stype": "R",
            "tables": ("ctlvmf",),
            "cols": (
                ("vtm_code", "", 0, "C"),
                ("vtm_desc", "", 0, "Description", "Y")),
            "where": [("vtm_cono", "=", self.opts["conum"])]}
        glm = {
            "stype": "R",
            "tables": ("genmst",),
            "cols": (
                ("glm_acno", "", 0, "Acc-Num"),
                ("glm_desc", "", 0, "Description", "Y")),
            "where": [("glm_cono", "=", self.opts["conum"])]}
        self.fld = [
            (("T",0,0,0),"IUA",3,"Product Group","",
                "","N",self.doGroup,gpm,None,("notblank",)),
            (("T",0,1,0),"INA",30,"Description","",
                "","N",None,None,self.doDelete,("notblank",)),
            (("T",0,2,0),"IUA",1,"Vat Code","",
                "","N",self.doVat,vtm,None,("notblank",))]
        row = 3
        if self.glint == "Y":
            self.fld.append((("T",0,3,0),"IUI",7,"Sales Account","",
                "","N",self.doSales,glm,None,("notzero",)))
            self.fld.append((("T",0,3,0),"ONA",30,""))
            self.fld.append((("T",0,4,0),"IUI",7,"COS Account","",
                "","N",self.doCos,glm,None,("notzero",)))
            self.fld.append((("T",0,4,0),"ONA",30,""))
            row = 5
        if self.automu in ("A", "L"):
            self.fld.append((("T",0,row,0),"IUD",5.1,"Mark-Up    Lv1","",
                "","N",None,None,None,("efld",)))
            if self.plevs > 1:
                for x in range(1, self.plevs):
                    self.fld.append((("T",0,row,0),"IUD",5.1,"Lv%s" % (x+1),"",
                        "","N",None,None,None,("efld",)))
        but = (
            ("Accept",None,self.doAccept,0,("T",0,2),("T",0,0)),
            ("Cancel",None,self.doCancel,0,("T",0,2),("T",0,0)))
        tnd = ((self.doEnd,"Y"), )
        txt = (self.doCloseProcess, )
        self.df = TartanDialog(self.opts["mf"], eflds=self.fld,
            butt=but, tend=tnd, txit=txt)

    def doGroup(self, frt, pag, r, c, p, i, w):
        self.group = w
        self.acc = self.sql.getRec("strgrp", where=[("gpm_cono", "=",
            self.opts["conum"]), ("gpm_group", "=", self.group)], limit=1)
        if not self.acc:
            self.new = "Y"
        else:
            self.new = "N"
            col = self.sql.strgrp_col
            self.df.loadEntry(frt, pag, p+1,
                    data=self.acc[col.index("gpm_desc")])
            self.df.loadEntry(frt, pag, p+2,
                    data=self.acc[col.index("gpm_vatcode")])
            p = 3
            if self.glint == "Y":
                self.df.loadEntry(frt, pag, p,
                        data=self.acc[col.index("gpm_sales")])
                des = self.getGenDesc(self.acc[col.index("gpm_sales")])
                if not des:
                    self.df.loadEntry(frt, pag, p+1,
                            data="Invalid Sales Code")
                else:
                    self.df.loadEntry(frt, pag, p+1,
                            data=des[0])
                self.df.loadEntry(frt, pag, p+2,
                        data=self.acc[col.index("gpm_costs")])
                des = self.getGenDesc(self.acc[col.index("gpm_costs")])
                if not des:
                    self.df.loadEntry(frt, pag, p+3,
                            data="Invalid Costs Code")
                else:
                    self.df.loadEntry(frt, pag, p+3,
                            data=des[0])
                p = 7
            if self.automu in ("A", "L"):
                for lev in range(self.plevs):
                    mup = self.sql.getRec("strgmu", cols=["smg_markup"],
                        where=[("smg_cono", "=", self.opts["conum"]),
                        ("smg_group", "=", self.group), ("smg_level",
                        "=", lev + 1)], limit=1)
                    if not mup:
                        mup = [0]
                    self.df.loadEntry(frt, pag, p+lev, data=mup[0])

    def doVat(self, frt, pag, r, c, p, i, w):
        vat = self.sql.getRec("ctlvmf", cols=["vtm_desc"],
            where=[("vtm_cono", "=", self.opts["conum"]), ("vtm_code", "=",
            w)], limit=1)
        if not vat:
            return "Invalid VAT Code"
        self.code = w

    def doSales(self, frt, pag, r, c, p, i, w):
        acc = self.getGenDesc(w)
        if not acc:
            return "Invalid Sales Code"
        self.sales = w
        self.df.loadEntry("T", 0, 4, data=acc[0])

    def doCos(self, frt, pag, r, c, p, i, w):
        acc = self.getGenDesc(w)
        if not acc:
            return "Invalid COS Code"
        self.cos = w
        self.df.loadEntry("T", 0, 6, data=acc[0])

    def doDelete(self):
        st1 = self.sql.getRec("strmf1", cols=["count(*)"],
            where=[("st1_cono", "=", self.opts["conum"]), ("st1_group", "=",
            self.group)], limit=1)
        if st1[0]:
            return "Records Exist for this Group, Not Deleted"
        self.sql.delRec("strgrp", where=[("gpm_cono", "=", self.opts["conum"]),
            ("gpm_group", "=", self.group)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        data = [self.opts["conum"]]
        for x in range(0, len(self.df.t_work[0][0])):
            if x == 7:
                break
            if self.glint == "Y":
                # Account Names
                if x in (4, 6):
                    continue
            elif x == 3:
                data.append(0)
                data.append(0)
                break
            data.append(self.df.t_work[0][0][x])
        if self.new == "Y":
            self.sql.insRec("strgrp", data=data)
        elif data != self.acc[:len(data)]:
            col = self.sql.strgrp_col
            data.append(self.acc[col.index("gpm_xflag")])
            self.sql.updRec("strgrp", data=data, where=[("gpm_cono",
                "=", self.opts["conum"]), ("gpm_group", "=", self.group)])
        self.sql.delRec("strgmu", where=[("smg_cono", "=", self.opts["conum"]),
            ("smg_group", "=", self.group)])
        if self.automu in ("A", "L"):
            for lvl, mup in enumerate(self.df.t_work[0][0][x:]):
                if not mup:
                    continue
                self.sql.insRec("strgmu", data=[self.opts["conum"],
                    self.group, lvl + 1, mup])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col+1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def getGenDesc(self, acno):
        return self.sql.getRec("genmst", cols=["glm_desc"],
            where=[("glm_cono", "=", self.opts["conum"]), ("glm_acno", "=",
            acno)], limit=1)

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doCloseProcess(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #23
0
class rtc210(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       ["chglog", "genmst", "rtlprm", "rtlmst"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        gc = GetCtl(self.opts["mf"])
        rtlctl = gc.getCtl("rtlctl", self.opts["conum"])
        if not rtlctl:
            return
        self.glint = rtlctl["ctr_glint"]
        return True

    def mainProcess(self):
        prm = {
            "stype":
            "R",
            "tables": ("rtlprm", ),
            "cols": (("rtp_code", "", 0, "Prm-Code"), ("rtp_desc", "", 0,
                                                       "Description", "Y")),
            "where": [("rtp_cono", "=", self.opts["conum"])]
        }
        glm = {
            "stype":
            "R",
            "tables": ("genmst", ),
            "cols": (("glm_acno", "", 0, "Acc-Num"), ("glm_desc", "", 0,
                                                      "Description", "Y")),
            "where": [("glm_cono", "=", self.opts["conum"])],
            "order":
            "glm_acno"
        }
        self.fld = [(("T", 0, 0, 0), "INA", 7, "Premises Code", "Premises", "",
                     "N", self.doPrmCod, prm, None, ("notblank", )),
                    (("T", 0, 1, 0), "INA", 30, "Description", "", "", "N",
                     None, None, self.doDelete, ("notblank", )),
                    (("T", 0, 2, 0), "INA", 30, "Address Line 1", "", "", "N",
                     None, None, None, ("notblank", )),
                    (("T", 0, 3, 0), "INA", 30, "Address Line 2", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, 4, 0), "INA", 30, "Address Line 3", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, 5, 0), "INA", 4, "Postal Code", "PCod", "", "N",
                     None, None, None, ("notblank", ))]
        if self.glint == "Y":
            self.fld.append(
                (("T", 0, 6, 0), "IUI", 7, "Rental Account", "", "", "N",
                 self.doRental, glm, None, ("notzero", ), None,
                 "Rental Control Account in the General Ledger."))
            self.fld.append((("T", 0, 6, 0), "ONA", 30, ""))
            self.fld.append(
                (("T", 0, 7, 0), "IUI", 7, "Income Account", "", "", "N",
                 self.doIncome, glm, None, ("notzero", ), None,
                 "Rental Income Account in the General Ledger."))
            self.fld.append((("T", 0, 7, 0), "ONA", 30, ""))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doPrmCod(self, frt, pag, r, c, p, i, w):
        self.code = w
        self.old = self.sql.getRec("rtlprm",
                                   where=[("rtp_cono", "=",
                                           self.opts["conum"]),
                                          ("rtp_code", "=", self.code)],
                                   limit=1)
        if not self.old:
            self.new = "y"
        else:
            self.new = "n"
            acc = copyList(self.old[:-1])
            acc.append("")
            acc.insert(8, "")
            for x in range(0, self.df.topq[pag]):
                self.df.loadEntry(frt, pag, p + x, data=acc[x + 1])
            if self.glint == "N":
                return
            des = self.sql.getRec("genmst",
                                  cols=["glm_desc"],
                                  where=[("glm_cono", "=", self.opts["conum"]),
                                         ("glm_acno", "=", acc[7])],
                                  limit=1)
            if des:
                self.df.loadEntry("T", 0, 7, data=des[0])
            des = self.sql.getRec("genmst",
                                  cols=["glm_desc"],
                                  where=[("glm_cono", "=", self.opts["conum"]),
                                         ("glm_acno", "=", acc[9])],
                                  limit=1)
            if des:
                self.df.loadEntry("T", 0, 9, data=des[0])

    def doRental(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("genmst",
                              cols=["glm_desc"],
                              where=[("glm_cono", "=", self.opts["conum"]),
                                     ("glm_acno", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid G/L Account"
        self.df.loadEntry("T", 0, 7, data=acc[0])

    def doIncome(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("genmst",
                              cols=["glm_desc"],
                              where=[("glm_cono", "=", self.opts["conum"]),
                                     ("glm_acno", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid G/L Account"
        self.df.loadEntry("T", 0, 9, data=acc[0])

    def doDelete(self):
        mst = self.sql.getRec("rtlmst",
                              cols=["count(*)"],
                              where=[("rtm_cono", "=", self.opts["conum"]),
                                     ("rtm_code", "=", self.code)],
                              limit=1)
        if mst[0]:
            return "Accounts Exist, Not Deleted"
        self.sql.delRec("rtlprm",
                        where=[("rtp_cono", "=", self.opts["conum"]),
                               ("rtp_code", "=", self.code)])
        dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
        self.sql.insRec("chglog",
                        data=[
                            "rtlprm", "D",
                            "%03i%-7s" % (self.opts["conum"], self.code), "",
                            dte, self.opts["capnm"], "", "", "", 0
                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        data = [self.opts["conum"]]
        for x in range(0, len(self.df.t_work[0][0])):
            if self.glint == "Y" and x in (7, 9):
                continue
            data.append(self.df.t_work[0][0][x])
        if self.glint == "N":
            data.extend([0, 0])
        if self.new == "y":
            self.sql.insRec("rtlprm", data=data)
        elif data != self.old[:len(data)]:
            col = self.sql.rtlprm_col
            data.append(self.old[col.index("rtp_xflag")])
            self.sql.updRec("rtlprm",
                            data=data,
                            where=[("rtp_cono", "=", self.opts["conum"]),
                                   ("rtp_code", "=", self.code)])
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.old):
                if dat != data[num]:
                    self.sql.insRec(
                        "chglog",
                        data=[
                            "rtlprm", "U",
                            "%03i%-7s" % (self.opts["conum"], self.code),
                            col[num], dte, self.opts["capnm"],
                            str(dat),
                            str(data[num]), "", 0
                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #24
0
class msc110(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.drawDialog()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       ["ctlsys", "ctlpwu", "chglog", "genmst"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            if self.sql.error == ["genmst"]:
                self.gl = False
            else:
                return
        else:
            self.gl = True
        self.acc = self.sql.getRec("ctlsys", limit=1)
        if not self.acc:
            self.new = True
            self.acc = [
                0, "N", 0, 0, 0, "", 0, 0, 0, "", "", "N", "", "", "N", 0
            ]
        else:
            self.new = False
        return True

    def drawDialog(self):
        r1s = (("Yes", "Y"), ("No", "N"))
        r2s = (("None", "0"), ("STARTTLS", "1"), ("SSL/TLS", "2"))
        r3s = (("None", "0"), ("Normal", "1"), ("Encrypted", "2"))
        self.fld = (
            (("T",0,0,0),"IUI",2,"Years to Keep History","",
                self.acc[0],"N",self.doHist,None,None,None,None,
                "The number of years that historical data must be kept, "\
                "Use 0 for No Limit"),
            (("T",0,1,0),("IRB",r1s),0,"Enforce Passwords","",
                self.acc[1],"N",self.doMust,None,None,None),
            (("T",0,2,0),"IUI",2,"Minimum Characters","",
                self.acc[2],"N",None,None,None,None),
            (("T",0,3,0),"IUI",2,"Maximum Life (Days)","",
                self.acc[3],"N",None,None,None,None),
            (("T",0,4,0),"IUI",3,"Backup History (Days)","",
                self.acc[4],"N",None,None,None,None,None,
                "0 for No Limit"),
            (("T",0,5,0),"ITX",30,"SMTP Server","",
                self.acc[5],"N",self.doSmtp,None,None,None),
            (("T",0,6,0),("IRB",r2s),0,"SMTP Security","",
                self.acc[6],"N",None,None,None,None),
            (("T",0,7,0),("IRB",r3s),0,"SMTP Authentication","",
                self.acc[7],"N",self.doAuth,None,None,None),
            (("T",0,8,0),"IUI",4,"SMTP Port","",
                self.acc[8],"N",None,None,None,None),
            (("T",0,9,0),"ITX",20,"SMTP Username","",
                self.acc[9],"N",self.doUsr,None,None,None),
            (("T",0,10,0),"IHA",20,"SMTP Password","",
                self.acc[10],"N",None,None,None,None),
            (("T",0,11,0),("IRB",r1s),0,"SMS Service","",
                self.acc[11],"N",self.doSms,None,None,None),
            (("T",0,12,0),"ITX",20,"SMS Username","",
                self.acc[12],"N",self.doSmsUsr,None,None,None),
            (("T",0,13,0),"IHA",20,"SMS Password","",
                self.acc[13],"N",self.doSmsPwd,None,None,None),
            (("T",0,14,0),("IRB",r1s),0,"G/L Departments","",
                self.acc[14],"N",self.doGlDept,None,None,None,None,
                "G/L Account Numbers include Department Numbers"),
            (("T",0,15,0),"IUI",1,"Number of Digits","",
                self.acc[15],"N",None,None,None,None,None,
                "The Number of Digits used for Department Numbers"))
        but = (("Accept", None, self.doAccept, 0, (("T", 0, 1), ("T", 0, 6)),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt,
                               focus=False)
        for n, f in enumerate(self.acc):
            self.df.loadEntry("T", 0, n, data=f)
        self.df.focusField("T", 0, 1, clr=False)

    def doHist(self, frt, pag, r, c, p, i, w):
        if w and w < 5:
            return "At least 5 Years of History should be kept"

    def doMust(self, frt, pag, r, c, p, i, w):
        if w == "N":
            self.df.loadEntry(frt, pag, p + 1, data=0)
            self.df.loadEntry(frt, pag, p + 2, data=0)
            return "sk2"

    def doSmtp(self, frt, pag, r, c, p, i, w):
        if not w:
            self.df.loadEntry(frt, pag, p + 1, data="0")
            self.df.loadEntry(frt, pag, p + 2, data="0")
            self.df.loadEntry(frt, pag, p + 3, data="")
            self.df.loadEntry(frt, pag, p + 4, data="")
            self.df.loadEntry(frt, pag, p + 5, data="")
            return "sk5"

    def doAuth(self, frt, pag, r, c, p, i, w):
        if not int(w):
            self.df.loadEntry(frt, pag, p + 1, 25)
            self.df.loadEntry(frt, pag, p + 2, "")
            self.df.loadEntry(frt, pag, p + 3, "")
            return "sk3"
        elif int(self.df.t_work[0][0][6]) == 1:
            self.df.loadEntry(frt, pag, p + 1, 587)
        elif int(self.df.t_work[0][0][6]) == 2:
            self.df.loadEntry(frt, pag, p + 1, 465)

    def doUsr(self, frt, pag, r, c, p, i, w):
        if not w:
            return "Invalid SMTP Name"

    def doSms(self, frt, pag, r, c, p, i, w):
        if w == "Y" and not chkMod("requests"):
            showError(self.opts["mf"].body, "Error", "Missing requests Module")
            w = "N"
            self.df.loadEntry(frt, pag, p, data=w)
        if w == "N":
            self.df.loadEntry(frt, pag, p + 1, data="")
            self.df.loadEntry(frt, pag, p + 2, data="")
            if not self.gl:
                self.df.loadEntry(frt, pag, p + 3, data="N")
                self.df.loadEntry(frt, pag, p + 4, data=0)
                return "sk4"
            return "sk2"

    def doSmsUsr(self, frt, pag, r, c, p, i, w):
        if not w:
            return "Invalid SMS User Name"

    def doSmsPwd(self, frt, pag, r, c, p, i, w):
        if not w:
            return "Invalid SMS Password"

    def doGlDept(self, frt, pag, r, c, p, i, w):
        if w == "N":
            self.df.loadEntry(frt, pag, p + 1, data=0)
            return "sk1"

    def doEnd(self):
        svr = self.df.t_work[0][0][5]
        if svr:
            prt = self.df.t_work[0][0][8]
            sec = self.df.t_work[0][0][6]
            aut = self.df.t_work[0][0][7]
            nam = self.df.t_work[0][0][9]
            pwd = self.df.t_work[0][0][10]
            chk = sendMail([svr, prt, sec, aut, nam, pwd],
                           "",
                           "",
                           "",
                           check=True,
                           err=self.opts["mf"].body,
                           wrkdir=self.opts["mf"].rcdic["wrkdir"])
            if not chk:
                self.df.focusField("T", 0, 6)
                return
        tme = time.localtime()
        data = copyList(self.df.t_work[0][0])
        if self.new:
            self.sql.insRec("ctlsys", data=data)
        elif data != self.acc[:len(data)]:
            self.sql.updRec("ctlsys", data=data)
            dte = int("%04i%02i%02i%02i%02i%02i" % tme[:-3])
            for num, dat in enumerate(self.acc):
                if dat != data[num]:
                    self.sql.insRec("chglog",
                                    data=[
                                        "ctlsys", "U",
                                        "%03i" % 0, self.sql.ctlsys_col[num],
                                        dte, self.opts["capnm"],
                                        str(dat),
                                        str(data[num]), "", 0
                                    ])
        # Reset all password dates to current date (Temporary Fix)
        dte = (tme[0] * 10000) + (tme[1] * 100) + tme[2]
        self.sql.updRec("ctlpwu", cols=["usr_last"], data=[dte])
        self.opts["mf"].dbm.commitDbase()
        self.doExit()

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #25
0
class ms1020(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       ["ctlsys", "ctlmst", "ctldep", "genmst", "wagmst"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        gc = GetCtl(self.opts["mf"])
        ctlsys = gc.getCtl("ctlsys")
        if not ctlsys:
            return
        dept = ctlsys["sys_gl_dep"]
        ctlmst = gc.getCtl("ctlmst", self.opts["conum"])
        if not ctlmst:
            return
        self.glint = "N"
        for x in range(0, len(ctlmst["ctm_modules"].rstrip()), 2):
            if ctlmst["ctm_modules"][x:x + 2] in ("SL", "WG"):
                dept = "Y"
                wagctl = gc.getCtl("wagctl", self.opts["conum"])
                if not wagctl:
                    self.glint = "N"
                else:
                    self.glint = wagctl["ctw_glint"]
                break
        if dept == "N":
            showError(self.opts["mf"].body, "Error",
                      "Departments have Not been Enabled")
            return
        if self.glint == "N":
            self.co1 = 0
            self.sy1 = 0
            self.cm1 = 0
            self.co2 = 0
            self.sy2 = 0
            self.cm2 = 0
        else:
            self.coys = self.sql.getRec("ctlmst", cols=["count(*)"],
                                        limit=1)[0]
        return True

    def mainProcess(self):
        dep = {
            "stype": "R",
            "tables": ("ctldep", ),
            "cols":
            (("dep_code", "", 0, "Cod"), ("dep_name", "", 0, "Name", "Y")),
            "where": [("dep_cono", "=", self.opts["conum"])]
        }
        coy = {
            "stype": "R",
            "tables": ("ctlmst", ),
            "cols":
            (("ctm_cono", "", 0, "Coy"), ("ctm_name", "", 0, "Name", "Y"))
        }
        glm = {
            "stype":
            "R",
            "tables": ("genmst", ),
            "cols": (("glm_acno", "", 0, "Acc-Num"), ("glm_desc", "", 0,
                                                      "Description", "Y")),
            "where": [("glm_cono", "=", self.opts["conum"])]
        }
        self.fld = [(("T", 0, 0, 0), "IUI", 3, "Department", "Department Code",
                     "", "N", self.doDepartment, dep, None, ("notzero", )),
                    (("T", 0, 1, 0), "INA", 30, "Name", "", "", "N",
                     self.doName, None, self.doDelete, ("notblank", ))]
        if self.glint == "Y":
            if self.coys == 1:
                self.fld.append((("T", 0, 2, 0), "OUI", 7, "Debit  Company"))
            else:
                self.fld.append(
                    (("T", 0, 2, 0), "IUI", 7, "Debit  Company", "",
                     self.opts["conum"], "N", self.doCoy, coy, None, None))
            self.fld.append((("T", 0, 2, 0), "ONA", 30, ""))
            self.fld.extend([
                (("T", 0, 3, 0), "IUI", 7, "       Salary A/C", "", "", "N",
                 self.doSal, glm, None, ("notzero", )),
                (("T", 0, 3, 0), "ONA", 30, ""),
                (("T", 0, 4, 0), "IUI", 7, "       Commission A/C", "", "",
                 "N", self.doCom, glm, None, ("efld", )),
                (("T", 0, 4, 0), "ONA", 30, "")
            ])
            if self.coys == 1:
                self.fld.append((("T", 0, 5, 0), "OUI", 7, "Credit Company"))
            else:
                self.fld.append(
                    (("T", 0, 5, 0), "IUI", 7, "Credit Company", "",
                     self.opts["conum"], "N", self.doCoy, coy, None, None))
            self.fld.append((("T", 0, 5, 0), "ONA", 30, ""))
            self.fld.extend([
                (("T", 0, 6, 0), "IUI", 7, "       Salary A/C", "", "", "N",
                 self.doSal, glm, None, ("notzero", )),
                (("T", 0, 6, 0), "ONA", 30, ""),
                (("T", 0, 7, 0), "IUI", 7, "       Commission A/C", "", "",
                 "N", self.doCom, glm, None, ("efld", )),
                (("T", 0, 7, 0), "ONA", 30, "")
            ])
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doDepartment(self, frt, pag, r, c, p, i, w):
        self.code = w
        self.old = self.sql.getRec("ctldep",
                                   where=[("dep_cono", "=",
                                           self.opts["conum"]),
                                          ("dep_code", "=", self.code)],
                                   limit=1)
        if not self.old:
            self.new = "Y"
        else:
            self.new = "N"
        self.doLoadRec(self.old)

    def doLoadRec(self, rec):
        if not rec:
            self.df.clearFrame("T", 0)
            self.df.loadEntry("T", 0, 0, data=self.code)
            return
        for num, dat in enumerate(rec[2:-1]):
            if num == 0:
                seq = 1
                self.df.loadEntry("T", 0, seq, data=dat)
                if self.glint == "N":
                    return
                seq += 1
            elif num in (1, 4):
                coy = dat
                if not coy:
                    dat = ""
                else:
                    nam = self.sql.getRec("ctlmst",
                                          cols=["ctm_name"],
                                          where=[("ctm_cono", "=", coy)],
                                          limit=1)
                    self.df.loadEntry("T", 0, seq, data=coy)
                    self.df.loadEntry("T", 0, seq + 1, data=nam[0])
                seq += 2
            elif num in (2, 3, 5, 6):
                if dat:
                    dsc = self.sql.getRec("genmst",
                                          cols=["glm_desc"],
                                          where=[("glm_cono", "=", coy),
                                                 ("glm_acno", "=", dat)],
                                          limit=1)
                else:
                    dsc = [""]
                self.df.loadEntry("T", 0, seq, data=dat)
                self.df.loadEntry("T", 0, seq + 1, data=dsc[0])
                seq += 2

    def doName(self, frt, pag, r, c, p, i, w):
        self.name = w
        if self.glint == "Y" and self.coys == 1:
            self.co1 = self.opts["conum"]
            self.co2 = self.opts["conum"]
            self.df.loadEntry(frt, pag, p + 1, data=self.opts["conum"])
            self.df.loadEntry(frt, pag, p + 2, data=self.opts["conam"])
            return "sk2"

    def doCoy(self, frt, pag, r, c, p, i, w):
        coy = self.sql.getRec("ctlmst",
                              cols=["ctm_name "],
                              where=[("ctm_cono", "=", w)],
                              limit=1)
        if not coy:
            return "Invalid Company Number"
        if p == 2:
            self.co1 = w
        else:
            self.co2 = w
        self.df.loadEntry(frt, pag, p + 1, coy[0])

    def doSal(self, frt, pag, r, c, p, i, w):
        if p == 4:
            co = self.co1
        else:
            co = self.co2
        chk = chkGenAcc(self.opts["mf"], co, w)
        if type(chk) is str:
            return chk
        self.df.loadEntry(frt, pag, p + 1, data=chk[0])

    def doCom(self, frt, pag, r, c, p, i, w):
        if w:
            if p == 6:
                co = self.co1
            else:
                co = self.co2
            chk = chkGenAcc(self.opts["mf"], co, w)
            if type(chk) is str:
                return chk
            self.df.loadEntry(frt, pag, p + 1, data=chk[0])
        if p == 6 and self.coys == 1:
            self.df.loadEntry(frt, pag, p + 2, data=self.opts["conum"])
            self.df.loadEntry(frt, pag, p + 3, data=self.opts["conam"])
            return "sk2"

    def doDelete(self):
        if self.glint == "Y":
            chk = self.sql.getRec("wagmst",
                                  where=[("wgm_dept", "=", self.code)])
            if chk:
                return "Department is in Use, Not Deleted"
        self.sql.delRec("ctldep",
                        where=[("dep_cono", "=", self.opts["conum"]),
                               ("dep_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        data = [self.opts["conum"]]
        for num, dat in enumerate(self.df.t_work[0][0]):
            if num in (3, 5, 7, 9, 11, 13):
                continue
            data.append(dat)
        if self.glint == "N":
            data.extend([0, 0, 0, 0, 0, 0])
        if self.new == "Y":
            self.sql.insRec("ctldep", data=data)
        elif data != self.old[:len(data)]:
            col = self.sql.ctldep_col
            data.append(self.old[col.index("dep_xflag")])
            self.sql.updRec("ctldep",
                            data=data,
                            where=[("dep_cono", "=", self.opts["conum"]),
                                   ("dep_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #26
0
class rc1020(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       ["chglog", "rcaprm", "rcaowm", "rcatnm"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        return True

    def mainProcess(self):
        own = {
            "stype":
            "R",
            "tables": ("rcaowm", ),
            "cols":
            (("rom_acno", "", 0, "Own-Cod"), ("rom_name", "", 0, "Name", "Y")),
            "where": [("rom_cono", "=", self.opts["conum"])]
        }
        prm = {
            "stype":
            "R",
            "tables": ("rcaprm", ),
            "cols": (("rcp_code", "", 0, "Prm-Code"), ("rcp_addr1", "", 0,
                                                       "Address-Line-1")),
            "where": [("rcp_cono", "=", self.opts["conum"])],
            "whera": [("T", "rcp_owner", 0, 0)]
        }
        self.fld = [(("T", 0, 0, 0), "INA", 7, "Owner Code", "Owner", "", "N",
                     self.doOwnCod, own, None, ("notblank", )),
                    (("T", 0, 0, 0), "ONA", 30, "Name"),
                    (("T", 0, 1, 0), "INA", 7, "Premises Code", "Premises", "",
                     "N", self.doPrmCod, prm, None, ("notblank", )),
                    (("T", 0, 2, 0), "INA", 30, "Description", "", "", "N",
                     None, None, self.doDelete, ("notblank", )),
                    (("T", 0, 3, 0), "INA", 30, "Address Line 1", "", "", "N",
                     None, None, None, ("notblank", )),
                    (("T", 0, 4, 0), "INA", 30, "Address Line 2", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, 5, 0), "INA", 30, "Address Line 3", "", "", "N",
                     None, None, None, ("efld", )),
                    (("T", 0, 6, 0), "INA", 4, "Postal Code", "PCod", "", "N",
                     None, None, None, ("notblank", )),
                    (("T", 0, 7, 0), "IUD", 6.2, "Commission Rate", "C-Rate",
                     "", "N", None, None, None, ("efld", ))]
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doOwnCod(self, frt, pag, r, c, p, i, w):
        acc = self.sql.getRec("rcaowm",
                              cols=["rom_name"],
                              where=[("rom_cono", "=", self.opts["conum"]),
                                     ("rom_acno", "=", w)],
                              limit=1)
        if not acc:
            return "Invalid Owner"
        self.owner = w
        self.name = acc[0]
        self.df.loadEntry(frt, pag, p + 1, data=self.name)

    def doPrmCod(self, frt, pag, r, c, p, i, w):
        self.code = w
        self.old = self.sql.getRec("rcaprm",
                                   where=[("rcp_cono", "=",
                                           self.opts["conum"]),
                                          ("rcp_owner", "=", self.owner),
                                          ("rcp_code", "=", self.code)],
                                   limit=1)
        if not self.old:
            self.new = "y"
        else:
            self.new = "n"
            for num, dat in enumerate(self.old[2:-1]):
                self.df.loadEntry(frt, pag, p + num, data=dat)

    def doDelete(self):
        mst = self.sql.getRec("rcatnm",
                              cols=["count(*)"],
                              where=[("rtn_cono", "=", self.opts["conum"]),
                                     ("rtn_code", "=", self.code)],
                              limit=1)
        if mst[0]:
            return "Accounts Exist, Not Deleted"
        self.sql.delRec("rcaprm",
                        where=[("rcp_cono", "=", self.opts["conum"]),
                               ("rcp_code", "=", self.code)])
        dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
        self.sql.insRec("chglog", data=["rcaprm", "D", "%03i%-7s" % \
            (self.opts["conum"], self.code), "", dte, self.opts["capnm"],
            "", "", "", 0])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        data = [self.opts["conum"]]
        for x in range(0, len(self.df.t_work[0][0])):
            if x == 1:
                continue
            data.append(self.df.t_work[0][0][x])
        if self.new == "y":
            self.sql.insRec("rcaprm", data=data)
        elif data != self.old[:len(data)]:
            col = self.sql.rcaprm_col
            data.append(self.old[col.index("rcp_xflag")])
            self.sql.updRec("rcaprm",
                            data=data,
                            where=[("rcp_cono", "=", self.opts["conum"]),
                                   ("rcp_code", "=", self.code)])
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            for num, dat in enumerate(self.old):
                if dat != data[num]:
                    self.sql.insRec(
                        "chglog",
                        data=[
                            "rcaprm", "U",
                            "%03i%-7s" % (self.opts["conum"], self.code),
                            col[num], dte, self.opts["capnm"],
                            str(dat),
                            str(data[num]), "", 0
                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #27
0
class stc210(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm,
                       "struoi",
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        return True

    def mainProcess(self):
        unm = {
            "stype":
            "R",
            "tables": ("struoi", ),
            "cols": (("unm_unit", "", 0, "Unit"), ("unm_desc", "", 0,
                                                   "Description", "Y")),
            "where": [("unm_cono", "=", self.opts["conum"])]
        }
        self.fld = ((("T", 0, 0, 0), "INA", 10, "Unit Of Issue", "", "", "N",
                     self.doUnit, unm, None, ("notblank", )),
                    (("T", 0, 1, 0), "INA", 30, "Description", "", "", "N",
                     None, None, self.doDelete, ("notblank", )))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2), ("T", 0, 0)))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.closeProcess, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doUnit(self, frt, pag, r, c, p, i, w):
        self.uoi = w
        self.old = self.sql.getRec("struoi",
                                   where=[("unm_cono", "=",
                                           self.opts["conum"]),
                                          ("unm_unit", "=", self.uoi)],
                                   limit=1)
        if not self.old:
            self.new = "Y"
        else:
            self.new = "N"
            desc = self.old[self.sql.struoi_col.index("unm_desc")]
            self.df.loadEntry(frt, pag, p + 1, data=desc)

    def doDelete(self):
        self.sql.delRec("struoi",
                        where=[("unm_cono", "=", self.opts["conum"]),
                               ("unm_unit", "=", self.uoi)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        data = [self.opts["conum"]]
        for x in range(0, len(self.df.t_work[0][0])):
            data.append(self.df.t_work[0][0][x])
        if self.new == "Y":
            self.sql.insRec("struoi", data=data)
        elif data != self.old[:len(data)]:
            col = self.sql.struoi_col
            data.append(self.old[col.index("unm_xflag")])
            self.sql.updRec("struoi",
                            data=data,
                            where=[("unm_cono", "=", self.opts["conum"]),
                                   ("unm_unit", "=", self.uoi)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def closeProcess(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #28
0
class glc110(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.drawDialog()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm, ["ctlctl", "genmst"],
                       prog=self.__class__.__name__)
        if self.sql.error:
            return
        # -------------------------------
        # General Ledger Control Records
        # -------------------------------
        # Get Company Details
        gc = GetCtl(self.opts["mf"])
        ctlmst = gc.getCtl("ctlmst", self.opts["conum"])
        if not ctlmst:
            return
        # Standard Controls
        self.glctrl = [("bank_1", "Bank Control 1"),
                       ("bank_2", "Bank Control 2"),
                       ("bank_3", "Bank Control 3"),
                       ("bank_4", "Bank Control 4"),
                       ("bank_5", "Bank Control 5"),
                       ("bank_6", "Bank Control 6"),
                       ("bank_7", "Bank Control 7"),
                       ("bank_8", "Bank Control 8"),
                       ("bank_9", "Bank Control 9"),
                       ("bank_10", "Bank Control 10"),
                       ("p_cash", "Petty Cash Control"),
                       ("crs_ctl", "Creditors Control"),
                       ("drs_ctl", "Debtors Control"),
                       ("ret_inc", "Retained Income"),
                       ("vat_ctl", "VAT Control")]
        # Check for Integrated Systems
        mod = []
        for x in range(0, len(ctlmst["ctm_modules"].rstrip()), 2):
            mod.append(ctlmst["ctm_modules"][x:x + 2])
        # Load Systems Integration
        if mod.count("AR"):
            assctl = gc.getCtl("assctl", self.opts["conum"], error=False)
            if assctl and assctl["cta_glint"] == "Y":
                self.glctrl.extend([("ass_sls", "Sale of Assets")])
        if mod.count("BK"):
            bkmctl = gc.getCtl("bkmctl", self.opts["conum"], error=False)
            if bkmctl and bkmctl["cbk_glint"] == "Y":
                self.glctrl.extend([("bkm_ctl", "Bookings Control"),
                                    ("bkm_chq", "Cheques Received"),
                                    ("bkm_csh", "Cash Received"),
                                    ("bkm_ccg", "Cancellation Fee")])
                if not mod.count("DR"):
                    self.glctrl.extend([("dis_all", "Discount Allowed")])
        if mod.count("CR"):
            crsctl = gc.getCtl("crsctl", self.opts["conum"], error=False)
            if crsctl and crsctl["ctc_glint"] == "Y":
                self.glctrl.extend([("dis_rec", "Discount Received")])
        if mod.count("CS"):
            cshctl = gc.getCtl("cshctl", self.opts["conum"], error=False)
            if cshctl and cshctl["ccc_glint"] == "Y":
                self.glctrl.extend([("csh_ctl", "Cash Control")])
        if mod.count("DR"):
            drsctl = gc.getCtl("drsctl", self.opts["conum"], error=False)
            if drsctl and drsctl["ctd_glint"] == "Y":
                self.glctrl.extend([("dis_all", "Discount Allowed")])
        if mod.count("LN"):
            lonctl = gc.getCtl("lonctl", self.opts["conum"], error=False)
            if lonctl and lonctl["cln_glint"] == "Y":
                self.glctrl.extend([("lon_ctl", "Loans Control"),
                                    ("int_pay", "Interest Paid"),
                                    ("int_rec", "Interest Received")])
        if mod.count("ML"):
            memctl = gc.getCtl("memctl", self.opts["conum"], error=False)
            if memctl and memctl["mcm_glint"] == "Y":
                self.glctrl.extend([("mem_ctl", "Members Control"),
                                    ("mem_pen", "Members Penalties")])
        if mod.count("RC"):
            rcactl = gc.getCtl("rcactl", self.opts["conum"], error=False)
            if rcactl and rcactl["cte_glint"] == "Y":
                self.glctrl.extend([("rca_com", "Commission Raised"),
                                    ("rca_dep", "Deposits Control"),
                                    ("rca_fee", "Contract Fees"),
                                    ("rca_own", "Owners Control"),
                                    ("rca_orx", "Owners Charges"),
                                    ("rca_tnt", "Tenants Control"),
                                    ("rca_trx", "Tenants Charges")])
        if mod.count("ST"):
            strctl = gc.getCtl("strctl", self.opts["conum"], error=False)
            if strctl and strctl["cts_glint"] == "Y":
                self.glctrl.extend([("stk_soh", "Stock on Hand"),
                                    ("stk_susp", "Stock Reconciliation")])
        if mod.count("WG") or mod.count("SL"):
            wagctl = gc.getCtl("wagctl", self.opts["conum"], error=False)
            if wagctl and wagctl["ctw_glint"] == "Y":
                self.glctrl.extend([("wag_ctl", "Salaries Control"),
                                    ("wag_slc", "Staff Loans Control"),
                                    ("wag_sli", "Staff Loans Interest")])
        return True

    def drawDialog(self):
        ctl = {
            "stype": "C",
            "titl": "Select Control",
            "head": ("Code", "Description"),
            "typs": (("NA", 10), ("NA", 30)),
            "data": self.glctrl
        }
        glm = {
            "stype":
            "R",
            "tables": ("genmst", ),
            "cols": (("glm_acno", "", 0, "Acc-Num"), ("glm_desc", "", 0,
                                                      "Description", "Y")),
            "where": [("glm_cono", "=", self.opts["conum"])]
        }
        r1s = (("None", "N"), ("OFX", "O"), ("QIF", "Q"), ("S/Bank Online",
                                                           "S"))
        r2s = (("None", "N"), ("CCYYMMDD", "A"), ("DDMMCCYY", "B"),
               ("MMDD(CC)YY", "C"))
        fld = ((("T", 0, 0, 0), "INA", 10, "Code", "Control Code", "", "Y",
                self.doCode, ctl, None, None), (("T", 0, 0, 25), "ONA", 30,
                                                "Description"),
               (("T", 0, 1, 0), "IUI", 7, "G/L Acc-Num", "G/L Account Number",
                "", "N", self.doAccNum, glm, self.doDelete,
                ("notzero", )), (("T", 0, 1, 25), "ONA", 30, "Description"),
               (("T", 0, 2, 0), "INA", 16, "Bank Account",
                "Bank Account Number", "", "N", self.doImpBnk, None, None,
                ("efld", )), (("T", 0, 3, 0), ("IRB", r1s), 0, "Import Format",
                              "", "N", "N", self.doImpFmt, None, None, None),
               (("T", 0, 4, 0), ("IRB", r2s), 0, "Date Format", "", "A", "N",
                self.doDteFmt, None, None, None))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 3), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 3), ("T", 0, 0)),
               ("Print", None, self.doPrint, 0, ("T", 0, 1),
                ("T", 0, 2)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)

    def doCode(self, frt, pag, r, c, p, i, w):
        self.code = w
        d1 = ""
        for ctl in self.glctrl:
            if self.code in ctl:
                d1 = ctl[1]
                break
        if not d1:
            return "Invalid Control Code"
        self.df.loadEntry(frt, pag, p + 1, data=d1)
        self.acc = self.sql.getRec("ctlctl",
                                   where=[("ctl_cono", "=",
                                           self.opts["conum"]),
                                          ("ctl_code", "=", self.code)],
                                   limit=1)
        if not self.acc:
            self.new = "y"
        else:
            self.new = "n"
            col = self.sql.ctlctl_col
            desc = self.readAcno(self.acc[col.index("ctl_conacc")])
            if not desc:
                desc = [""]
            self.df.loadEntry(frt,
                              pag,
                              p + 2,
                              data=self.acc[col.index("ctl_conacc")])
            self.df.loadEntry(frt, pag, p + 3, data=desc[0])
            self.df.loadEntry(frt,
                              pag,
                              p + 4,
                              data=self.acc[col.index("ctl_bankac")])
            self.df.loadEntry(frt,
                              pag,
                              p + 5,
                              data=self.acc[col.index("ctl_impfmt")])
            self.df.loadEntry(frt,
                              pag,
                              p + 6,
                              data=self.acc[col.index("ctl_dtefmt")])

    def doDelete(self):
        self.sql.delRec("ctlctl",
                        where=[("ctl_cono", "=", self.opts["conum"]),
                               ("ctl_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccNum(self, frt, pag, r, c, p, i, w):
        desc = self.readAcno(w)
        if not desc:
            return "Invalid Account Number"
        self.df.loadEntry(frt, pag, p + 1, data=desc[0])
        if self.code[:4] != "bank":
            self.impfmt = "N"
            self.bankac = ""
            self.dtefmt = "N"
            return "nd"

    def readAcno(self, acno):
        self.acno = acno
        acc = self.sql.getRec("genmst",
                              cols=["glm_desc"],
                              where=[("glm_cono", "=", self.opts["conum"]),
                                     ("glm_acno", "=", self.acno)],
                              limit=1)
        return acc

    def doImpBnk(self, frt, pag, r, c, p, i, w):
        self.bankac = w
        if not self.bankac:
            self.impfmt = "N"
            self.dtefmt = "N"
            self.df.loadEntry(frt, pag, p + 1, data=self.impfmt)
            self.df.loadEntry(frt, pag, p + 2, data=self.dtefmt)
            return "sk2"

    def doImpFmt(self, frt, pag, r, c, p, i, w):
        self.impfmt = w
        if self.impfmt == "N":
            self.dtefmt = "N"
            self.df.loadEntry(frt, pag, p + 1, data=self.dtefmt)
            return "nd"
        self.df.loadEntry(frt, pag, p + 1, data="A")

    def doDteFmt(self, frt, pag, r, c, p, i, w):
        if w not in ("A", "B", "C"):
            return "Invalid Date Format"
        self.dtefmt = w

    def doEnd(self):
        data = [
            self.opts["conum"], self.code, self.df.t_work[0][0][1], self.acno,
            self.bankac, self.impfmt, self.dtefmt
        ]
        if self.new == "y":
            self.sql.insRec("ctlctl", data=data)
        elif data != self.acc[:len(data)]:
            col = self.sql.ctlctl_col
            data.append(self.acc[col.index("ctl_xflag")])
            self.sql.updRec("ctlctl",
                            data=data,
                            where=[("ctl_cono", "=", self.opts["conum"]),
                                   ("ctl_code", "=", self.code)])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doPrint(self):
        table = ["ctlctl"]
        heads = ["General Ledger Control Accounts"]
        state = self.df.disableButtonsTags()
        self.df.setWidget(self.df.mstFrame, "hide")
        RepPrt(self.opts["mf"],
               name="glc110",
               tables=table,
               heads=heads,
               where=[("ctl_cono", "=", self.opts["conum"])],
               order="ctl_code",
               prtdia=(("Y", "V"), ("Y", "N")))
        self.df.setWidget(self.df.mstFrame, "show")
        self.df.enableButtonsTags(state=state)
        self.df.focusField(self.df.frt, self.df.pag, self.df.col)

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()
Пример #29
0
class rt1010(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.mainProcess()
            if "wait" in self.opts:
                self.df.mstFrame.wait_window()
            else:
                self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(
            self.opts["mf"].dbm,
            ["ctlmst", "rtlprm", "rtlmst", "rtlcon", "rtltrn", "chglog"],
            prog=self.__class__.__name__)
        if self.sql.error:
            return
        self.gc = GetCtl(self.opts["mf"])
        ctlmst = self.gc.getCtl("ctlmst", self.opts["conum"])
        if not ctlmst:
            return
        self.taxdf = ctlmst["ctm_taxdf"]
        return True

    def mainProcess(self):
        prm = {
            "stype":
            "R",
            "tables": ("rtlprm", ),
            "cols": (("rtp_code", "", 0, "Prm-Code"), ("rtp_desc", "", 0,
                                                       "Description", "Y")),
            "where": [("rtp_cono", "=", self.opts["conum"])]
        }
        acc = {
            "stype":
            "R",
            "tables": ("rtlmst", ),
            "cols":
            (("rtm_acno", "", 0, "Acc-Num"), ("rtm_name", "", 0, "Name", "Y")),
            "where": [("rtm_cono", "=", self.opts["conum"])],
            "whera": (("T", "rtm_code", 0, 0), )
        }
        r1s = (("Monthly", "M"), ("Quarterly", "3"), ("Bi-Annually", "6"),
               ("Annually", "A"))
        r2s = (("Current", "C"), ("Expired", "X"))
        self.fld = ((("T", 0, 0, 0), "INA", 7, "Premises Code", "", "", "Y",
                     self.doPremises, prm, None, ("notblank", )),
                    (("T", 0, 1, 0), "INA", 7, "Account Code", "", "", "N",
                     self.doAccount, acc, None, ("notblank", )),
                    (("T", 0, 2, 0), "INA", 30, "Tenant Name", "", "", "N",
                     None, None, self.doDelete, ("notblank", )),
                    (("T", 0, 3, 0), "INA", 30, "Address Line 1", "", "", "N",
                     None, None, None,
                     ("efld", )), (("T", 0, 4, 0), "INA", 30, "Address Line 2",
                                   "", "", "N", None, None, None, ("efld", )),
                    (("T", 0, 5, 0), "INA", 30, "Address Line 3", "", "", "N",
                     None, None, None,
                     ("efld", )), (("T", 0, 6, 0), "INA", 4, "Postal Code", "",
                                   "", "N", None, None, None, ("efld", )),
                    (("T", 0, 7, 0), "INA", 20, "Telephone Number", "", "",
                     "N", None, None, None,
                     ("efld", )), (("T", 0, 8, 0), "ITX", 50, "E-Mail Address",
                                   "", "", "N", None, None, None, ("email", )),
                    (("T", 0, 9, 0), "IUA", 1, "VAT Indicator", "", self.taxdf,
                     "N", None, None, None,
                     ("notblank", )), (("T", 0, 10, 0), "INA", 10,
                                       "VAT Number", "", "", "N",
                                       self.doVatNum, None, None, ("efld", )),
                    (("T", 0, 11, 0), ("IRB", r1s), 0, "Payment Frequency", "",
                     "M", "N", None, None, None,
                     None), (("T", 0, 12, 0), "ID1", 10, "Start Date", "", "",
                             "N", self.doStart, None, None,
                             ("notzero", )), (("T", 0, 13, 0), "IUI", 3,
                                              "Number of Periods", "", "", "N",
                                              None, None, None, ("notzero", )),
                    (("T", 0, 14, 0), "IUD", 12.2, "Rental Amount", "", "",
                     "N", self.doAmount, None, None,
                     ("notzero", )), (("T", 0, 15,
                                       0), ("IRB", r2s), 0, "Status", "", "",
                                      "N", None, None, None, None))
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 2), ("T", 0, 0)),
               ("Cancel", None, self.doCancel, 0, ("T", 0, 2),
                ("T", 0, 0)), ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)
        if "args" in self.opts:
            self.df.doKeyPressed("T", 0, 0, data=self.opts["args"][0])
            self.df.doKeyPressed("T", 0, 1, data=self.opts["args"][1])

    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)

    def doAccount(self, frt, pag, r, c, p, i, w):
        self.acno = w
        self.oldm = self.sql.getRec("rtlmst",
                                    where=[("rtm_cono", "=",
                                            self.opts["conum"]),
                                           ("rtm_code", "=", self.code),
                                           ("rtm_acno", "=", self.acno)],
                                    limit=1)
        if not self.oldm:
            self.new = "y"
            for num in range(2, self.df.topq[0]):
                self.df.clearEntry(frt, pag, num + 1)
            con = self.sql.getRec("rtlcon",
                                  cols=["count(*)"],
                                  where=[("rtc_cono", "=", self.opts["conum"]),
                                         ("rtc_code", "=", self.code),
                                         ("rtc_acno", "=", self.acno)],
                                  limit=1)
            if not con[0]:
                self.cnum = 1
            else:
                self.cnum = con[0] + 1
        else:
            self.new = "n"
            for num, fld in enumerate(self.oldm[2:]):
                self.df.loadEntry(frt, pag, p + num, data=fld)
            self.oldc = self.sql.getRec("rtlcon",
                                        where=[("rtc_cono", "=",
                                                self.opts["conum"]),
                                               ("rtc_code", "=", self.code),
                                               ("rtc_acno", "=", self.acno)],
                                        order="rtc_cnum")
            self.cnum = self.oldc[-1:][0][3]
            for num, fld in enumerate(self.oldc[-1:][0][4:-1]):
                self.df.loadEntry(frt, pag, num + 11, data=fld)
            trn = self.sql.getRec("rtltrn",
                                  cols=["count(*)"],
                                  where=[("rtt_cono", "=", self.opts["conum"]),
                                         ("rtt_code", "=", self.code),
                                         ("rtt_acno", "=", self.acno)],
                                  limit=1)
            if trn[0]:
                self.trn = True
            else:
                self.trn = False

    def doVatNum(self, frt, pag, r, c, p, i, w):
        if self.new == "n" and self.trn:
            return "sk1"

    def doStart(self, frt, pag, r, c, p, i, w):
        if self.new == "y" and self.end and w < self.end.work:
            return "Premises Already Let till %s" % self.end.disp

    def doAmount(self, frt, pag, r, c, p, i, w):
        if self.new == "y":
            self.df.loadEntry(frt, pag, p + 1, data="C")

    def doDelete(self):
        if self.trn:
            return "Transactions Exist, Not Deleted"
        self.sql.delRec("rtlmst",
                        where=[("rtm_cono", "=", self.opts["conum"]),
                               ("rtm_code", "=", self.code),
                               ("rtm_acno", "=", self.acno)])
        self.sql.delRec("rtlcon",
                        where=[("rtc_cono", "=", self.opts["conum"]),
                               ("rtc_code", "=", self.code),
                               ("rtc_acno", "=", self.acno)])
        dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
        self.sql.insRec("chglog",
                        data=[
                            "rtlmst", "D",
                            "%03i%-7s" % (self.opts["conum"], self.code), "",
                            dte, self.opts["capnm"], "", "", 0
                        ])
        self.opts["mf"].dbm.commitDbase()
        self.df.focusField("T", 0, 1)

    def doEnd(self):
        datm = [self.opts["conum"]]
        datc = [self.opts["conum"], self.code, self.acno, self.cnum]
        for num, fld in enumerate(self.df.t_work[0][0]):
            if num < 11:
                datm.append(fld)
            if num > 10:
                datc.append(fld)
        if self.new == "y":
            self.sql.insRec("rtlmst", data=datm)
            self.sql.insRec("rtlcon", data=datc)
        else:
            dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
            if datm != self.oldm[:len(datm)]:
                col = self.sql.rtlmst_col
                datm.append(self.oldm[col.index("rtm_xflag")])
                self.sql.updRec("rtlmst",
                                data=datm,
                                where=[("rtm_cono", "=", self.opts["conum"]),
                                       ("rtm_code", "=", self.code),
                                       ("rtm_acno", "=", self.acno)])
                for num, dat in enumerate(self.oldm):
                    if dat != datm[num]:
                        self.sql.insRec(
                            "chglog",
                            data=[
                                "rtlmst", "U",
                                "%03i%-7s" % (self.opts["conum"], self.code),
                                col[num], dte, self.opts["capnm"],
                                str(dat),
                                str(datm[num]), "", 0
                            ])
            if datc != self.oldc[-1:][0][:len(datc)]:
                col = self.sql.rtlcon_col
                datc.append(self.oldc[col.index("rtc_xflag")])
                self.sql.updRec("rtlcon",
                                data=datc,
                                where=[("rtc_cono", "=", self.opts["conum"]),
                                       ("rtc_code", "=", self.code),
                                       ("rtc_acno", "=", self.acno),
                                       ("rtc_cnum", "=", self.cnum)])
                for num, dat in enumerate(self.oldc[-1:][0]):
                    if dat != datc[num]:
                        self.sql.insRec("chglog",
                                        data=[
                                            "rtlcon", "U",
                                            "%03i%-7s%-7s%03i" %
                                            (self.opts["conum"], self.code,
                                             self.acno, self.cnum), col[num],
                                            dte, self.opts["capnm"],
                                            str(dat),
                                            str(datc[num]), "", 0
                                        ])
        if "args" in self.opts:
            self.doExit()
        else:
            self.opts["mf"].dbm.commitDbase()
            self.df.focusField("T", 0, 1)

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.df.doEndFrame("T", 0, cnf="N")

    def doCancel(self):
        self.opts["mf"].dbm.rollbackDbase()
        self.df.focusField("T", 0, 1)

    def doExit(self):
        self.df.closeProcess()
        if "wait" not in self.opts:
            self.opts["mf"].closeLoop()
Пример #30
0
class bcc110(object):
    def __init__(self, **opts):
        self.opts = opts
        if self.setVariables():
            self.drawDialog()
            self.opts["mf"].startLoop()

    def setVariables(self):
        self.sql = Sql(self.opts["mf"].dbm, [
            "memctl", "memctc", "memmst", "memadd", "memkon", "bwlctl",
            "bwltab", "chglog"
        ],
                       prog=self.__class__.__name__)
        if self.sql.error:
            if self.sql.error == ["memctl"]:
                self.memctl = False
                self.chgint = False
                self.mlint = None
                self.same = "N"
            else:
                return
        else:
            self.memctl = True
        self.acc = self.sql.getRec("bwlctl",
                                   where=[("ctb_cono", "=", self.opts["conum"])
                                          ],
                                   limit=1)
        if not self.acc:
            self.new = True
            self.acc = [
                self.opts["conum"], "N", "N", 0, 0, 0, 0, "C", "A", "N", "Y",
                4, 0, 0, "A", "B", "", ""
            ]
        else:
            self.new = False
            self.oldm = self.acc[self.sql.bwlctl_col.index("ctb_mstart")]
            self.oldf = self.acc[self.sql.bwlctl_col.index("ctb_fstart")]
            self.oldn = self.acc[self.sql.bwlctl_col.index("ctb_nstart")]
        if self.memctl:
            self.mlint = self.sql.getRec("memctl",
                                         where=[("mcm_cono", "=",
                                                 self.opts["conum"])],
                                         limit=1)
        return True

    def drawDialog(self):
        cat = {
            "stype":
            "R",
            "tables": ("memctc", ),
            "cols":
            (("mcc_code", "", 0, "Code"), ("mcc_desc", "", 0, "Description")),
            "where":
            (("mcc_cono", "=", self.opts["conum"]), ("mcc_type", "=", "C"))
        }
        r1s = (("Yes", "Y"), ("No", "N"))
        r2s = (("Position", "P"), ("Rating", "R"), ("Combined", "C"))
        r3s = (("Ascending", "A"), ("Descending", "D"))
        r4s = (("S32L-S32L", "A"), ("S32L-L23S", "B"))
        if self.memctl:
            self.fld = [
                (("T",0,0,0),["IRB",r1s],0,"M/L Integration","",
                    self.acc[1],"N",self.doMlint,None,None,None,None,
                    "Select whether to Integrate this system with the "\
                    "Members Ledger System."),
                (("T",0,1,0),("IRB",r1s),0,"Same Numbers","",
                    self.acc[2],"N",self.doSame,None,None,None,None,
                    "If the Members Ledger is Integrated select "\
                    "whether the Tab numbers and Members Ledger numbers "\
                    "are the Same."),
                (("T",0,2,0),"IUI",2,"Category Code","",
                    self.acc[3],"N",self.doCat,cat,None,None,None,
                    "If the Members Ledger is Integrated enter which "\
                    "Members Ledger Sports category is for Bowls.")]
            seq = 3
        else:
            self.fld = []
            seq = 0
        self.fld.extend([
            (("T",0,seq,0),"IUI",6,"Male Start Seq","",
                self.acc[4],"N",self.doMStart,None,None,("notzero",),None,
                "The Starting Tab number for Males."),
            (("T",0,seq + 1,0),"IUI",6,"Female Start Seq","",
                self.acc[5],"N",self.doFStart,None,None,("notzero",),None,
                "The Starting Tab number for Females."),
            (("T",0,seq + 2,0),"IUI",6,"Non-Member Start Seq","",
                self.acc[6],"N",self.doNStart,None,None,("notzero",),None,
                "The Starting Tab number for Visitors."),
            (("T",0,seq + 3,0),("IRB",r2s),0,"Draw Base","",
                self.acc[7],"N",self.doBase,None,None,None,None,
                "The Default method of doing Draws."),
            (("T",0,seq + 4,0),("IRB",r3s),0,"Rating Order","",
                self.acc[8],"N",None,None,None,None,None,
                "With Ratings select whether Ratings are Ascending "\
                "or Descending in strength."),
            (("T",0,seq + 5,0),("IRB",r1s),0,"Mixed Ratings","",
                self.acc[9],"N",None,None,None,None,None,
                "Select if Different Ratings are Used for Mixed "\
                "Gender Draws."),
            (("T",0,seq + 6,0),("IRB",r1s),0,"Replace Fours","",
                self.acc[10],"N",None,None,None,None,None,
                "When the Draw is Trips Use Pairs Instead of Fours "\
                "when Applicable."),
            (("T",0,seq + 7,0),"IUI",2,"Weeks Between Draws","",
                self.acc[11],"N",None,None,None,("between", 0, 4),None,
                "Minimum number of Weeks that Players Should Not be "\
                "Drawn in the Same Team."),
            (("T",0,seq + 8,0),"IUD",5.2,"Rate - Member","",
                self.acc[12],"N",None,None,None,("efld",)),
            (("T",0,seq + 9,0),"IUD",5.2,"Rate - Visitor","",
                self.acc[13],"N",None,None,None,("efld",)),
            (("T",0,seq + 10,0),"IUA",6,"Greens","",
                self.acc[14],"N",self.doGreens,None,None,("notblank",)),
            (("T",0,seq + 11,0),("IRB",r4s),0,"Draw Format","",
                self.acc[15],"N",None,None,None,None),
            (("T",0,seq + 12,0),"ITX",50,"Email Address","",
                self.acc[16],"N",None,None,None,("email",))])
        but = (("Accept", None, self.doAccept, 0, ("T", 0, 1), ("T", 0, 0)),
               ("Quit", None, self.doExit, 1, None, None))
        tnd = ((self.doEnd, "Y"), )
        txt = (self.doExit, )
        self.df = TartanDialog(self.opts["mf"],
                               eflds=self.fld,
                               butt=but,
                               tend=tnd,
                               txit=txt)
        if not self.new:
            if self.memctl:
                seq = 1
                self.oldint = self.acc[0]
            else:
                seq = 4
            for n, f in enumerate(self.acc[seq:-1]):
                self.df.loadEntry("T", 0, n, data=f)
        if not self.memctl:
            self.chgint = False
            self.same = "N"
        self.df.focusField("T", 0, 1, clr=False)

    def doMlint(self, frt, pag, r, c, p, i, w):
        if w == "Y" and not self.mlint:
            return "Invalid Selection, Member's System Not Set Up"
        if not self.new and w != self.oldint:
            self.chgint = True
        else:
            self.chgint = False
        if w == "N":
            self.same = "N"
            self.df.loadEntry(frt, pag, p + 1, data=self.same)
            self.mcat = 0
            self.df.loadEntry(frt, pag, p + 2, data=self.mcat)
            return "sk2"

    def doSame(self, frt, pag, r, c, p, i, w):
        self.same = w

    def doCat(self, frt, pag, r, c, p, i, w):
        chk = self.sql.getRec("memctc",
                              where=[("mcc_cono", "=", self.opts["conum"]),
                                     ("mcc_type", "=", "C"),
                                     ("mcc_code", "=", w)],
                              limit=1)
        if not chk:
            return "Invalid Code"
        self.mcat = w

    def doMStart(self, frt, pag, r, c, p, i, w):
        self.mstart = w

    def doFStart(self, frt, pag, r, c, p, i, w):
        if w == self.mstart and self.same == "N":
            return "Invalid Number, Same as Male"
        if w != self.mstart:
            if w < self.mstart:
                r = self.mstart - w
                g = "Female"
            else:
                r = w - self.mstart
                g = "Male"
            if r < 200:
                return "ff5|Invalid Numbers, Too Few %s Tabs. (Minimum 200)" % g
        self.fstart = w

    def doNStart(self, frt, pag, r, c, p, i, w):
        if w < self.mstart or w < self.fstart or w > 890000:
            return "Invalid Number, Less than Male or Female or > 890000"
        if self.mstart == self.fstart:
            t = "Members"
            r = w - self.mstart
            m = 400
        elif self.fstart < self.mstart:
            t = "Male"
            r = w - self.mstart
            m = 200
        else:
            t = "Female"
            r = w - self.fstart
            m = 200
        if r < m:
            return "Invalid Number, Too Few %s Tabs. (Minimum %s)" % (t, m)
        self.nstart = w

    def doBase(self, frt, pag, r, c, p, i, w):
        if w == "P":
            self.df.loadEntry(frt, pag, p + 1, data="A")
            return "sk1"
        if not self.acc[7]:
            self.df.t_work[0][0][p + 1] = "A"

    def doGreens(self, frt, pag, r, c, p, i, w):
        w = w.strip().replace(" ", "")
        self.df.loadEntry(frt, pag, p, data=w)

    def doEnd(self):
        err = None
        if self.same == "Y":
            if self.mstart + 400 > self.nstart:
                err = "Invalid Range, Too Few Members Allowed For"
        elif self.mstart == self.fstart and self.same == "N":
            err = "Same Male and Female Starting Numbers"
        elif self.mstart < self.fstart:
            if self.fstart - self.mstart < 200:
                err = "Invalid Range, Too Few Male Numbers"
            elif self.nstart < self.fstart + 200:
                err = "Invalid Range, Too Few Female Numbers"
        elif self.mstart - self.fstart < 200:
            err = "Invalid Range, Too Few Female Numbers"
        elif self.nstart < self.mstart + 200:
            err = "Invalid Range, Too Few Male Numbers"
        if err:
            self.df.focusField("T", 0, 3, err=err)
        else:
            data = [self.opts["conum"]]
            if not self.memctl:
                data.extend(["N", "N"])
            for x in range(0, len(self.df.t_work[0][0])):
                data.append(self.df.t_work[0][0][x])
            if self.new:
                self.sql.insRec("bwlctl", data=data)
            elif data != self.acc[:len(data)]:
                col = self.sql.bwlctl_col
                data.append(self.acc[col.index("ctb_xflag")])
                self.sql.updRec("bwlctl",
                                data=data,
                                where=[("ctb_cono", "=", self.opts["conum"])])
                dte = int("%04i%02i%02i%02i%02i%02i" % time.localtime()[:-3])
                for num, dat in enumerate(self.acc):
                    if dat != data[num]:
                        self.sql.insRec("chglog",
                                        data=[
                                            "bwlctl", "U",
                                            "%03i" % self.opts["conum"],
                                            col[num], dte, self.opts["capnm"],
                                            str(dat),
                                            str(data[num]), "", 0
                                        ])
            if self.chgint and self.oldint == "Y":
                recs = self.sql.getRec("bwltab",
                                       cols=["btb_memno"],
                                       where=[("btb_cono", "=",
                                               self.opts["conum"])])
                for rec in recs:
                    data = self.doLoadMember(rec[0])
                    if data == [0, "", "", "", "", "", "", "", ""]:
                        continue
                    self.sql.updRec("bwltab",
                                    cols=[
                                        "btb_memno", "btb_add1", "btb_add2",
                                        "btb_add3", "btb_pcod", "btb_home",
                                        "btb_work", "btb_cell", "btb_mail"
                                    ],
                                    data=data,
                                    where=[("btb_cono", "=",
                                            self.opts["conum"]),
                                           ("btb_memno", "=", rec[0])])
            if not self.new and (self.mstart != self.oldm or \
                    self.fstart != self.oldf or self.nstart != self.oldn):
                # Tab ranges changed
                ok = askQuestion(self.opts["mf"].body, "Ranges", "Tab Ranges "\
                    "Have Changed, Do You Want to Change the Tabs to the "\
                    "New Ranges?", default="no")
                if ok == "yes":
                    mdif = self.mstart - self.oldm
                    fdif = self.fstart - self.oldf
                    ndif = self.nstart - self.oldn
                    recs = []
                    if ndif > 0:
                        recs.extend(self.getNon())
                    if self.oldm > self.oldf:
                        recs.extend(self.getWom())
                        recs.extend(self.getMen())
                    else:
                        recs.extend(self.getMen())
                        recs.extend(self.getWom())
                    if ndif < 0:
                        recs.extend(self.getNon())
                    self.df.setWidget(self.df.mstFrame, state="hide")
                    pb = ProgressBar(self.opts["mf"].body,
                                     typ="Changing Tabs",
                                     mxs=len(recs))
                    for num, rec in enumerate(recs):
                        pb.displayProgress(num)
                        tab = rec[self.sql.bwltab_col.index("btb_tab")]
                        gdr = rec[self.sql.bwltab_col.index("btb_gender")]
                        if tab < self.oldn:
                            if gdr == "M":
                                new = tab + mdif
                            else:
                                new = tab + fdif
                        else:
                            new = tab + ndif
                        callModule(
                            self.opts["mf"],
                            None,
                            "bc6010",
                            coy=[self.opts["conum"], self.opts["conam"]],
                            args=[tab, new])
                    pb.closeProgress()
                    self.df.setWidget(self.df.mstFrame, state="show")
            self.opts["mf"].dbm.commitDbase()
            self.doExit()

    def getMen(self):
        recs = self.sql.getRec("bwltab",
                               where=[("btb_cono", "=", self.opts["conum"]),
                                      ("btb_tab", "<", self.oldn),
                                      ("btb_gender", "=", "M")],
                               order="btb_tab")
        return recs

    def getWom(self):
        recs = self.sql.getRec("bwltab",
                               where=[("btb_cono", "=", self.opts["conum"]),
                                      ("btb_tab", "<", self.oldn),
                                      ("btb_gender", "=", "F")],
                               order="btb_tab")
        return recs

    def getNon(self):
        end = self.oldm
        if self.oldf > end:
            end = self.oldf
        recs = self.sql.getRec("bwltab",
                               where=[("btb_cono", "=", self.opts["conum"]),
                                      ("btb_tab", ">=", self.oldn)],
                               order="btb_tab")
        return recs

    def doLoadMember(self, memno):
        acc = self.sql.getRec("memmst",
                              cols=["mlm_surname", "mlm_names", "mlm_gender"],
                              where=[("mlm_cono", "=", self.opts["conum"]),
                                     ("mlm_memno", "=", memno)],
                              limit=1)
        if not acc:
            return [0, "", "", "", "", "", "", "", ""]
        self.df.loadEntry("T", 0, 1, data=memno)
        self.df.loadEntry("T", 0, 2, data=acc[0])
        self.df.loadEntry("T", 0, 3, data=acc[1])
        self.gender = acc[2]
        self.df.loadEntry("T", 0, 4, data=self.gender)
        for typ in ("A", "P"):
            data = self.sql.getRec(
                "memadd",
                cols=["mla_add1", "mla_add2", "mla_add3", "mla_code"],
                where=[("mla_cono", "=", self.opts["conum"]),
                       ("mla_memno", "=", memno), ("mla_type", "=", typ)],
                limit=1)
            if data:
                break
        if data:
            data.insert(0, 0)
        else:
            data = ["", "", "", "", ""]
        for num, cod in enumerate((1, 2, 3, 5)):
            kk = self.sql.getRec("memkon",
                                 cols=["mlk_detail"],
                                 where=[("mlk_cono", "=", self.opts["conum"]),
                                        ("mlk_memno", "=", memno),
                                        ("mlk_code", "=", cod)],
                                 limit=1)
            if kk:
                data.append(kk[0])
            else:
                data.append("")
        return data

    def doAccept(self):
        frt, pag, col, mes = self.df.doCheckFields()
        if mes:
            self.df.focusField(frt, pag, (col + 1), err=mes)
        else:
            self.same = self.df.t_work[0][0][1]
            self.mcat = self.df.t_work[0][0][2]
            self.mstart = self.df.t_work[0][0][3]
            self.fstart = self.df.t_work[0][0][4]
            self.nstart = self.df.t_work[0][0][5]
            self.df.doEndFrame("T", 0, cnf="N")

    def doExit(self):
        self.df.closeProcess()
        self.opts["mf"].closeLoop()