예제 #1
0
 def getValues(self, data):
     self.grp = CCD(data[0], "UA", 3)
     code = CCD(data[1], "NA", 20)
     desc = CCD(data[2], "NA", 30)
     uoi = CCD(data[3], "NA", 10)
     bals = Balances(self.opts["mf"],
                     "STR",
                     self.opts["conum"],
                     self.cutoff,
                     keys=(self.grp.work, code.work, self.loc,
                           ("P", self.opts["period"][0])))
     m_ob, m_mv, m_cb, y_ob, y_mv, y_cb, ac, lc, ls = bals.doStrBals()
     m_qty = 0
     m_cst = 0
     m_sls = 0
     for t, q, c, s in m_mv:
         if t == 7:
             m_qty = q
             m_cst = c
             m_sls = s
             break
     y_qty = 0
     y_cst = 0
     y_sls = 0
     for t, q, c, s in y_mv:
         if t == 7:
             y_qty = q
             y_cst = c
             y_sls = s
             break
     mq = CCD(float(ASD(0) - ASD(m_qty)), "SI", 9)
     mc = CCD(float(ASD(0) - ASD(m_cst)), "SI", 9)
     ms = CCD(float(ASD(0) - ASD(m_sls)), "SI", 9)
     mp = float(ASD(ms.work) - ASD(mc.work))
     mp = CCD(mp, "SI", 9)
     if ms.work == 0:
         mn = 0
     else:
         mn = round((mp.work * 100 / ms.work), 2)
     mn = CCD(mn, "SD", 7.2)
     yq = CCD(float(ASD(0) - ASD(y_qty)), "SI", 9)
     yc = CCD(float(ASD(0) - ASD(y_cst)), "SI", 9)
     ys = CCD(float(ASD(0) - ASD(y_sls)), "SI", 9)
     yp = float(ASD(ys.work) - ASD(yc.work))
     yp = CCD(yp, "SI", 9)
     if not ys.work:
         yn = 0
     else:
         yn = round((yp.work * 100.0 / ys.work), 2)
     yn = CCD(yn, "SD", 7.2)
     if mq.work == 0 and mc.work == 0 and ms.work == 0 and \
             yq.work == 0 and yc.work == 0 and ys.work == 0:
         return
     self.gtot[0] = float(ASD(self.gtot[0]) + ASD(mq.work))
     self.gtot[1] = float(ASD(self.gtot[1]) + ASD(ms.work))
     self.gtot[2] = float(ASD(self.gtot[2]) + ASD(mp.work))
     self.gtot[3] = float(ASD(self.gtot[3]) + ASD(yq.work))
     self.gtot[4] = float(ASD(self.gtot[4]) + ASD(ys.work))
     self.gtot[5] = float(ASD(self.gtot[5]) + ASD(yp.work))
     return (code, desc, uoi, mq, ms, mp, mn, yq, ys, yp, yn)
예제 #2
0
 def getValues(self, data):
     acc = CCD(data[0], "UI", 6)
     name = CCD("%s, %s %s" % (data[3], data[1], data[2]), "NA", 30)
     bals = Balances(self.opts["mf"],
                     "MEM",
                     self.opts["conum"],
                     self.cutoff,
                     keys=(acc.work, ))
     obal, cbal, ages = bals.doAllBals()
     bal = CCD(cbal, "SD", 13.2)
     if self.limit and bal.work < self.limit:
         return
     if self.zero == "Y" and not bal.work:
         return
     if self.credit == "N" and bal.work < 0:
         return
     if self.onlycr == "Y" and bal.work >= 0:
         return
     cur = CCD(ages[0], "SD", 13.2)
     d30 = CCD(ages[1], "SD", 13.2)
     d60 = CCD(ages[2], "SD", 13.2)
     d90 = CCD(ages[3], "SD", 13.2)
     d120 = CCD(ages[4], "SD", 13.2)
     if bal.work < 0:
         deb = CCD(bal.work, "SD", 13.2)
     else:
         deb = CCD(0, "SD", 13.2)
     self.gtots[0] = float(ASD(self.gtots[0]) + ASD(deb.work))
     self.gtots[1] = float(ASD(self.gtots[1]) + ASD(bal.work))
     self.gtots[2] = float(ASD(self.gtots[2]) + ASD(cur.work))
     self.gtots[3] = float(ASD(self.gtots[3]) + ASD(d30.work))
     self.gtots[4] = float(ASD(self.gtots[4]) + ASD(d60.work))
     self.gtots[5] = float(ASD(self.gtots[5]) + ASD(d90.work))
     self.gtots[6] = float(ASD(self.gtots[6]) + ASD(d120.work))
     return (acc, name, deb, bal, cur, d30, d60, d90, d120)
예제 #3
0
 def updateTables(self, rec):
     bals = Balances(self.opts["mf"],
                     "STR",
                     self.opts["conum"],
                     int(self.sysdtw / 100),
                     keys=(rec[0], rec[1], rec[2],
                           ("P", self.opts["period"][0])))
     m_ob, m_mv, m_cb, y_ob, y_mv, y_cb, ac, lc, ls = bals.doStrBals()
     if self.minus == "N" and not ac and not lc:
         return
     fqty = CCD(y_cb[0], "SD", 12.2)
     fval = CCD(y_cb[1], "SD", 12.2)
     if self.minus == "Y" and fqty.work < 0:
         nqty = 0
     else:
         nqty = fqty.work
     if self.method == "L" and lc:
         nval = nqty * lc
     elif self.method == "A" and ac:
         nval = nqty * ac
     elif lc:
         nval = nqty * lc
     else:
         nval = nqty * ac
     dqty = float(ASD(nqty) - ASD(fqty.work))
     dval = float(ASD(nval) - ASD(fval.work))
     if not dqty and not dval:
         return
     # Stores Ledger Transaction
     if dqty >= 0:
         rtn = 5
     else:
         rtn = 6
     txt = "Revaluation"
     self.sql.insRec("strtrn",
                     data=[
                         self.opts["conum"], rec[0], rec[1], rec[2],
                         self.date, rtn, self.cnt, "ST-RVAL", "", dqty,
                         dval, 0, self.curdt, txt, 0, "", "", "STR", 0, "",
                         self.opts["capnm"], self.sysdtw, 0
                     ])
     if self.glint == "N":
         self.cnt = self.cnt + 1
         return
     # General Ledger Control Transaction (Stock On Hand)
     self.sql.insRec("gentrn",
                     data=[
                         self.opts["conum"], self.stk_soh, self.curdt,
                         self.date, 4, self.cnt, "ST-RVAL", dval, 0, txt,
                         "N", "", 0, self.opts["capnm"], self.sysdtw, 0
                     ])
     # General Ledger Control Transaction (Stock Reconciliation)
     val = float(ASD(0) - ASD(dval))
     self.sql.insRec("gentrn",
                     data=[
                         self.opts["conum"], self.stk_susp, self.curdt,
                         self.date, 4, self.cnt, "ST-RVAL", val, 0, txt,
                         "N", "", 0, self.opts["capnm"], self.sysdtw, 0
                     ])
