Add insured amount
This commit is contained in:
@@ -487,6 +487,25 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
return fee
|
||||
return None
|
||||
|
||||
def _get_report_incoming_amount_data(self):
|
||||
total = Decimal('0.0')
|
||||
currency = None
|
||||
for move in (self.incoming_moves or []):
|
||||
quantity = Decimal(str(getattr(move, 'quantity', 0) or 0))
|
||||
unit_price = Decimal(str(getattr(move, 'unit_price', 0) or 0))
|
||||
total += (quantity * unit_price)
|
||||
if not currency:
|
||||
currency = getattr(move, 'currency', None)
|
||||
return total, currency
|
||||
|
||||
@staticmethod
|
||||
def _get_report_currency_text(currency):
|
||||
return (
|
||||
getattr(currency, 'rec_name', None)
|
||||
or getattr(currency, 'code', None)
|
||||
or getattr(currency, 'symbol', None)
|
||||
or '')
|
||||
|
||||
@staticmethod
|
||||
def _format_report_amount(value):
|
||||
if value in (None, ''):
|
||||
@@ -559,14 +578,25 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
if not fee:
|
||||
return ''
|
||||
currency = getattr(fee, 'currency', None)
|
||||
currency_text = (
|
||||
getattr(currency, 'rec_name', None)
|
||||
or getattr(currency, 'code', None)
|
||||
or getattr(currency, 'symbol', None)
|
||||
or '')
|
||||
currency_text = self._get_report_currency_text(currency)
|
||||
amount = self._format_report_amount(fee.get_amount())
|
||||
return ' '.join(part for part in [currency_text, amount] if part)
|
||||
|
||||
@property
|
||||
def report_insurance_incoming_amount(self):
|
||||
amount, currency = self._get_report_incoming_amount_data()
|
||||
currency_text = self._get_report_currency_text(currency)
|
||||
amount_text = self._format_report_amount(amount)
|
||||
return ' '.join(part for part in [currency_text, amount_text] if part)
|
||||
|
||||
@property
|
||||
def report_insurance_amount_insured(self):
|
||||
amount, currency = self._get_report_incoming_amount_data()
|
||||
insured_amount = amount * Decimal('1.10')
|
||||
currency_text = self._get_report_currency_text(currency)
|
||||
amount_text = self._format_report_amount(insured_amount)
|
||||
return ' '.join(part for part in [currency_text, amount_text] if part)
|
||||
|
||||
@property
|
||||
def report_insurance_surveyor(self):
|
||||
if self.controller:
|
||||
|
||||
Reference in New Issue
Block a user