Commssion DN/CN

This commit is contained in:
2026-06-19 08:34:29 +02:00
parent 2b0381c2ae
commit 227a6c14a8
3 changed files with 53 additions and 3 deletions

View File

@@ -3746,7 +3746,7 @@
<table:table-column table:style-name="Tableau2.B"/>
<table:table-row table:style-name="Tableau2.1">
<table:table-cell table:style-name="Tableau2.A1" office:value-type="string">
<text:p text:style-name="P14" loext:marker-style-name="T9"><text:span text:style-name="T9"><text:placeholder text:placeholder-type="text">&lt;invoice.report_note_title.upper()&gt;</text:placeholder> N. <text:placeholder text:placeholder-type="text">&lt;invoice.number&gt;</text:placeholder></text:span><text:span text:style-name="T9"/></text:p>
<text:p text:style-name="P14" loext:marker-style-name="T9"><text:span text:style-name="T9"><text:placeholder text:placeholder-type="text">&lt;invoice.report_commission_note_title.upper()&gt;</text:placeholder> N. <text:placeholder text:placeholder-type="text">&lt;invoice.number&gt;</text:placeholder></text:span><text:span text:style-name="T9"/></text:p>
<text:p text:style-name="P11" loext:marker-style-name="T9"/>
<text:p text:style-name="P11" loext:marker-style-name="T9"/>
<text:p text:style-name="P14" loext:marker-style-name="T7"><text:span text:style-name="T7">INVOICE N. <text:placeholder text:placeholder-type="text">&lt;invoice.reference or invoice.report_proforma_invoice_number or &apos;&apos;&gt;</text:placeholder></text:span><text:span text:style-name="T7"/></text:p>
@@ -3864,13 +3864,13 @@
</table:table-row>
<table:table-row table:style-name="Tableau6.1">
<table:table-cell table:style-name="Tableau6.A1" office:value-type="string">
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T7">TOTAL DUE TO YOU</text:span><text:span text:style-name="T7"/></text:p>
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T7"><text:placeholder text:placeholder-type="text">&lt;invoice.report_commission_due_label&gt;</text:placeholder></text:span><text:span text:style-name="T7"/></text:p>
</table:table-cell>
<table:table-cell table:style-name="Tableau6.A1" office:value-type="string">
<text:p text:style-name="P15" loext:marker-style-name="T11"><text:span text:style-name="T7"><text:placeholder text:placeholder-type="text">&lt;invoice.currency.name&gt;</text:placeholder></text:span><text:span text:style-name="T7"/></text:p>
</table:table-cell>
<table:table-cell table:style-name="Tableau6.A1" office:value-type="string">
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T7"><text:placeholder text:placeholder-type="text">&lt;format_number(invoice.total_amount, invoice.party.lang, digits=invoice.currency.digits)&gt;</text:placeholder></text:span><text:span text:style-name="T7"/></text:p>
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T7"><text:placeholder text:placeholder-type="text">&lt;invoice.report_commission_note_total_display&gt;</text:placeholder></text:span><text:span text:style-name="T7"/></text:p>
</table:table-cell>
</table:table-row>
</table:table>

View File

@@ -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 ''

View File

@@ -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')