예제 #4
0
 def printReport(self, recs):
     p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True)
     self.head = "%03u %-95s" % (self.opts["conum"], self.opts["conam"])
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head)
     self.tots = [0, 0]
     self.pglin = 999
     for num, dat in enumerate(recs):
         p.displayProgress(num)
         if p.quit:
             break
         chn = CCD(dat[self.col.index("drm_chain")], "UI", 3)
         acno = CCD(dat[self.col.index("drm_acno")], "NA", 7)
         name = CCD(dat[self.col.index("drm_name")], "NA", 30)
         rft = CCD(dat[self.col.index("drm_rfterms")], "UI", 3)
         per = CCD(dat[self.col.index("drm_int_per")], "UD", 5.2)
         if not per.work:
             if not self.defrte:
                 continue
             per = CCD(self.defrte, "UD", 5.2)
         bals = Balances(self.opts["mf"], "DRS", self.opts["conum"],
                         int(self.cutoff / 100), (chn.work, acno.work))
         obal, tbal, ages = bals.doAllBals()
         if tbal <= 0:
             continue
         bal = CCD(tbal, "SD", 13.2)
         tm = int(rft.work / 30)
         if tm > 4:
             tm = 4
         od = 0
         for x in range(tm, 5):
             od = float(ASD(od) + ASD(ages[x]))
         odu = CCD(od, "SD", 13.2)
         if odu.work <= 0 or (self.minbal and odu.work < self.minbal):
             continue
         b = round((odu.work * per.work / 1200), 2)
         amt = CCD(b, "SD", 13.2)
         if self.pglin > self.fpdf.lpp:
             self.pageHeading()
         self.fpdf.drawText("%s %s %s %s %s %s       %s %s" % \
             (chn.disp, acno.disp, name.disp, rft.disp, bal.disp,
             odu.disp, per.disp, amt.disp))
         self.pglin += 1
         self.tots[0] = float(ASD(self.tots[0]) + ASD(odu.work))
         self.tots[1] = float(ASD(self.tots[1]) + ASD(amt.work))
     p.closeProgress()
     if self.fpdf.page and not p.quit:
         self.grandTotal()
         pdfnam = getModName(self.opts["mf"].rcdic["wrkdir"],
                             self.__class__.__name__,
                             self.opts["conum"],
                             ext="pdf")
         self.fpdf.output(pdfnam, "F")
         doPrinter(mf=self.opts["mf"],
                   conum=self.opts["conum"],
                   pdfnam=pdfnam,
                   header=self.tit,
                   repprt=self.df.repprt,
                   fromad=self.fromad,
                   repeml=self.df.repeml)
예제 #5
0
 def doProcess(self):
     self.df.closeProcess()
     recs = self.sql.getRec("drsmst",
                            where=[("drm_cono", "=", self.opts["conum"]),
                                   ("drm_stat", "<>", "X")],
                            order="drm_chain, drm_name")
     if recs:
         col = self.sql.drsmst_col
         p = ProgressBar(self.opts["mf"].body,
                         typ="Calculating Ratings",
                         mxs=len(recs))
         for num, rec in enumerate(recs):
             p.displayProgress(num)
             chn = rec[col.index("drm_chain")]
             acc = rec[col.index("drm_acno")]
             rft = int(rec[col.index("drm_rfterms")] / 30)
             rjt = int(rec[col.index("drm_rjterms")] / 30)
             lim = rec[col.index("drm_limit")]
             stp = rec[col.index("drm_stop")]
             rte = rec[col.index("drm_rating")]
             if rte == "B" or stp == "Y":
                 rating = "B"
             else:
                 rating = None
                 bal = Balances(self.opts["mf"], "DRS", self.opts["conum"],
                                self.curdt, [chn, acc])
                 obal, cbal, age = bal.doAllBals()
                 if cbal > 0:
                     if lim and cbal > lim:
                         rating = "P"
                     if not rating and rft > 0:
                         bal = 0
                         for y in range(rft - 1, 5):
                             bal = float(ASD(bal) + ASD(age[y]))
                         if bal > 0:
                             rating = "F"
                     if not rating and rjt > 0:
                         bal = 0
                         for y in range(rjt - 1, 5):
                             bal = float(ASD(bal) + ASD(age[y]))
                         if bal > 0:
                             rating = "B"
                     if not rating and rte in ("", "N"):
                         rating = "G"
                 elif self.ignore == "N" and cbal == 0 and rte in ("", "N"):
                     rating = "G"
             if rating:
                 self.sql.updRec("drsmst",
                                 cols=["drm_rating"],
                                 data=[rating],
                                 where=[("drm_cono", "=",
                                         self.opts["conum"]),
                                        ("drm_chain", "=", chn),
                                        ("drm_acno", "=", acc)])
         p.closeProgress()
     self.opts["mf"].dbm.commitDbase(ask=True)
     self.opts["mf"].closeLoop()
예제 #6
0
 def loadBalances(self):
     bals = Balances(self.opts["mf"],
                     "ASS",
                     self.opts["conum"],
                     self.sper,
                     keys=(self.group, self.code))
     asset = bals.doAssBals(start=self.sper, end=self.eper, trans="C")
     if not asset:
         return
     cap, cdp, rdp, cbl, rbl, mov, trn = asset
     dte = self.sql.getRec("asstrn",
                           cols=["min(ast_date)"],
                           where=[("ast_cono", "=", self.opts["conum"]),
                                  ("ast_group", "=", self.group),
                                  ("ast_code", "=", self.code),
                                  ("ast_mtyp", "=", 1)],
                           limit=1)
     if dte[0]:
         val = self.sql.getRec("asstrn",
                               cols=["ast_amt1"],
                               where=[("ast_cono", "=", self.opts["conum"]),
                                      ("ast_group", "=", self.group),
                                      ("ast_code", "=", self.code),
                                      ("ast_mtyp", "=", 1),
                                      ("ast_date", "=", dte[0])],
                               limit=1)
         self.df.loadEntry("T", 2, 0, data=dte[0])
         self.df.loadEntry("T", 2, 1, data=val[0])
     self.df.loadEntry("C", 2, 0, data=cbl)
     if self.rordp == "Y":
         self.df.loadEntry("C", 2, 1, data=rbl)
     else:
         self.df.loadEntry("C", 2, 1, data=0)
     if mov:
         for n, c, r in mov:
             if self.rordp == "Y":
                 p = n * 2
             else:
                 p = n
             cbl = float(ASD(cbl) + ASD(c))
             if self.rordp == "Y":
                 rbl = float(ASD(rbl) + ASD(r))
             self.df.loadEntry("C", 2, p, data=c)
             if self.rordp == "Y":
                 self.df.loadEntry("C", 2, p + 1, data=r)
     if self.rordp == "Y":
         self.df.loadEntry("C", 2, 12, data=cbl)
         self.df.loadEntry("C", 2, 13, data=rbl)
     else:
         self.df.loadEntry("C", 2, 6, data=cbl)
