Revision 863f59f5
Added by Thomas Noël almost 12 years ago
calebasse/facturation/b2.py | ||
---|---|---|
122 | 122 |
|
123 | 123 |
return invoice_lines |
124 | 124 |
|
125 |
def b2(seq_id, batches): |
|
126 |
hc = batches[0].health_center |
|
125 |
def b2(seq_id, hc, batches): |
|
127 | 126 |
to = hc.b2_000() |
128 | 127 |
total = sum(b.total for b in batches) |
129 | 128 |
first_batch = min(b.number for b in batches) |
... | ... | |
171 | 170 |
nb_lines += 1 |
172 | 171 |
nb_batches += 1 |
173 | 172 |
|
173 |
if nb_lines > 990: |
|
174 |
# FIXME grouper les lots comme y fo pour que ca n'arrive jamais |
|
175 |
print "[FIXME] TROP DE LIGNES -- ", nb_lines |
|
176 |
raise |
|
177 |
|
|
174 | 178 |
end_999 = '999' + TYPE_EMETTEUR + '00000' + NUMERO_EMETTEUR + \ |
175 | 179 |
filler(6) + to + filler(6) + APPLICATION + \ |
176 | 180 |
file_id + \ |
... | ... | |
203 | 207 |
print 'Facturation', invoicing.seq_id |
204 | 208 |
batches = build_batches(invoicing) |
205 | 209 |
for hc in batches: |
206 |
# XXX : pour l'instant, faire un fichier par batch...
|
|
210 |
print 'pour', hc
|
|
207 | 211 |
for b in batches[hc]: |
208 |
b2_filename, mail_filename = b2(invoicing.seq_id, [b]) |
|
209 |
print ' B2 :', b2_filename |
|
210 |
print ' smime :', mail_filename |
|
212 |
print ' lot', b |
|
213 |
b2_filename, mail_filename = b2(invoicing.seq_id, hc, batches[hc]) |
|
214 |
print ' B2 :', b2_filename |
|
215 |
print ' smime :', mail_filename |
|
211 | 216 |
|
212 | 217 |
|
calebasse/facturation/batches.py | ||
---|---|---|
13 | 13 |
self.start_date = min(invoice.start_date for invoice in invoices) |
14 | 14 |
self.end_date = max(invoice.end_date for invoice in invoices) |
15 | 15 |
|
16 |
def __str__(self): |
|
17 |
return '%s pour %s (%d factures)' % (self.number, self.health_center, self.number_of_invoices) |
|
18 |
|
|
16 | 19 |
def build_batches(invoicing): |
17 | 20 |
invoices = invoicing.invoice_set.order_by('number') |
18 | 21 |
prebatches = defaultdict(lambda:[]) |
19 | 22 |
for invoice in invoices: |
20 | 23 |
prebatches[(invoice.health_center, invoice.batch)].append(invoice) |
21 | 24 |
batches_by_health_center = defaultdict(lambda:[]) |
25 |
# FIXME / A REVOIR car il ne pas depasser 999 lignes par batches_by_health_center... |
|
22 | 26 |
for health_center, batch_number in sorted(prebatches.keys()): |
23 |
batches_by_health_center[health_center].append(Batch(batch_number, |
|
27 |
hc = health_center.hc_invoice or health_center |
|
28 |
batches_by_health_center[hc].append(Batch(batch_number, |
|
24 | 29 |
prebatches[(health_center, batch_number)])) |
25 | 30 |
return batches_by_health_center |
26 | 31 |
|
Also available in: Unified diff
b2: multiple batch in a B2 file