02.04.26
This commit is contained in:
@@ -440,12 +440,19 @@ class Sale(metaclass=PoolMeta):
|
||||
if line and line.unit:
|
||||
return line.unit.rec_name.upper()
|
||||
return ''
|
||||
|
||||
def _get_report_line_quantity(self, line):
|
||||
phys_lots = [l for l in line.lots if l.lot_type == 'physic']
|
||||
if phys_lots:
|
||||
return sum(Decimal(str(l.get_current_quantity() or 0))
|
||||
for l in phys_lots)
|
||||
return Decimal(str(line.quantity or 0))
|
||||
|
||||
@property
|
||||
def report_qt(self):
|
||||
lines = self._get_report_lines()
|
||||
if lines:
|
||||
total = sum(Decimal(str(line.quantity or 0)) for line in lines)
|
||||
total = sum(self._get_report_line_quantity(line) for line in lines)
|
||||
return quantity_to_words(total)
|
||||
return ''
|
||||
|
||||
@@ -456,10 +463,11 @@ class Sale(metaclass=PoolMeta):
|
||||
return ''
|
||||
details = []
|
||||
for line in lines:
|
||||
current_quantity = self._get_report_line_quantity(line)
|
||||
quantity = self._format_report_number(
|
||||
line.quantity, keep_trailing_decimal=True)
|
||||
current_quantity, keep_trailing_decimal=True)
|
||||
unit = line.unit.rec_name.upper() if line.unit and line.unit.rec_name else ''
|
||||
words = quantity_to_words(Decimal(str(line.quantity or 0)))
|
||||
words = quantity_to_words(current_quantity)
|
||||
period = line.del_period.description if getattr(line, 'del_period', None) else ''
|
||||
detail = ' '.join(
|
||||
part for part in [
|
||||
@@ -523,6 +531,28 @@ class Sale(metaclass=PoolMeta):
|
||||
if lines:
|
||||
return '\n'.join(self._format_report_price_line(line) for line in lines)
|
||||
return ''
|
||||
|
||||
@property
|
||||
def report_trade_blocks(self):
|
||||
lines = self._get_report_lines()
|
||||
blocks = []
|
||||
for line in lines:
|
||||
current_quantity = self._get_report_line_quantity(line)
|
||||
quantity = self._format_report_number(
|
||||
current_quantity, keep_trailing_decimal=True)
|
||||
unit = line.unit.rec_name.upper() if line.unit and line.unit.rec_name else ''
|
||||
words = quantity_to_words(current_quantity)
|
||||
period = line.del_period.description if getattr(line, 'del_period', None) else ''
|
||||
quantity_line = ' '.join(
|
||||
part for part in [
|
||||
quantity,
|
||||
unit,
|
||||
f"({words})",
|
||||
f"- {period}" if period else '',
|
||||
] if part)
|
||||
price_line = self._format_report_price_line(line)
|
||||
blocks.append((quantity_line, price_line))
|
||||
return blocks
|
||||
|
||||
@property
|
||||
def report_delivery(self):
|
||||
|
||||
Reference in New Issue
Block a user