[Erp5-report] r27694 - in /erp5/trunk/products/ERP5: Document/ PropertySheet/ bootstrap/erp...
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Jun 19 18:40:14 CEST 2009
Author: jerome
Date: Fri Jun 19 18:40:14 2009
New Revision: 27694
URL: http://svn.erp5.org?rev=27694&view=rev
Log:
more support for isCancellationAmount:
- setSourceDebit(-1) will set cancellation amount
- inventory API treat a movement of quantity -1 as an input movement if
cancellation amount is set
- s/getSource/DestinationTotalAssetDebit/Credit also support cancellation amount like
s/getSource/DestinationDebit/Credit
Modified:
erp5/trunk/products/ERP5/Document/Movement.py
erp5/trunk/products/ERP5/PropertySheet/Amount.py
erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventory.xml
erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_catalog_stock_list.xml
erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_create_stock.xml
erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/revision
erp5/trunk/products/ERP5/tests/testAccounting.py
erp5/trunk/products/ERP5/tests/testAmount.py
erp5/trunk/products/ERP5/tests/testInventoryAPI.py
Modified: erp5/trunk/products/ERP5/Document/Movement.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Movement.py?rev=27694&r1=27693&r2=27694&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Movement.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Movement.py [utf8] Fri Jun 19 18:40:14 2009
@@ -372,7 +372,9 @@
"""
result = self.getSourceInventoriatedTotalAssetPrice()
if result is not None :
- if result > 0:
+ if result > 0 and not self.isCancellationAmount():
+ return result
+ if result < 0 and self.isCancellationAmount():
return result
return 0.0
@@ -384,7 +386,9 @@
"""
result = self.getSourceInventoriatedTotalAssetPrice()
if result is not None :
- if result < 0:
+ if result < 0 and not self.isCancellationAmount():
+ return -result
+ if result > 0 and self.isCancellationAmount():
return -result
return 0.0
@@ -416,7 +420,9 @@
"""
result = self.getDestinationInventoriatedTotalAssetPrice()
if result is not None :
- if result > 0:
+ if result > 0 and not self.isCancellationAmount():
+ return result
+ if result < 0 and self.isCancellationAmount():
return result
return 0.0
@@ -428,7 +434,9 @@
"""
result = self.getDestinationInventoriatedTotalAssetPrice()
if result is not None :
- if result < 0:
+ if result < 0 and not self.isCancellationAmount():
+ return -result
+ if result > 0 and self.isCancellationAmount():
return -result
return 0.0
@@ -762,8 +770,7 @@
return - quantity
elif quantity > 0 and self.isCancellationAmount():
return - quantity
- else:
- return 0.0
+ return 0.0
security.declareProtected( Permissions.AccessContentsInformation,
'getSourceCredit')
@@ -779,8 +786,7 @@
if quantity < 0 and not self.isCancellationAmount() \
or quantity > 0 and self.isCancellationAmount():
return 0.0
- else:
- return quantity
+ return quantity
security.declareProtected( Permissions.AccessContentsInformation,
'getDestinationDebit', 'getDestinationCredit')
@@ -798,6 +804,7 @@
source_debit = float(source_debit)
except TypeError:
source_debit = 0.0
+ self.setCancellationAmount(source_debit < 0)
self.setQuantity(- source_debit)
security.declareProtected(Permissions.ModifyPortalContent, 'setSourceCredit')
@@ -811,6 +818,7 @@
source_credit = float(source_credit)
except TypeError:
source_credit = 0.0
+ self.setCancellationAmount(source_credit < 0)
self.setQuantity(source_credit)
security.declareProtected( Permissions.ModifyPortalContent,
@@ -827,13 +835,17 @@
"""
quantity = 0
if kw.has_key('source_debit') and kw.has_key('source_credit'):
- quantity += ((kw.pop('source_credit') or 0) -
- (kw.pop('source_debit') or 0))
+ source_credit = kw.pop('source_credit') or 0
+ source_debit = kw.pop('source_debit') or 0
+ quantity += (source_credit - source_debit)
kw['quantity'] = quantity
+ kw['cancellation_amount'] = (source_credit < 0 or source_debit < 0)
if kw.has_key('destination_debit') and kw.has_key('destination_credit'):
- quantity += (kw.pop('destination_debit') or 0 -
- kw.pop('destination_credit') or 0)
+ destination_credit = kw.pop('destination_credit') or 0
+ destination_debit = kw.pop('destination_debit') or 0
+ quantity += (destination_debit - destination_credit)
kw['quantity'] = quantity
+ kw['cancellation_amount'] = (destination_credit < 0 or destination_debit < 0)
if not edit_order:
edit_order = ('variation_category_list', )
return XMLObject._edit(self, edit_order=edit_order, **kw)
@@ -854,10 +866,10 @@
quantity = float(quantity)
except TypeError:
quantity = 0.0
- if quantity < 0:
+ if quantity < 0 and not self.isCancellationAmount() \
+ or quantity > 0 and self.isCancellationAmount():
return 0.0
- else:
- return quantity
+ return quantity
security.declareProtected( Permissions.AccessContentsInformation,
'getSourceAssetCredit' )
@@ -874,10 +886,11 @@
quantity = float(quantity)
except TypeError:
quantity = 0.0
- if quantity < 0:
+ if (quantity < 0 and not self.isCancellationAmount()):
return - quantity
- else:
- return 0.0
+ elif quantity > 0 and self.isCancellationAmount():
+ return - quantity
+ return 0.0
security.declareProtected( Permissions.AccessContentsInformation,
'getDestinationAssetDebit' )
@@ -894,10 +907,10 @@
quantity = float(quantity)
except TypeError:
quantity = 0.0
- if quantity < 0:
+ if quantity < 0 and not self.isCancellationAmount() \
+ or quantity > 0 and self.isCancellationAmount():
return 0.0
- else:
- return quantity
+ return quantity
security.declareProtected( Permissions.AccessContentsInformation,
'getDestinationAssetCredit' )
@@ -914,10 +927,11 @@
quantity = float(quantity)
except TypeError:
quantity = 0.0
- if quantity < 0:
- return -quantity
- else:
- return 0.0
+ if (quantity < 0 and not self.isCancellationAmount()):
+ return - quantity
+ elif quantity > 0 and self.isCancellationAmount():
+ return - quantity
+ return 0.0
security.declareProtected( Permissions.ModifyPortalContent,
'setSourceAssetDebit' )
@@ -932,6 +946,7 @@
source_debit = float(source_debit)
except TypeError:
source_debit = 0.0
+ self.setCancellationAmount(source_debit < 0)
self.setSourceTotalAssetPrice(source_debit)
security.declareProtected( Permissions.ModifyPortalContent,
@@ -947,6 +962,7 @@
source_credit = float(source_credit)
except TypeError:
source_credit = 0.0
+ self.setCancellationAmount(source_credit < 0)
self.setSourceTotalAssetPrice( - source_credit)
security.declareProtected( Permissions.ModifyPortalContent,
@@ -962,6 +978,7 @@
destination_debit = float(destination_debit)
except TypeError:
destination_debit = 0.0
+ self.setCancellationAmount(destination_debit < 0)
self.setDestinationTotalAssetPrice(destination_debit)
security.declareProtected( Permissions.ModifyPortalContent,
@@ -977,6 +994,7 @@
destination_credit = float(destination_credit)
except TypeError:
destination_credit = 0.0
+ self.setCancellationAmount(destination_credit < 0)
self.setDestinationTotalAssetPrice( - destination_credit)
# Item Access (tracking)
Modified: erp5/trunk/products/ERP5/PropertySheet/Amount.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/PropertySheet/Amount.py?rev=27694&r1=27693&r2=27694&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/PropertySheet/Amount.py [utf8] (original)
+++ erp5/trunk/products/ERP5/PropertySheet/Amount.py [utf8] Fri Jun 19 18:40:14 2009
@@ -95,6 +95,7 @@
{ 'id' : 'cancellation_amount',
'description' : 'defines if this quantity is used in order to cancel another one',
'type' : 'boolean',
+ 'default': False,
'mode' : 'w' },
# quantity_sign is used by QuantitySignMovementGroup
# When comparing a delivery to a property_dict coming from a MovementGroup,
Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventory.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventory.xml?rev=27694&r1=27693&r2=27694&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventory.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventory.xml [utf8] Fri Jun 19 18:40:14 2009
@@ -270,7 +270,8 @@
</dtml-if>\n
\n
<dtml-if omit_input>\n
- AND stock.quantity < 0\n
+ AND ( ( stock.is_cancellation AND stock.quantity > 0 )\n
+ OR ( not stock.is_cancellation AND stock.quantity < 0 ))\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
OR stock.section_uid <> stock.mirror_section_uid\n
OR stock.mirror_node_uid IS NULL\n
@@ -278,7 +279,8 @@
OR stock.payment_uid IS NOT NULL )\n
</dtml-if>\n
<dtml-if omit_output>\n
- AND stock.quantity > 0\n
+ AND ( ( stock.is_cancellation AND stock.quantity < 0 )\n
+ OR ( not stock.is_cancellation AND stock.quantity > 0 ))\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
OR stock.section_uid <> stock.mirror_section_uid\n
OR stock.mirror_node_uid IS NULL\n
@@ -410,7 +412,8 @@
</dtml-if>\n
\n
<dtml-if omit_input>\n
- AND stock.quantity < 0\n
+ AND ( ( stock.is_cancellation AND stock.quantity > 0 )\n
+ OR ( not stock.is_cancellation AND stock.quantity < 0 ))\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
OR stock.section_uid <> stock.mirror_section_uid\n
OR stock.mirror_node_uid IS NULL\n
@@ -418,7 +421,8 @@
OR stock.payment_uid IS NOT NULL )\n
</dtml-if>\n
<dtml-if omit_output>\n
- AND stock.quantity > 0\n
+ AND ( ( stock.is_cancellation AND stock.quantity < 0 )\n
+ OR ( not stock.is_cancellation AND stock.quantity > 0 ))\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
OR stock.section_uid <> stock.mirror_section_uid\n
OR stock.mirror_node_uid IS NULL\n
Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml?rev=27694&r1=27693&r2=27694&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetMovementHistoryList.xml [utf8] Fri Jun 19 18:40:14 2009
@@ -700,7 +700,8 @@
</dtml-if>\n
\n
<dtml-if omit_input>\n
- AND stock.quantity < 0\n
+ AND ( ( stock.is_cancellation AND stock.quantity > 0 )\n
+ OR ( not stock.is_cancellation AND stock.quantity < 0 ))\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
OR stock.section_uid <> stock.mirror_section_uid\n
OR stock.mirror_node_uid IS NULL\n
@@ -708,7 +709,8 @@
OR stock.payment_uid IS NOT NULL )\n
</dtml-if>\n
<dtml-if omit_output>\n
- AND stock.quantity > 0\n
+ AND ( ( stock.is_cancellation AND stock.quantity < 0 )\n
+ OR ( not stock.is_cancellation AND stock.quantity > 0 ))\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
OR stock.section_uid <> stock.mirror_section_uid\n
OR stock.mirror_node_uid IS NULL\n
@@ -858,7 +860,8 @@
</dtml-if>\n
\n
<dtml-if omit_input>\n
- AND stock.quantity < 0\n
+ AND ( ( stock.is_cancellation AND stock.quantity > 0 )\n
+ OR ( not stock.is_cancellation AND stock.quantity < 0 ))\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
OR stock.section_uid <> stock.mirror_section_uid\n
OR stock.mirror_node_uid IS NULL\n
@@ -866,7 +869,8 @@
OR stock.payment_uid IS NOT NULL )\n
</dtml-if>\n
<dtml-if omit_output>\n
- AND stock.quantity > 0\n
+ AND ( ( stock.is_cancellation AND stock.quantity < 0 )\n
+ OR ( not stock.is_cancellation AND stock.quantity > 0 ))\n
AND ( stock.node_uid <> stock.mirror_node_uid\n
OR stock.section_uid <> stock.mirror_section_uid\n
OR stock.mirror_node_uid IS NULL\n
Modified: erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_catalog_stock_list.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_catalog_stock_list.xml?rev=27694&r1=27693&r2=27694&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_catalog_stock_list.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_catalog_stock_list.xml [utf8] Fri Jun 19 18:40:14 2009
@@ -157,6 +157,12 @@
</item>
<item>
<key> <string>isMovement</string> </key>
+ <value>
+ <dictionary/>
+ </value>
+ </item>
+ <item>
+ <key> <string>isCancellationAmount</string> </key>
<value>
<dictionary/>
</value>
@@ -182,6 +188,7 @@
<string>getSourceSectionUid</string>
<string>getDestinationSectionUid</string>
<string>isMovement</string>
+ <string>isCancellationAmount</string>
<string>isInventoryMovement</string>
<string>getSourcePaymentUid</string>
<string>getDestinationPaymentUid</string>
@@ -222,6 +229,7 @@
getSourceSectionUid\r\n
getDestinationSectionUid\r\n
isMovement\r\n
+isCancellationAmount\r\n
isInventoryMovement\r\n
getSourcePaymentUid\r\n
getDestinationPaymentUid\r\n
@@ -304,6 +312,7 @@
getSourceUid[loop_item], \n
getResourceUid[loop_item],\n
getInventoriatedQuantity[loop_item],\n
+ isCancellationAmount[loop_item],\n
getStopDate[loop_item], \n
getStartDate[loop_item], \n
getDestinationInventoriatedTotalAssetPrice[loop_item], \n
@@ -326,6 +335,7 @@
getDestinationUid[loop_item], \n
getResourceUid[loop_item],\n
-(getInventoriatedQuantity[loop_item] or 0), \n
+ isCancellationAmount[loop_item],\n
getStartDate[loop_item], \n
getStopDate[loop_item],\n
getSourceInventoriatedTotalAssetPrice[loop_item], \n
@@ -354,13 +364,14 @@
<dtml-sqlvar expr="row_item[8]" type="int" optional>,\n
<dtml-sqlvar expr="row_item[9]" type="int">, \n
<dtml-sqlvar expr="row_item[10]" type="float" optional>,\n
- <dtml-sqlvar expr="row_item[11]" type="datetime" optional>,\n
+ <dtml-sqlvar expr="row_item[11]" type="int">, \n
<dtml-sqlvar expr="row_item[12]" type="datetime" optional>,\n
- <dtml-sqlvar expr="row_item[13]" type="float" optional>,\n
- <dtml-sqlvar expr="row_item[14]" type="string" optional>,\n
+ <dtml-sqlvar expr="row_item[13]" type="datetime" optional>,\n
+ <dtml-sqlvar expr="row_item[14]" type="float" optional>,\n
<dtml-sqlvar expr="row_item[15]" type="string" optional>,\n
<dtml-sqlvar expr="row_item[16]" type="string" optional>,\n
- <dtml-sqlvar expr="row_item[17]" type="string" optional>\n
+ <dtml-sqlvar expr="row_item[17]" type="string" optional>,\n
+ <dtml-sqlvar expr="row_item[18]" type="string" optional>\n
)\n
<dtml-if sequence-end><dtml-else>,</dtml-if>\n
</dtml-in>\n
@@ -433,6 +444,7 @@
getSourceUid[loop_item], \n
getResourceUid[loop_item],\n
getInventoriatedQuantity[loop_item],\n
+ isCancellationAmount[loop_item],\n
getStopDate[loop_item], \n
getStartDate[loop_item], \n
getDestinationInventoriatedTotalAssetPrice[loop_item], \n
@@ -455,6 +467,7 @@
getDestinationUid[loop_item], \n
getResourceUid[loop_item],\n
-(getInventoriatedQuantity[loop_item] or 0), \n
+ isCancellationAmount[loop_item],\n
getStartDate[loop_item], \n
getStopDate[loop_item],\n
getSourceInventoriatedTotalAssetPrice[loop_item], \n
@@ -483,13 +496,14 @@
<dtml-sqlvar expr="row_item[8]" type="int" optional>,\n
<dtml-sqlvar expr="row_item[9]" type="int">, \n
<dtml-sqlvar expr="row_item[10]" type="float" optional>,\n
- <dtml-sqlvar expr="row_item[11]" type="datetime" optional>,\n
+ <dtml-sqlvar expr="row_item[11]" type="int">, \n
<dtml-sqlvar expr="row_item[12]" type="datetime" optional>,\n
- <dtml-sqlvar expr="row_item[13]" type="float" optional>,\n
- <dtml-sqlvar expr="row_item[14]" type="string" optional>,\n
+ <dtml-sqlvar expr="row_item[13]" type="datetime" optional>,\n
+ <dtml-sqlvar expr="row_item[14]" type="float" optional>,\n
<dtml-sqlvar expr="row_item[15]" type="string" optional>,\n
<dtml-sqlvar expr="row_item[16]" type="string" optional>,\n
- <dtml-sqlvar expr="row_item[17]" type="string" optional>\n
+ <dtml-sqlvar expr="row_item[17]" type="string" optional>,\n
+ <dtml-sqlvar expr="row_item[18]" type="string" optional>\n
)\n
<dtml-if sequence-end><dtml-else>,</dtml-if>\n
</dtml-in>\n
Modified: erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_create_stock.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_create_stock.xml?rev=27694&r1=27693&r2=27694&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_create_stock.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_create_stock.xml [utf8] Fri Jun 19 18:40:14 2009
@@ -97,7 +97,8 @@
`mirror_section_uid` BIGINT UNSIGNED,\n
`mirror_node_uid` BIGINT UNSIGNED,\n
`resource_uid` BIGINT UNSIGNED,\n
- `quantity` real ,\n
+ `quantity` real,\n
+ `is_cancellation` BOOLEAN,\n
`date` datetime,\n
`mirror_date` datetime,\n
`total_price` real ,\n
@@ -171,7 +172,8 @@
`mirror_section_uid` BIGINT UNSIGNED,\n
`mirror_node_uid` BIGINT UNSIGNED,\n
`resource_uid` BIGINT UNSIGNED,\n
- `quantity` real ,\n
+ `quantity` real,\n
+ `is_cancellation` BOOLEAN,\n
`date` datetime,\n
`mirror_date` datetime,\n
`total_price` real ,\n
Modified: erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/revision
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/revision?rev=27694&r1=27693&r2=27694&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/revision [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_mysql_innodb_catalog/bt/revision [utf8] Fri Jun 19 18:40:14 2009
@@ -1,1 +1,1 @@
-138
+139
Modified: erp5/trunk/products/ERP5/tests/testAccounting.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testAccounting.py?rev=27694&r1=27693&r2=27694&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testAccounting.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testAccounting.py [utf8] Fri Jun 19 18:40:14 2009
@@ -809,6 +809,22 @@
doActionFor(accounting_transaction, 'stop_action')
self.assertEquals('stopped', accounting_transaction.getSimulationState())
+
+ def test_CancellationAmount(self):
+ accounting_transaction = self._makeOne(
+ portal_type='Accounting Transaction',
+ start_date=DateTime('2007/01/02'),
+ destination_section_value=self.organisation_module.client_1,
+ lines=(dict(source_value=self.account_module.payable,
+ source_debit=500,)
+ dict(source_value=self.account_module.receivable,
+ source_debit=-500,
+ cancellation_amount=True
+ )))
+
+ self.assertEquals([], accounting_transaction.checkConsistency())
+ self.portal.portal_workflow.doActionFor(accounting_transaction,
+ 'stop_action')
class TestClosingPeriod(AccountingTestCase):
Modified: erp5/trunk/products/ERP5/tests/testAmount.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testAmount.py?rev=27694&r1=27693&r2=27694&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testAmount.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testAmount.py [utf8] Fri Jun 19 18:40:14 2009
@@ -384,6 +384,110 @@
mvt.edit(destination_asset_debit=None, destination_debit=200)
self.assertEquals(0.0, mvt.getDestinationAssetDebit())
self.assertEquals(200, mvt.getDestinationDebit())
+
+ def testCancellationAmountGetDestinationCredit(self):
+ mvt = self._makeOne('mvt')
+ mvt.setCancellationAmount(True)
+ mvt.setQuantity(10)
+ self.assertEquals(mvt.getQuantity(), 10)
+ self.assertEquals(mvt.getDestinationDebit(), 0)
+ self.assertEquals(mvt.getDestinationCredit(), -10)
+
+ def testCancellationAmountGetDestinationDebit(self):
+ mvt = self._makeOne('mvt')
+ mvt.setCancellationAmount(True)
+ mvt.setQuantity(-10)
+ self.assertEquals(mvt.getQuantity(), -10)
+ self.assertEquals(mvt.getDestinationDebit(), -10)
+ self.assertEquals(mvt.getDestinationCredit(), 0)
+
+ def testCancellationAmountGetSourceCredit(self):
+ mvt = self._makeOne('mvt')
+ mvt.setCancellationAmount(True)
+ mvt.setQuantity(-10)
+ self.assertEquals(mvt.getQuantity(), -10)
+ self.assertEquals(mvt.getSourceDebit(), 0)
+ self.assertEquals(mvt.getSourceCredit(), -10)
+
+ def testCancellationAmountGetSourceDebit(self):
+ mvt = self._makeOne('mvt')
+ mvt.setCancellationAmount(True)
+ mvt.setQuantity(10)
+ self.assertEquals(mvt.getQuantity(), 10)
+ self.assertEquals(mvt.getSourceDebit(), -10)
+ self.assertEquals(mvt.getSourceCredit(), 0)
+
+ def testCancellationAmountSetDestinationCredit(self):
+ mvt = self._makeOne('mvt')
+ mvt.setDestinationCredit(-10)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getDestinationDebit(), 0)
+ self.assertEquals(mvt.getDestinationCredit(), -10)
+
+ mvt.setDestinationCredit(10)
+ self.assertFalse(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getDestinationDebit(), 0)
+ self.assertEquals(mvt.getDestinationCredit(), 10)
+
+ def testCancellationAmountSetDestinationDebit(self):
+ mvt = self._makeOne('mvt')
+ mvt.setDestinationDebit(-10)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getDestinationDebit(), -10)
+ self.assertEquals(mvt.getDestinationCredit(), 0)
+
+ mvt.setDestinationDebit(10)
+ self.assertFalse(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getDestinationDebit(), 10)
+ self.assertEquals(mvt.getDestinationCredit(), 0)
+
+ def testCancellationAmountSetDestinationDebitCredit(self):
+ mvt = self._makeOne('mvt')
+ mvt.edit(destination_debit=-10, destination_credit=0)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getDestinationDebit(), -10)
+ self.assertEquals(mvt.getDestinationCredit(), 0)
+
+ mvt.edit(destination_debit=-10, destination_credit=None)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getDestinationDebit(), -10)
+ self.assertEquals(mvt.getDestinationCredit(), 0)
+
+ def testCancellationAmountSetSourceCredit(self):
+ mvt = self._makeOne('mvt')
+ mvt.setSourceCredit(-10)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getSourceDebit(), 0)
+ self.assertEquals(mvt.getSourceCredit(), -10)
+
+ mvt.setSourceCredit(10)
+ self.assertFalse(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getSourceDebit(), 0)
+ self.assertEquals(mvt.getSourceCredit(), 10)
+
+ def testCancellationAmountSetSourceDebit(self):
+ mvt = self._makeOne('mvt')
+ mvt.setSourceDebit(-10)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getSourceDebit(), -10)
+ self.assertEquals(mvt.getSourceCredit(), 0)
+
+ mvt.setSourceDebit(10)
+ self.assertFalse(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getSourceDebit(), 10)
+ self.assertEquals(mvt.getSourceCredit(), 0)
+
+ def testCancellationAmountSetSourceDebitCredit(self):
+ mvt = self._makeOne('mvt')
+ mvt.edit(source_debit=-10, source_credit=0)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getSourceDebit(), -10)
+ self.assertEquals(mvt.getSourceCredit(), 0)
+
+ mvt.edit(source_debit=-10, source_credit=None)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(mvt.getSourceDebit(), -10)
+ self.assertEquals(mvt.getSourceCredit(), 0)
class TestAccountingTransactionLine(TestMovement):
@@ -522,6 +626,47 @@
self.assertEquals(0, mvt.getDestinationInventoriatedTotalAssetCredit())
self.assertEquals(200, mvt.getDestinationInventoriatedTotalAssetPrice())
+ def testDestinationAssetDebitCancellation(self):
+ mvt = self._makeOne('mvt')
+ mvt.edit(destination_asset_debit=-100)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(-100, mvt.getDestinationAssetDebit())
+ self.assertEquals(0, mvt.getQuantity())
+ self.assertEquals(-100, mvt.getDestinationInventoriatedTotalAssetDebit())
+ self.assertEquals(0, mvt.getDestinationInventoriatedTotalAssetCredit())
+ self.assertEquals(-100, mvt.getDestinationInventoriatedTotalAssetPrice())
+
+ def testDestinationAssetCreditCancellation(self):
+ mvt = self._makeOne('mvt')
+ mvt.edit(destination_asset_credit=-100)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(-100, mvt.getDestinationAssetCredit())
+ self.assertEquals(0, mvt.getQuantity())
+ self.assertEquals(-100, mvt.getDestinationInventoriatedTotalAssetCredit())
+ self.assertEquals(0, mvt.getDestinationInventoriatedTotalAssetDebit())
+ self.assertEquals(100, mvt.getDestinationInventoriatedTotalAssetPrice())
+
+ def testSourceAssetDebitCancellation(self):
+ mvt = self._makeOne('mvt')
+ mvt.edit(source_asset_debit=-100)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(-100, mvt.getSourceAssetDebit())
+ self.assertEquals(0, mvt.getQuantity())
+ self.assertEquals(-100, mvt.getSourceInventoriatedTotalAssetDebit())
+ self.assertEquals(0, mvt.getSourceInventoriatedTotalAssetCredit())
+ self.assertEquals(-100, mvt.getSourceInventoriatedTotalAssetPrice())
+
+ def testSourceAssetCreditCancellation(self):
+ mvt = self._makeOne('mvt')
+ mvt.edit(source_asset_credit=-100)
+ self.assertTrue(mvt.isCancellationAmount())
+ self.assertEquals(-100, mvt.getSourceAssetCredit())
+ self.assertEquals(0, mvt.getQuantity())
+ self.assertEquals(-100, mvt.getSourceInventoriatedTotalAssetCredit())
+ self.assertEquals(0, mvt.getSourceInventoriatedTotalAssetDebit())
+ self.assertEquals(100, mvt.getSourceInventoriatedTotalAssetPrice())
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestAmount))
Modified: erp5/trunk/products/ERP5/tests/testInventoryAPI.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testInventoryAPI.py?rev=27694&r1=27693&r2=27694&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testInventoryAPI.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testInventoryAPI.py [utf8] Fri Jun 19 18:40:14 2009
@@ -599,6 +599,19 @@
payment_uid=self.other_payment_node.getUid(),
omit_output=1))
+ def test_OmitInputOmitOutputCancellationAmount(self):
+ getInventory = self.getSimulationTool().getInventory
+ self._makeMovement(quantity=-1, price=1, cancellation_amount=True)
+ self._makeMovement(quantity=2, price=1, cancellation_amount=True)
+ self.assertEquals(2, getInventory(node_uid=self.node.getUid(),
+ omit_input=1))
+ self.assertEquals(-1, getInventory(node_uid=self.node.getUid(),
+ omit_output=1))
+ # omit_output & omit_input return nothing in that case
+ self.assertEquals(0, getInventory(node_uid=self.node.getUid(),
+ omit_input=1,
+ omit_output=1))
+
def test_OmitInputOmitOutputWithDifferentPaymentSameNodeSameSection(self):
getInventory = self.getSimulationTool().getInventory
self._makeMovement(quantity=2, price=1,
@@ -789,6 +802,24 @@
self.assertEquals(1, len(inventory_list))
self.assertEquals(-2, inventory_list[0].total_price)
self.assertEquals(-2, inventory_list[0].total_quantity)
+
+ def test_OmitInputOmitOutputCancellationAmount(self):
+ getInventoryList = self.getSimulationTool().getInventoryList
+ self._makeMovement(quantity=-1, price=1, cancellation_amount=True)
+ self._makeMovement(quantity=2, price=1, cancellation_amount=True)
+
+ inventory_list = getInventoryList(node_uid=self.node.getUid(),
+ omit_input=1)
+ self.assertEquals(1, len(inventory_list))
+ self.assertEquals(2, inventory_list[0].total_price)
+ self.assertEquals(2, inventory_list[0].total_quantity)
+
+ # omit output ignores movement going to this node
+ inventory_list = getInventoryList(node_uid=self.node.getUid(),
+ omit_output=1)
+ self.assertEquals(1, len(inventory_list))
+ self.assertEquals(-1, inventory_list[0].total_price)
+ self.assertEquals(-1, inventory_list[0].total_quantity)
def test_CurentAvailableFutureInventoryList(self):
def makeMovement(simulation_state=None, quantity=None):
@@ -831,6 +862,7 @@
checkInventory(line=3, type='Future', source=1, quantity=-9)
checkInventory(line=3, type='Future', destination=1, quantity=9)
+
class TestMovementHistoryList(InventoryAPITestCase):
"""Tests Movement history list methods.
"""
@@ -1440,6 +1472,28 @@
self.assertEquals(1, len(movement_history_list))
self.assertEquals(-2, movement_history_list[0].total_price)
self.assertEquals(-2, movement_history_list[0].total_quantity)
+
+ def test_OmitInputOmitOutputCancellationAmount(self):
+ getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
+ self._makeMovement(quantity=-1, price=1, cancellation_amount=True)
+ self._makeMovement(quantity=2, price=1, cancellation_amount=True)
+ mvt_history_list = getMovementHistoryList(node_uid=self.node.getUid(),
+ omit_input=1)
+ self.assertEquals(1, len(mvt_history_list))
+ self.assertEquals(2, mvt_history_list[0].total_price)
+ self.assertEquals(2, mvt_history_list[0].total_quantity)
+
+ mvt_history_list = getMovementHistoryList(node_uid=self.node.getUid(),
+ omit_output=1)
+ self.assertEquals(1, len(mvt_history_list))
+ self.assertEquals(-1, mvt_history_list[0].total_price)
+ self.assertEquals(-1, mvt_history_list[0].total_quantity)
+
+ self.assertEquals(0, len(getMovementHistoryList(
+ node_uid=self.node.getUid(),
+ omit_input=1,
+ omit_output=1)))
+
class TestNextNegativeInventoryDate(InventoryAPITestCase):
"""Tests getInventory methods.
More information about the Erp5-report
mailing list