02.04.26
This commit is contained in:
@@ -343,19 +343,43 @@ class Sale(metaclass=PoolMeta):
|
||||
return text or '0'
|
||||
|
||||
def _format_report_price_words(self, line):
|
||||
value = self._get_report_display_price_value(line)
|
||||
currency = self._get_report_display_currency(line)
|
||||
if currency and (currency.rec_name or '').upper() == 'USC':
|
||||
return amount_to_currency_words(value, 'USC', 'USC')
|
||||
return amount_to_currency_words(value)
|
||||
|
||||
def _get_report_display_currency(self, line):
|
||||
if getattr(line, 'price_type', None) == 'basis':
|
||||
if getattr(line, 'enable_linked_currency', False) and getattr(line, 'linked_currency', None):
|
||||
return line.linked_currency
|
||||
return self.currency
|
||||
return getattr(line, 'linked_currency', None) or self.currency
|
||||
|
||||
def _get_report_display_unit(self, line):
|
||||
if getattr(line, 'price_type', None) == 'basis':
|
||||
if getattr(line, 'enable_linked_currency', False) and getattr(line, 'linked_unit', None):
|
||||
return line.linked_unit
|
||||
return getattr(line, 'unit', None)
|
||||
return getattr(line, 'linked_unit', None) or getattr(line, 'unit', None)
|
||||
|
||||
def _get_report_display_price_value(self, line):
|
||||
if getattr(line, 'price_type', None) == 'basis':
|
||||
if getattr(line, 'enable_linked_currency', False) and getattr(line, 'linked_currency', None):
|
||||
return Decimal(str(line.premium or 0))
|
||||
return Decimal(str(line._get_premium_price() or 0))
|
||||
if getattr(line, 'linked_price', None):
|
||||
return amount_to_currency_words(line.linked_price, 'USC', 'USC')
|
||||
return amount_to_currency_words(line.unit_price)
|
||||
return Decimal(str(line.linked_price or 0))
|
||||
return Decimal(str(line.unit_price or 0))
|
||||
|
||||
def _format_report_price_line(self, line):
|
||||
currency = getattr(line, 'linked_currency', None) or self.currency
|
||||
unit = getattr(line, 'linked_unit', None) or getattr(line, 'unit', None)
|
||||
currency = self._get_report_display_currency(line)
|
||||
unit = self._get_report_display_unit(line)
|
||||
pricing_text = getattr(line, 'get_pricing_text', '') or ''
|
||||
parts = [
|
||||
(currency.rec_name.upper() if currency and currency.rec_name else '').strip(),
|
||||
self._format_report_number(
|
||||
line.linked_price if getattr(line, 'linked_price', None)
|
||||
else line.unit_price,
|
||||
self._get_report_display_price_value(line),
|
||||
strip_trailing_zeros=False),
|
||||
'PER',
|
||||
(unit.rec_name.upper() if unit and unit.rec_name else '').strip(),
|
||||
@@ -374,16 +398,32 @@ class Sale(metaclass=PoolMeta):
|
||||
|
||||
@property
|
||||
def report_gross(self):
|
||||
line = self._get_report_first_line()
|
||||
if line:
|
||||
return sum([l.get_current_gross_quantity() for l in line.lots if l.lot_type == 'physic'])
|
||||
lines = self._get_report_lines()
|
||||
if lines:
|
||||
total = Decimal(0)
|
||||
for line in lines:
|
||||
phys_lots = [l for l in line.lots if l.lot_type == 'physic']
|
||||
if phys_lots:
|
||||
total += sum(Decimal(str(l.get_current_gross_quantity() or 0))
|
||||
for l in phys_lots)
|
||||
else:
|
||||
total += Decimal(str(line.quantity or 0))
|
||||
return total
|
||||
return ''
|
||||
|
||||
@property
|
||||
def report_net(self):
|
||||
line = self._get_report_first_line()
|
||||
if line:
|
||||
return sum([l.get_current_quantity() for l in line.lots if l.lot_type == 'physic'])
|
||||
lines = self._get_report_lines()
|
||||
if lines:
|
||||
total = Decimal(0)
|
||||
for line in lines:
|
||||
phys_lots = [l for l in line.lots if l.lot_type == 'physic']
|
||||
if phys_lots:
|
||||
total += sum(Decimal(str(l.get_current_quantity() or 0))
|
||||
for l in phys_lots)
|
||||
else:
|
||||
total += Decimal(str(line.quantity or 0))
|
||||
return total
|
||||
return ''
|
||||
|
||||
@property
|
||||
@@ -474,13 +514,7 @@ class Sale(metaclass=PoolMeta):
|
||||
def report_price(self):
|
||||
line = self._get_report_first_line()
|
||||
if line:
|
||||
if line.price_type == 'priced':
|
||||
if line.linked_price:
|
||||
return amount_to_currency_words(line.linked_price,'USC','USC')
|
||||
else:
|
||||
return amount_to_currency_words(line.unit_price)
|
||||
elif line.price_type == 'basis':
|
||||
return amount_to_currency_words(line.unit_price) + ' ' + line.get_pricing_text
|
||||
return self._format_report_price_words(line)
|
||||
return ''
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user