feat: add new report
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2022-09-21 08:11:04 +02:00
parent 9f1c90387b
commit c17e0fd38b
7 changed files with 41 additions and 93 deletions

View File

@ -1,38 +0,0 @@
const Component = require(`${appPath}/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
module.exports = {
name: 'campaign-metrics',
async serverPrefetch() {
this.client = await this.fetchClient(this.recipientId);
this.sales = await this.fetchSales(this.recipientId, this.from, this.to);
if (!this.client)
throw new Error('Something went wrong');
},
methods: {
fetchClient(clientId) {
return this.findOneFromDef('client', [clientId]);
},
fetchSales(clientId, from, to) {
return this.rawSqlFromDef('sales', [clientId, from, to]);
},
},
components: {
'report-header': reportHeader.build(),
'report-footer': reportFooter.build()
},
props: {
recipientId: {
type: [Number, String],
required: true
},
from: {
required: true
},
to: {
required: true
}
}
};

View File

@ -1,12 +1,4 @@
reportName: consumo-cliente
title: Expiración Tarjetas Vehículos
Client: Cliente
clientData: Datos del cliente
dated: Fecha
From: Desde
To: Hasta
client: Cliente {0}
Stems: Tallos
Plate: Matrícula
Concept: Concepto
expirationDate: Fecha caducidad

View File

@ -1,13 +0,0 @@
SELECT
c.street,
c.socialName,
c.city,
c.postcode,
c.id,
c.name AS clientName,
p.name AS province,
co.country
FROM client c
JOIN province p ON c.provinceFk = p.id
JOIN country co ON c.countryFk = co.id
WHERE c.id = ?

View File

@ -1,20 +0,0 @@
SELECT
SUM(s.quantity) AS subtotal,
s.itemFk,
s.concept,
i.subName,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
WHERE
t.clientFk = ? AND it.isPackaging = FALSE
AND DATE(t.shipped) BETWEEN ? AND ?
GROUP BY s.itemFk
ORDER BY i.typeFk , i.name

View File

@ -0,0 +1,7 @@
SELECT
v.numberPlate,
ve.description,
ve.finished
FROM vehicleEvent ve
JOIN vehicle v ON v.id = ve.vehicleFk
WHERE ve.id IN (?)

View File

@ -10,11 +10,9 @@
<!-- Block -->
<div class="grid-row">
<div class="grid-block">
<div class="columns">
<div class="size50">
<h1 class="title uppercase">{{$t('title')}}</h1>
<div class="content">
<h1 class="title centered uppercase">{{$t('title')}}</h1>
</div>
</div>
<table class="column-oriented">
<thead>
<tr>
@ -23,22 +21,16 @@
<th>{{$t('expirationDate')}}</th>
</tr>
</thead>
<tbody v-for="sale in sales">
<tbody v-for="vehicleEvent in vehicleEvents">
<tr>
<td>{{sale.itemFk | zerofill('000000')}}</td>
<td>{{Math.trunc(sale.subtotal)}}</td>
<td>{{sale.concept}}</td>
<td>{{vehicleEvent.numberPlate}}</td>
<td>{{vehicleEvent.description}}</td>
<td>{{vehicleEvent.finished | date('%d-%m-%Y')}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Footer block -->
<report-footer id="pageFooter"
v-bind:left-text="$t('client', [client.id])"
v-bind:center-text="client.socialName"
v-bind="$props">
</report-footer>
</td>
</tr>
</tbody>

View File

@ -0,0 +1,28 @@
const Component = require(`${appPath}/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
module.exports = {
name: 'vehicle-event-expired',
async serverPrefetch() {
this.vehicleEvents = await this.fetchVehicleEvent(this.eventIds);
if (!this.vehicleEvents)
throw new Error('Something went wrong');
},
methods: {
fetchVehicleEvent(vehicleEventIds) {
return this.rawSqlFromDef('vehicleEvents', [vehicleEventIds]);
},
},
components: {
'report-header': reportHeader.build(),
'report-footer': reportFooter.build()
},
props: {
eventIds: {
type: [Array],
required: false
}
}
};