Ajuste les mentions et numeros de facture
This commit is contained in:
1 parent
dd1053491b
commit
fc1dffd940
2 files changed
+23
-17
No files matched your search
@@ -40,7 +40,7 @@ export function sanitizeLegalMentions(value) {
|
|||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
function collectPdf(draw, options = {}) {
|
function collectPdf(draw, { pageNumbers = true, ...options } = {}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const doc = new PDFDocument({ size: 'A4', margin: 48, bufferPages: true, ...options });
|
const doc = new PDFDocument({ size: 'A4', margin: 48, bufferPages: true, ...options });
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
@@ -48,18 +48,20 @@ function collectPdf(draw, options = {}) {
|
|||||||
doc.on('end', () => resolve(Buffer.concat(chunks)));
|
doc.on('end', () => resolve(Buffer.concat(chunks)));
|
||||||
doc.on('error', reject);
|
doc.on('error', reject);
|
||||||
draw(doc);
|
draw(doc);
|
||||||
const range = doc.bufferedPageRange();
|
if (pageNumbers) {
|
||||||
for (let page = range.start; page < range.start + range.count; page += 1) {
|
const range = doc.bufferedPageRange();
|
||||||
doc.switchToPage(page);
|
for (let page = range.start; page < range.start + range.count; page += 1) {
|
||||||
const bottomMargin = doc.page.margins.bottom;
|
doc.switchToPage(page);
|
||||||
doc.page.margins.bottom = 0;
|
const bottomMargin = doc.page.margins.bottom;
|
||||||
doc.fontSize(8).fillColor('#8A8279').text(
|
doc.page.margins.bottom = 0;
|
||||||
`Page ${page - range.start + 1} / ${range.count}`,
|
doc.fontSize(8).fillColor('#8A8279').text(
|
||||||
48,
|
`Page ${page - range.start + 1} / ${range.count}`,
|
||||||
doc.page.height - 24,
|
48,
|
||||||
{ width: doc.page.width - 96, align: 'right', lineBreak: false }
|
doc.page.height - 24,
|
||||||
);
|
{ width: doc.page.width - 96, align: 'right', lineBreak: false }
|
||||||
doc.page.margins.bottom = bottomMargin;
|
);
|
||||||
|
doc.page.margins.bottom = bottomMargin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
doc.end();
|
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()}.`
|
? `Facture réglée le ${dateFr(invoice.paid_at)} par ${paymentLabel(invoice.payment_method).toLowerCase()}.`
|
||||||
: invoice.status === 'annulee'
|
: invoice.status === 'annulee'
|
||||||
? 'Facture annulée.'
|
? '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 });
|
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,
|
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];
|
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.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 });
|
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 }) {
|
export function buildPaidMembersPdf({ season, rows }) {
|
||||||
|
|||||||
@@ -219,8 +219,12 @@ billingRouter.post('/seasons/:season/invoices', validate(billingSeasonParam, 'pa
|
|||||||
? settings.sluc_partner_amount_ht
|
? settings.sluc_partner_amount_ht
|
||||||
: settings.non_partner_amount_ht;
|
: settings.non_partner_amount_ht;
|
||||||
const amountNet = Math.round(amountHt * 100) / 100;
|
const amountNet = Math.round(amountHt * 100) / 100;
|
||||||
const sequence = await client.query(`SELECT nextval('billing_invoice_number_seq') AS n`);
|
const sequence = await client.query(
|
||||||
const invoiceNumber = `FAC-${req.params.season.slice(0, 4)}-${String(sequence.rows[0].n).padStart(5, '0')}`;
|
`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(
|
await client.query(
|
||||||
`INSERT INTO membership_invoices
|
`INSERT INTO membership_invoices
|
||||||
(season, member_id, invoice_number, due_date, member_name, member_address, member_email,
|
(season, member_id, invoice_number, due_date, member_name, member_address, member_email,
|
||||||
|
|||||||
Reference in new issue
Block a user