Ajuste les mentions et numeros de facture
This commit is contained in:
1 parent
dd1053491b
commit
fc1dffd940
2 files changed
+11
-5
No files matched your search
@@ -40,7 +40,7 @@ export function sanitizeLegalMentions(value) {
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
function collectPdf(draw, options = {}) {
|
||||
function collectPdf(draw, { pageNumbers = true, ...options } = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const doc = new PDFDocument({ size: 'A4', margin: 48, bufferPages: true, ...options });
|
||||
const chunks = [];
|
||||
@@ -48,6 +48,7 @@ function collectPdf(draw, options = {}) {
|
||||
doc.on('end', () => resolve(Buffer.concat(chunks)));
|
||||
doc.on('error', reject);
|
||||
draw(doc);
|
||||
if (pageNumbers) {
|
||||
const range = doc.bufferedPageRange();
|
||||
for (let page = range.start; page < range.start + range.count; page += 1) {
|
||||
doc.switchToPage(page);
|
||||
@@ -61,6 +62,7 @@ function collectPdf(draw, options = {}) {
|
||||
);
|
||||
doc.page.margins.bottom = bottomMargin;
|
||||
}
|
||||
}
|
||||
doc.end();
|
||||
});
|
||||
}
|
||||
@@ -129,7 +131,7 @@ export function buildInvoicePdf(invoice) {
|
||||
? `Facture réglée le ${dateFr(invoice.paid_at)} par ${paymentLabel(invoice.payment_method).toLowerCase()}.`
|
||||
: invoice.status === 'annulee'
|
||||
? 'Facture annulée.'
|
||||
: `Paiement attendu avant le ${dateFr(invoice.due_date)} par virement, chèque ou carte bleue.`;
|
||||
: `Paiement attendu avant le ${dateFr(invoice.due_date)} par virement ou chèque.`;
|
||||
doc.font('Helvetica').fontSize(8.5).fillColor(GRAY).text(paymentStatus, 48, 655, { width: 499 });
|
||||
const ribValues = [issuer.iban, issuer.bic, issuer.rib_account_holder, issuer.rib_bank_name,
|
||||
issuer.rib_bank_code, issuer.rib_branch_code, issuer.rib_account_number, issuer.rib_key];
|
||||
@@ -175,7 +177,7 @@ export function buildInvoicePdf(invoice) {
|
||||
doc.moveTo(48, 84).lineTo(547, 84).lineWidth(2).strokeColor(RED).stroke();
|
||||
doc.font('Helvetica').fontSize(9).fillColor(GRAY).text(legalMentions, 48, 108, { width: 499, lineGap: 3 });
|
||||
}
|
||||
}, { info: { Title: `Facture ${invoice.invoice_number}`, Author: text(invoice.issuer_snapshot?.association_name) } });
|
||||
}, { pageNumbers: false, info: { Title: `Facture ${invoice.invoice_number}`, Author: text(invoice.issuer_snapshot?.association_name) } });
|
||||
}
|
||||
|
||||
export function buildPaidMembersPdf({ season, rows }) {
|
||||
|
||||
@@ -219,8 +219,12 @@ billingRouter.post('/seasons/:season/invoices', validate(billingSeasonParam, 'pa
|
||||
? settings.sluc_partner_amount_ht
|
||||
: settings.non_partner_amount_ht;
|
||||
const amountNet = Math.round(amountHt * 100) / 100;
|
||||
const sequence = await client.query(`SELECT nextval('billing_invoice_number_seq') AS n`);
|
||||
const invoiceNumber = `FAC-${req.params.season.slice(0, 4)}-${String(sequence.rows[0].n).padStart(5, '0')}`;
|
||||
const sequence = await client.query(
|
||||
`SELECT nextval('billing_invoice_number_seq') AS n,
|
||||
to_char(CURRENT_DATE, 'YYYY') AS year,
|
||||
to_char(CURRENT_DATE, 'MM') AS month`
|
||||
);
|
||||
const invoiceNumber = `FAC-${sequence.rows[0].year}-${sequence.rows[0].month}-${String(sequence.rows[0].n).padStart(5, '0')}`;
|
||||
await client.query(
|
||||
`INSERT INTO membership_invoices
|
||||
(season, member_id, invoice_number, due_date, member_name, member_address, member_email,
|
||||
|
||||
Reference in new issue
Block a user