home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog Special Freeware 31
/
FreelogHS31.iso
/
ArgentCompta
/
Bankperfect
/
bp.exe
/
Scripts
/
Ventilate
/
ventilate.py
< prev
Wrap
Text File
|
2006-11-04
|
4KB
|
115 lines
import BP
def AddLine(Sender):
global value
v = EVal.Text
try:
v = round(abs(float(v.replace(",", ".").replace(" ", ""))), 2)
except:
v = 0
if v == 0: BP.MsgBox("Le montant est incorrect", 64)
elif v > value: BP.MsgBox("Le montant saisi dΘpasse le montant disponible (%s)" %("%.2f" %value), 64)
else:
i = CCtg.ItemIndex - 1
CIndex = CIndexes[i]
ops.append((EInfo.Text, CIndex, v))
if i == -1: List.Items.Add("Sans catΘgorie (%.2f)" %v)
else: List.Items.Add("%s (%.2f)" %(CTrimNames[i], v))
value = round(value - v, 2)
EVal.Text = "%.2f" %value
EVal.SetFocus()
def RemoveLine(Sender):
global value
i = List.ItemIndex
if i > -1:
v = ops[i][2]
del ops[i]
List.Items.Delete(i)
value = round(value + v, 2)
EVal.Text = "%.2f" %value
c = len(List.Items)
if c > 0:
if i >= c: i = c - 1
List.ItemIndex = i
def Ventil(Sender):
if value > 0:
BP.MsgBox("Le montant d'origine n'a pas ΘtΘ totalement ventilΘ", 64)
return
BP.LineDelete(a, i)
last = len(ops)
for idx, op in enumerate(ops):
BP.LineAdd(a, date, mode, "[%d/%d] %s" %(idx + 1, last, tiers), "%s (Total: %.2f)" %(op[0], ovalue), op[1], sgn * op[2], 0)
BP.AccountRefreshScreen()
f.Close()
cnames = BP.CategName
CTrimNames = []
CPositions = {-1: -1}
CIndexes = {-1: -1}
CNames = []
for i, c in enumerate(cnames):
p = c.find("=")
CNames.append(c[p+1:])
CTrimNames.append(c[p+1:].strip())
idx = int(c[:p])
CPositions[idx] = i
CIndexes[i] = idx
CNames = ["-- Aucune --"] + CNames
i = BP.LineSelect(-1)
a = BP.AccountCurrent()
ovalue = round(BP.OperationAmount[a][i], 2)
value = abs(ovalue)
if ovalue < 0: sgn = -1
else: sgn = 1
date = BP.OperationDate[a][i]
mode = BP.OperationMode[a][i]
if mode.find("Chq ") == 0: mode = "ChΦque Θmis"
tiers = BP.Operationthirdparty[a][i]
info = BP.OperationDetails[a][i]
categ = BP.OperationCateg[a][i]
ops = []
f = CreateComponent("TForm", None)
f.SetProps(Position="poMainFormCenter", Width=650, Height=330, BorderStyle="bsSingle", BorderIcons=["biSystemMenu","biMinimize"], Caption="Ventilation d'une opΘration")
f.Font.Name = "Tahoma"
L1 = CreateComponent("TLabel", f)
L1.SetProps(Parent=f, Left=30, Top=74, Caption="DΘtail :")
L2 = CreateComponent("TLabel", f)
L2.SetProps(Parent=f, Left=30, Top=104, Caption="CatΘgorie :")
L3 = CreateComponent("TLabel", f)
L3.SetProps(Parent=f, Left=30, Top=25, Caption="%s (montant : %.2f)" %(tiers, value))
L3.Font.Style = ["fsBold"]
L4 = CreateComponent("TLabel", f)
L4.SetProps(Parent=f, Left=30, Top=138, Caption="Montant :")
EInfo = CreateComponent("TEdit", f)
CCtg = CreateComponent("TComboBox", f)
EVal = CreateComponent("TEdit", f)
EInfo.SetProps(Parent=f, Left=120, Top=74, Width=130, Text=info)
CCtg.SetProps(Parent=f, Left=120, Top=104, Width=130, Style="csDropDownList")
CCtg.Items.Text = "\n".join(CNames)
CCtg.ItemIndex = CPositions[categ] + 1
EVal.SetProps(Parent=f, Left=120, Top=138, Width=130, Text="%.2f" %value)
BAdd = CreateComponent("TButton", f)
BAdd.SetProps(Parent=f, Left=284, Top=88, Width=75, Height=25, Caption="Ajouter ╗", OnClick=AddLine)
BDel = CreateComponent("TButton", f)
BDel.SetProps(Parent=f, Left=284, Top=120, Width=75, Height=25, Caption="½ Retirer", OnClick=RemoveLine)
List = CreateComponent("TListBox", f)
List.SetProps(Parent=f, Left=390, Top=68, Width=222, Height=104)
List.Items.Text = ""
BCancel = CreateComponent("TButton", f)
BCancel.SetProps(Parent=f, Left=225, Top=230, Width=90, Height=25, Caption="Annuler", Cancel=1, ModalResult=2)
BOK = CreateComponent("TButton", f)
BOK.SetProps(Parent=f, Left=325, Top=230, Width=90, Height=25, Caption="Ventiler", Default=1, OnClick=Ventil)
f.ShowModal()