mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[FIX] Handle full and partial reconciliation amounts.
[ADD] Cancel the journal entries by canceling and deleting the linked voucher, if available.
This commit is contained in:
@@ -1748,7 +1748,7 @@ class account_bank_statement_line(osv.osv):
|
|||||||
|
|
||||||
# Update the statement line to indicate that it has been posted
|
# Update the statement line to indicate that it has been posted
|
||||||
# ... no longer need to set the move_id on the voucher?
|
# ... no longer need to set the move_id on the voucher?
|
||||||
#self.write(cr, uid, st_line.id, {'state': 'confirmed'}, context)
|
self.write(cr, uid, st_line.id, {'state': 'confirmed'}, context)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -1776,8 +1776,10 @@ class account_bank_statement_line(osv.osv):
|
|||||||
# Check whether this is a full or partial reconciliation
|
# Check whether this is a full or partial reconciliation
|
||||||
if st_line.import_transaction_id.payment_option=='with_writeoff':
|
if st_line.import_transaction_id.payment_option=='with_writeoff':
|
||||||
writeoff = abs(st_line.amount)-abs(amount_currency)
|
writeoff = abs(st_line.amount)-abs(amount_currency)
|
||||||
|
line_amount = abs(amount_currency)
|
||||||
else:
|
else:
|
||||||
writeoff = 0.0
|
writeoff = 0.0
|
||||||
|
line_amount = abs(st_line.amount)
|
||||||
|
|
||||||
# Define the voucher
|
# Define the voucher
|
||||||
voucher = {
|
voucher = {
|
||||||
@@ -1799,7 +1801,7 @@ class account_bank_statement_line(osv.osv):
|
|||||||
#'voucher_id': v_id,
|
#'voucher_id': v_id,
|
||||||
'move_line_id': st_line.import_transaction_id.move_line_id.id,
|
'move_line_id': st_line.import_transaction_id.move_line_id.id,
|
||||||
'reconcile': True,
|
'reconcile': True,
|
||||||
'amount': abs(amount_currency),
|
'amount': line_amount,
|
||||||
'account_id': st_line.import_transaction_id.move_line_id.account_id.id,
|
'account_id': st_line.import_transaction_id.move_line_id.account_id.id,
|
||||||
'type': st_line.import_transaction_id.move_line_id.credit and 'dr' or 'cr',
|
'type': st_line.import_transaction_id.move_line_id.credit and 'dr' or 'cr',
|
||||||
}
|
}
|
||||||
@@ -1871,7 +1873,9 @@ class account_bank_statement_line(osv.osv):
|
|||||||
ids = [ids]
|
ids = [ids]
|
||||||
account_move_obj = self.pool.get('account.move')
|
account_move_obj = self.pool.get('account.move')
|
||||||
import_transaction_obj = self.pool.get('banking.import.transaction')
|
import_transaction_obj = self.pool.get('banking.import.transaction')
|
||||||
|
voucher_pool = self.pool.get('account.voucher')
|
||||||
transaction_cancel_ids = []
|
transaction_cancel_ids = []
|
||||||
|
voucher_cancel_ids = []
|
||||||
move_unlink_ids = []
|
move_unlink_ids = []
|
||||||
set_draft_ids = []
|
set_draft_ids = []
|
||||||
# harvest ids for various actions
|
# harvest ids for various actions
|
||||||
@@ -1883,18 +1887,29 @@ class account_bank_statement_line(osv.osv):
|
|||||||
_("Cannot cancel bank transaction"),
|
_("Cannot cancel bank transaction"),
|
||||||
_("The bank statement that this transaction belongs to has "
|
_("The bank statement that this transaction belongs to has "
|
||||||
"already been confirmed"))
|
"already been confirmed"))
|
||||||
if st_line.import_transaction_id:
|
|
||||||
transaction_cancel_ids.append(st_line.import_transaction_id.id)
|
# Check if the transaction has a voucher
|
||||||
if st_line.move_id:
|
if st_line.voucher_id:
|
||||||
move_unlink_ids.append(st_line.move_id.id)
|
voucher_cancel_ids.append(st_line.voucher_id.id)
|
||||||
else:
|
else:
|
||||||
raise osv.except_osv(
|
if st_line.import_transaction_id:
|
||||||
_("Cannot cancel bank transaction"),
|
transaction_cancel_ids.append(st_line.import_transaction_id.id)
|
||||||
_("Cannot cancel this bank transaction. The information "
|
if st_line.move_id:
|
||||||
"needed to undo the accounting entries has not been "
|
move_unlink_ids.append(st_line.move_id.id)
|
||||||
"recorded"))
|
else:
|
||||||
|
raise osv.except_osv(
|
||||||
|
_("Cannot cancel bank transaction"),
|
||||||
|
_("Cannot cancel this bank transaction. The information "
|
||||||
|
"needed to undo the accounting entries has not been "
|
||||||
|
"recorded"))
|
||||||
set_draft_ids.append(st_line.id)
|
set_draft_ids.append(st_line.id)
|
||||||
# perform actions
|
|
||||||
|
# Cancel and delete the vouchers
|
||||||
|
voucher_pool.cancel_voucher(cr, uid, voucher_cancel_ids, context=context)
|
||||||
|
voucher_pool.action_cancel_draft(cr, uid, voucher_cancel_ids, context=context)
|
||||||
|
voucher_pool.unlink(cr, uid, voucher_cancel_ids, context=context)
|
||||||
|
|
||||||
|
# Perform actions
|
||||||
import_transaction_obj.cancel(
|
import_transaction_obj.cancel(
|
||||||
cr, uid, transaction_cancel_ids, context=context)
|
cr, uid, transaction_cancel_ids, context=context)
|
||||||
account_move_obj.button_cancel(cr, uid, move_unlink_ids, context)
|
account_move_obj.button_cancel(cr, uid, move_unlink_ids, context)
|
||||||
|
|||||||
@@ -218,10 +218,12 @@ class banking_transaction_wizard(osv.osv_memory):
|
|||||||
"""
|
"""
|
||||||
if isinstance(ids, (int, float)):
|
if isinstance(ids, (int, float)):
|
||||||
ids = [ids]
|
ids = [ids]
|
||||||
# self.write(cr, uid, ids,
|
self.write(cr, uid, ids,
|
||||||
# {'manual_invoice_id': False,
|
{'partner_id': False,
|
||||||
|
# 'manual_invoice_id': False,
|
||||||
# 'manual_move_line_id': False,
|
# 'manual_move_line_id': False,
|
||||||
# }, context=context)
|
}, context=context)
|
||||||
|
|
||||||
wizs = self.read(
|
wizs = self.read(
|
||||||
cr, uid, ids, ['import_transaction_id'], context=context)
|
cr, uid, ids, ['import_transaction_id'], context=context)
|
||||||
trans_ids = [x['import_transaction_id'][0] for x in wizs
|
trans_ids = [x['import_transaction_id'][0] for x in wizs
|
||||||
|
|||||||
Reference in New Issue
Block a user