예제 #7
0
 def loadBalances(self):
     bals = Balances(self.opts["mf"], "DRS", self.opts["conum"],
                     int(self.sysdtw / 100), (self.chain, self.acno))
     obal, tbal, ages = bals.doAllBals()
     this, hist = bals.doCrsDrsHist()
     self.sale = hist[0]
     self.pays = hist[1]
     last = self.sql.getRec("drstrn",
                            cols=["max(drt_trdt)"],
                            where=[("drt_cono", "=", self.opts["conum"]),
                                   ("drt_chain", "=", self.chain),
                                   ("drt_acno", "=", self.acno),
                                   ("drt_type", "=", 1)],
                            limit=1)
     if not last or not last[0]:
         lastsald = 0
     else:
         lastsald = last[0]
     last = self.sql.getRec("drstrn",
                            cols=["max(drt_trdt)"],
                            where=[("drt_cono", "=", self.opts["conum"]),
                                   ("drt_chain", "=", self.chain),
                                   ("drt_acno", "=", self.acno),
                                   ("drt_type", "=", 5)],
                            limit=1)
     if not last or not last[0]:
         lastpayd = 0
     else:
         lastpayd = last[0]
     for x in range(0, 8):
         if x == 0:
             data = lastsald
         elif x == 1:
             data = lastpayd
         elif x == 2:
             data = tbal
         else:
             data = ages[x - 3]
         self.df.loadEntry("T", 3, x, data=data)
     p = 0
     for x in range(0, 13):
         i = 0
         self.df.loadEntry("C", 4, p, data=self.sale[x])
         p = p + 1
         i = i + 1
         pay = float(ASD(0) - ASD(self.pays[x]))
         self.df.loadEntry("C", 4, p, data=pay)
         p = p + 1
         i = i + 1
예제 #8
0
 def getValues(self, data):
     grp = CCD(data[0], "UA", 3)
     code = CCD(data[1], "NA", 20)
     desc = CCD(data[2], "UA", 30)
     uoi = CCD(data[3], "NA", 10)
     whr = [("st2_cono", "=", self.opts["conum"]),
            ("st2_group", "=", grp.work), ("st2_code", "=", code.work)]
     if self.loc:
         whr.append(("st2_loc", "=", self.loc))
     st2 = self.sql.getRec(
         "strmf2",
         cols=["st2_reord_ind", "st2_reord_level", "st2_reord_qty"],
         where=whr,
         limit=1)
     if not st2:
         return
     if self.zero == "N" and not st2[1]:
         return
     req = CCD(st2[1], "SD", 12.2)
     bals = Balances(self.opts["mf"],
                     "STR",
                     self.opts["conum"],
                     int(self.repdtw / 100),
                     keys=(grp.work, code.work, self.loc))
     cbal, obal, bbal = bals.doStrOrds()
     tbal = float(ASD(cbal.work) + ASD(obal.work) - ASD(bbal.work))
     if req.work < tbal:
         if self.zero == "N":
             return
         tbal = CCD(0, "SD", 12.2)
         return (grp, code, desc, uoi, cbal, obal, bbal, tbal)
     tbal = float(ASD(req.work) - ASD(tbal))
     if tbal < st2[2]:
         tbal = st2[2]
     tbal = CCD(tbal, "SD", 12.2)
     if self.zero == "N" and not tbal.work:
         return
     if self.zero == "Y" and not cbal.work and not obal.work and not \
                                         bbal.work and not tbal.work:
         return
     return (grp, code, desc, uoi, cbal, obal, bbal, tbal)
예제 #9
0
 def getValues(self, data):
     bals = Balances(self.opts["mf"],
                     "ASS",
                     self.opts["conum"],
                     self.sper,
                     keys=(data[0], data[1]))
     asset = bals.doAssBals(start=self.sper, end=self.endper)
     if not asset:
         return
     cap, cdp, rdp, cbl, rbl, mov = asset
     vals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
     vals[0] = cap
     if self.rtype == "C":
         vals[1] = cdp
         vals[2] = cbl
         vals[9] = cbl
     else:
         vals[1] = rdp
         vals[2] = rbl
         vals[9] = rbl
     woff = False
     sold = False
     if mov:
         for m in mov:
             if m[0] == 3:
                 woff = True
             if m[0] == 5:
                 sold = True
             if self.rtype == "C":
                 idx = 1
             else:
                 idx = 2
             vals[m[0] + 2] = float(ASD(vals[m[0] + 2]) + ASD(m[idx]))
             vals[9] = float(ASD(vals[9]) + ASD(m[idx]))
     if woff or sold:
         vals[8] = vals[9]
         vals[9] = 0
     if self.zero == "Y" and all(v == 0 for v in vals[2:10]):
         return
     return vals
예제 #10
0
 def doGetBalTrn(self):
     if self.paid == "Y":
         trans = "A"
     else:
         trans = "Y"
     bals = Balances(self.opts["mf"], "MEM", self.opts["conum"], self.curdt,
                     (self.memno, ))
     self.obal, self.tbal, self.ages, self.mlt = bals.doAllBals(trans=trans)
     lnk = self.sql.getRec("memlnk",
                           cols=["mll_lnkno"],
                           where=[("mll_cono", "=", self.opts["conum"]),
                                  ("mll_memno", "=", self.memno)])
     if not lnk:
         return
     for l in lnk:
         bals = Balances(self.opts["mf"], "MEM", self.opts["conum"],
                         self.curdt, (l[0], ))
         obal, tbal, ages, mlt = bals.doAllBals(trans=trans)
         for n, d in enumerate(mlt[1]):
             mlt[1][n][mlt[0].index("mlt_desc")] = "%s (%s)" % \
                 (d[mlt[0].index("mlt_desc")][:30],
                 d[mlt[0].index("mlt_memno")])
         self.obal = float(ASD(self.obal) + ASD(obal))
         self.tbal = float(ASD(self.tbal) + ASD(tbal))
         for x in range(5):
             self.ages[x] = float(ASD(self.ages[x]) + ASD(ages[x]))
         self.mlt[1].extend(mlt[1])
         self.mlt[2] += mlt[2]
     # Sort Transaction by Date
     self.mlt[1].sort(key=lambda x: x[mlt[0].index("mlt_trdt")])
예제 #11
0
 def getValues(self, data):
     self.grp = CCD(data[0], "UA", 3)
     if self.df.repprt[2] != "export":
         if self.lstgrp and self.lstgrp != self.grp.work:
             self.groupTotal()
     cod = CCD(data[1], "NA", 20)
     dsc = CCD(data[2], "NA", 30)
     uoi = CCD(data[3], "NA", 10)
     bals = Balances(self.opts["mf"],
                     "STR",
                     self.opts["conum"],
                     self.coffw,
                     keys=(self.grp.work, cod.work, self.loc, ("S",
                                                               self.start)))
     more = []
     if self.chain:
         more.append(("stt_chain", "=", self.chain))
     if self.acno:
         more.append(("stt_acno", "in", tuple(self.acno)))
     this, hist = bals.doStrHist(more=more)
     bals = hist[2]
     purchd = ""
     purchw = []
     tot = 0
     for x in range(11, -1, -1):
         if self.rtype == "Q":
             amt = float(ASD(0) - ASD(bals[x][0]))
         elif self.rtype == "V":
             amt = float(ASD(0) - ASD(bals[x][2]))
         else:
             amt = float(ASD(0) - ASD(bals[x][2]) + ASD(bals[x][1]))
         amt = CCD(round(amt, 0), "SI", 10)
         tot = float(ASD(tot) + ASD(amt.work))
         self.stots[x] = float(ASD(self.stots[x]) + ASD(amt.work))
         self.gtots[x] = float(ASD(self.gtots[x]) + ASD(amt.work))
         purchd = purchd + amt.disp
         purchw.append(amt.work)
     if tot == 0:
         return
     return (cod, dsc, uoi, amt, purchd, purchw)
