Exemple #1
0
 def doNames(self, frt, pag, r, c, p, i, w):
     if self.newtab:
         chk = self.sql.getRec("bwltab",
                               where=[("btb_cono", "=", self.opts["conum"]),
                                      ("btb_surname", "=", self.sname,
                                       "and", "btb_names", "=", w)],
                               limit=1)
         if chk:
             tab = chk[self.sql.bwltab_col.index("btb_tab")]
             self.doTab(frt, pag, 0, 1, 0, 0, tab)
             return "ff3"
         if self.mstart < self.fstart and self.tab >= self.fstart:
             self.df.loadEntry(frt, pag, p + 1, data="F")
         elif self.fstart < self.mstart and self.tab < self.mstart:
             self.df.loadEntry(frt, pag, p + 1, data="F")
         return
     if self.sname != self.snam or w != self.fnam:
         but = [("Amendment", "A"), ("Re-Issue", "R"), ("Neither", "N")]
         ok = askChoice(self.opts["mf"].body,
                        "Name Change",
                        "Please Select the Reason for the Name Change",
                        butt=but,
                        default="Neither")
         if ok == "N":
             return "ff3"
         if ok == "R":
             self.tabchg = True
             for x in range(1, 15):
                 self.df.clearEntry(frt, pag, c + x)
Exemple #2
0
 def doPrint(self):
     mess = "Select the Required Print Option."
     butt = (("Information", "I"), ("Transactions", "T"), ("Both", "B"),
             ("None", "N"))
     self.doPrintOption(
         askChoice(self.opts["mf"].body, "Print Options", mess, butt=butt))
     self.df.focusField(self.df.frt, self.df.pag, self.df.col)
Exemple #3
0
    def doExport(self):
        self.df.setWidget(self.df.mstFrame, state="hide")
        typ = askChoice(self.opts["mf"].window, "Type", "Select the File Type",
            butt=(
                ("CSV", "C", "Export to a csv file for Importing "\
                    "into e.g. 'Password Safe'"),
                ("XML", "X", "Export to a xml file for Importing "\
                    "into e.g. 'KeePassX'")), default="CSV")
        self.df.setWidget(self.df.mstFrame, state="show")
        if typ == "C":
            fle = os.path.join(self.opts["mf"].rcdic["wrkdir"], "secrets.csv")
            csvwrt = csv.writer(open(fle, "w"), delimiter=";", quotechar='"',
               quoting=csv.QUOTE_MINIMAL)
            csvwrt.writerow(["Title", "Category", "Username", "Password",
                "Website","Comments"])
        else:
            fle = os.path.join(self.opts["mf"].rcdic["wrkdir"], "secrets.xml")
            xml = open(fle, "w")
            xml.write("""<!DOCTYPE KEEPASSX_DATABASE>
<database>
 <group>
  <title>Secrets</title>
  <icon>0</icon>""")
        codes = list(self.data[self.opts["capnm"]].keys())
        codes.sort()
        for code in codes:
            log, enc = self.data[self.opts["capnm"]][code]
            log = log.replace("&", "and").replace("<", "").replace(">","")
            enc = enc.replace("&", "and").replace("<", "").replace(">","")
            if typ == "C":
                csvwrt.writerow([code, "", log, enc, "", ""])
            else:
                xml.write("""
  <entry>
   <title>%s</title>
   <username>%s</username>
   <password>%s</password>
   <url></url>
   <comment></comment>
   <icon>0</icon>
   <creation>0</creation>
   <lastaccess>0</lastaccess>
   <lastmod>0</lastmod>
   <expire>Never</expire>
  </entry>""" % (code, log, enc))
        if typ == "X":
            xml.write("""
 </group>
</database>""")
            xml.close()
        showInfo(self.opts["mf"].body, "Export",
            """The following file has been created:

%s

Please Note that this file is Unencrypted.

This file will be treated as a Temporary File when Exiting Tartan.""" % fle)
        self.df.focusField("T", 0, 1)
Exemple #4
0
 def doPrint(self):
     mess = "Select the Required Print Option."
     butt = [("Information", "I"), ("Transactions", "T")]
     if self.itype == "R":
         butt.append(("Recipe", "R"))
     butt.append(("None", "N"))
     self.doPrintOption(
         askChoice(self.opts["mf"].body, "Print Options", mess, butt=butt))
     self.df.focusField(self.df.frt, self.df.pag, self.df.col)
