unit correction
This commit is contained in:
@@ -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