Commit 8798915c authored by Łukasz Nowak's avatar Łukasz Nowak

Use accounting_day term.

Everything *before* the accounting_day day of the month will be delivered.

Allow to pass accounting_date in params in order to easy testing (otherwise
DateTime object would have to be mocked up).
parent b4998ff4
......@@ -50,8 +50,24 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
from Products.ERP5Type.DateUtils import getClosestDate\n
<value> <string encoding="cdata"><![CDATA[
if params is None:\n
params = {}\n
\n
from DateTime import DateTime\n
from Products.ERP5Type.DateUtils import addToDate\n
from Products.ZSQLCatalog.SQLCatalog import Query\n
\n
def getAccountingDate(accounting_date):\n
accounting_day = 25\n
if accounting_date.day() <= accounting_day:\n
accounting_date = addToDate(accounting_date, dict(month=-1))\n
diff = accounting_day - accounting_date.day()\n
accounting_date = addToDate(accounting_date, dict(day=diff))\n
return accounting_date\n
\n
accounting_date = params.get(\'accounting_date\', DateTime().earliestTime())\n
\n
portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
......@@ -60,10 +76,14 @@ portal.portal_catalog.searchAndActivate(\n
causality_state=\'solved\',\n
specialise_uid=portal.restrictedTraverse(portal.portal_preferences.getPreferredAggregatedSaleTradeCondition()).getUid(),\n
method_id=\'Delivery_deliverConfirmedAggregatedSalePackingList\',\n
activate_kw={\'tag\': tag}\n
activate_kw={\'tag\': tag},\n
**{\'delivery.start_date\': Query(range="max",\n
**{\'delivery.start_date\': getAccountingDate(accounting_date)})}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
......
......@@ -1378,7 +1378,9 @@ class TestSlapOSDeliverConfirmedAggregatedSalePackingListAlarm(testSlapOSMixin):
not_visited = 'Not visited by %s' % self.script
visited = 'Visited by %s' % self.script
module = self.portal.getDefaultModule(portal_type=self.portal_type)
delivery = module.newContent(title=not_visited,
delivery_date = DateTime('2012/04/22')
accounting_date = DateTime('2012/04/28')
delivery = module.newContent(title=not_visited, start_date=delivery_date,
portal_type=self.portal_type, specialise=specialise)
_jumpToStateFor = self.portal.portal_workflow._jumpToStateFor
_jumpToStateFor(delivery, simulation_state)
......@@ -1386,7 +1388,7 @@ class TestSlapOSDeliverConfirmedAggregatedSalePackingListAlarm(testSlapOSMixin):
self.tic()
alarm = getattr(self.portal.portal_alarms, self.alarm)
alarm.activeSense()
alarm.activeSense(params=dict(accounting_date=accounting_date))
self.tic()
if positive:
......
182
\ No newline at end of file
183
\ No newline at end of file
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