Exemple #5
0
 def doPrint(self):
     mess = "Select the Required Print Option."
     butt = (
         ("Info Only", "I"),
         ("Deposit Only", "D"),
         ("Transactions Only", "T"),
         ("Info and Transactions", "B"),
         ("None", "N"))
     self.doPrintOption(askChoice(self.opts["mf"].body, "Print Options",
         mess, butt=butt))
     self.df.selPage("Premises")
     self.df.focusField("T", 1, 1)
Exemple #6
0
 def doEndsFin(self, frt, pag, r, c, p, i, w):
     self.bonus = self.bpts
     if w != self.ends:
         if not w:
             but = (("Exit",1),("Skipped",2),("Abandoned",3))
             ok = askChoice(self.opts["mf"].body, head="Zero Ends",
                 mess="No Ends Completed, Choose Option", butt=but)
             if ok == 1:
                 return "rf"
             elif ok == 2:
                 self.sql.updRec("bwlgme", cols=["bcg_aflag"], data=["S"],
                     where=[("bcg_cono", "=", self.opts["conum"]),
                     ("bcg_ccod", "=", self.ccod), ("bcg_game", "=",
                     self.gcod)])
             elif ok == 3:
                 self.sql.updRec("bwlgme", cols=["bcg_ocod", "bcg_rink",
                     "bcg_sfor", "bcg_sagt", "bcg_points",
                     "bcg_a_sfor", "bcg_a_sagt", "bcg_a_points",
                     "bcg_aflag"], data=[0, "", 0, 0, 0, 0, 0, 0, "A"],
                     where=[("bcg_cono", "=", self.opts["conum"]),
                     ("bcg_ccod", "=", self.ccod), ("bcg_game", "=",
                     self.gcod)])
             self.opts["mf"].dbm.commitDbase()
             return "xt"
         ok = askQuestion(self.opts["mf"].body, head="Shortened",
             mess="Was This Game Shortened?", default="no")
         if ok == "no":
             return "rf"
         if self.bonus == "Y":
             ok = askQuestion(self.opts["mf"].body, head="Bonus Points",
                 mess="Must Bonus Points Still be Awarded?", default="no")
             if ok == "no":
                 self.bonus = "N"
     self.totpts = (w * self.epts) + self.gpts
     if self.skins == "Y":
         self.totpts = self.totpts + (int(w / self.sends) * self.spts)
     if self.bonus == "Y":
         self.maxpts = float(ASD(self.totpts) + ASD(1))
     else:
         self.maxpts = self.totpts
Exemple #7
0
 def doGenerate(self):
     self.opts["mf"].updateStatus("")
     but = (("Members", "M"), ("Non Members", "N"), ("All", "A"), ("None",
                                                                   "X"))
     ok = askChoice(self.opts["mf"].body, "ARE YOU SURE???",
         "Are you Certain this is what you want To Do? This will "\
         "Automatically Generate New Tab Numbers For Selected Range "\
         "Based On Member's Names and Gender!", butt=but, default="None")
     if ok == "X":
         self.df.focusField("T", 0, 1)
         return
     self.df.closeProcess()
     splash = SplashScreen(self.opts["mf"].body,
                           "Generating New Tab Numbers ... Please Wait")
     # Create temporary tables
     for ot in self.tables:
         tt = "%s_temp" % ot[0]
         self.sql.sqlRec("Create table %s as Select * from %s "\
             "where %s = %s" % (tt, ot[0], ot[1], self.opts["conum"]))
         self.sql.delRec(ot[0], where=[(ot[1], "=", self.opts["conum"])])
     mem = self.sql.sqlRec("Select * from bwltab_temp where btb_cono = %s "\
         "and btb_tab < %s order by btb_surname, btb_names" %
         (self.opts["conum"], self.nstart))
     non = self.sql.sqlRec("Select * from bwltab_temp where btb_cono = %s "\
         "and btb_tab >= %s order by btb_surname, btb_names" %
         (self.opts["conum"], self.nstart))
     mstart = self.mstart
     fstart = self.fstart
     nstart = self.nstart
     key = {}
     for tab in mem:
         otb = tab[self.sql.bwltab_col.index("btb_tab")]
         if ok in ("A", "M"):
             gdr = tab[self.sql.bwltab_col.index("btb_gender")]
             if gdr == "M":
                 new = mstart
                 mstart += 1
             else:
                 new = fstart
                 fstart += 1
             key[otb] = new
         else:
             key[otb] = otb
     for tab in non:
         otb = tab[self.sql.bwltab_col.index("btb_tab")]
         if ok in ("A", "N"):
             key[otb] = nstart
             nstart += 1
         else:
             key[otb] = otb
     for ot in self.tables:
         tt = "%s_temp" % ot[0]
         cc = getattr(self.sql, "%s_col" % ot[0])
         recs = self.sql.sqlRec("Select * from %s" % tt)
         for rec in recs:
             for k in ot[2:]:
                 c = rec[cc.index(k)]
                 if c not in key:
                     continue
                 rec[cc.index(k)] = key[c]
             self.sql.insRec(ot[0], data=rec)
         self.sql.sqlRec("Drop table %s" % tt)
     self.opts["mf"].dbm.commitDbase(ask=True)
     splash.closeSplash()
     if "wait" not in self.opts:
         self.opts["mf"].closeLoop()
