75
75
sizer=wx.BoxSizer(wx.VERTICAL)
77
# Store the opening transaction in a TransactionForm object
78
self.transaction = form_objects.TransactionForm()
80
77
# Create the input labels and fields in a grid sizer
81
78
fields_sizer=wx.FlexGridSizer(rows=5, cols=2, hgap=20, vgap=20)
262
259
def set_opening_balance(self, balance, datestamp):
263
260
"""Creates a transaction to set the opening balance"""
265
self.transaction.description = "%s opening balance" % self.account.fullname
266
self.transaction.datestamp = datestamp
262
# Store the opening transaction in a TransactionForm object
263
transaction = form_objects.TransactionForm()
265
transaction.description = "%s opening balance" % self.account.fullname
266
transaction.datestamp = datestamp
267
267
# This is an opening balance transaction (system type 1)
268
self.transaction.system = 1
268
transaction.system = 1
270
270
# Get the system opening balances account - this being the account with system = 2
271
271
op_account = get_account_by_system(2)
273
# Ensure the transaction.trans_list is empty
274
self.transaction.clear()
276
273
# If balance is greater than zero, then debit the account by the
277
274
# balance, otherwise credit it
278
275
if balance > D(0):
279
self.transaction.add(self.account, debit=balance)
280
self.transaction.add(op_account, credit=balance)
276
transaction.add(self.account, debit=balance)
277
transaction.add(op_account, credit=balance)
282
279
balance = abs(balance)
283
self.transaction.add(self.account, credit=balance)
284
self.transaction.add(op_account, debit=balance)
280
transaction.add(self.account, credit=balance)
281
transaction.add(op_account, debit=balance)
286
status, message = self.transaction.check()
283
status, message = transaction.check()
288
285
return False, message
290
287
# In this case do not confirm the transaction - as doing so does not add any value
292
289
# Must now implement the opening balance transaction
293
transaction_id = transactions.implement(None, self.transaction)
290
transactions.implement(None, transaction)
295
292
info_log("opening balance set")
296
293
return True, None