home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Freeware 31 / FreelogHS31.iso / ArgentCompta / Bankperfect / bp.exe / Scripts / ModifyGroup / modifygroup.py < prev   
Text File  |  2006-11-04  |  4KB  |  107 lines

  1. import BP, time
  2.  
  3. def Apply(Sender):
  4.   isdt = CDte.Checked
  5.   ismd = CMod.Checked
  6.   iswh = CWho.Checked
  7.   isnf = CNfo.Checked
  8.   iscg = CCtg.Checked
  9.   isvl = CVal.Checked
  10.   ismk = CMrk.Checked
  11.  
  12.   a = BP.AccountCurrent()
  13.   if isdt:
  14.     dt = time.gmtime((int(EDte.Date) - 25569) * 86400)[:3]
  15.     dt = "%.2d-%.2d-%.4d" %(dt[2], dt[1], dt[0])
  16.   if ismd:
  17.     if EMod.ItemIndex < 6: sgn = -1
  18.     else: sgn = 1
  19.     md = EMod.Items[EMod.ItemIndex]
  20.   if iswh: wh = EWho.Text
  21.   if isnf: nf = ENfo.Text
  22.   if iscg: cg = CIndexes[ECtg.ItemIndex - 1]
  23.   
  24.   if isvl:
  25.     try:
  26.       vl = abs(float(EVal.Text.replace(",", ".")))
  27.     except:
  28.       BP.MsgBox("Le montant saisi est incorrect", 64)
  29.       return
  30.   if ismk: mk = EMrk.ItemIndex
  31.  
  32.   for i in idx:
  33.     if isdt: BP.OperationDate[a][i] = dt
  34.     if ismd and sgn == BP.OperationModeSign[a][i]:
  35.       BP.OperationMode[a][i] = md
  36.     if iswh: BP.Operationthirdparty[a][i] = wh
  37.     if isnf: BP.OperationDetails[a][i] = nf
  38.     if iscg: BP.OperationCateg[a][i] = cg
  39.     if isvl: BP.OperationAmount[a][i] = vl * BP.OperationModeSign[a][i]
  40.     if ismk: BP.OperationMark[a][i] = mk
  41.     
  42.   BP.AccountRefreshScreen()
  43.   f.Close()
  44.  
  45.  
  46. cnames = BP.CategName
  47. CTrimNames = []
  48. CPositions = {-1: -1}
  49. CIndexes = {-1: -1}
  50. CNames = []
  51. for i, c in enumerate(cnames):
  52.   p = c.find("=")
  53.   CNames.append(c[p+1:])
  54.   CTrimNames.append(c[p+1:].strip())
  55.   idx = int(c[:p])
  56.   CPositions[idx] = i
  57.   CIndexes[i] = idx
  58. CNames = ["-- Aucune --"] + CNames
  59.  
  60. modes = [BP.OperationGetNameFromModeIndex(i) for i in range(10)]
  61.  
  62. l1, l2 = BP.LineSelect(-1), BP.LineSelect(-2)
  63. if l1 > l2: l1, l2 = l2, l1
  64. idx = [i for i in BP.VisibleLines() if i >= l1 and i <= l2]
  65.  
  66. f = CreateComponent("TForm", None)
  67. f.SetProps(Position="poMainFormCenter", Width=350, Height=360, BorderStyle="bsSingle", BorderIcons=["biSystemMenu","biMinimize"], Caption="Modifier un groupe d'opΘrations")
  68. CDte = CreateComponent("TCheckBox", f)
  69. CDte.SetProps(Parent=f, Left=30, Top=30, Width=76, Caption="Date :")
  70. CMod = CreateComponent("TCheckBox", f)
  71. CMod.SetProps(Parent=f, Left=30, Top=60, Width=80, Caption="Mode :")
  72. CWho = CreateComponent("TCheckBox", f)
  73. CWho.SetProps(Parent=f, Left=30, Top=90, Width=80, Caption="Tiers :")
  74. CNfo = CreateComponent("TCheckBox", f)
  75. CNfo.SetProps(Parent=f, Left=30, Top=120, Width=80, Caption="DΘtails :")
  76. CCtg = CreateComponent("TCheckBox", f)
  77. CCtg.SetProps(Parent=f, Left=30, Top=150, Width=80, Caption="CatΘgorie :")
  78. CVal = CreateComponent("TCheckBox", f)
  79. CVal.SetProps(Parent=f, Left=30, Top=180, Width=80, Caption="Montant :")
  80. CMrk = CreateComponent("TCheckBox", f)
  81. CMrk.SetProps(Parent=f, Left=30, Top=210, Width=80, Caption="Pointage :")
  82. EDte = CreateComponent("TDateTimePicker", f)
  83. EDte.SetProps(Parent=f, Left=130, Top=30, Width=180, Height=20, Format="ddd d MMMM yyyy")
  84. EMod = CreateComponent("TComboBox", f)
  85. EMod.SetProps(Parent=f, Left=130, Top=60, Width=180, Style="csDropDownList")
  86. EMod.Items.Text = "\n".join(modes)
  87. EMod.ItemIndex = 0
  88. EWho = CreateComponent("TEdit", f)
  89. EWho.SetProps(Parent=f, Left=130, Top=90, Width=180, Text="")
  90. ENfo = CreateComponent("TEdit", f)
  91. ENfo.SetProps(Parent=f, Left=130, Top=120, Width=180, Text="")
  92. ECtg = CreateComponent("TComboBox", f)
  93. ECtg.SetProps(Parent=f, Left=130, Top=150, Width=180, Style="csDropDownList")
  94. ECtg.Items.Text = "\n".join(CNames)
  95. ECtg.ItemIndex = 0
  96. EVal = CreateComponent("TEdit", f)
  97. EVal.SetProps(Parent=f, Left=130, Top=180, Width=180, Text="")
  98. EMrk = CreateComponent("TComboBox", f)
  99. EMrk.SetProps(Parent=f, Left=130, Top=210, Width=180, Style="csDropDownList")
  100. EMrk.Items.Text = "Non pointΘ\nPointΘ\nRapprochΘ"
  101. EMrk.ItemIndex = 0
  102. BCnl = CreateComponent("TButton", f)
  103. BCnl.SetProps(Parent=f, Left=80, Top=264, Width=90, Height=25, Caption="Annuler", Cancel=1, Modalresult=2)
  104. BOK = CreateComponent("TButton", f)
  105. BOK.SetProps(Parent=f, Left=176, Top=264, Width=90, Height=25, Caption="OK", Default=1, OnClick=Apply)
  106.  
  107. f.ShowModal()