Exemple #8
0
 def doUpdateTables(self):
     nrnd = self.rnum + 1
     if self.fmat == "K" and self.clup == "Y" and self.ctyp == "M":
         # Closed up draw (1st and maybe 2nd Round)
         skps = self.sql.getRec("scpgme",
                                where=[("scg_cono", "=",
                                        self.opts["conum"]),
                                       ("scg_ccod", "=", self.ccod),
                                       ("scg_ctyp", "=", self.ctyp),
                                       ("scg_snum", "=", self.snum),
                                       ("scg_subs", "=", self.subs),
                                       ("scg_rnum", "=", self.rnum)])
         byes = []
         nums = {}
         for skp in skps:
             scod = skp[self.sql.scpgme_col.index("scg_scod")]
             ocod = skp[self.sql.scpgme_col.index("scg_ocod")]
             if not ocod:
                 byes.append(scod)
             nums[scod] = skp
         for skp in byes:
             if self.opts["test"]:
                 ok = "B"
             else:
                 ok = askChoice(self.opts["mf"].body, "Capture Error",
                     "The Results for Skip %s - %s is Missing. Did he/she "\
                     "Withdraw or have a Bye?" % (skp, self.getName(skp)),
                     butt=(("No", "N"), ("Withdraw", "W"), ("Bye", "B"),
                     ("Abort", "A")), default="Bye")
             if ok == "N":
                 return "continue"
             if ok == "A":
                 return "abort"
             if ok == "W":
                 self.sql.delRec("scpgme",
                                 where=[("scg_cono", "=",
                                         self.opts["conum"]),
                                        ("scg_ccod", "=", self.ccod),
                                        ("scg_scod", "=", skp)])
                 byes.remove(skp)
                 del nums[skp]
                 continue
         for scod in nums:
             rec = nums[scod]
             scod = rec[self.sql.scpgme_col.index("scg_scod")]
             ocod = rec[self.sql.scpgme_col.index("scg_ocod")]
             sfor = rec[self.sql.scpgme_col.index("scg_sfor")]
             sagt = rec[self.sql.scpgme_col.index("scg_sagt")]
             where = [("scg_cono", "=", self.opts["conum"]),
                      ("scg_ccod", "=", self.ccod),
                      ("scg_ctyp", "=", self.ctyp),
                      ("scg_snum", "=", self.snum),
                      ("scg_subs", "=", self.subs), ("scg_rnum", "=", nrnd),
                      ("scg_scod", "=", scod)]
             if scod in byes:
                 self.byenum += 1
                 # Create bye
                 self.sql.updRec("scpgme",
                                 cols=["scg_ocod"],
                                 data=[self.byenum],
                                 where=where)
             if nrnd < self.lrnd:
                 # Create next round record
                 rec[self.sql.scpgme_col.index("scg_rnum")] = nrnd
                 rec[self.sql.scpgme_col.index("scg_ocod")] = 0
                 rec[self.sql.scpgme_col.index("scg_sfor")] = 0
                 rec[self.sql.scpgme_col.index("scg_sagt")] = 0
                 rec[self.sql.scpgme_col.index("scg_seed")] = 0
                 rec[self.sql.scpgme_col.index("scg_pair")] = 0
                 if scod not in byes and sfor < sagt and ocod:
                     scod = ocod
                     rec[self.sql.scpgme_col.index("scg_scod")] = scod
                 chk = self.sql.getRec("scpgme", where=where, limit=1)
                 if not chk:
                     self.sql.insRec("scpgme", data=rec)
                 else:
                     self.sql.updRec("scpgme", data=rec, where=where)
             else:
                 # Update playoff records
                 cod = self.snum + 700000
                 if sfor > sagt:
                     win = scod
                 else:
                     win = ocod
                 whr = where[:6]
                 whr[2] = ("scg_ctyp", "=", "P")
                 whr[3] = ("scg_snum", "=", 1)
                 whr[5] = ("scg_rnum", "=", 1)
                 whr.append(("scg_scod", "=", cod))
                 self.sql.updRec("scpgme",
                                 cols=["scg_scod"],
                                 data=[win],
                                 where=whr)
                 whr[6] = ("scg_ocod", "=", cod)
                 self.sql.updRec("scpgme",
                                 cols=["scg_ocod"],
                                 data=[win],
                                 where=whr)
     if (self.fmat == "K" and self.clup == "N") or self.ctyp == "P":
         recs = self.sql.getRec("scpgme",
                                where=[("scg_cono", "=",
                                        self.opts["conum"]),
                                       ("scg_ccod", "=", self.ccod),
                                       ("scg_ctyp", "=", self.ctyp),
                                       ("scg_snum", "=", self.snum),
                                       ("scg_rnum", "=", self.rnum)],
                                order="scg_group, scg_pair")
         group = 0
         for num in range(0, len(recs), 2):
             one = recs[num]
             snum = one[self.sql.scpgme_col.index("scg_snum")]
             subs = one[self.sql.scpgme_col.index("scg_subs")]
             if group != one[self.sql.scpgme_col.index("scg_group")]:
                 group = one[self.sql.scpgme_col.index("scg_group")]
                 pair = 1
             else:
                 pair += 1
             cod1 = one[self.sql.scpgme_col.index("scg_scod")]
             opp1 = one[self.sql.scpgme_col.index("scg_ocod")]
             for1 = one[self.sql.scpgme_col.index("scg_sfor")]
             agt1 = one[self.sql.scpgme_col.index("scg_sagt")]
             if opp1 > 900000 or for1 > agt1:
                 win1 = cod1
             else:
                 win1 = opp1
             if len(recs[num:]) > 1:
                 two = recs[num + 1]
                 cod2 = two[self.sql.scpgme_col.index("scg_scod")]
                 opp2 = two[self.sql.scpgme_col.index("scg_ocod")]
                 for2 = two[self.sql.scpgme_col.index("scg_sfor")]
                 agt2 = two[self.sql.scpgme_col.index("scg_sagt")]
                 if opp2 > 900000 or for2 > agt2:
                     win2 = cod2
                 else:
                     win2 = opp2
             else:
                 win2 = 0
             # Create next round record
             sgc = self.sql.scpgme_col
             whr = [("scg_cono", "=", one[sgc.index("scg_cono")]),
                    ("scg_ccod", "=", one[sgc.index("scg_ccod")]),
                    ("scg_ctyp", "=", one[sgc.index("scg_ctyp")]),
                    ("scg_snum", "=", one[sgc.index("scg_snum")]),
                    ("scg_subs", "=", one[sgc.index("scg_subs")]),
                    ("scg_rnum", "=", nrnd),
                    ("scg_ktyp", "=", one[sgc.index("scg_ktyp")]),
                    ("scg_scod", "=", win1)]
             one[sgc.index("scg_rnum")] = nrnd
             one[sgc.index("scg_scod")] = win1
             one[sgc.index("scg_ocod")] = win2
             one[sgc.index("scg_sfor")] = 0
             one[sgc.index("scg_sagt")] = 0
             one[sgc.index("scg_pnts")] = 0
             one[sgc.index("scg_pair")] = pair
             if not self.sql.getRec("scpgme", where=whr, limit=1):
                 self.sql.insRec("scpgme", data=one)
             else:
                 self.sql.updRec("scpgme",
                                 cols=["scg_ocod", "scg_pair"],
                                 data=[win2, pair],
                                 where=whr)
             if self.rnum == self.lrnd and \
                     self.ctyp == "M" and self.nsec > 2:
                 # Create playoff records with winners codes
                 if not self.oldwin:
                     if subs == "B":
                         key = snum + 800000
                     else:
                         key = snum + 700000
                 else:
                     key = self.oldwin[snum]
                 self.sql.updRec("scpgme",
                                 cols=["scg_scod"],
                                 data=[win1],
                                 where=[("scg_cono", "=",
                                         self.opts["conum"]),
                                        ("scg_ccod", "=", self.ccod),
                                        ("scg_ctyp", "=", "P"),
                                        ("scg_rnum", "=", 1),
                                        ("scg_scod", "=", key)])
                 self.sql.updRec("scpgme",
                                 cols=["scg_ocod"],
                                 data=[win1],
                                 where=[("scg_cono", "=",
                                         self.opts["conum"]),
                                        ("scg_ccod", "=", self.ccod),
                                        ("scg_ctyp", "=", "P"),
                                        ("scg_rnum", "=", 1),
                                        ("scg_ocod", "=", key)])
     elif self.squa == "S" and self.rnum == self.lrnd:
         # Update playoff records with winners codes
         if self.ssub == "Y":
             lsub = "B"
         else:
             lsub = ""
         whr = [("scg_cono", "=", self.opts["conum"]),
                ("scg_ccod", "=", self.ccod), ("scg_ctyp", "=", self.ctyp),
                ("scg_snum", "=", self.snum), ("scg_subs", "=", self.subs)]
         if self.fmat == "K":
             col = ["scg_scod", "scg_ocod", "scg_sfor", "scg_sagt"]
             whr.append(("scg_rnum", "=", self.lrnd))
             rec = self.sql.getRec("scpgme", cols=col, where=whr, limit=1)
             if rec[2] > rec[3]:
                 win = rec[0]
             else:
                 win = rec[1]
         else:
             self.doGetNewWin(sect=self.snum, sub=self.subs)
             win = self.newwin[self.snum]
         if not self.oldwin:
             if self.subs == "B":
                 key = self.snum + 800000
             else:
                 key = self.snum + 700000
         else:
             key = self.oldwin[self.snum]
         self.sql.updRec("scpgme",
                         cols=["scg_scod"],
                         data=[win],
                         where=[("scg_cono", "=", self.opts["conum"]),
                                ("scg_ccod", "=", self.ccod),
                                ("scg_ctyp", "=", "P"),
                                ("scg_rnum", "=", 1),
                                ("scg_scod", "=", key)])
         self.sql.updRec("scpgme",
                         cols=["scg_ocod"],
                         data=[win],
                         where=[("scg_cono", "=", self.opts["conum"]),
                                ("scg_ccod", "=", self.ccod),
                                ("scg_ctyp", "=", "P"),
                                ("scg_rnum", "=", 1),
                                ("scg_ocod", "=", key)])
         if self.snum == self.nsec and self.subs == lsub:
             self.sql.updRec("scpgme",
                             cols=["scg_ktyp"],
                             data=["M"],
                             where=[("scg_cono", "=", self.opts["conum"]),
                                    ("scg_ccod", "=", self.ccod),
                                    ("scg_ctyp", "=", "P")])
     # Check if all results for the round are captured
     chek = self.sql.getRec("scpgme",
                            cols=["count(*)"],
                            where=[("scg_cono", "=", self.opts["conum"]),
                                   ("scg_ccod", "=", self.ccod),
                                   ("scg_ctyp", "=", self.ctyp),
                                   ("scg_rnum", "=", self.rnum),
                                   ("scg_scod", "<", 900000),
                                   ("scg_ocod", "<", 900000),
                                   ("scg_sfor", "=", 0),
                                   ("scg_sagt", "=", 0)],
                            limit=1)
     if chek[0]:
         return
     if self.clup == "Y" and self.ctyp == "M" and nrnd == self.lrnd:
         state = 3
     elif self.rnum == self.lrnd:
         if self.ctyp == "M":
             state = 3
         else:
             state = 6
     elif self.ctyp == "M":
         state = 2
     else:
         state = 5
     self.sql.updRec("scpcmp",
                     cols=["scp_state"],
                     data=[state],
                     where=[("scp_cono", "=", self.opts["conum"]),
                            ("scp_ccod", "=", self.ccod)])
