Commit 64b61d7a authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: Define appropriate Start Data on Movements

parent a63fc26f
...@@ -10,7 +10,10 @@ if context.getSimulationState() == 'confirmed' \ ...@@ -10,7 +10,10 @@ if context.getSimulationState() == 'confirmed' \
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()]: portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()]:
comment = 'Start by alarm as all actions in confirmed state are ready.' comment = 'Start by alarm as all actions in confirmed state are ready.'
date = context.getStartDate()
if date is None:
date = DateTime().earliestTime() date = DateTime().earliestTime()
context.edit(start_date=date, stop_date=date) context.edit(start_date=date, stop_date=date)
if isTransitionPossible(context, 'start'): if isTransitionPossible(context, 'start'):
context.start(comment=comment) context.start(comment=comment)
...@@ -61,8 +61,8 @@ for movement in movement_list: ...@@ -61,8 +61,8 @@ for movement in movement_list:
destination_section=movement.getDestination(), destination_section=movement.getDestination(),
destination_decision=movement.getDestination(), destination_decision=movement.getDestination(),
specialise=specialise, specialise=specialise,
price_currency=movement.getPriceCurrency() price_currency=movement.getPriceCurrency(),
) start_date=movement.getStartDate())
# XXX Shamefully hardcoded values # XXX Shamefully hardcoded values
if movement.getResource() == 'service_module/slapos_instance_subscription': if movement.getResource() == 'service_module/slapos_instance_subscription':
...@@ -84,8 +84,7 @@ for movement in movement_list: ...@@ -84,8 +84,7 @@ for movement in movement_list:
if subscription is not None: if subscription is not None:
temp_movement.edit( temp_movement.edit(
specialise=specialise_to_set, specialise=specialise_to_set,
causality=subscription, causality=subscription)
start_date=movement.getStartDate())
elif movement.getCausality(portal_type="Subscription Request") is not None: elif movement.getCausality(portal_type="Subscription Request") is not None:
temp_movement.edit( temp_movement.edit(
specialise=specialise_to_set, specialise=specialise_to_set,
......
...@@ -13,7 +13,8 @@ def newPackingList(movement, causality, message): ...@@ -13,7 +13,8 @@ def newPackingList(movement, causality, message):
destination_decision=movement.getDestination(), destination_decision=movement.getDestination(),
specialise=movement.getSpecialise(), specialise=movement.getSpecialise(),
price_currency=movement.getPriceCurrency(), price_currency=movement.getPriceCurrency(),
causality=causality) causality=causality,
start_date=movement.getStartDate())
delivery.confirm(message) delivery.confirm(message)
return delivery return delivery
...@@ -51,6 +52,9 @@ for movement in movement_list: ...@@ -51,6 +52,9 @@ for movement in movement_list:
if delivery is not None and delivery.getSource() != movement.getSource(): if delivery is not None and delivery.getSource() != movement.getSource():
delivery.setSource(movement.getSource()) delivery.setSource(movement.getSource())
if delivery is not None and delivery.getSourceSection() != movement.getSourceSection():
delivery.setSourceSection(movement.getSourceSection())
person_delivery_mapping["%s---%s---%s" % (person.getUid(), causality, specialise_uid)] = delivery person_delivery_mapping["%s---%s---%s" % (person.getUid(), causality, specialise_uid)] = delivery
return person_delivery_mapping.values() return person_delivery_mapping.values()
...@@ -1101,7 +1101,7 @@ class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm( ...@@ -1101,7 +1101,7 @@ class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm(
False, delivery_date=DateTime("2012/04/22"), False, delivery_date=DateTime("2012/04/22"),
accounting_date=DateTime('2012/04/23')) accounting_date=DateTime('2012/04/23'))
def test_start_date_is_resetted(self): def test_start_date_isnt_resetted(self):
delivery = self.portal.sale_packing_list_module.newContent( delivery = self.portal.sale_packing_list_module.newContent(
portal_type="Sale Packing List", portal_type="Sale Packing List",
start_date=DateTime("2012/04/22"), start_date=DateTime("2012/04/22"),
...@@ -1122,9 +1122,9 @@ class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm( ...@@ -1122,9 +1122,9 @@ class TestSlapOSStartConfirmedAggregatedSalePackingListAlarm(
self.portal.portal_workflow._jumpToStateFor(delivery, 'solved') self.portal.portal_workflow._jumpToStateFor(delivery, 'solved')
self.portal.portal_workflow._jumpToStateFor(delivery, 'confirmed') self.portal.portal_workflow._jumpToStateFor(delivery, 'confirmed')
delivery.Delivery_startConfirmedAggregatedSalePackingList() delivery.Delivery_startConfirmedAggregatedSalePackingList()
self.assertEqual(delivery.getStartDate(), self.assertNotEqual(delivery.getStartDate(),
DateTime().earliestTime()) DateTime().earliestTime())
self.assertEqual(delivery.getStopDate(), self.assertNotEqual(delivery.getStopDate(),
DateTime().earliestTime()) DateTime().earliestTime())
self.assertEqual(delivery.getSimulationState(), 'started') self.assertEqual(delivery.getSimulationState(), 'started')
......
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