'period_id': voucher.period_id.id,
'partner_id': voucher.partner_id.id,
'currency_id': company_currency <> current_currency and current_currency or False,
- 'amount_currency': company_currency <> current_currency and sign * voucher.amount or 0.0,
+ 'amount_currency': (sign * abs(voucher.amount) # amount < 0 for refunds
+ if company_currency != current_currency else 0.0),
'date': voucher.date,
'date_maturity': voucher.date_due
}
if line.amount == line.amount_unreconciled:
if not line.move_line_id:
raise osv.except_osv(_('Wrong voucher line'),_("The invoice you are willing to pay is not valid anymore."))
- sign = voucher.type in ('payment', 'purchase') and -1 or 1
+ sign = line.type =='dr' and -1 or 1
currency_rate_difference = sign * (line.move_line_id.amount_residual - amount)
else:
currency_rate_difference = 0.0
# otherwise we use the rates of the system
amount_currency = currency_obj.compute(cr, uid, company_currency, line.move_line_id.currency_id.id, move_line['debit']-move_line['credit'], context=ctx)
if line.amount == line.amount_unreconciled:
- sign = voucher.type in ('payment', 'purchase') and -1 or 1
- foreign_currency_diff = sign * line.move_line_id.amount_residual_currency + amount_currency
+ foreign_currency_diff = line.move_line_id.amount_residual_currency - abs(amount_currency)
move_line['amount_currency'] = amount_currency
voucher_line = move_line_obj.create(cr, uid, move_line)