home *** CD-ROM | disk | FTP | other *** search
Wrap
import BP, time, cPickle def DecToText(Value): uni = ['un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize'] diz = ['vingt', 'trente', 'quarante', 'cinquante', 'soixante', '', 'quatre-vingt'] mil = ['cent', 'mille', 'million', 'milliard', 'billion', 'milliers-de-billions', 'trillion'] try: N = long(Value) if N < 0: return "" except: return "" if N == 0: return "ZΘro" Result = "" k = 0 while N != 0: U = N % 10 N = N / 10 D = N % 10 N = N / 10 if D in [1, 7, 9]: D -= 1 U += 10 s = '' if D > 1: s = " %s" %diz[D - 2] if (D < 8) and ((U == 1) or (U == 11)): s += " et" if U > 16: s += " %s" %uni[9] U -= 10 if U > 0: s += " %s" %uni[U - 1] if (Result == "") and (D == 8) and (U == 0): Result = "s" Result = s + Result C, N = N % 10, N / 10 if C > 0: s = "" if C > 1: s = " %s%s" %(uni[C - 1], s) s += " %s" %mil[0] if (Result == '') and (C > 1): Result = "s" Result = s + Result if N > 0: k += 1 I = N % 1000 if (I > 1) and (k > 1): Result = "s%s" %Result if I > 0: Result = " %s%s" %(mil[k], Result) if (I == 1) and (k == 1): N -= 1 return Result.replace("un milliers", "un millier").replace("llionss", "llions").strip() def WebCurr(f): s = str(f).replace(".", ",").replace("-", "") i = s.find(",") if i > -1: ipart = int(s[:i]) fpart = int(s[i + 1:][:2]) else: ipart = int(s) fpart = 0 if fpart == 0: txt = "%s euros" %(DecToText(ipart)) else: txt = "%s euros et %s cents" %(DecToText(ipart), DecToText(fpart)) return "%d,%.2d\xA0Ç (%s)" %(ipart, fpart, txt) def WebDate(dt): m = ["janvier", "fΘvrier", "mars", "avril", "mai", "juin", "juillet", "ao√t", "septembre", "octobre", "novembre", "dΘcembre"] j = int(dt[:2]) if j == 1: return "1er\xA0%s\xA0%s" %(m[int(dt[3:5]) - 1], dt[6:]) return "%d\xA0%s\xA0%s" %(j, m[int(dt[3:5]) - 1], dt[6:]) def save_file(): f = open(fpath, "w") cPickle.dump(dic, f) f.close() def load_file(): try: f = open(fpath, "r") dic = cPickle.load(f) f.close() return dic except: return {} Somme_rb = 0 Somme_pr = 0 NbRbts = 0 detail = [] ppath = "%sScripts\\Receipt" %BP.BankPerfectExePath() fpath = "%s\\receipt.dat" %ppath dic = load_file() acc = BP.AccountCurrent() for i in BP.VisibleLines(): mod = BP.OperationMode[acc][i] val = BP.OperationAmount[acc][i] thd = BP.Operationthirdparty[acc][i] det = BP.OperationDetails[acc][i] dte = BP.OperationDate[acc][i] if val > 0: Somme_pr = Somme_pr + val else: NbRbts += 1 s = mod[0].upper() if s in ['P', 'V']: s = 'virement' elif s == 'R': s = 'versement en espΦces' else: if mod.find("Chq ") == 0: s = 'chΦque n░ %s' %mod[5:] else: s = 'chΦque' detail.append("TextRect 250;0;1900;- Un %s d'un montant de %s le %s" %(s, WebCurr(val), WebDate(dte))) Somme_rb = Somme_rb - val detail = "\n".join(detail) f = CreateComponent("TForm", None) f.SetProps(Position="poScreenCenter", Caption="CrΘation d'un reτu", Width=500, Height=330, BorderStyle="bsSingle", BorderIcons=["biSystemMenu","biMinimize"]) f.Font.Name = "Tahoma" CreateComponent("TLabel", f).SetProps(Parent=f, Left=30, Top=30, Caption="Nom du payeur :") EPayer = CreateComponent("TEdit", f) EPayer.SetProps(Parent=f, Left=220, Top=25, Width=240, Text=dic.get("payer", "")) CreateComponent("TLabel", f).SetProps(Parent=f, Left=30, Top=60, Caption="Ville o∙ va Ωtre signΘ le reτu :") ECity = CreateComponent("TEdit", f) ECity.SetProps(Parent=f, Left=220, Top=55, Width=240, Text=dic.get("city", "")) LT = CreateComponent("TLabel", f) LT.SetProps(Parent=f, Left=30, Top=100, Caption="BΘnΘficiaire :") LT.Font.Style = ["fsBold"] CreateComponent("TLabel", f).SetProps(Parent=f, Left=50, Top=130, Caption="Nom :") EPayee = CreateComponent("TEdit", f) EPayee.SetProps(Parent=f, Left=220, Top=125, Width=240, Text=dic.get("payee", "")) CreateComponent("TLabel", f).SetProps(Parent=f, Left=50, Top=160, Caption="Adresse complΦte :") EAdr = CreateComponent("TEdit", f) EAdr.SetProps(Parent=f, Left=220, Top=155, Width=240, Text=dic.get("address", "")) CreateComponent("TLabel", f).SetProps(Parent=f, Left=50, Top=190, Caption="Sexe :") CBSex = CreateComponent("TComboBox", f) CBSex.SetProps(Parent=f, Left=220, Top=185, Width=240, Style="csDropDownList") CBSex.Items.Text = "Masculin\nFΘminin" CBSex.ItemIndex = Text=dic.get("sex", 0) CreateComponent("TButton", f).SetProps(Parent=f, Left=155, Top=240, Width=90, Height=25, Caption="OK", Default=1, ModalResult=1) CreateComponent("TButton", f).SetProps(Parent=f, Left=255, Top=240, Width=90, Height=25, Caption="Annuler", Cancel=1, ModalResult=2) f.ShowModal() dic = {"payer": EPayer.Text, "payee": EPayee.Text, "city": ECity.Text, "address": EAdr.Text, "sex": CBSex.ItemIndex} save_file() payeur = EPayer.Text beneficiaire = EPayee.Text ville = ECity.Text adresse = EAdr.Text if CBSex.ItemIndex == 1: mf = "e" else: mf = "" footer = 'La somme totale α payer Θtant Θgale α %s, ' %WebCurr(Somme_pr) if Somme_rb >= Somme_pr: footer += 'elle a ΘtΘ intΘgralement remboursΘe. A ce jour, %s ne me doit plus rien.' %payeur else: footer += '%s doit encore me rembourser %s.' %(payeur, WebCurr(Somme_pr - Somme_rb)) now = time.localtime() now = "%.2d-%.2d-%.4d" %(now[2], now[1], now[0]) path = "%s\\recu.pdf" %ppath params = {"footer": footer, "bg": 0x00EEEEEE, "path": path.replace("\\", "\\\\"), "payeur": payeur, "sexe": mf, "beneficiaire": beneficiaire, "adresse": adresse, "total": WebCurr(Somme_rb), "NbRbts": NbRbts, "detail": detail, "footer": footer, "ville": ville, "now": WebDate(now)} code = """Create Reτu;%(path)s;2100;2970 PenColor 0 FillRect 200;200;1900;320;%(bg)d DrawRectangle 200;200;1900;320 FontName TimesBold FontSize 90 TextOut 1000;290;Reτu FontName Helvetica FontSize 40 CurrY 500 TextRect 200;0;1900;Je soussignΘ%(sexe)s, %(beneficiaire)s, demeurant %(adresse)s, reconnais avoir reτu de %(payeur)s la somme de %(total)s sous la forme de %(NbRbts)d versements selon les modalitΘs suivantes : FontSize 30 TextOut 200;0; %(detail)s FontSize 40 TextOut 200;0; TextRect 200;0;1900;%(footer)s TextOut 200;-50;Le prΘsent reτu a ΘtΘ Θtabli en double exemplaire, dont un m'a ΘtΘ remis. TextOut 200;0;Fait α %(ville)s, le %(now)s.""" %params if f.ModalResult == 1: BP.GetURL("pdf:%s" %code) BP.ShellExecute("open", path, "", 1)