[domino] gives invoices a subject and a description by extracting details from Domino invoices
This commit is contained in:
parent
5ed9207bef
commit
5f8f0eae39
|
@ -1,4 +1,5 @@
|
|||
from datetime import datetime
|
||||
import collections
|
||||
|
||||
from qommon.cron import CronJob
|
||||
from qommon.publisher import get_publisher_class
|
||||
|
@ -63,6 +64,41 @@ def synchronize_domino(publisher):
|
|||
payment_invoice.amount = invoice.reste_du
|
||||
payment_invoice.date = invoice.creation
|
||||
payment_invoice.domino_synchro_date = datetime.now()
|
||||
if 'etablissement' in invoice._detail:
|
||||
etablissement = invoice._detail['etablissement'].encode('utf-8')
|
||||
payment_invoice.subject = _('%s - Childcare services') % etablissement
|
||||
else:
|
||||
payment_invoice.subject = _('Childcare services')
|
||||
if invoice._detail.get('lignes'):
|
||||
details = []
|
||||
details.append('<table class="invoice-details"><thead>')
|
||||
tpl = '''<tr>
|
||||
<td>%(designation)s</td>
|
||||
<td>%(quantite)s</td>
|
||||
<td>%(prix)s</td>
|
||||
<td>%(montant)s</td>
|
||||
</tr>'''
|
||||
captions = {
|
||||
'designation': _('Caption'),
|
||||
'quantite': _('Quantity'),
|
||||
'prix': _('Price'),
|
||||
'amount': _('Amount')
|
||||
}
|
||||
details.append(tpl % captions)
|
||||
details.append('</thead>')
|
||||
details.append('<tbody>')
|
||||
for ligne in invoice._detail['lignes']:
|
||||
def encode(x):
|
||||
a, b = x
|
||||
b = b.encode('utf-8')
|
||||
return (a,b)
|
||||
ligne = map(encode, ligne)
|
||||
ligne = dict(ligne)
|
||||
base = collections.defaultdict(lambda:'')
|
||||
base.update(ligne)
|
||||
details.append(tpl % base)
|
||||
details.append('</tbody></table>')
|
||||
payment_invoice.details = '\n'.join(details)
|
||||
payment_invoice.store()
|
||||
logger.info('domino cron: remote invoice %s for family %s added to user %s invoices with id %s',
|
||||
invoice.id, invoice.family.id, user.id, payment_invoice.id)
|
||||
|
|
|
@ -372,7 +372,7 @@ class Invoice(SimpleObject):
|
|||
('', 'montant', Decimal, ''),
|
||||
('', 'reste_du', Decimal, ''),
|
||||
)
|
||||
_detail = None
|
||||
_detail = {}
|
||||
|
||||
def detail(self):
|
||||
if not self._detail:
|
||||
|
|
15
po/fr.po
15
po/fr.po
|
@ -2233,6 +2233,21 @@ msgstr "Abonnement aux annonces"
|
|||
msgid "Message on top of invoices page"
|
||||
msgstr "Texte en haut de la page des paiements"
|
||||
|
||||
msgid "%s - Childcare services"
|
||||
msgstr "Prestations jeunesse - %s"
|
||||
|
||||
msgid "Childcare services"
|
||||
msgstr "Prestations jeunesse"
|
||||
|
||||
msgid "Caption"
|
||||
msgstr "Désignation"
|
||||
|
||||
msgid "Quantity"
|
||||
msgstr "Quantité"
|
||||
|
||||
msgid "Price"
|
||||
msgstr "Prix"
|
||||
|
||||
#~ msgid "Update the family"
|
||||
#~ msgstr "Mettre à jour la famille"
|
||||
|
||||
|
|
Reference in New Issue