예제 #12
0
 def getValues(self, data):
     acc = CCD(data[0], "NA", 7)
     name = CCD(data[1], "NA", 30)
     bals = Balances(self.opts["mf"], "CRS", self.opts["conum"], self.coffw,
         (acc.work,))
     this, hist = bals.doCrsDrsHist()
     if not this:
         return
     purchd = ""
     purchw = []
     purtot = 0
     for x in range(11, -1, -1):
         amt = CCD(round(hist[0][x], 0), "SI", 10)
         self.gtots[x] = self.gtots[x] + amt.work
         purtot = purtot + amt.work
         if purchd:
             purchd = "%s %9s" % (purchd, amt.disp)
         else:
             purchd = "%9s" % amt.disp
         purchw.append(amt.work)
     if self.zer == "Y" and purtot == 0:
         return
     return acc, name, purchd, purchw
예제 #13
0
 def getRecipeItems(self):
     tab = ["strrcp", "strmf1"]
     col = ["srr_rgroup", "srr_rcode", "st1_desc", "srr_rqty"]
     whr = [("srr_cono", "=", self.opts["conum"]),
            ("srr_group", "=", self.group), ("srr_code", "=", self.code),
            ("srr_loc", "=", self.loc), ("st1_cono=srr_cono", ),
            ("st1_group=srr_rgroup", ), ("st1_code=srr_rcode", )]
     odr = "srr_rgroup, srr_rcode"
     items = self.sql.getRec(tables=tab, cols=col, where=whr, order=odr)
     for seq, item in enumerate(items):
         bals = Balances(self.opts["mf"],
                         "STR",
                         self.opts["conum"],
                         int(self.sysdtw / 100),
                         keys=(item[0], item[1], self.loc,
                               ("P", self.opts["period"][0])))
         m_ob, m_mv, m_cb, y_ob, y_mv, y_cb, ac, lc, ls = bals.doStrBals()
         items[seq].extend([y_cb[0], lc])
     return ((("srr_rgroup", "UA", 3.0, "Grp"), ("srr_rcode", "NA", 20.0,
                                                 "Product-Code"),
              ("st1_desc", "NA", 30.0,
               "Description"), ("srr_rqty", "UD", 11.2, "   Quantity"),
              ("balance", "SD", 13.2,
               "    In-Stock"), ("cost", "UD", 11.2, "  Last-Cost")), items)
예제 #14
0
 def printReport(self, recs):
     p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True)
     if self.rordp == "Y":
         self.head = "%03u %-118s" % (self.opts["conum"],
                                      self.opts["conam"])
     else:
         self.head = "%03u %-91s" % (self.opts["conum"], self.opts["conam"])
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head)
     oldgrp = ""
     oldcod = ""
     self.pglin = 999
     mc = self.sql.assmst_col
     for num, dat in enumerate(recs):
         p.displayProgress(num)
         if p.quit:
             break
         self.grp = CCD(dat[mc.index("asm_group")], "UA", 3)
         self.cod = CCD(dat[mc.index("asm_code")], "Na", 7)
         self.desc = CCD(dat[mc.index("asm_desc")], "NA", 30)
         bals = Balances(self.opts["mf"],
                         "ASS",
                         self.opts["conum"],
                         self.sper,
                         keys=(self.grp.work, self.cod.work))
         asset = bals.doAssBals(start=self.sdate, end=self.edate, trans="C")
         if not asset:
             continue
         cap, cdp, rdp, cbl, rbl, mov, trn = asset
         self.bal1 = cbl
         self.bal2 = rbl
         if trn[0]:
             for z in trn[0]:
                 dt = CCD(z[trn[1].index("ast_date")], "d1", 10)
                 rf = CCD(z[trn[1].index("ast_refno")], "Na", 9)
                 tp = CCD(z[trn[1].index("ast_type")], "UI", 1)
                 bt = CCD(z[trn[1].index("ast_batch")], "Na", 7)
                 mv = CCD(z[trn[1].index("ast_mtyp")], "UI", 1)
                 m1 = CCD(z[trn[1].index("ast_amt1")], "SD", 13.2)
                 m2 = CCD(z[trn[1].index("ast_amt2")], "SD", 13.2)
                 ds = CCD(z[trn[1].index("ast_desc")], "NA", 30)
                 if self.pglin > (self.fpdf.lpp - 10):
                     self.pageHeading()
                 if (oldgrp and self.grp.work != oldgrp) or \
                         (oldcod and self.cod.work != oldcod):
                     if self.npag == "Y":
                         self.pageHeading()
                     else:
                         self.accountHeading()
                 self.bal1 = float(ASD(self.bal1) + ASD(m1.work))
                 self.bal2 = float(ASD(self.bal2) + ASD(m2.work))
                 b1 = CCD(self.bal1, "SD", 13.2)
                 if self.rordp == "Y":
                     b2 = CCD(self.bal2, "SD", 13.2)
                     self.fpdf.drawText("%s %s %s %s %s %s %s %s %s %s" % \
                         (dt.disp, rf.disp, artrtp[tp.work-1][0], bt.disp,
                         armvtp[mv.work-1][0], m1.disp, b1.disp, m2.disp,
                         b2.disp, ds.disp))
                 else:
                     self.fpdf.drawText("%s %s %s %s %s %s %s %s" % \
                         (dt.disp, rf.disp, artrtp[tp.work-1][0], bt.disp,
                         armvtp[mv.work-1][0], m1.disp, b1.disp, ds.disp))
                 self.pglin += 1
                 oldgrp = self.grp.work
                 oldcod = self.cod.work
     p.closeProgress()
     if self.fpdf.page and not p.quit:
         pdfnam = getModName(self.opts["mf"].rcdic["wrkdir"],
                             self.__class__.__name__,
                             self.opts["conum"],
                             ext="pdf")
         self.fpdf.output(pdfnam, "F")
         doPrinter(mf=self.opts["mf"],
                   conum=self.opts["conum"],
                   pdfnam=pdfnam,
                   header=self.tit,
                   repprt=self.df.repprt,
                   repeml=self.df.repeml,
                   fromad=self.fromad)
예제 #15
0
 def getValues(self, data):
     chn = CCD(data[0], "UI", 3)
     acc = CCD(data[1], "NA", 7)
     name = CCD(data[2], "NA", 30)
     if self.base == "A":
         bals = Balances(self.opts["mf"],
                         "DRS",
                         self.opts["conum"],
                         self.cutoff,
                         keys=(data[0], data[1]))
         obal, cbal, ages = bals.doAllBals()
     else:
         pers = []
         yr = int(self.cutoff / 100)
         mt = int(self.cutoff % 100)
         for x in range(4):
             pers.append((yr * 100) + mt)
             mt -= 1
             if not mt:
                 yr -= 1
                 mt = 12
         cbal = 0
         ages = [0, 0, 0, 0, 0]
         bals = self.sql.getRec("drstrn",
                                cols=["drt_curdt", "sum(drt_tramt)"],
                                where=[("drt_cono", "=",
                                        self.opts["conum"]),
                                       ("drt_chain", "=", chn.work),
                                       ("drt_acno", "=", acc.work),
                                       ("drt_curdt", "<=", pers[0])],
                                group="drt_curdt",
                                order="drt_curdt")
         for bal in bals:
             try:
                 idx = pers.index(bal[0])
             except:
                 idx = 4
             ages[idx] = float(ASD(ages[idx]) + ASD(bal[1]))
             cbal = float(ASD(cbal) + ASD(bal[1]))
     bal = CCD(cbal, "SD", 13.2)
     if self.limit and bal.work < self.limit:
         return
     if self.zero == "Y" and not bal.work:
         return
     if self.credit == "N" and bal.work < 0:
         return
     if self.credit == "O" and bal.work >= 0:
         return
     cur = CCD(ages[0], "SD", 13.2)
     d30 = CCD(ages[1], "SD", 13.2)
     d60 = CCD(ages[2], "SD", 13.2)
     d90 = CCD(ages[3], "SD", 13.2)
     d120 = CCD(ages[4], "SD", 13.2)
     if bal.work < 0:
         deb = CCD(bal.work, "SD", 13.2)
     else:
         deb = CCD(0, "SD", 13.2)
     self.gtots[0] = float(ASD(self.gtots[0]) + ASD(deb.work))
     self.gtots[1] = float(ASD(self.gtots[1]) + ASD(bal.work))
     self.gtots[2] = float(ASD(self.gtots[2]) + ASD(cur.work))
     self.gtots[3] = float(ASD(self.gtots[3]) + ASD(d30.work))
     self.gtots[4] = float(ASD(self.gtots[4]) + ASD(d60.work))
     self.gtots[5] = float(ASD(self.gtots[5]) + ASD(d90.work))
     self.gtots[6] = float(ASD(self.gtots[6]) + ASD(d120.work))
     return (chn, acc, name, deb, bal, cur, d30, d60, d90, d120)
