02.04.26
This commit is contained in:
@@ -233,5 +233,51 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
with self.assertRaises(UserError):
|
||||
ContractFactory._get_line_sources(contract_detail, sources, ct)
|
||||
|
||||
def test_sale_report_price_lines_basis_displays_premium_only(self):
|
||||
'basis report pricing displays only the premium in templates'
|
||||
Sale = Pool().get('sale.sale')
|
||||
|
||||
line = Mock()
|
||||
line.type = 'line'
|
||||
line.price_type = 'basis'
|
||||
line.enable_linked_currency = True
|
||||
line.linked_currency = Mock(rec_name='USC')
|
||||
line.linked_unit = Mock(rec_name='POUND')
|
||||
line.unit = Mock(rec_name='MT')
|
||||
line.unit_price = Decimal('1598.3495')
|
||||
line.linked_price = Decimal('72.5000')
|
||||
line.premium = Decimal('8.3000')
|
||||
line.get_pricing_text = 'ON ICE Cotton #2 MARCH 2026'
|
||||
|
||||
sale = Sale()
|
||||
sale.currency = Mock(rec_name='USD')
|
||||
sale.lines = [line]
|
||||
|
||||
self.assertEqual(
|
||||
sale.report_price_lines,
|
||||
'USC 8.3000 PER POUND (EIGHT USC AND THIRTY CENTS) ON ICE Cotton #2 MARCH 2026')
|
||||
|
||||
def test_sale_report_net_and_gross_sum_all_lines(self):
|
||||
'sale report totals aggregate every line instead of the first one only'
|
||||
Sale = Pool().get('sale.sale')
|
||||
|
||||
def make_lot(quantity):
|
||||
lot = Mock()
|
||||
lot.lot_type = 'physic'
|
||||
lot.get_current_quantity.return_value = Decimal(quantity)
|
||||
lot.get_current_gross_quantity.return_value = Decimal(quantity)
|
||||
return lot
|
||||
|
||||
line_a = Mock(type='line', quantity=Decimal('1000'))
|
||||
line_a.lots = [make_lot('1000')]
|
||||
line_b = Mock(type='line', quantity=Decimal('1000'))
|
||||
line_b.lots = [make_lot('1000')]
|
||||
|
||||
sale = Sale()
|
||||
sale.lines = [line_a, line_b]
|
||||
|
||||
self.assertEqual(sale.report_net, Decimal('2000'))
|
||||
self.assertEqual(sale.report_gross, Decimal('2000'))
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
|
||||
Reference in New Issue
Block a user