Add insured amount
This commit is contained in:
@@ -312,12 +312,17 @@ Source code: `modules/purchase_trade/stock.py`
|
|||||||
- `report_insurance_discharge_port`
|
- `report_insurance_discharge_port`
|
||||||
- `report_insurance_transport`
|
- `report_insurance_transport`
|
||||||
- `report_insurance_amount`
|
- `report_insurance_amount`
|
||||||
|
- `report_insurance_incoming_amount`
|
||||||
|
- `report_insurance_amount_insured`
|
||||||
- `report_insurance_surveyor`
|
- `report_insurance_surveyor`
|
||||||
- `report_insurance_issue_place_and_date`
|
- `report_insurance_issue_place_and_date`
|
||||||
|
|
||||||
Usage typique:
|
Usage typique:
|
||||||
- templates shipment relies a l'assurance
|
- templates shipment relies a l'assurance
|
||||||
- templates qui lisent le fee `Insurance` d'un `stock.shipment.in`
|
- `report_insurance_incoming_amount`: somme `incoming_moves` de
|
||||||
|
`quantity * unit_price`
|
||||||
|
- `report_insurance_amount_insured`: `110%` de
|
||||||
|
`report_insurance_incoming_amount`
|
||||||
- base de travail pour un certificat d'assurance lie a un shipment
|
- base de travail pour un certificat d'assurance lie a un shipment
|
||||||
|
|
||||||
## 10) Recommandations
|
## 10) Recommandations
|
||||||
|
|||||||
@@ -149,8 +149,11 @@ Derniere mise a jour: `2026-04-02`
|
|||||||
- Pour ce template, ne pas compter sur une variable Genshi locale `shipment`
|
- Pour ce template, ne pas compter sur une variable Genshi locale `shipment`
|
||||||
dans tout le document; preferer `records[0]....` dans le `.fodt`.
|
dans tout le document; preferer `records[0]....` dans le `.fodt`.
|
||||||
- Source de verite du montant assure:
|
- Source de verite du montant assure:
|
||||||
- le `fee.fee` du shipment dont le produit contient `Insurance`
|
- sommer les montants des `incoming_moves` du shipment
|
||||||
- montant via `fee.get_amount()`
|
- montant d'un move = `move.quantity * move.unit_price`
|
||||||
|
- exposer au moins:
|
||||||
|
- le montant total des incoming moves
|
||||||
|
- le montant assure a `110%` de ce total
|
||||||
|
|
||||||
### TR-016 - Hypotheses actuelles pour le certificat d'assurance shipment
|
### TR-016 - Hypotheses actuelles pour le certificat d'assurance shipment
|
||||||
|
|
||||||
|
|||||||
@@ -487,6 +487,25 @@ class ShipmentIn(metaclass=PoolMeta):
|
|||||||
return fee
|
return fee
|
||||||
return None
|
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
|
@staticmethod
|
||||||
def _format_report_amount(value):
|
def _format_report_amount(value):
|
||||||
if value in (None, ''):
|
if value in (None, ''):
|
||||||
@@ -559,14 +578,25 @@ class ShipmentIn(metaclass=PoolMeta):
|
|||||||
if not fee:
|
if not fee:
|
||||||
return ''
|
return ''
|
||||||
currency = getattr(fee, 'currency', None)
|
currency = getattr(fee, 'currency', None)
|
||||||
currency_text = (
|
currency_text = self._get_report_currency_text(currency)
|
||||||
getattr(currency, 'rec_name', None)
|
|
||||||
or getattr(currency, 'code', None)
|
|
||||||
or getattr(currency, 'symbol', None)
|
|
||||||
or '')
|
|
||||||
amount = self._format_report_amount(fee.get_amount())
|
amount = self._format_report_amount(fee.get_amount())
|
||||||
return ' '.join(part for part in [currency_text, amount] if part)
|
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
|
@property
|
||||||
def report_insurance_surveyor(self):
|
def report_insurance_surveyor(self):
|
||||||
if self.controller:
|
if self.controller:
|
||||||
|
|||||||
Reference in New Issue
Block a user