Exemple #9
0
    def printReport(self, mems):
        ktypes = {}
        ctk = self.sql.getRec("memctk")
        for c in ctk:
            ktypes[c[1]] = c[2]
        for mem in mems:
            text = """Dear %s %s %s

Here are your details as stored on the club's database. Please could you be so kind as to check them and let us have any changes by return email so that we can update our records.

%-30s%s
%-30s%s
%-30s%s
%-30s%s""" % (mem[1], mem[2], mem[3], "Membership Number:", mem[0], "Names:",
              mem[4], "Nationality:", countries[mem[5]][1], "Date of Birth:",
              CCD(mem[6], "D1", 10).disp)
            add = self.sql.getRec("memadd",
                                  cols=[
                                      "mla_type", "mla_add1", "mla_add2",
                                      "mla_add3", "mla_city", "mla_code"
                                  ],
                                  where=[("mla_cono", "=", self.opts["conum"]),
                                         ("mla_memno", "=", mem[0])])
            for a in add:
                if a[0] == "P":
                    text = """%s
%-30s%s""" % (text, "Postal Address:", a[1])
                else:
                    text = """%s
%-30s%s""" % (text, "Street Address:", a[1])
                for n in a[2:]:
                    if n:
                        text = """%s, %s""" % (text, n)
            kon = self.sql.getRec(tables=["memctk", "memkon"],
                                  cols=["mck_code", "mck_type", "mlk_detail"],
                                  where=[("mlk_cono", "=", self.opts["conum"]),
                                         ("mlk_memno", "=", mem[0]),
                                         ("mck_code=mlk_code", )])
            mail = []
            for e in kon:
                if e[0] == 5:
                    ktyp = "E-Mail Address:"
                else:
                    ktyp = "%s:" % ktypes[e[1]]
                text = """%s
%-30s%s""" % (text, ktyp, e[2])
                if e[1] == "E" and e[2][:2] != "08":
                    mail.append(e[2])
            if not mail:
                continue
            text = """%s

With Thanks

Membership Secretary
%s""" % (text, self.opts["conam"])
            ok = sendMail(self.smtp,
                          self.fadd,
                          mail,
                          "Member's Details",
                          mess=text,
                          wrkdir=self.opts["mf"].rcdic["wrkdir"])
            if not ok and self.ignore == "N":
                ok = askChoice(self.opts["mf"].body,
                               "SMTP Server Error",
                               "Mail to %s Could Not be Sent" % mail,
                               butt=(("Continue", "C"), ("Quit", "Q")),
                               default="Continue")
                if ok == "Q":
                    self.doExit()
                    break