예제 #16
0
 def doRaiseAll(self, recs):
     if not self.args:
         p = ProgressBar(self.opts["mf"].body,
                         mxs=len(recs),
                         typ="Raising Depreciation ... Please Wait")
     for num, dat in enumerate(recs):
         if not self.args:
             p.displayProgress(num)
         self.group = CCD(dat[self.sql.assmst_col.index("asm_group")], "UA",
                          3)
         grp = self.sql.getRec("assgrp",
                               where=[("asg_cono", "=", self.opts["conum"]),
                                      ("asg_group", "=", self.group.work)],
                               limit=1)
         if not grp:
             if not self.args:
                 showError(self.opts["mf"].body, "Group Error",
                           "Missing Group (%s) Record" % self.group.disp)
             abort = True
             break
         self.depacc = grp[self.sql.assgrp_col.index("asg_depacc")]
         self.expacc = grp[self.sql.assgrp_col.index("asg_expacc")]
         self.code = dat[self.sql.assmst_col.index("asm_code")]
         depcod = dat[self.sql.assmst_col.index("asm_depcod")]
         # Get Depreciation Record
         self.dep = self.sql.getRec(tables="assdep",
                                    where=[("asd_cono", "=",
                                            self.opts["conum"]),
                                           ("asd_code", "=", depcod)],
                                    limit=1)
         if not self.dep:
             showError(self.opts["mf"].body, "Error",
                 "Depreciation Code %s Does Not Exist.\n\n"\
                 "Aborting." % depcod)
             abort = True
             break
         bals = Balances(self.opts["mf"],
                         "ASS",
                         self.opts["conum"],
                         self.sper,
                         keys=(self.group.work, self.code))
         asset = bals.doAssBals()
         if not asset:
             continue
         self.cap, cdp, rdp, cbl, rbl, mov = asset
         # Raise depreciation from start period to curdt or sale date
         self.lurdt = self.sper
         sales = False
         while not sales and self.lurdt <= self.curdt:
             trans = self.sql.getRec(
                 "asstrn",
                 cols=["ast_mtyp", "round(sum(ast_amt1), 2)"],
                 where=[("ast_cono", "=", self.opts["conum"]),
                        ("ast_group", "=", self.group.work),
                        ("ast_code", "=", self.code),
                        ("ast_curdt", "=", self.lurdt),
                        ("ast_mtyp", "<>", 4)],
                 group="ast_mtyp")
             if trans:
                 for mov, amt in trans:
                     if mov == 5:
                         sales = True
                         self.cap = 0
                         break
                     self.cap = float(ASD(self.cap) + ASD(amt))
             if self.cap:
                 self.doRaiseDep()
             self.lurdt = self.doIncrCurdt()
     if not self.args:
         p.closeProgress()
     if abort:
         self.opts["mf"].dbm.rollbackDbase()
     else:
         self.sql.updRec("assctl",
                         cols=["cta_lastp"],
                         data=[self.curdt],
                         where=[("cta_cono", "=", self.opts["conum"])])
         self.opts["mf"].dbm.commitDbase()
예제 #17
0
 def doProcess(self, drm):
     dmc = self.sql.drsmst_col
     dtc = self.sql.drstrn_col
     tdc = self.form.sql.tpldet_col
     self.chn = drm[dmc.index("drm_chain")]
     self.acc = drm[dmc.index("drm_acno")]
     eml = drm[dmc.index("drm_acc_email")]
     self.form.account_details("drm", dmc, drm, 1)
     if drm[dmc.index("drm_stames")]:
         self.mesno = drm[dmc.index("drm_stames")]
     else:
         self.mesno = self.mess
     for col in dmc:
         d = "%s_C00" % col
         if d in self.form.newdic:
             dat = drm[dmc.index(col)]
             self.form.newdic[d][tdc.index("tpd_text")] = dat
     bals = Balances(self.opts["mf"], "DRS", self.opts["conum"], self.curdt,
                     (self.chn, self.acc))
     if self.alloc == "Y":
         tt = "A"
     else:
         tt = "Y"
     obal, self.tbal, self.ages, trns = bals.doAllBals(trans=tt)
     if not trns[1]:
         return
     if self.sttyp == "O":
         self.tots = [0.0, 0.0, 0.0]
         cmth = False
         tran = copyList(trns[1])
         for t in tran:
             if t[dtc.index("drt_type")] not in (2, 6) and \
                     t[dtc.index("drt_curdt")] == self.curdt:
                 self.tots[1] = float(ASD(self.tots[1]) + \
                     ASD(t[dtc.index("drt_tramt")]))
                 if t[dtc.index("drt_taxamt")]:
                     self.tots[1] = float(ASD(self.tots[1]) - \
                         ASD(t[dtc.index("drt_taxamt")]))
                     self.tots[2] = float(ASD(self.tots[2]) + \
                         ASD(t[dtc.index("drt_taxamt")]))
             else:
                 self.tots[0] = float(ASD(self.tots[0]) + \
                     ASD(t[dtc.index("drt_tramt")]))
             if t[dtc.index("drt_curdt")] == self.curdt:
                 cmth = True
             elif self.oitem == "N":
                 trns[1].remove(t)
         if self.zeros == "N" and not self.tbal and not cmth:
             return
         if self.minus == "N" and self.tbal < 0:
             return
         if self.oitem == "N" and obal:
             t[trns[0].index("drt_type")] = 3
             t[trns[0].index("drt_ref1")] = "O/Bal"
             t[trns[0].index("drt_batch")] = ""
             t[trns[0].index("drt_trdt")] = (self.curdt * 100) + 1
             t[trns[0].index("drt_ref2")] = ""
             t[trns[0].index("drt_tramt")] = obal
             t[trns[0].index("drt_taxamt")] = 0
             t[trns[0].index("drt_desc")] = "Opening Balance"
             t[trns[0].index("drt_taxind")] = ""
             t[trns[0].index("drt_batind")] = ""
             trns[1].insert(0, t)
         if len(trns[1]) <= self.form.maxlines:
             self.doBody(trns[0], trns[1], tdc)
         else:
             pages = int(len(trns[1]) / self.form.maxlines)
             if len(trns[1]) % self.form.maxlines:
                 pages += 1
             if pages <= self.pages:
                 self.doBody(trns[0], trns[1], tdc)
             else:
                 bal = 0
                 lines = len(
                     trns[1]) - (self.pages * self.form.maxlines) + 1
                 for _ in range(lines):
                     trn = trns[1].pop(0)
                     bal = float(
                         ASD(bal) + ASD(trn[dtc.index("drt_tramt")]))
                 trn[trns[0].index("drt_type")] = 3
                 trn[trns[0].index("drt_ref1")] = "B/FWD"
                 trn[trns[0].index("drt_batch")] = ""
                 trn[trns[0].index("drt_ref2")] = ""
                 trn[trns[0].index("drt_tramt")] = bal
                 trn[trns[0].index("drt_taxamt")] = 0
                 trn[trns[0].index("drt_desc")] = "Balance Brought Forward"
                 trn[trns[0].index("drt_taxind")] = ""
                 trn[trns[0].index("drt_batind")] = ""
                 trns[1].insert(0, trn)
                 self.doBody(trns[0], trns[1], tdc)
     else:
         if self.zeros == "N" and not self.tbal:
             return
         if self.minus == "N" and self.tbal < 0:
             return
         self.doBody(trns[0], trns[1], tdc)
     self.doTotal(tdc)
     self.doTail(tdc)
     if self.df.repeml[1] == "Y" and not self.emadd:
         self.df.repeml[2] = eml
         self.doPrint()
