64 lines
2.2 KiB
JavaScript
Executable File
64 lines
2.2 KiB
JavaScript
Executable File
const strftime = require('strftime');
|
|
const db = require(`${appPath}/core/database`);
|
|
const Component = require(`${appPath}/core/component`);
|
|
const reportHeader = new Component('report-header');
|
|
const reportFooter = new Component('report-footer');
|
|
|
|
module.exports = {
|
|
name: 'rpt-claim-pickup-order',
|
|
async serverPrefetch() {
|
|
this.claim = await this.fetchClaim(this.claimId);
|
|
this.sales = await this.fetchSales(this.claimId);
|
|
},
|
|
created() {
|
|
if (this.locale)
|
|
this.$i18n.locale = this.locale;
|
|
},
|
|
methods: {
|
|
dated: () => {
|
|
return strftime('%d-%m-%Y', new Date());
|
|
},
|
|
fetchClaim(claimId) {
|
|
return db.findOne(
|
|
`SELECT
|
|
u.lang locale,
|
|
c.id clientId,
|
|
cl.id claimId,
|
|
c.email AS recipient,
|
|
c.socialName,
|
|
c.name AS clientName,
|
|
c.fi,
|
|
a.city,
|
|
a.postalCode,
|
|
a.street,
|
|
a.nickname,
|
|
p.name AS province,
|
|
ct.country
|
|
FROM claim cl
|
|
JOIN client c ON c.id = cl.clientFk
|
|
JOIN account.user u ON u.id = c.id
|
|
JOIN country ct ON ct.id = c.countryFk
|
|
JOIN ticket t ON t.id = cl.ticketFk
|
|
JOIN address a ON a.id = t.addressFk
|
|
LEFT JOIN province p ON p.id = c.provinceFk
|
|
WHERE cl.id = ?`, [claimId]);
|
|
},
|
|
fetchSales(claimId) {
|
|
return db.pool.query(
|
|
`SELECT
|
|
s.id,
|
|
s.quantity,
|
|
s.concept,
|
|
cb.quantity claimQuantity
|
|
FROM claimBeginning cb
|
|
JOIN sale s ON s.id = cb.saleFk
|
|
WHERE cb.claimFk = ?`, [claimId]);
|
|
},
|
|
},
|
|
components: {
|
|
'report-header': reportHeader.build(),
|
|
'report-footer': reportFooter.build()
|
|
},
|
|
props: ['claimId', 'isPreview']
|
|
};
|