unit correction
This commit is contained in:
@@ -3930,7 +3930,7 @@
|
||||
<text:p text:style-name="P25">Goods description</text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau5.A1" office:value-type="string">
|
||||
<text:p text:style-name="P26">QUANTITY: <text:placeholder text:placeholder-type="text"><format_number(invoice.report_lbs, invoice.party.lang) if invoice.report_lbs != '' else ''></text:placeholder><text:s/>LBS (<text:placeholder text:placeholder-type="text"><format_number(invoice.report_net, invoice.party.lang) if invoice.report_net != '' else ''></text:placeholder> <text:placeholder text:placeholder-type="text"><invoice.report_weight_unit_upper></text:placeholder>)</text:p>
|
||||
<text:p text:style-name="P26">QUANTITY: <text:placeholder text:placeholder-type="text"><invoice.report_lbs_display></text:placeholder><text:s/>LBS (<text:placeholder text:placeholder-type="text"><invoice.report_net_display></text:placeholder> <text:placeholder text:placeholder-type="text"><invoice.report_weight_unit_upper></text:placeholder>)</text:p>
|
||||
<text:p text:style-name="P26"/>
|
||||
<text:p text:style-name="P21"><text:placeholder text:placeholder-type="text"><invoice.report_description_upper or invoice.report_product_description></text:placeholder><text:placeholder text:placeholder-type="text"><' CROP ' + invoice.report_crop_name if invoice.report_crop_name else ''></text:placeholder></text:p>
|
||||
<text:p text:style-name="P21"><text:placeholder text:placeholder-type="text"><invoice.report_attributes_name></text:placeholder></text:p>
|
||||
@@ -3974,10 +3974,10 @@
|
||||
<text:p text:style-name="P15"><text:placeholder text:placeholder-type="text"><invoice.report_nb_bale></text:placeholder><text:s/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau6.A2" office:value-type="string">
|
||||
<text:p text:style-name="P15"><text:placeholder text:placeholder-type="text"><format_number(invoice.report_gross, invoice.party.lang) if invoice.report_gross != '' else ''></text:placeholder><text:s/></text:p>
|
||||
<text:p text:style-name="P15"><text:placeholder text:placeholder-type="text"><invoice.report_gross_display></text:placeholder><text:s/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau6.A2" office:value-type="string">
|
||||
<text:p text:style-name="P30"><text:placeholder text:placeholder-type="text"><format_number(invoice.report_net, invoice.party.lang) if invoice.report_net != '' else ''></text:placeholder><text:s/></text:p>
|
||||
<text:p text:style-name="P30"><text:placeholder text:placeholder-type="text"><invoice.report_net_display></text:placeholder><text:s/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau6.A2" office:value-type="string">
|
||||
<text:p text:style-name="P16"/>
|
||||
@@ -4001,7 +4001,7 @@
|
||||
<text:p text:style-name="P16">Equivalent to LBS</text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau7.A1" office:value-type="string">
|
||||
<text:p text:style-name="P16"><text:placeholder text:placeholder-type="text"><format_number(invoice.report_lbs, invoice.party.lang) if invoice.report_lbs != '' else ''></text:placeholder><text:s/></text:p>
|
||||
<text:p text:style-name="P16"><text:placeholder text:placeholder-type="text"><invoice.report_lbs_display></text:placeholder><text:s/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau7.A1" office:value-type="string">
|
||||
<text:p text:style-name="P20"/>
|
||||
|
||||
@@ -3916,7 +3916,7 @@
|
||||
<text:p text:style-name="P26">Goods description</text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau5.A1" office:value-type="string">
|
||||
<text:p text:style-name="P27">QUANTITY: <text:placeholder text:placeholder-type="text"><format_number(invoice.report_lbs, invoice.party.lang) if invoice.report_lbs != '' else ''></text:placeholder><text:s/>LBS (<text:placeholder text:placeholder-type="text"><format_number(invoice.report_net, invoice.party.lang) if invoice.report_net != '' else ''></text:placeholder> <text:placeholder text:placeholder-type="text"><invoice.report_weight_unit_upper></text:placeholder>)</text:p>
|
||||
<text:p text:style-name="P27">QUANTITY: <text:placeholder text:placeholder-type="text"><invoice.report_lbs_display></text:placeholder><text:s/>LBS (<text:placeholder text:placeholder-type="text"><invoice.report_net_display></text:placeholder> <text:placeholder text:placeholder-type="text"><invoice.report_weight_unit_upper></text:placeholder>)</text:p>
|
||||
<text:p text:style-name="P27"/>
|
||||
<text:p text:style-name="P21"><text:placeholder text:placeholder-type="text"><invoice.report_description_upper or invoice.report_product_description></text:placeholder><text:placeholder text:placeholder-type="text"><' CROP ' + invoice.report_crop_name if invoice.report_crop_name else ''></text:placeholder></text:p>
|
||||
<text:p text:style-name="P21"><text:placeholder text:placeholder-type="text"><invoice.report_attributes_name></text:placeholder></text:p>
|
||||
@@ -3959,10 +3959,10 @@
|
||||
<text:p text:style-name="P15"><text:placeholder text:placeholder-type="text"><invoice.report_cndn_nb_bale></text:placeholder><text:s/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau6.A2" office:value-type="string">
|
||||
<text:p text:style-name="P15"><text:placeholder text:placeholder-type="text"><format_number(invoice.report_gross, invoice.party.lang) if invoice.report_gross != '' else ''></text:placeholder><text:s/></text:p>
|
||||
<text:p text:style-name="P15"><text:placeholder text:placeholder-type="text"><invoice.report_gross_display></text:placeholder><text:s/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau6.A2" office:value-type="string">
|
||||
<text:p text:style-name="P32"><text:placeholder text:placeholder-type="text"><format_number(invoice.report_net, invoice.party.lang) if invoice.report_net != '' else ''></text:placeholder><text:s/></text:p>
|
||||
<text:p text:style-name="P32"><text:placeholder text:placeholder-type="text"><invoice.report_net_display></text:placeholder><text:s/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau6.A2" office:value-type="string">
|
||||
<text:p text:style-name="P16"/>
|
||||
@@ -3986,7 +3986,7 @@
|
||||
<text:p text:style-name="P16">Equivalent to LBS</text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau7.A1" office:value-type="string">
|
||||
<text:p text:style-name="P16"><text:placeholder text:placeholder-type="text"><format_number(invoice.report_lbs, invoice.party.lang) if invoice.report_lbs != '' else ''></text:placeholder><text:s/></text:p>
|
||||
<text:p text:style-name="P16"><text:placeholder text:placeholder-type="text"><invoice.report_lbs_display></text:placeholder><text:s/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau7.A1" office:value-type="string">
|
||||
<text:p text:style-name="P20"/>
|
||||
|
||||
@@ -26,6 +26,11 @@ class Invoice(metaclass=PoolMeta):
|
||||
text += '.0'
|
||||
return text or '0'
|
||||
|
||||
@classmethod
|
||||
def _format_report_quantity_display(cls, value):
|
||||
return cls._format_report_number(
|
||||
value, digits='0.01', strip_trailing_zeros=False)
|
||||
|
||||
def _get_report_invoice_line(self):
|
||||
for line in self.lines or []:
|
||||
if getattr(line, 'type', None) == 'line':
|
||||
@@ -658,15 +663,14 @@ class Invoice(metaclass=PoolMeta):
|
||||
quantity, _ = self._get_report_invoice_line_weights(line)
|
||||
if quantity == '':
|
||||
continue
|
||||
quantity_text = self._format_report_number(
|
||||
quantity, keep_trailing_decimal=True)
|
||||
quantity_text = self._format_report_quantity_display(quantity)
|
||||
unit = self._get_report_invoice_line_unit(line)
|
||||
unit_name = unit.rec_name.upper() if unit and unit.rec_name else ''
|
||||
lbs = self._convert_report_quantity_to_lbs(quantity, unit)
|
||||
parts = [quantity_text, unit_name]
|
||||
if lbs != '':
|
||||
parts.append(
|
||||
f"({self._format_report_number(lbs, digits='0.01')} LBS)")
|
||||
f"({self._format_report_quantity_display(lbs)} LBS)")
|
||||
detail = ' '.join(part for part in parts if part)
|
||||
if detail:
|
||||
details.append(detail)
|
||||
@@ -856,6 +860,27 @@ class Invoice(metaclass=PoolMeta):
|
||||
return 'Unchanged'
|
||||
return nb_bale
|
||||
|
||||
@property
|
||||
def report_net_display(self):
|
||||
net = self.report_net
|
||||
if net == '':
|
||||
return ''
|
||||
return self._format_report_quantity_display(net)
|
||||
|
||||
@property
|
||||
def report_gross_display(self):
|
||||
gross = self.report_gross
|
||||
if gross == '':
|
||||
return ''
|
||||
return self._format_report_quantity_display(gross)
|
||||
|
||||
@property
|
||||
def report_lbs_display(self):
|
||||
lbs = self.report_lbs
|
||||
if lbs == '':
|
||||
return ''
|
||||
return self._format_report_quantity_display(lbs)
|
||||
|
||||
@property
|
||||
def report_gross(self):
|
||||
if self.lines:
|
||||
|
||||
@@ -1130,7 +1130,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(invoice.report_weight_unit_upper, 'LBS')
|
||||
self.assertEqual(
|
||||
invoice.report_quantity_lines,
|
||||
'950.0 LBS (950.00 LBS)')
|
||||
'950.00 LBS (950.00 LBS)')
|
||||
|
||||
def test_invoice_report_lbs_converts_kilogram_to_lbs(self):
|
||||
'invoice lbs helper converts kilogram quantities with the proper uom ratio'
|
||||
@@ -1159,7 +1159,9 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(invoice.report_lbs, Decimal('2204608.98'))
|
||||
self.assertEqual(
|
||||
invoice.report_quantity_lines,
|
||||
'999995.0 KILOGRAM (2204608.98 LBS)')
|
||||
'999995.00 KILOGRAM (2204608.98 LBS)')
|
||||
self.assertEqual(invoice.report_net_display, '999995.00')
|
||||
self.assertEqual(invoice.report_lbs_display, '2204608.98')
|
||||
|
||||
def test_invoice_report_weights_keep_line_sign_with_lot_hist_values(self):
|
||||
'invoice lot hist values keep the invoice line sign for final notes'
|
||||
|
||||
Reference in New Issue
Block a user