Exemple #10
0
 def doTrans2c(self):
     tit = "Transactions for Item: %s %s - %s" % \
         (self.group, self.code, self.desc)
     tab = ["strtrn"]
     crt = (("stt_trdt", "", 0, "   Date"), ("stt_batch", "", 0, "Batch"),
            ("stt_type", "NA", 3,
             "Typ"), ("stt_ref1", "", 0, "Reference",
                      "Y"), ("stt_ref2", "", 0,
                             "Ref-Num-2"), ("stt_qty", "", 0, "  Quantity"),
            ("stt_cost", "", 0, "      Cost"), ("stt_sell", "", 0,
                                                "   Selling"),
            ("qbal", "SD", 13.2,
             "   Qty-Bal"), ("cbal", "SD", 13.2,
                             "  Cost-Bal"), ("stt_desc", "", 0, "Details"))
     whr = [("stt_cono", "=", self.opts["conum"]),
            ("stt_group", "=", self.group), ("stt_code", "=", self.code),
            ("stt_loc", "=", self.loc)]
     if self.per_from:
         whr.extend([("stt_curdt", ">=", self.per_from),
                     ("stt_curdt", "<=", self.per_to)])
     odr = "stt_trdt, stt_qty desc"
     recs = self.sql.getRec("strtrn",
                            cols=[
                                "stt_trdt", "stt_batch", "stt_type",
                                "stt_ref1", "stt_ref2", "stt_qty",
                                "stt_cost", "stt_sell", "stt_desc"
                            ],
                            where=whr,
                            order=odr)
     data = []
     tqty = 0
     tcst = 0
     for rec in recs:
         rec[2] = sttrtp[rec[2] - 1][0]
         tqty = float(ASD(tqty) + ASD(rec[5]))
         tcst = float(ASD(tcst) + ASD(rec[6]))
         rec.insert(8, tqty)
         rec.insert(9, tcst)
         data.append(rec)
     state = self.df.disableButtonsTags()
     while True:
         rec = SRec(self.opts["mf"],
                    screen=self.df.nb.Page4,
                    title=tit,
                    tables=tab,
                    cols=crt,
                    where=data,
                    wtype="D")
         if rec.selection:
             for n, t in enumerate(sttrtp):
                 if t[0] == rec.selection[2]:
                     typ = n + 1
                     break
             dte = rec.selection[0]
             doc = rec.selection[3]
             if self.itype == "R" and typ in (7, 8):
                 bt = (("Transaction", "T"), ("Recipe", "R"))
                 ask = askChoice(
                     self.df.window,
                     head="Details",
                     mess="Transaction Details or the Recipe Details",
                     butt=bt,
                     default="Transaction")
             else:
                 ask = "T"
             if ask == "T":
                 wher = [("stt_cono", "=", self.opts["conum"]),
                         ("stt_group", "=", self.group),
                         ("stt_code", "=", self.code),
                         ("stt_loc", "=", self.loc), ("stt_type", "=", typ),
                         ("stt_trdt", "=", dte), ("stt_ref1", "=", doc)]
                 TabPrt(self.opts["mf"],
                        tabs="strtrn",
                        where=wher,
                        pdia=False)
             elif typ == 7:
                 rct = "Recipe Details"
                 rcc = (("si3_line", "", 0, ""), ("si3_rgroup", "", 0, ""),
                        ("si3_rcode", "", 0, ""), ("st1_desc", "", 0, ""),
                        ("si3_rqty", "", 0, ""), ("si3_cost", "", 0, ""))
                 rcw = (("si3_cono", "=", self.opts["conum"]),
                        ("si3_rtn", "=", "I"), ("si3_docno", "=", doc),
                        ("st1_cono=si3_cono", ), ("st1_group=si3_rgroup", ),
                        ("st1_code=si3_rcode", ))
                 rco = "si3_line"
                 SRec(self.opts["mf"],
                      title=rct,
                      tables=["slsiv3", "strmf1"],
                      cols=rcc,
                      where=rcw,
                      order=rco)
             else:
                 rct = "Recipe Details"
                 rcc = (("prp_rowno", "", 0, ""), ("prp_rgroup", "", 0, ""),
                        ("prp_rcode", "", 0, ""), ("st1_desc", "", 0, ""),
                        ("prp_rqty", "", 0, ""), ("prp_cost", "", 0, ""))
                 rcw = (("prp_cono", "=", self.opts["conum"]), ("prp_docno",
                                                                "=", doc),
                        ("st1_cono=prp_cono", ), ("st1_group=prp_rgroup", ),
                        ("st1_code=prp_rcode", ))
                 rco = "prp_rowno"
                 SRec(self.opts["mf"],
                      title=rct,
                      tables=["posrcp", "strmf1"],
                      cols=rcc,
                      where=rcw,
                      order=rco)
         else:
             break
     self.df.enableButtonsTags(state=state)
     self.df.focusField("T", 4, 1)
