Commssion DN/CN
This commit is contained in:
@@ -731,6 +731,33 @@ class Invoice(metaclass=PoolMeta):
|
||||
return self._get_report_commission_value(
|
||||
'report_commission_total_display')
|
||||
|
||||
def _get_report_commission_amount(self):
|
||||
fee = self._get_report_commission_fee()
|
||||
if fee and hasattr(fee, 'get_amount'):
|
||||
return fee.get_amount()
|
||||
return self.total_amount or 0
|
||||
|
||||
@property
|
||||
def report_commission_note_title(self):
|
||||
amount = Decimal(str(self._get_report_commission_amount() or 0))
|
||||
if amount < 0:
|
||||
return 'Credit Note'
|
||||
return 'Debit Note'
|
||||
|
||||
@property
|
||||
def report_commission_due_label(self):
|
||||
amount = Decimal(str(self._get_report_commission_amount() or 0))
|
||||
if amount < 0:
|
||||
return 'TOTAL DUE TO US'
|
||||
return 'TOTAL DUE TO YOU'
|
||||
|
||||
@property
|
||||
def report_commission_note_total_display(self):
|
||||
amount = self._get_report_commission_amount()
|
||||
return self._format_report_number(
|
||||
abs(Decimal(str(amount or 0))), digits='0.01',
|
||||
strip_trailing_zeros=False)
|
||||
|
||||
def _get_report_commission_address_for(self, kind):
|
||||
trade = self._get_report_commission_trade_for(kind)
|
||||
return getattr(trade, 'report_address', '') or ''
|
||||
|
||||
@@ -7446,6 +7446,29 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
debit.total_amount = Decimal('-10')
|
||||
self.assertEqual(debit.report_note_title, 'Debit Note')
|
||||
|
||||
def test_invoice_commission_note_uses_company_to_broker_direction(self):
|
||||
'commission note title follows company to broker correction direction'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
|
||||
credit = Invoice()
|
||||
credit.total_amount = Decimal('-79.37')
|
||||
self.assertEqual(credit.report_commission_note_title, 'Credit Note')
|
||||
self.assertEqual(credit.report_commission_due_label, 'TOTAL DUE TO US')
|
||||
|
||||
debit = Invoice()
|
||||
debit.total_amount = Decimal('79.37')
|
||||
self.assertEqual(debit.report_commission_note_title, 'Debit Note')
|
||||
self.assertEqual(debit.report_commission_due_label, 'TOTAL DUE TO YOU')
|
||||
|
||||
def test_invoice_commission_note_total_is_absolute(self):
|
||||
'commission note total is displayed without the accounting sign'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
|
||||
invoice = Invoice()
|
||||
invoice.total_amount = Decimal('-79.37')
|
||||
|
||||
self.assertEqual(invoice.report_commission_note_total_display, '79.37')
|
||||
|
||||
def test_invoice_report_net_sums_signed_invoice_lines(self):
|
||||
'invoice report net uses the signed differential from invoice lines'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
|
||||
Reference in New Issue
Block a user