02.04.26
This commit is contained in:
@@ -167,9 +167,6 @@ class Invoice(metaclass=PoolMeta):
|
||||
|
||||
@property
|
||||
def report_quantity_lines(self):
|
||||
sale = self._get_report_sale()
|
||||
if sale and getattr(sale, 'report_quantity_lines', None):
|
||||
return sale.report_quantity_lines
|
||||
details = []
|
||||
for line in self._get_report_invoice_lines():
|
||||
quantity = getattr(line, 'report_net', '')
|
||||
@@ -193,9 +190,6 @@ class Invoice(metaclass=PoolMeta):
|
||||
|
||||
@property
|
||||
def report_trade_blocks(self):
|
||||
sale = self._get_report_sale()
|
||||
if sale and getattr(sale, 'report_trade_blocks', None):
|
||||
return sale.report_trade_blocks
|
||||
blocks = []
|
||||
quantity_lines = self.report_quantity_lines.splitlines()
|
||||
rate_lines = self.report_rate_lines.splitlines()
|
||||
@@ -241,9 +235,6 @@ class Invoice(metaclass=PoolMeta):
|
||||
|
||||
@property
|
||||
def report_rate_lines(self):
|
||||
sale = self._get_report_sale()
|
||||
if sale and getattr(sale, 'report_price_lines', None):
|
||||
return sale.report_price_lines
|
||||
details = []
|
||||
for line in self._get_report_invoice_lines():
|
||||
currency = getattr(line, 'report_rate_currency_upper', '') or ''
|
||||
@@ -309,9 +300,6 @@ class Invoice(metaclass=PoolMeta):
|
||||
|
||||
@property
|
||||
def report_gross(self):
|
||||
sale = self._get_report_sale()
|
||||
if sale and sale.report_gross != '':
|
||||
return sale.report_gross
|
||||
if self.lines:
|
||||
return sum(
|
||||
Decimal(str(getattr(line, 'quantity', 0) or 0))
|
||||
@@ -326,9 +314,6 @@ class Invoice(metaclass=PoolMeta):
|
||||
|
||||
@property
|
||||
def report_net(self):
|
||||
trade = self._get_report_trade()
|
||||
if trade and getattr(trade, 'report_net', '') != '':
|
||||
return trade.report_net
|
||||
if self.lines:
|
||||
return sum(
|
||||
Decimal(str(getattr(line, 'quantity', 0) or 0))
|
||||
@@ -352,15 +337,19 @@ class Invoice(metaclass=PoolMeta):
|
||||
|
||||
@property
|
||||
def report_weight_unit_upper(self):
|
||||
sale = self._get_report_sale()
|
||||
if sale and getattr(sale, 'report_quantity_unit_upper', None):
|
||||
return sale.report_quantity_unit_upper
|
||||
line = self._get_report_trade_line() or self._get_report_invoice_line()
|
||||
unit = getattr(line, 'unit', None) if line else None
|
||||
if unit and unit.rec_name:
|
||||
return unit.rec_name.upper()
|
||||
return 'KGS'
|
||||
|
||||
@property
|
||||
def report_note_title(self):
|
||||
total = Decimal(str(self.total_amount or 0))
|
||||
if total < 0:
|
||||
return 'Debit Note'
|
||||
return 'Credit Note'
|
||||
|
||||
@property
|
||||
def report_bl_date(self):
|
||||
shipment = self._get_report_shipment()
|
||||
|
||||
@@ -310,5 +310,28 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
'USC 8.3000 PER POUND (EIGHT USC AND THIRTY CENTS) ON ICE Cotton #2 MARCH 2026',
|
||||
)])
|
||||
|
||||
def test_invoice_report_note_title_uses_total_amount_sign(self):
|
||||
'final invoice title switches between credit and debit note'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
|
||||
credit = Invoice()
|
||||
credit.total_amount = Decimal('10')
|
||||
self.assertEqual(credit.report_note_title, 'Credit Note')
|
||||
|
||||
debit = Invoice()
|
||||
debit.total_amount = Decimal('-10')
|
||||
self.assertEqual(debit.report_note_title, 'Debit Note')
|
||||
|
||||
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')
|
||||
|
||||
line_a = Mock(type='line', quantity=Decimal('1000'))
|
||||
line_b = Mock(type='line', quantity=Decimal('-200'))
|
||||
invoice = Invoice()
|
||||
invoice.lines = [line_a, line_b]
|
||||
|
||||
self.assertEqual(invoice.report_net, Decimal('800'))
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
|
||||
Reference in New Issue
Block a user