Exemple #11
0
 def doEnd(self):
     self.df.closeProcess()
     col = [
         "mlm_memno", "mlm_surname", "mlm_names", "mlm_payplan", "mlc_code"
     ]
     whr = [("mlm_cono", "=", self.opts["conum"]), ("mlm_state", "=", "A")]
     if self.plan == "N":
         whr.append(("mlm_payplan", "=", "N"))
     whr.extend([("mlc_cono=mlm_cono", ), ("mlc_memno=mlm_memno", ),
                 ("mlc_type", "=", "B")])
     grp = "mlm_memno, mlm_surname, mlm_names, mlm_payplan, mlc_code"
     if self.sort == "N":
         odr = "mlm_memno"
     else:
         odr = "mlm_surname"
     sp = SplashScreen(self.opts["mf"].body,
                       "Preparing Report ... Please Wait")
     recs = self.sql.getRec(tables=["memmst", "memcat"],
                            cols=col,
                            where=whr,
                            group=grp,
                            order=odr)
     sp.closeSplash()
     if not recs:
         self.opts["mf"].closeLoop()
         return
     p = ProgressBar(self.opts["mf"].body,
                     typ="Generating the Report",
                     mxs=len(recs),
                     esc=True)
     data = []
     for num, rec in enumerate(recs):
         p.displayProgress(num)
         if p.quit:
             break
         whr = [("mlt_cono", "=", self.opts["conum"]),
                ("mlt_memno", "=", rec[0])]
         trn = getTrn(self.opts["mf"].dbm, "mem", whr=whr, zer="N")
         bal = 0
         inv = 0
         for t in trn[1]:
             c = trn[0]
             bal = float(ASD(bal) + ASD(t[c.index("mlt_tramt")]))
             if t[c.index("mlt_type")] == 1 and \
                     t[c.index("mlt_curdt")] >= self.s_per:
                 inv = float(ASD(inv) + ASD(t[c.index("mlt_tramt")]))
         if not bal or bal < inv:
             continue
         cat = self.sql.getRec(tables=["memctc", "memctp"],
                               cols=["mcc_desc", "mcp_rate_01"],
                               where=[("mcc_cono", "=", self.opts["conum"]),
                                      ("mcc_type", "=", "B"),
                                      ("mcc_code", "=", rec[4]),
                                      ("mcp_cono=mcc_cono", ),
                                      ("mcp_type=mcc_type", ),
                                      ("mcp_code=mcc_code", )],
                               order="mcp_date desc",
                               limit=1)
         if not cat or bal < cat[1]:
             continue
         rec[1] = "%s, %s" % (rec[1], rec[2])
         del rec[2]
         rec[3] = cat[0]
         rec.append(cat[1])
         rec.append(inv)
         rec.append(bal)
         data.append(rec)
     p.closeProgress()
     if p.quit:
         self.opts["mf"].closeLoop()
         return
     name = self.__class__.__name__
     head = ["Members Suspension Report"]
     cols = [["a", "NA", 7, "Mem-No", "y"], ["b", "NA", 50, "Name", "y"],
             ["d", "UA", 1, "P", "y"],
             ["c", "NA", 30, "Active-Category", "y"],
             ["e", "SD", 13.2, "Subscription", "y"],
             ["f", "SD", 13.2, "Tot-Invoiced", "y"],
             ["g", "SD", 13.2, "Tot-Balance", "y"]]
     rep = RepPrt(self.opts["mf"],
                  conum=self.opts["conum"],
                  conam=self.opts["conam"],
                  name=name,
                  tables=data,
                  heads=head,
                  cols=cols,
                  gtots=("e", "f", "g"),
                  ttype="D",
                  repprt=self.df.repprt,
                  repeml=self.df.repeml,
                  fromad=self.fromad)
     if not rep.xits:
         ask = askChoice(self.opts["mf"].body,
                         "Suspend Members",
                         "Select Members to Suspend",
                         butt=(("All", "A"), ("Some", "S"), ("None", "N")),
                         default="None")
         if ask in ("A", "S"):
             if ask == "S":
                 cols = ["memno", "name"]
                 dics = {
                     "memno": ("", 0, "UI", 6, "Member Number", "Mem-No"),
                     "name": ("", 1, "NA", 50, "Member Name", "Name")
                 }
                 newd = []
                 for dat in data:
                     newd.append((dat[0], dat[1]))
                 data = getSingleRecords(self.opts["mf"],
                                         "",
                                         cols,
                                         where=newd,
                                         ttype="D",
                                         dic=dics)
             if data:
                 p = ProgressBar(self.opts["mf"].body,
                                 typ="Suspending Members",
                                 mxs=len(data))
                 for num, rec in enumerate(data):
                     p.displayProgress(num)
                     self.sql.updRec("memmst",
                                     cols=["mlm_state", "mlm_sdate"],
                                     data=["S", self.sysdtw],
                                     where=[("mlm_cono", "=",
                                             self.opts["conum"]),
                                            ("mlm_memno", "=", rec[0])])
                     self.sql.insRec("memsta",
                                     data=[
                                         self.opts["conum"], rec[0], "S",
                                         self.sysdtw, self.opts["capnm"],
                                         self.sysdtw, 0
                                     ])
                 self.opts["mf"].dbm.commitDbase()
     p.closeProgress()
     self.opts["mf"].closeLoop()