~credativ/account-banking/fix-variable-error-6.0

« back to all changes in this revision

Viewing changes to account_banking/wizard/wizard_payment_order.py

  • Committer: Pieter J. Kersten
  • Date: 2011-02-13 09:28:59 UTC
  • Revision ID: pieter@terp.edusense.nl-20110213092859-03peyimtepvon1q1
[FIX] account_banking: fix date comparison in payment order wizard

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from tools.misc import UpdateableStr
28
28
from tools.translate import _
29
29
from account_banking.struct import struct
30
 
from account_banking.parsers.convert import str2date, date2str
 
30
from account_banking.parsers import convert
31
31
 
32
32
__doc__ = '''
33
33
This module is a slightly modified version of the identical named payment
43
43
 
44
44
today = datetime.date.today
45
45
 
 
46
def str2date(str):
 
47
    dt = convert.str2date(str, '%Y-%m-%d')
 
48
    return datetime.date(dt.year, dt.month, dt.day)
 
49
 
46
50
class wizard_payment_order(wizard.interface):
47
51
    '''
48
52
    Create a payment object with lines corresponding to the account move line
67
71
            'string': 'Due Date',
68
72
            'type': 'date',
69
73
            'required': True,
70
 
            'default': lambda *a: date2str(today()),
 
74
            'default': lambda *a: convert.date2str(today()),
71
75
        },
72
76
    }
73
77
    arch_duedate='''<?xml version="1.0"?>
145
149
                date_to_pay = False
146
150
            elif payment.date_prefered == 'due':
147
151
                date_to_pay = line.date_maturity and \
148
 
                              line.date_maturity > _today and \
149
 
                              line.date_maturity or False
 
152
                           str2date(line.date_maturity) > _today\
 
153
                           and line.date_maturity or False
150
154
            elif payment.date_prefered == 'fixed':
151
155
                date_to_pay = payment.date_planned and \
152
 
                              payment.date_planned > _today and \
153
 
                              payment.date_planned or False
 
156
                           str2date(payment.date_planned) > _today\
 
157
                           and payment.date_planned or False
154
158
            values = struct(
155
159
                move_line_id = line.id,
156
160
                amount_currency = line.amount_to_pay,