Skip to content

Commit

Permalink
[FIX]: account: reconciliation: handling negative amount_residual
Browse files Browse the repository at this point in the history
  • Loading branch information
Whisno committed Sep 12, 2014
1 parent f393171 commit b2385d6
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions addons/account/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,19 +794,29 @@ def prepare_move_lines_for_reconciliation_widget(self, cr, uid, lines, target_cu
'partial_reconciliation_siblings_ids': partial_reconciliation_siblings_ids,
}

# Amount residual can be negative
debit = line.debit
credit = line.credit
amount_residual = line.amount_residual
amount_residual_currency = line.amount_residual_currency
if line.amount_residual < 0:
debit, credit = credit, debit
amount_residual = -amount_residual
amount_residual_currency = -amount_residual_currency

# Get right debit / credit:
line_currency = line.currency_id or company_currency
amount_currency_str = ""
if line.currency_id and line.amount_currency:
amount_currency_str = rml_parser.formatLang(line.amount_currency, currency_obj=line.currency_id)
if target_currency and line_currency == target_currency and target_currency != company_currency:
debit = line.debit > 0 and line.amount_residual_currency or 0.0
credit = line.credit > 0 and line.amount_residual_currency or 0.0
amount_currency_str = rml_parser.formatLang(line.amount_residual, currency_obj=company_currency)
debit = debit > 0 and amount_residual_currency or 0.0
credit = credit > 0 and amount_residual_currency or 0.0
amount_currency_str = amount_residual_currency(amount_residual, currency_obj=company_currency)
amount_str = rml_parser.formatLang(debit or credit, currency_obj=target_currency)
else:
debit = line.debit > 0 and line.amount_residual or 0.0
credit = line.credit > 0 and line.amount_residual or 0.0
debit = debit > 0 and amount_residual or 0.0
credit = credit > 0 and amount_residual or 0.0
amount_str = rml_parser.formatLang(debit or credit, currency_obj=company_currency)
if target_currency and target_currency != company_currency:
amount_currency_str = rml_parser.formatLang(debit or credit, currency_obj=line_currency)
Expand All @@ -817,12 +827,6 @@ def prepare_move_lines_for_reconciliation_widget(self, cr, uid, lines, target_cu
credit = currency_obj.compute(cr, uid, target_currency.id, company_currency.id, credit, context=ctx)
amount_str = rml_parser.formatLang(debit or credit, currency_obj=target_currency)

# Amount residual can be negative
if debit < 0:
debit, credit = credit, -debit
if credit < 0:
debit, credit = -credit, debit

ret_line['credit'] = credit
ret_line['debit'] = debit
ret_line['amount_str'] = amount_str
Expand Down

0 comments on commit b2385d6

Please sign in to comment.