def doAcno(self, frt, pag, r, c, p, i, w): self.acno = w if self.acno: self.old = self.sql.getRec("crsmst", where=[("crm_cono", "=", self.opts["conum"]), ("crm_acno", "=", self.acno)], limit=1) if not self.acno or not self.old: ok = askQuestion(self.opts["mf"].body, "New Account", "Is This a New Account?", default="no") if ok == "no": return "Invalid Account Number" pw = PwdConfirm(self.opts["mf"], conum=self.opts["conum"], system="CRS", code="NewAcc") if pw.flag == "no": if "args" in self.opts: return "xt" else: return "New Account Creation is Not Allowed" self.new = True elif self.old[self.sql.crsmst_col.index("crm_stat")] == "X": return "Invalid Account, Redundant" else: self.new = False self.df.loadEntry("T", pag, p + 1, data=self.old[2]) d = 3 for pge in range(1, self.df.pgs + 1): for x in range(0, self.df.topq[pge]): self.df.loadEntry("T", pge, x, data=self.old[d]) d = d + 1
def doCalCost(self, grp, code, qty, chk=True): # Calculate cost price icost, tcost, bal = getCost(self.sql, self.opts["conum"], grp, code, loc=self.loc, qty=qty, tot=True, bal=True) if chk and qty > bal[0]: acc = self.sql.getRec("strmf1", cols=["st1_desc"], where=[("st1_cono", "=", self.opts["conum"]), ("st1_group", "=", grp), ("st1_code", "=", code)], limit=1) cf = PwdConfirm(self.opts["mf"], conum=self.opts["conum"], system="STR", code="ExQty", product=(grp, code, acc[0])) if cf.flag == "no": return return tcost
def doEnd(self): recs = self.sql.getRec("ctlbat", cols=["count(*)"], where=[("btm_cono", "=", self.opts["conum"]), ("btm_styp", "=", "MEM"), ("btm_ind", "=", "N"), ("btm_curdt", "=", self.curdt)], limit=1) if recs[0]: ok = askQuestion(self.opts["mf"].body, "Unbalanced Batches Exist", "There are Unbalanced Batches for this Month. You "\ "Should Not Continue, but Print a Batch Error Report, and "\ "Correct the Errors. Continue, YES or NO ?", default="no") if ok == "yes": ok = PwdConfirm(self.opts["mf"], conum=self.opts["conum"], system="MST", code="UnbalBatch") if ok.flag == "no": self.closeProcess() else: self.doEnder() else: self.closeProcess() else: self.doEnder()
def doCod(self, frt, pag, r, c, p, i, w): strmf1 = self.sql.getRec("strmf1", where=[("st1_cono", "=", self.opts["conum"]), ("st1_group", "=", self.grp), ("st1_code", "=", w)], limit=1) if not strmf1: return "Invalid Code" if strmf1[self.sql.strmf1_col.index("st1_type")] == "R": return "Invalid Code (Recipe)" if strmf1[self.sql.strmf1_col.index("st1_type")] == "X": return "Invalid Code (Redundant)" if strmf1[self.sql.strmf1_col.index("st1_value_ind")] == "N": return "Invalid Code (Value Indicator)" self.vatcod = strmf1[self.sql.strmf1_col.index("st1_vatcode")] strmf2 = self.sql.getRec("strmf2", where=[("st2_cono", "=", self.opts["conum"]), ("st2_group", "=", self.grp), ("st2_code", "=", w), ("st2_loc", "=", self.loc)], limit=1) if not strmf2: return "Invalid Location" odt = self.sql.getRec("strpot", cols=["count(*)"], where=[("pot_cono", "=", self.opts["conum"]), ("pot_ordno", "=", self.ordno), ("pot_group", "=", self.grp), ("pot_code", "=", w)], limit=1) if odt[0]: return "This Item is Already On This Order" odq = self.sql.getRec(tables=["strpom", "strpot"], cols=["sum(pot_qty)"], where=[("pom_cono", "=", self.opts["conum"]), ("pom_loc", "=", self.loc), ("pom_delno", "=", ""), ("pot_cono", "=", self.opts["conum"]), ("pot_ordno=pom_ordno", ), ("pot_group", "=", self.grp), ("pot_code", "=", w)], limit=1) if odq[0]: state = self.df.disableButtonsTags() cf = PwdConfirm(self.opts["mf"], conum=self.opts["conum"], system="STR", code="DupOrd", desc="%s of this Item is Already On Order" % odq[0]) self.df.enableButtonsTags(state=state) if cf.flag == "no": return "rf" self.code = w desc = strmf1[self.sql.strmf1_col.index("st1_desc")] self.uoi = strmf1[self.sql.strmf1_col.index("st1_uoi")] self.df.loadEntry(frt, pag, p + 1, data=desc)
def doTntDat(self, frt, pag, r, c, p, i, w): if w < self.ch1 or w > self.ch2: ov = PwdConfirm(self.opts["mf"], conum=self.opts["conum"], system="RCA", code="DateOver") if ov.flag == "no": return "Invalid Date (< %s or > %s)" % (self.ch1, self.ch2) self.trndat = w data = [] for x in range(1, len(rctrtp) + 1): data.append((x, rctrtp[x - 1][1])) self.df.colf[2][2][8]["data"] = data
def doAcno(self, frt, pag, r, c, p, i, w): self.acno = w if self.acno: self.old = self.sql.getRec("drsmst", where=[("drm_cono", "=", self.opts["conum"]), ("drm_chain", "=", self.chain), ("drm_acno", "=", self.acno)], limit=1) if not self.acno or not self.old: ok = askQuestion(self.opts["mf"].body, "New Account", "Is This a New Account?", default="no") if ok == "no": return "Invalid Account Number" pw = PwdConfirm(self.opts["mf"], conum=self.opts["conum"], system="DRS", code="NewAcc") if pw.flag == "no": if "args" in self.opts: return "xt" else: return "New Account Creation is Not Allowed" self.new = True elif self.old[self.sql.drsmst_col.index("drm_stat")] == "X": return "Invalid Account, Redundant" else: self.new = False self.df.loadEntry("T", pag, p + 1, data=self.old[3]) d = 4 for pg in range(1, self.df.pgs + 1): for x in range(0, self.df.topq[pg]): if pg == 1 and x in (17, 19, 21): continue if pg == 2 and x in (8, 10): continue if pg == 2 and x == 11 and not self.old[d]: data = "N" else: data = self.old[d] self.df.loadEntry("T", pg, x, data=data) d += 1 self.loadRep() self.loadAct() self.loadTyp() self.loadInvMess() self.loadStaMess()
def doStrMaint(self): state = self.df.disableButtonsTags() cf = PwdConfirm(self.opts["mf"], conum=self.opts["conum"], system="STR", code="NewStr") if cf.flag == "yes": callModule(self.opts["mf"], self.df, "st1010", coy=(self.opts["conum"], self.opts["conam"]), period=None, user=self.opts["capnm"]) self.df.enableButtonsTags(state=state) self.df.focusField(self.df.frt, self.df.pag, self.df.col)
def doOwnAmt(self, frt, pag, r, c, p, i, w): if self.trntyp == 3 and w > self.due: op = PwdConfirm(self.opts["mf"], conum=self.opts["conum"], system="RCA", code="Overpaid") if op.flag == "no": return "Overpaid" self.trnamt = w # Ignore VAT at this stage self.vatcode = "" self.trnvat = 0 self.df.loadEntry(frt, pag, p + 1, data=self.vatcode) self.df.loadEntry(frt, pag, p + 2, data=self.trnvat) return "sk2"
def doEnd(self): recs = self.sql.getRec("ctlbat", cols=["count(*)"], where=[("btm_cono", "=", self.opts["conum"]), ("btm_styp", "=", "RTL"), ("btm_ind", "=", "N"), ("btm_curdt", "=", self.curdt)], limit=1) if recs[0]: ok = askQuestion(self.opts["mf"].body, "Unbalanced Batches Exist", "There are unbalanced batches for this month. You "\ "SHOULD not continue, but print a batch error report, and "\ "correct the errors. Continue, YES or NO ?", default="no") if ok == "yes": ok = PwdConfirm(self.opts["mf"], conum=self.opts["conum"], system="RTL", code="UnbalBatch") if ok.flag == "no": self.closeProcess() else: self.updateTables() else: self.closeProcess() else: self.updateTables()
def setVariables(self): self.gc = GetCtl(self.opts["mf"]) ctlsys = self.gc.getCtl("ctlsys", self.opts["conum"]) if not ctlsys: return self.years = ctlsys["sys_years"] if self.years and self.years < 7: showError( self.opts["mf"].body, "History", """At least 7 years history should be retained. Please select Control --> System Record Maintenance and change the Years to Keep field""" ) return ctlmst = self.gc.getCtl("ctlmst", self.opts["conum"]) if not ctlmst: return tabs = ["ctlsys", "ctlynd", "ftable"] self.mod = [] for x in range(0, len(ctlmst["ctm_modules"].rstrip()), 2): self.mod.append(ctlmst["ctm_modules"][x:x + 2]) if "AR" in self.mod: tabs.append("assctl") if "CR" in self.mod: tabs.append("crsage") if "DR" in self.mod: tabs.append("drsage") if "GL" in self.mod: ctlctl = self.gc.getCtl("ctlctl", self.opts["conum"]) if not ctlctl: return if self.gc.chkRec(self.opts["conum"], ctlctl, ["ret_inc"]): return self.ri_acc = ctlctl["ret_inc"] tabs.extend(["genbal", "genmst", "gentrn"]) if "LN" in self.mod: tabs.append("lonctl") if "ML" in self.mod: tabs.append("memage") tabs.append("memctl") if "RC" in self.mod: tabs.append("rcactl") if "RT" in self.mod: tabs.append("rtlctl") if "WG" in self.mod: tabs.append("wagctl") self.sql = Sql(self.opts["mf"].dbm, tabs, prog=self.__class__.__name__) if self.sql.error: return t = time.localtime() self.sysdtw = (t[0] * 10000) + (t[1] * 100) + t[2] self.c_per = int(self.opts["period"][0]) self.start = self.opts["period"][1][0] self.end = self.opts["period"][2][0] self.cur = int(self.opts["period"][2][0] / 100) self.l_per = self.sql.getRec("ctlynd", cols=["max(cye_period)"], where=[("cye_cono", "=", self.opts["conum"])], limit=1)[0] self.last, self.oldf = self.sql.getRec( "ctlynd", cols=["cye_last", "cye_final"], where=[("cye_cono", "=", self.opts["conum"]), ("cye_period", "=", self.opts["period"][0])], limit=1)[:2] if self.oldf == "Y" and "args" not in self.opts: cf = PwdConfirm(self.opts["mf"], conum=0, system="MST", code="YearEnd") if cf.pwd and cf.flag == "ok": return True if not cf.pwd: showError(self.opts["mf"].body, "Year-End Error", "This Period Has Already Been Finalised") return return True