Commit 680c911c authored by Vincent Pelletier's avatar Vincent Pelletier

Implement getTotalNetPrice.

Activate unit test (was commented out unitl now).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20778 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dd3dc352
...@@ -130,6 +130,16 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -130,6 +130,16 @@ class Delivery(XMLObject, ImmobilisationDelivery):
aggregate = self.Delivery_zGetTotal(**kw)[0] aggregate = self.Delivery_zGetTotal(**kw)[0]
return aggregate.total_price or 0 return aggregate.total_price or 0
security.declareProtected(Permissions.AccessContentsInformation,
'getTotalNetPrice')
def getTotalNetPrice(self, fast=0, src__=0, **kw):
"""
Same as getTotalPrice, but including Tax and Discount.
"""
total_price = self.getTotalPrice(fast=fast, src__=src__, **kw)
kw['portal_type'] = self.getPortalTaxMovementTypeList()
return total_price + self.getTotalPrice(fast=fast, src__=src__, **kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getTotalQuantity') 'getTotalQuantity')
def getTotalQuantity(self, fast=0, src__=0, **kw): def getTotalQuantity(self, fast=0, src__=0, **kw):
......
...@@ -63,23 +63,15 @@ class Invoice(AccountingTransaction): ...@@ -63,23 +63,15 @@ class Invoice(AccountingTransaction):
Permissions.AccessContentsInformation, 'getTotalPrice') Permissions.AccessContentsInformation, 'getTotalPrice')
def getTotalPrice(self, **kw): def getTotalPrice(self, **kw):
""" Returns the total price for this invoice """ """ Returns the total price for this invoice """
kw.update({ kw.setdefault('portal_type',
'portal_type': self.getPortalObject()\ self.getPortalInvoiceMovementTypeList())
.getPortalInvoiceMovementTypeList() })
return Delivery.getTotalPrice(self, **kw) return Delivery.getTotalPrice(self, **kw)
security.declareProtected( security.declareProtected(
Permissions.AccessContentsInformation, 'getTotalQuantity') Permissions.AccessContentsInformation, 'getTotalQuantity')
def getTotalQuantity(self, **kw): def getTotalQuantity(self, **kw):
""" Returns the total quantity for this invoice """ """ Returns the total quantity for this invoice """
kw.update({ kw.setdefault('portal_type',
'portal_type': self.getPortalObject()\ self.getPortalInvoiceMovementTypeList())
.getPortalInvoiceMovementTypeList() })
return Delivery.getTotalQuantity(self, **kw) return Delivery.getTotalQuantity(self, **kw)
security.declareProtected(
Permissions.AccessContentsInformation, 'getTotalNetPrice')
def getTotalNetPrice(self):
""" Returns the total net price for this invoice """
raise NotImplementedError
return self.Invoice_zGetTotalNetPrice()
...@@ -719,8 +719,8 @@ class TestTaxLineCalculation(TradeConditionTestCase): ...@@ -719,8 +719,8 @@ class TestTaxLineCalculation(TradeConditionTestCase):
self.assertEquals(self.tax, tax_line.getResourceValue()) self.assertEquals(self.tax, tax_line.getResourceValue())
self.assertEquals(0.2, tax_line.getPrice()) self.assertEquals(0.2, tax_line.getPrice())
# TODO: discuss this behaviour, and what about getTotalNetPrice ? self.assertEquals(100, self.order.getTotalPrice(fast=0))
#self.assertEquals(120, self.order.getTotalPrice(fast=0)) self.assertEquals(120, self.order.getTotalNetPrice(fast=0))
def test_hierarchical_order_line_and_tax_line(self): def test_hierarchical_order_line_and_tax_line(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment