Delta neg
This commit is contained in:
@@ -482,17 +482,24 @@ class Fee(ModelSQL,ModelView):
|
||||
if quantity is None:
|
||||
quantity = self.get_quantity()
|
||||
return Decimal(quantity or 0)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _unsigned_amount(amount):
|
||||
if amount is None:
|
||||
return None
|
||||
return abs(Decimal(amount))
|
||||
|
||||
def get_amount(self,name=None):
|
||||
sign = Decimal(1)
|
||||
if self.price:
|
||||
# if self.p_r:
|
||||
# if self.p_r == 'pay':
|
||||
# sign = -1
|
||||
if self.mode == 'lumpsum':
|
||||
return self.price * sign
|
||||
elif self.mode == 'ppack':
|
||||
return round(self.price * self.quantity,2)
|
||||
# if self.p_r == 'pay':
|
||||
# sign = -1
|
||||
if self.mode == 'lumpsum':
|
||||
return self._unsigned_amount(self.price * sign)
|
||||
elif self.mode == 'ppack':
|
||||
return self._unsigned_amount(
|
||||
round(self.price * self.quantity,2))
|
||||
elif self.mode == 'rate':
|
||||
if self.line:
|
||||
if self.line.estimated_date:
|
||||
@@ -503,7 +510,9 @@ class Fee(ModelSQL,ModelView):
|
||||
Decimal(self.price) / Decimal(100)
|
||||
* Decimal(est_line.fin_int_delta) / Decimal(360)
|
||||
)
|
||||
return round(factor * self.line.unit_price * self._get_amount_quantity() * sign,2)
|
||||
return self._unsigned_amount(round(
|
||||
factor * self.line.unit_price
|
||||
* self._get_amount_quantity() * sign,2))
|
||||
if self.sale_line:
|
||||
if self.sale_line.estimated_date:
|
||||
est_lines = [
|
||||
@@ -516,38 +525,38 @@ class Fee(ModelSQL,ModelView):
|
||||
Decimal(self.price) / Decimal(100)
|
||||
* Decimal(est_line.fin_int_delta) / Decimal(360)
|
||||
)
|
||||
return round(
|
||||
return self._unsigned_amount(round(
|
||||
factor * self.sale_line.unit_price
|
||||
* self._get_amount_quantity() * sign, 2)
|
||||
|
||||
elif self.mode == 'perqt':
|
||||
if self.shipment_in:
|
||||
StockMove = Pool().get('stock.move')
|
||||
sm = StockMove.search(['shipment','=','stock.shipment.in,'+str(self.shipment_in.id)])
|
||||
if sm:
|
||||
unique_lots = {e.lot for e in sm if e.lot}
|
||||
return round(self.price * Decimal(sum([e.get_current_quantity_converted(0,self.unit) for e in unique_lots])) * sign,2)
|
||||
LotQt = Pool().get('lot.qt')
|
||||
lqts = LotQt.search(['lot_shipment_in','=',self.shipment_in.id])
|
||||
if lqts:
|
||||
return round(self.price * Decimal(lqts[0].lot_quantity) * sign,2)
|
||||
|
||||
return round((self.quantity if self.quantity else 0) * self.price * sign,2)
|
||||
elif self.mode == 'pprice':
|
||||
if self.line:
|
||||
return round(self.price / 100 * self.line.unit_price * (self.quantity if self.quantity else 0) * sign,2)
|
||||
if self.sale_line:
|
||||
return round(self.price / 100 * self.sale_line.unit_price * (self.quantity if self.quantity else 0) * sign,2)
|
||||
if self.shipment_in:
|
||||
StockMove = Pool().get('stock.move')
|
||||
sm = StockMove.search(['shipment','=','stock.shipment.in,'+str(self.shipment_in.id)])
|
||||
if sm:
|
||||
if sm[0].lot:
|
||||
return round(self.price * Decimal(sum([e.lot.get_lot_price() for e in sm if e.lot])) / 100 * self.quantity * sign,2)
|
||||
LotQt = Pool().get('lot.qt')
|
||||
lqts = LotQt.search(['lot_shipment_in','=',self.shipment_in.id])
|
||||
if lqts:
|
||||
return round(self.price * Decimal(lqts[0].lot_p.get_lot_price()) / 100 * lqts[0].lot_quantity * sign,2)
|
||||
* self._get_amount_quantity() * sign, 2))
|
||||
|
||||
elif self.mode == 'perqt':
|
||||
if self.shipment_in:
|
||||
StockMove = Pool().get('stock.move')
|
||||
sm = StockMove.search(['shipment','=','stock.shipment.in,'+str(self.shipment_in.id)])
|
||||
if sm:
|
||||
unique_lots = {e.lot for e in sm if e.lot}
|
||||
return self._unsigned_amount(round(self.price * Decimal(sum([e.get_current_quantity_converted(0,self.unit) for e in unique_lots])) * sign,2))
|
||||
LotQt = Pool().get('lot.qt')
|
||||
lqts = LotQt.search(['lot_shipment_in','=',self.shipment_in.id])
|
||||
if lqts:
|
||||
return self._unsigned_amount(round(self.price * Decimal(lqts[0].lot_quantity) * sign,2))
|
||||
|
||||
return self._unsigned_amount(round((self.quantity if self.quantity else 0) * self.price * sign,2))
|
||||
elif self.mode == 'pprice':
|
||||
if self.line:
|
||||
return self._unsigned_amount(round(self.price / 100 * self.line.unit_price * (self.quantity if self.quantity else 0) * sign,2))
|
||||
if self.sale_line:
|
||||
return self._unsigned_amount(round(self.price / 100 * self.sale_line.unit_price * (self.quantity if self.quantity else 0) * sign,2))
|
||||
if self.shipment_in:
|
||||
StockMove = Pool().get('stock.move')
|
||||
sm = StockMove.search(['shipment','=','stock.shipment.in,'+str(self.shipment_in.id)])
|
||||
if sm:
|
||||
if sm[0].lot:
|
||||
return self._unsigned_amount(round(self.price * Decimal(sum([e.lot.get_lot_price() for e in sm if e.lot])) / 100 * self.quantity * sign,2))
|
||||
LotQt = Pool().get('lot.qt')
|
||||
lqts = LotQt.search(['lot_shipment_in','=',self.shipment_in.id])
|
||||
if lqts:
|
||||
return self._unsigned_amount(round(self.price * Decimal(lqts[0].lot_p.get_lot_price()) / 100 * lqts[0].lot_quantity * sign,2))
|
||||
|
||||
@classmethod
|
||||
def copy(cls, fees, default=None):
|
||||
|
||||
Reference in New Issue
Block a user