Commit f5db18fe authored by Jérome Perrin's avatar Jérome Perrin

payroll: reimplement date formatting for printouts

See 4bb5d32e
parent c2c46708
...@@ -73,13 +73,15 @@ def getCareerId(career_title): ...@@ -73,13 +73,15 @@ def getCareerId(career_title):
preferred_date_order = context.getPortalObject().portal_preferences\ preferred_date_order = context.getPortalObject().portal_preferences\
.getPreferredDateOrder() or 'ymd' .getPreferredDateOrder() or 'ymd'
separator = '/'
def getOrderedDate(date): def getOrderedDate(date):
if date is None: if date is None:
return '' return ''
pattern = separator.join(['%%%s' % s for s in list(preferred_date_order)]) date_parts = {
pattern = pattern.replace('y', 'Y') 'y': '%04d' % date.year(),
return date.strftime(pattern) 'm': '%02d' % date.month(),
'd': '%02d' % date.day(),
}
return '/'.join([date_parts[part] for part in preferred_date_order])
def getPaymentConditionText(order): def getPaymentConditionText(order):
if order.getPaymentConditionPaymentEndOfMonth(): if order.getPaymentConditionPaymentEndOfMonth():
......
...@@ -100,13 +100,15 @@ year_to_date_total_employer_tax = paysheet.PaySheetTransaction_getYearToDateMove ...@@ -100,13 +100,15 @@ year_to_date_total_employer_tax = paysheet.PaySheetTransaction_getYearToDateMove
preferred_date_order = portal.portal_preferences\ preferred_date_order = portal.portal_preferences\
.getPreferredDateOrder() or 'ymd' .getPreferredDateOrder() or 'ymd'
separator = '/'
def getOrderedDate(date): def getOrderedDate(date):
if date is None: if date is None:
return '' return ''
pattern = separator.join(['%%%s' % s for s in list(preferred_date_order)]) date_parts = {
pattern = pattern.replace('y', 'Y') 'y': '%04d' % date.year(),
return date.strftime(pattern) 'm': '%02d' % date.month(),
'd': '%02d' % date.day(),
}
return '/'.join([date_parts[part] for part in preferred_date_order])
def getPaymentConditionText(paysheet): def getPaymentConditionText(paysheet):
date = '' date = ''
......
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