예제 #18
0
 def printReport(self, recs):
     p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True)
     self.head = "%03u %-169s" % (self.opts["conum"], self.opts["conam"])
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head)
     self.stots = [0] * 13
     self.ctots = [0] * 13
     self.pglin = 999
     for x1, r1 in enumerate(recs):
         p.displayProgress(x1)
         if p.quit:
             break
         rep = CCD(r1[0], "Na", 3)
         name = CCD(r1[1], "NA", 30)
         bals = Balances(self.opts["mf"], "STR", self.opts["conum"],
             self.end, (rep.work,))
         this, hist = bals.doStrHist(self.start)
         if this == 0:
             continue
         costsd = ""
         salesd = ""
         proftd = ""
         prperd = ""
         prt = False
         mchart = ["T", name.work]
         for x2 in range(11,-1,-1):
             c = float(ASD(0) - ASD(hist[2][x2][1]))
             c = CCD(round(c, 0), "SL", 11)
             s = float(ASD(0) - ASD(hist[2][x2][2]))
             s = CCD(round(s, 0), "SL", 11)
             if c.work or s.work:
                 prt = True
             prf = float(ASD(s.work) - ASD(c.work))
             prf = CCD(round(prf, 0), "SL", 11)
             if s.work == 0:
                 pcn = 0
             else:
                 pcn = round((prf.work * 100.0 / s.work), 2)
             pcn = CCD(pcn, "SD", 11.2)
             self.ctots[x2] = self.ctots[x2] + c.work
             self.stots[x2] = self.stots[x2] + s.work
             costsd = costsd + c.disp
             salesd = salesd + s.disp
             proftd = proftd + prf.disp
             prperd = prperd + pcn.disp
             mchart.append(s.work)
         if not prt:
             continue
         self.mchart.append(mchart)
         if self.pglin > (self.fpdf.lpp - 5):
             self.pageHeading()
         self.fpdf.drawText("%s %s %-6s %s" % (rep.disp, name.disp,
             "Sales", salesd))
         self.fpdf.drawText("%-34s %-6s %s" % ("", "Costs ", costsd))
         self.fpdf.drawText("%-34s %-6s %s" % ("", "Profit", proftd))
         self.fpdf.drawText("%-34s %-6s %s" % ("", "Prf-% ", prperd))
         self.fpdf.underLine(txt=self.head)
         self.pglin += 5
     p.closeProgress()
     if self.fpdf.page and not p.quit:
         self.grandTotal()
         if "args" not in self.opts or "noprint" not in self.opts["args"]:
             pdfnam = getModName(self.opts["mf"].rcdic["wrkdir"],
                 self.__class__.__name__, self.opts["conum"], ext="pdf")
             self.fpdf.output(pdfnam, "F")
             doPrinter(mf=self.opts["mf"], conum=self.opts["conum"],
                 pdfnam=pdfnam, header=self.tit, repprt=self.df.repprt,
                 fromad=self.fromad, repeml=self.df.repeml)
             CreateChart(self.opts["mf"], self.opts["conum"],
                 self.opts["conam"], [self.start, self.end],
                 [[self.opts["conam"], "Saleman's Sales History"],
                 "Values"], None, self.mchart)
예제 #19
0
 def printReport(self, recs):
     p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True)
     self.head = "%03u %-108s" % (self.opts["conum"], self.opts["conam"])
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head)
     self.stot = [0] * 3
     self.gtot = [0] * 3
     lstgrp = ""
     self.pglin = 999
     for num, rec in enumerate(recs):
         p.displayProgress(num)
         if p.quit:
             break
         self.grp = CCD(rec[0], "UA", 3)
         code = CCD(rec[1], "NA", 20)
         desc = CCD(rec[2], "NA", 30)
         uoi = CCD(rec[3], "NA", 10)
         bals = Balances(self.opts["mf"],
                         "STR",
                         self.opts["conum"],
                         self.per,
                         keys=(self.grp.work, code.work, self.loc,
                               ("P", self.opts["period"][0])))
         m_ob, m_mv, m_cb, y_ob, y_mv, y_cb, ac, lc, ls = bals.doStrBals()
         m_qty = 0
         m_cst = 0
         m_sls = 0
         for t, q, c, s in m_mv:
             if t == 7:
                 m_qty = q
                 m_cst = c
                 m_sls = s
                 break
         mq = CCD(float(ASD(0) - ASD(m_qty)), "SD", 13.2)
         mc = CCD(float(ASD(0) - ASD(m_cst)), "SD", 13.2)
         ms = CCD(float(ASD(0) - ASD(m_sls)), "SD", 13.2)
         mp = float(ASD(ms.work) - ASD(mc.work))
         mp = CCD(mp, "SD", 13.2)
         if ms.work == 0:
             mn = 0
         else:
             mn = round((mp.work * 100.0 / ms.work), 2)
         mn = CCD(mn, "SD", 7.2)
         if mq.work == 0 and mc.work == 0 and ms.work == 0:
             continue
         if lstgrp and lstgrp != self.grp.work:
             self.groupTotal()
             self.pglin = 999
         if self.pglin > self.fpdf.lpp:
             self.pageHeading()
         self.fpdf.drawText("%s %s %s %s %s %s %s" %
                            (code.disp, desc.disp, uoi.disp, mq.disp,
                             ms.disp, mp.disp, mn.disp))
         self.stot[0] = float(ASD(self.stot[0]) + ASD(mq.work))
         self.stot[1] = float(ASD(self.stot[1]) + ASD(ms.work))
         self.stot[2] = float(ASD(self.stot[2]) + ASD(mp.work))
         self.gtot[0] = float(ASD(self.gtot[0]) + ASD(mq.work))
         self.gtot[1] = float(ASD(self.gtot[1]) + ASD(ms.work))
         self.gtot[2] = float(ASD(self.gtot[2]) + ASD(mp.work))
         self.pglin += 1
         lstgrp = self.grp.work
     p.closeProgress()
     if self.fpdf.page and not p.quit:
         self.groupTotal()
         self.grandTotal()
         if "args" not in self.opts or "noprint" not in self.opts["args"]:
             pdfnam = getModName(self.opts["mf"].rcdic["wrkdir"],
                                 self.__class__.__name__,
                                 self.opts["conum"],
                                 ext="pdf")
             self.fpdf.output(pdfnam, "F")
             doPrinter(mf=self.opts["mf"],
                       conum=self.opts["conum"],
                       pdfnam=pdfnam,
                       header=self.tit,
                       repprt=self.df.repprt,
                       fromad=self.fromad,
                       repeml=self.df.repeml)
