CN/DN
This commit is contained in:
@@ -3981,7 +3981,7 @@
|
||||
<text:p text:style-name="P32" loext:marker-style-name="T3"><text:span text:style-name="T4">Net Landed Weight</text:span><text:span text:style-name="T4"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P33" loext:marker-style-name="T3"><text:span text:style-name="T4"><text:placeholder text:placeholder-type="text"><invoice.report_net_display></text:placeholder></text:span><text:span text:style-name="T4"/></text:p>
|
||||
<text:p text:style-name="P33" loext:marker-style-name="T3"><text:span text:style-name="T4"><text:placeholder text:placeholder-type="text"><invoice.report_gross_display></text:placeholder></text:span><text:span text:style-name="T4"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P34" loext:marker-style-name="T3"><text:span text:style-name="T4"><text:placeholder text:placeholder-type="text"><invoice.report_weight_unit_upper></text:placeholder></text:span><text:span text:style-name="T4"/></text:p>
|
||||
@@ -3992,7 +3992,7 @@
|
||||
<text:p text:style-name="P32" loext:marker-style-name="T3"><text:span text:style-name="T4">or</text:span><text:span text:style-name="T4"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P33" loext:marker-style-name="T3"><text:span text:style-name="T4"><text:placeholder text:placeholder-type="text"><invoice.report_lbs_display></text:placeholder></text:span><text:span text:style-name="T4"/></text:p>
|
||||
<text:p text:style-name="P33" loext:marker-style-name="T3"><text:span text:style-name="T4"><text:placeholder text:placeholder-type="text"><invoice.report_gross_lbs_display></text:placeholder></text:span><text:span text:style-name="T4"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P34" loext:marker-style-name="T3"><text:span text:style-name="T4">LBS</text:span><text:span text:style-name="T4"/></text:p>
|
||||
@@ -4011,10 +4011,10 @@
|
||||
</table:table-row>
|
||||
<table:table-row table:style-name="Tableau3.1">
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P32" loext:marker-style-name="T3"><text:span text:style-name="T4">Gain in Weight</text:span><text:span text:style-name="T4"/></text:p>
|
||||
<text:p text:style-name="P32" loext:marker-style-name="T3"><text:span text:style-name="T4">Difference in Weight</text:span><text:span text:style-name="T4"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P33" loext:marker-style-name="T3"><text:span text:style-name="T4"></text:span><text:span text:style-name="T4"/></text:p>
|
||||
<text:p text:style-name="P33" loext:marker-style-name="T3"><text:span text:style-name="T4"><text:placeholder text:placeholder-type="text"><invoice.report_weight_difference_display></text:placeholder></text:span><text:span text:style-name="T4"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P34" loext:marker-style-name="T3"><text:span text:style-name="T4"><text:placeholder text:placeholder-type="text"><invoice.report_weight_unit_upper></text:placeholder></text:span><text:span text:style-name="T4"/></text:p>
|
||||
@@ -4025,7 +4025,7 @@
|
||||
<text:p text:style-name="P32" loext:marker-style-name="T3"><text:span text:style-name="T4">or</text:span><text:span text:style-name="T4"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P33" loext:marker-style-name="T3"><text:span text:style-name="T4"></text:span><text:span text:style-name="T4"/></text:p>
|
||||
<text:p text:style-name="P33" loext:marker-style-name="T3"><text:span text:style-name="T4"><text:placeholder text:placeholder-type="text"><invoice.report_weight_difference_lbs_display></text:placeholder></text:span><text:span text:style-name="T4"/></text:p>
|
||||
</table:table-cell>
|
||||
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
|
||||
<text:p text:style-name="P34" loext:marker-style-name="T3"><text:span text:style-name="T4">LBS</text:span><text:span text:style-name="T4"/></text:p>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from decimal import Decimal, ROUND_HALF_UP
|
||||
from datetime import date as dt_date
|
||||
import os
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from sql import Literal
|
||||
@@ -20,8 +19,6 @@ from trytond.modules.sale.sale import SaleReport as BaseSaleReport
|
||||
from trytond.modules.purchase.purchase import (
|
||||
PurchaseReport as BasePurchaseReport)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class InvoiceLineLotWeight(ModelSQL, ModelView):
|
||||
"Invoice Line Lot Weight"
|
||||
@@ -929,34 +926,13 @@ class Invoice(metaclass=PoolMeta):
|
||||
def _get_report_weight_adjustment_totals(self):
|
||||
reused_lots = self._get_report_reused_lot_lines()
|
||||
if not reused_lots:
|
||||
logger.warning(
|
||||
"REPORT_WEIGHT_ADJUSTMENT_NO_REUSED_LOTS: invoice=%s "
|
||||
"line_count=%s lines=%s",
|
||||
getattr(self, 'id', None),
|
||||
len(self._get_report_invoice_lines()),
|
||||
[
|
||||
{
|
||||
'line': getattr(line, 'id', None),
|
||||
'quantity': str(getattr(line, 'quantity', None)),
|
||||
'lot': getattr(getattr(line, 'lot', None), 'id', None),
|
||||
'lot_keys': self._get_report_line_lot_keys(line),
|
||||
}
|
||||
for line in self._get_report_invoice_lines()
|
||||
])
|
||||
return None
|
||||
|
||||
invoice_total = Decimal(0)
|
||||
landed_total = Decimal(0)
|
||||
matched = False
|
||||
for data in reused_lots.values():
|
||||
lot = data['lot']
|
||||
lines = data['lines']
|
||||
logger.warning(
|
||||
"REPORT_WEIGHT_ADJUSTMENT_GROUP: invoice=%s lot=%s "
|
||||
"line_ids=%s quantities=%s",
|
||||
getattr(self, 'id', None), getattr(lot, 'id', None),
|
||||
[getattr(line, 'id', None) for line in lines],
|
||||
[str(getattr(line, 'quantity', None)) for line in lines])
|
||||
negative_lines = [
|
||||
line for line in lines
|
||||
if Decimal(str(getattr(line, 'quantity', 0) or 0)) < 0
|
||||
@@ -966,14 +942,6 @@ class Invoice(metaclass=PoolMeta):
|
||||
if Decimal(str(getattr(line, 'quantity', 0) or 0)) > 0
|
||||
]
|
||||
if not negative_lines or not positive_lines:
|
||||
logger.warning(
|
||||
"REPORT_WEIGHT_ADJUSTMENT_SKIP_GROUP: invoice=%s lot=%s "
|
||||
"negative=%s positive=%s",
|
||||
getattr(self, 'id', None), getattr(lot, 'id', None),
|
||||
[str(getattr(line, 'quantity', None))
|
||||
for line in negative_lines],
|
||||
[str(getattr(line, 'quantity', None))
|
||||
for line in positive_lines])
|
||||
continue
|
||||
|
||||
invoice_values = [
|
||||
@@ -982,31 +950,12 @@ class Invoice(metaclass=PoolMeta):
|
||||
landed_values = [
|
||||
abs(self._get_report_invoice_line_quantity_from_line(line))
|
||||
for line in positive_lines]
|
||||
logger.warning(
|
||||
"REPORT_WEIGHT_ADJUSTMENT_VALUES: invoice=%s lot=%s "
|
||||
"negative_raw=%s invoice_values=%s positive_raw=%s "
|
||||
"landed_values=%s",
|
||||
getattr(self, 'id', None), getattr(lot, 'id', None),
|
||||
[str(getattr(line, 'quantity', None))
|
||||
for line in negative_lines],
|
||||
[str(value) for value in invoice_values],
|
||||
[str(getattr(line, 'quantity', None))
|
||||
for line in positive_lines],
|
||||
[str(value) for value in landed_values])
|
||||
invoice_total += sum(invoice_values)
|
||||
landed_total += sum(landed_values)
|
||||
matched = True
|
||||
|
||||
if not matched:
|
||||
logger.warning(
|
||||
"REPORT_WEIGHT_ADJUSTMENT_NO_MATCH: invoice=%s reused_lots=%s",
|
||||
getattr(self, 'id', None), list(reused_lots.keys()))
|
||||
return None
|
||||
logger.warning(
|
||||
"REPORT_WEIGHT_ADJUSTMENT_RESULT: invoice=%s invoice_weight=%s "
|
||||
"landed_weight=%s difference=%s",
|
||||
getattr(self, 'id', None), invoice_total, landed_total,
|
||||
abs(landed_total - invoice_total))
|
||||
return {
|
||||
'invoice': invoice_total,
|
||||
'landed': landed_total,
|
||||
@@ -1828,9 +1777,6 @@ class Invoice(metaclass=PoolMeta):
|
||||
if self.lines:
|
||||
adjustment = self._get_report_weight_adjustment_totals()
|
||||
if adjustment:
|
||||
logger.warning(
|
||||
"REPORT_WEIGHT_ADJUSTMENT_USE_GROSS: invoice=%s value=%s",
|
||||
getattr(self, 'id', None), adjustment['landed'])
|
||||
return adjustment['landed']
|
||||
reused_gross = self._get_report_reused_lot_gross_total()
|
||||
if reused_gross is not None:
|
||||
@@ -1855,9 +1801,6 @@ class Invoice(metaclass=PoolMeta):
|
||||
if self.lines:
|
||||
adjustment = self._get_report_weight_adjustment_totals()
|
||||
if adjustment:
|
||||
logger.warning(
|
||||
"REPORT_WEIGHT_ADJUSTMENT_USE_NET: invoice=%s value=%s",
|
||||
getattr(self, 'id', None), adjustment['invoice'])
|
||||
return adjustment['invoice']
|
||||
return sum(
|
||||
self._get_report_invoice_line_weights(line)[0]
|
||||
@@ -1894,10 +1837,6 @@ class Invoice(metaclass=PoolMeta):
|
||||
def report_weight_difference(self):
|
||||
adjustment = self._get_report_weight_adjustment_totals()
|
||||
if adjustment:
|
||||
logger.warning(
|
||||
"REPORT_WEIGHT_ADJUSTMENT_USE_DIFFERENCE: invoice=%s "
|
||||
"value=%s",
|
||||
getattr(self, 'id', None), adjustment['difference'])
|
||||
return adjustment['difference']
|
||||
gross = self.report_gross
|
||||
net = self.report_net
|
||||
|
||||
Reference in New Issue
Block a user