CN/DN
This commit is contained in:
@@ -3787,10 +3787,10 @@
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5">Net Invoice Weight</text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_net_display></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_commission_invoice_weight_display></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_weight_unit_upper></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_commission_adjustment_unit_upper></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
</table:table-row>
|
||||
</table:table>
|
||||
@@ -3804,10 +3804,10 @@
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5">Net Landed Weight</text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau4.A1" office:value-type="string">
|
||||
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_gross_display></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_commission_landed_weight_display></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau4.A1" office:value-type="string">
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_weight_unit_upper></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_commission_adjustment_unit_upper></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
</table:table-row>
|
||||
<table:table-row table:style-name="Tableau4.1">
|
||||
@@ -3815,7 +3815,7 @@
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5">or</text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau4.A1" office:value-type="string">
|
||||
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_gross_lbs_display></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_commission_landed_lbs_display></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau4.A1" office:value-type="string">
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5">LBS</text:span><text:span text:style-name="T5"/></text:p>
|
||||
@@ -3832,10 +3832,10 @@
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5">Difference in Weight</text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau5.A1" office:value-type="string">
|
||||
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_weight_difference_display></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_commission_weight_difference_display></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau5.A1" office:value-type="string">
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5">KG</text:span><text:span text:style-name="T5"/></text:p>
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_commission_adjustment_unit_upper></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
</table:table-row>
|
||||
<table:table-row table:style-name="Tableau5.1">
|
||||
@@ -3843,7 +3843,7 @@
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5">or</text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau5.A1" office:value-type="string">
|
||||
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_weight_difference_lbs_display></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
<text:p text:style-name="P16" loext:marker-style-name="T11"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><invoice.report_commission_weight_difference_lbs_display></text:placeholder></text:span><text:span text:style-name="T5"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau5.A1" office:value-type="string">
|
||||
<text:p text:style-name="P14" loext:marker-style-name="T11"><text:span text:style-name="T5">LBS</text:span><text:span text:style-name="T5"/></text:p>
|
||||
@@ -3883,4 +3883,4 @@
|
||||
<text:p text:style-name="P18"/>
|
||||
</office:text>
|
||||
</office:body>
|
||||
</office:document>
|
||||
</office:document>
|
||||
|
||||
@@ -392,6 +392,146 @@ class Invoice(metaclass=PoolMeta):
|
||||
if trade:
|
||||
return trade
|
||||
|
||||
def _get_report_commission_kind(self):
|
||||
fee = self._get_report_commission_fee()
|
||||
if fee:
|
||||
if getattr(fee, 'sale_line', None):
|
||||
return 'sale'
|
||||
if getattr(fee, 'line', None):
|
||||
return 'purchase'
|
||||
for lot in self._get_report_commission_lots():
|
||||
if getattr(lot, 'sale_line', None):
|
||||
return 'sale'
|
||||
if getattr(lot, 'line', None):
|
||||
return 'purchase'
|
||||
|
||||
def _get_report_commission_adjustment_unit(self):
|
||||
fee = self._get_report_commission_fee()
|
||||
if fee:
|
||||
unit = (
|
||||
getattr(fee, 'linked_unit', None)
|
||||
if getattr(fee, 'enable_linked_currency', False) else None)
|
||||
if unit:
|
||||
return unit
|
||||
if getattr(fee, 'unit', None):
|
||||
return fee.unit
|
||||
lots = self._get_report_commission_lots()
|
||||
if lots:
|
||||
lot = lots[0]
|
||||
return (
|
||||
getattr(lot, 'lot_unit_line', None)
|
||||
or getattr(lot, 'lot_unit', None))
|
||||
line = self._get_report_invoice_line()
|
||||
return getattr(line, 'unit', None) if line else None
|
||||
|
||||
def _get_report_commission_provisional_line(self, lot, kind):
|
||||
if kind == 'sale':
|
||||
return getattr(lot, 'sale_invoice_line_prov', None)
|
||||
return getattr(lot, 'invoice_line_prov', None)
|
||||
|
||||
def _get_report_commission_lot_current_quantity(self, lot, unit):
|
||||
if hasattr(lot, 'get_current_quantity_converted'):
|
||||
try:
|
||||
return Decimal(str(
|
||||
lot.get_current_quantity_converted(0, unit) or 0))
|
||||
except TypeError:
|
||||
return Decimal(str(
|
||||
lot.get_current_quantity_converted() or 0))
|
||||
net, _ = self._get_report_lot_hist_weights(lot)
|
||||
if net is None:
|
||||
return Decimal(0)
|
||||
return self._convert_report_quantity(
|
||||
net, getattr(lot, 'lot_unit_line', None), unit)
|
||||
|
||||
def _get_report_commission_lot_provisional_quantity(self, lot, kind, unit):
|
||||
line = self._get_report_commission_provisional_line(lot, kind)
|
||||
if not line:
|
||||
return None
|
||||
quantity = Decimal(str(getattr(line, 'quantity', 0) or 0))
|
||||
if kind == 'sale':
|
||||
quantity -= Decimal(str(
|
||||
getattr(lot, 'sale_invoice_padding', 0) or 0))
|
||||
return self._convert_report_quantity(
|
||||
quantity, getattr(line, 'unit', None), unit)
|
||||
|
||||
def _get_report_commission_adjustment_totals(self):
|
||||
kind = self._get_report_commission_kind()
|
||||
unit = self._get_report_commission_adjustment_unit()
|
||||
if not kind or not unit:
|
||||
return None
|
||||
invoice_total = Decimal(0)
|
||||
landed_total = Decimal(0)
|
||||
matched = False
|
||||
for lot in self._get_report_commission_lots():
|
||||
provisional_quantity = (
|
||||
self._get_report_commission_lot_provisional_quantity(
|
||||
lot, kind, unit))
|
||||
if provisional_quantity is None:
|
||||
continue
|
||||
invoice_total += abs(provisional_quantity)
|
||||
landed_total += abs(
|
||||
self._get_report_commission_lot_current_quantity(lot, unit))
|
||||
matched = True
|
||||
if not matched:
|
||||
return None
|
||||
return {
|
||||
'invoice': invoice_total,
|
||||
'landed': landed_total,
|
||||
'difference': abs(landed_total - invoice_total),
|
||||
'unit': unit,
|
||||
}
|
||||
|
||||
@property
|
||||
def report_commission_adjustment_unit_upper(self):
|
||||
totals = self._get_report_commission_adjustment_totals()
|
||||
unit = totals['unit'] if totals else self._get_report_commission_adjustment_unit()
|
||||
if unit:
|
||||
return (
|
||||
getattr(unit, 'symbol', None)
|
||||
or getattr(unit, 'rec_name', None)
|
||||
or getattr(unit, 'name', None)
|
||||
or '').upper()
|
||||
return ''
|
||||
|
||||
@property
|
||||
def report_commission_invoice_weight_display(self):
|
||||
totals = self._get_report_commission_adjustment_totals()
|
||||
if not totals:
|
||||
return self.report_net_display
|
||||
return self._format_report_quantity_display(totals['invoice'])
|
||||
|
||||
@property
|
||||
def report_commission_landed_weight_display(self):
|
||||
totals = self._get_report_commission_adjustment_totals()
|
||||
if not totals:
|
||||
return self.report_gross_display
|
||||
return self._format_report_quantity_display(totals['landed'])
|
||||
|
||||
@property
|
||||
def report_commission_landed_lbs_display(self):
|
||||
totals = self._get_report_commission_adjustment_totals()
|
||||
if not totals:
|
||||
return self.report_gross_lbs_display
|
||||
lbs = self._convert_report_quantity_to_lbs(
|
||||
totals['landed'], totals['unit'])
|
||||
return self._format_report_quantity_display(lbs)
|
||||
|
||||
@property
|
||||
def report_commission_weight_difference_display(self):
|
||||
totals = self._get_report_commission_adjustment_totals()
|
||||
if not totals:
|
||||
return self.report_weight_difference_display
|
||||
return self._format_report_quantity_display(totals['difference'])
|
||||
|
||||
@property
|
||||
def report_commission_weight_difference_lbs_display(self):
|
||||
totals = self._get_report_commission_adjustment_totals()
|
||||
if not totals:
|
||||
return self.report_weight_difference_lbs_display
|
||||
lbs = self._convert_report_quantity_to_lbs(
|
||||
totals['difference'], totals['unit'])
|
||||
return self._format_report_quantity_display(lbs)
|
||||
|
||||
@property
|
||||
def report_commission_address(self):
|
||||
trade = self._get_report_commission_trade()
|
||||
|
||||
@@ -5468,6 +5468,36 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(
|
||||
invoice.report_purchase_commission_secondary_rate_line, '')
|
||||
|
||||
def test_commission_cndn_weight_adjustment_uses_fee_lot_weights(self):
|
||||
'commission note adjustment uses provisional and current lot weights'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
unit = SimpleNamespace(id=1, rec_name='MT', symbol='MT')
|
||||
provisional_line = SimpleNamespace(
|
||||
quantity=Decimal('400'), unit=unit)
|
||||
lot = SimpleNamespace(
|
||||
id=1,
|
||||
sale_invoice_line_prov=provisional_line,
|
||||
sale_invoice_padding=Decimal('0'),
|
||||
get_current_quantity_converted=lambda state=0, unit=None: Decimal('397'))
|
||||
fee = SimpleNamespace(
|
||||
enable_linked_currency=False,
|
||||
unit=unit,
|
||||
sale_line=SimpleNamespace(sale=SimpleNamespace()),
|
||||
line=None,
|
||||
lots=[lot],
|
||||
_get_effective_fee_lots=lambda: [lot])
|
||||
invoice = Invoice()
|
||||
invoice.lines = [
|
||||
SimpleNamespace(type='line', fee=fee, quantity=Decimal('1'))]
|
||||
|
||||
self.assertEqual(
|
||||
invoice.report_commission_invoice_weight_display, '400.00')
|
||||
self.assertEqual(
|
||||
invoice.report_commission_landed_weight_display, '397.00')
|
||||
self.assertEqual(
|
||||
invoice.report_commission_weight_difference_display, '3.00')
|
||||
self.assertEqual(invoice.report_commission_adjustment_unit_upper, 'MT')
|
||||
|
||||
def test_fee_delete_detects_generated_ordered_purchase(self):
|
||||
'ordered fee deletion targets only its generated service purchase'
|
||||
Fee = Pool().get('fee.fee')
|
||||
|
||||
Reference in New Issue
Block a user