예제 #20
0
 def printReport(self, recs):
     data = []
     p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True)
     self.head = "%03u %-135s" % (self.opts["conum"], self.opts["conam"])
     for num, dat in enumerate(recs):
         p.displayProgress(num)
         if p.quit:
             break
         grp = dat[self.sql.strvar_col.index("stv_group")]
         code = dat[self.sql.strvar_col.index("stv_code")]
         sbin = dat[self.sql.strvar_col.index("stv_bin")]
         qty1 = dat[self.sql.strvar_col.index("stv_qty")]
         prc = dat[self.sql.strvar_col.index("stv_ucost")]
         bals = Balances(self.opts["mf"],
                         "STR",
                         self.opts["conum"],
                         int(self.date / 100),
                         keys=(grp, code, self.loc,
                               ("P", self.opts["period"][0])))
         m_ob, m_mv, m_cb, y_ob, y_mv, y_cb, ac, lc, ls = bals.doStrBals()
         fq = y_cb[0]
         if ac:
             fp = ac
         else:
             fp = lc
         diff = float(ASD(fq) - ASD(qty1))
         rslt = self.sql.getRec("strmf1",
                                cols=["st1_desc", "st1_uoi"],
                                where=[("st1_cono", "=",
                                        self.opts["conum"]),
                                       ("st1_group", "=", grp),
                                       ("st1_code", "=", code)],
                                limit=1)
         desc = rslt[0]
         uoi = rslt[1]
         data.append([grp, code, desc, uoi, sbin, fp, prc, fq, qty1, diff])
     p.closeProgress()
     if not p.quit:
         name = self.__class__.__name__
         head = [
             "Stock Take Variance Report as at %s" % self.dated,
             "Location %s  %s" % (self.loc, self.locd)
         ]
         cols = [["a", "NA", 3, "Grp", "y"],
                 ["b", "NA", 20, "Product-Code", "y"],
                 ["c", "NA", 30, "Description", "y"],
                 ["d", "NA", 10, "U.O.I", "y"],
                 ["e", "NA", 8, "Bin-Loc", "y"],
                 ["f", "SD", 12.2, "File-Cost", "y"],
                 ["g", "UD", 12.2, "Stkt-Cost", "y"],
                 ["h", "SD", 12.2, "File-Qty", "y"],
                 ["i", "SD", 12.2, "Stkt-Qty", "y"],
                 ["j", "SD", 12.2, "Difference", "y"]]
         RepPrt(self.opts["mf"],
                conum=self.opts["conum"],
                conam=self.opts["conam"],
                name=name,
                tables=data,
                heads=head,
                cols=cols,
                ttype="D",
                repprt=self.df.repprt,
                repeml=self.df.repeml,
                fromad=self.fromad)
예제 #21
0
 def loadBalances(self):
     bals = Balances(self.opts["mf"],
                     "STR",
                     self.opts["conum"],
                     int(self.sysdtw / 100),
                     keys=(self.group, self.code, self.loc,
                           ("P", self.opts["period"][0])))
     m_ob, m_mv, m_cb, y_ob, y_mv, y_cb, ac, lc, ls = bals.doStrBals()
     cb, oo, bo = bals.doStrOrds()
     this, hist = bals.doStrHist()
     rec = hist[0]
     rec.append(this[0])
     iss = hist[1]
     iss.append(this[1])
     lrec = self.sql.getRec("strtrn",
                            cols=["max(stt_trdt)"],
                            where=[("stt_cono", "=", self.opts["conum"]),
                                   ("stt_group", "=", self.group),
                                   ("stt_code", "=", self.code),
                                   ("stt_loc", "=", self.loc),
                                   ("stt_type", "in", (1, 3))])
     if not lrec[0][0]:
         lastrec = 0
     else:
         lastrec = lrec[0][0]
     liss = self.sql.getRec("strtrn",
                            cols=["max(stt_trdt)"],
                            where=[("stt_cono", "=", self.opts["conum"]),
                                   ("stt_group", "=", self.group),
                                   ("stt_code", "=", self.code),
                                   ("stt_loc", "=", self.loc),
                                   ("stt_type", "in", (2, 4, 7, 8))])
     if not liss or not liss[0][0]:
         lastiss = 0
     else:
         lastiss = liss[0][0]
     qbal = float(y_cb[0])
     vbal = float(y_cb[1])
     if qbal:
         cost = round((vbal / qbal), 2)
     else:
         cost = 0.0
     cst = CCD(cost, "SD", 10.2)
     self.df.loadEntry("T", 2, 0, data=lastrec)
     self.df.loadEntry("T", 2, 1, data=lastiss)
     self.df.loadEntry("T", 2, 2, data=qbal)
     self.df.loadEntry("T", 2, 3, data=vbal)
     self.df.loadEntry("T", 2, 4, data=cst.disp)
     self.df.loadEntry("T", 2, 5, data=oo.disp)
     self.df.loadEntry("T", 2, 6, data=bo.disp)
     p = 0
     for x in range(0, 13):
         i = 0
         self.df.loadEntry("C", 3, p, data=rec[x][0])
         p = p + 1
         i = i + 1
         self.df.loadEntry("C", 3, p, data=rec[x][1])
         p = p + 1
         i = i + 1
         amt = float(ASD(0) - ASD(iss[x][0]))
         self.df.loadEntry("C", 3, p, data=amt)
         p = p + 1
         i = i + 1
         amt = float(ASD(0) - ASD(iss[x][1]))
         self.df.loadEntry("C", 3, p, data=amt)
         p = p + 1
         i = i + 1
