From 11cb562e1643680d76ec864ac668645b1a32b9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 22 Mar 2006 13:59:10 +0000 Subject: [PATCH] manually default start date to stop date; make sure resource is a Currency; compare date as DateTime objects again git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6178 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../scripts/validateTransaction.xml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml b/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml index 8b4df60043..987f526709 100755 --- a/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml +++ b/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml @@ -108,12 +108,16 @@ if destination_section is not None and \\\n if destination_section is None and check_destination :\n raiseError(\'Destination Section is not Defined.\')\n \n -currency = transaction.getResource()\n +currency = transaction.getResource(portal_type = \'Currency\')\n if not currency :\n raiseError(\'Currency is not Defined.\')\n \n -if transaction.getStartDate() in (None, \'\') :\n - raiseError(\'date is not Defined\')\n +# XXX manually default start date to stop date\n +if not transaction.getStartDate() and transaction.getStopDate():\n + transaction.setStartDate(transaction.getStopDate())\n +\n +if not transaction.getStartDate() :\n + raiseError(\'Date is not Defined\')\n else:\n if not skip_period_validation :\n valid_date = False\n @@ -133,10 +137,9 @@ else:\n valid_date = True\n for apd in openned_accounting_period_list:\n apd = apd.getObject()\n - # Compare date, not datetime\n - if apd.getStartDate().strftime("%Y/%m/%d") <= transaction_date.strftime("%Y/%m/%d") <= apd.getStopDate().strftime("%Y/%m/%d"):\n + if apd.getStartDate() <= transaction_date <= apd.getStopDate():\n valid_date = True\n - if not valid_date:\n + if not valid_date :\n raiseError("Date is not in an openned Accounting Period "\n "for source section")\n # do the same for destination section \n @@ -154,8 +157,7 @@ else:\n valid_date = True\n for apd in openned_accounting_period_list:\n apd = apd.getObject()\n - # Compare date, not datetime\n - if apd.getStartDate().strftime("%Y/%m/%d") <= transaction_date.strftime("%Y/%m/%d") <= apd.getStopDate().strftime("%Y/%m/%d"):\n + if apd.getStartDate() <= transaction_date <= apd.getStopDate():\n valid_date = True\n if not valid_date :\n raiseError("Date is not in an openned Accounting Period "+\n -- 2.30.9