예제 #22
0
 def updateTables(self, cnt, col, rec):
     grp = rec[col.index("stv_group")]
     code = rec[col.index("stv_code")]
     loc = rec[col.index("stv_loc")]
     vqty = CCD(rec[col.index("stv_qty")], "SD", 12.2)
     vprc = CCD(rec[col.index("stv_ucost")], "UD", 12.2)
     sell = CCD(rec[col.index("stv_usell")], "UD", 12.2)
     # Selling Price Records
     if sell.work:
         whr = [("stp_cono", "=", self.opts["conum"]),
                ("stp_group", "=", grp), ("stp_code", "=", code),
                ("stp_loc", "=", loc), ("stp_level", "=", 1)]
         self.sql.delRec("strprc", where=whr)
         self.sql.insRec(
             "strprc",
             data=[self.opts["conum"], grp, code, loc, 1, sell.work])
     # Test for Variances
     bals = Balances(self.opts["mf"],
                     "STR",
                     self.opts["conum"],
                     self.curdt,
                     keys=(grp, code, loc, ("P", self.opts["period"][0])))
     m_ob, m_mv, m_cb, y_ob, y_mv, y_cb, ac, lc, ls = bals.doStrBals()
     fqty = CCD(y_cb[0], "SD", 12.2)
     fval = CCD(y_cb[1], "SD", 12.2)
     if fval.work and fqty.work:
         c = round((fval.work / fqty.work), 2)
     else:
         c = 0
     fprc = CCD(c, "SD", 12.2)
     if fprc.work != vprc.work and vprc.work:
         prc = vprc.work
     else:
         prc = fprc.work
     prc = CCD(prc, "SD", 12.2)
     val = round((prc.work * vqty.work), 2)
     vval = CCD(val, "SD", 12.2)
     qdif = CCD(float(ASD(vqty.work) - ASD(fqty.work)), "SD", 12.2)
     vdif = CCD(float(ASD(vval.work) - ASD(fval.work)), "SD", 12.2)
     if not qdif.work and not vdif.work:
         return
     # Stores Ledger Transaction
     if qdif.work >= 0:
         rtn = 5
     else:
         rtn = 6
     ref = CCD(cnt, "Na", 9).work
     self.sql.insRec("strtrn",
                     data=[
                         self.opts["conum"], rec[col.index("stv_group")],
                         rec[col.index("stv_code")],
                         rec[col.index("stv_loc")], self.date, rtn, ref,
                         "ST-MERG", "", qdif.work, vdif.work, 0, self.curdt,
                         "Stock Take Adjustment", 0, "", "", "STR", 0, "",
                         self.opts["capnm"], self.sysdtw, 0
                     ])
     if self.glint == "N":
         return
     # General Ledger Control Transaction (Stock On Hand)
     col = self.sql.gentrn_col
     acc = self.sql.getRec("gentrn",
                           where=[("glt_cono", "=", self.opts["conum"]),
                                  ("glt_acno", "=", self.stk_soh),
                                  ("glt_curdt", "=", self.curdt),
                                  ("glt_trdt", "=", self.date),
                                  ("glt_type", "=", 4),
                                  ("glt_refno", "=", "STOCK-ADJ"),
                                  ("glt_batch", "=", "ST-MERG")],
                           limit=1)
     if acc:
         amnt = float(ASD(acc[col.index("glt_tramt")]) + ASD(vdif.work))
         self.sql.updRec("gentrn",
                         cols=["glt_tramt"],
                         data=[amnt],
                         where=[("glt_seq", "=", acc[col.index("glt_seq")])
                                ])
     else:
         self.sql.insRec("gentrn",
                         data=[
                             self.opts["conum"], self.stk_soh, self.curdt,
                             self.date, 4, "STOCK-ADJ", "ST-MERG",
                             vdif.work, 0, "Stock Take Adjustment", "N", "",
                             0, self.opts["capnm"], self.sysdtw, 0
                         ])
     # General Ledger Control Transaction (Stock Suspense)
     val = float(ASD(0) - ASD(vdif.work))
     acc = self.sql.getRec("gentrn",
                           where=[("glt_cono", "=", self.opts["conum"]),
                                  ("glt_acno", "=", self.stk_susp),
                                  ("glt_curdt", "=", self.curdt),
                                  ("glt_trdt", "=", self.date),
                                  ("glt_type", "=", 4),
                                  ("glt_refno", "=", "STOCK-ADJ"),
                                  ("glt_batch", "=", "ST-MERG")],
                           limit=1)
     if acc:
         amnt = float(ASD(acc[col.index("glt_tramt")]) + ASD(val))
         self.sql.updRec("gentrn",
                         cols=["glt_tramt"],
                         data=[amnt],
                         where=[("glt_seq", "=", acc[col.index("glt_seq")])
                                ])
     else:
         self.sql.insRec("gentrn",
                         data=[
                             self.opts["conum"], self.stk_susp, self.curdt,
                             self.date, 4, "STOCK-ADJ", "ST-MERG", val, 0,
                             "Stock Take Adjustment", "N", "", 0,
                             self.opts["capnm"], self.sysdtw, 0
                         ])
예제 #23
0
 def printReport(self, recs):
     p = ProgressBar(self.opts["mf"].body, mxs=len(recs), esc=True)
     self.head = "%03u %-87s" % (self.opts["conum"], self.opts["conam"])
     self.fpdf = MyFpdf(name=self.__class__.__name__, head=self.head)
     lstgrp = ""
     self.pglin = 999
     for num, dat in enumerate(recs):
         p.displayProgress(num)
         if p.quit:
             break
         grp = CCD(dat[0], "UA", 3)
         cod = CCD(dat[1], "NA", 20)
         desc = CCD(dat[2], "UA", 30)
         bals = Balances(self.opts["mf"],
                         "STR",
                         self.opts["conum"],
                         self.edate,
                         keys=(grp.work, cod.work, self.loc,
                               ("P", self.opts["period"][0])))
         m_ob, m_mv, m_cb, y_ob, y_mv, y_cb, ac, lc, ls, stt_rslt = \
             bals.doStrBals(self.sdate, trans="Y")
         self.qfwd = y_ob[0]
         self.vfwd = y_ob[1]
         trs = stt_rslt[0]
         dic = stt_rslt[1]
         if self.qfwd or self.vfwd or trs:
             if lstgrp and self.npag == "Y":
                 self.pageHeading(grp.disp, cod.disp, desc.disp)
             elif lstgrp or self.qfwd or self.vfwd:
                 self.accountHeading(grp.disp, cod.disp, desc.disp)
             lstgrp = grp.work
         if trs:
             for z in trs:
                 dt = CCD(z[dic["stt_trdt"][1]], "d1", 10)
                 qt = CCD(z[dic["stt_qty"][1]], "SD", 12.2)
                 cs = CCD(z[dic["stt_cost"][1]], "SD", 12.2)
                 bt = CCD(z[dic["stt_batch"][1]], "Na", 7)
                 r1 = CCD(z[dic["stt_ref1"][1]], "Na", 9)
                 r2 = CCD(z[dic["stt_ref1"][1]], "Na", 7)
                 tp = CCD(z[dic["stt_type"][1]], "UI", 1)
                 if self.pglin > (self.fpdf.lpp - 7):
                     self.pageHeading(grp.disp, cod.disp, desc.disp)
                 self.qfwd = float(ASD(self.qfwd) + ASD(qt.work))
                 self.vfwd = float(ASD(self.vfwd) + ASD(cs.work))
                 qb = CCD(self.qfwd, "SD", 12.2)
                 vb = CCD(self.vfwd, "SD", 12.2)
                 self.fpdf.drawText("%s %s %s %s %s %s %s %s %s" % \
                     (bt.disp, r1.disp, r2.disp, sttrtp[tp.work-1][0],
                     dt.disp, qt.disp, cs.disp, qb.disp, vb.disp))
                 self.pglin += 1
     p.closeProgress()
     if self.fpdf.page and not p.quit:
         if "args" not in self.opts or "noprint" not in self.opts["args"]:
             pdfnam = getModName(self.opts["mf"].rcdic["wrkdir"],
                                 self.__class__.__name__,
                                 self.opts["conum"],
                                 ext="pdf")
             self.fpdf.output(pdfnam, "F")
             doPrinter(mf=self.opts["mf"],
                       conum=self.opts["conum"],
                       pdfnam=pdfnam,
                       header=self.tit,
                       repprt=self.df.repprt,
                       fromad=self.fromad,
                       repeml=self.df.repeml)