Merge branch 'dev' into 2457-fix_regularizeClaim_unit_test
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-09-29 12:22:11 +00:00
commit 5bdc67f96e
56 changed files with 568 additions and 462 deletions

View File

@ -1,3 +1,2 @@
Invoice out: Facturas InvoiceOut: Facturas
invoiceOut: factura
Search invoices by reference: Buscar facturas por referencia Search invoices by reference: Buscar facturas por referencia

View File

@ -22,7 +22,7 @@
"url": "/index?q", "url": "/index?q",
"state": "invoiceOut.index", "state": "invoiceOut.index",
"component": "vn-invoice-out-index", "component": "vn-invoice-out-index",
"description": "Invoice out" "description": "InvoiceOut"
}, },
{ {
"url": "/summary", "url": "/summary",

View File

@ -93,10 +93,11 @@ class Component {
const component = this.build(); const component = this.build();
const i18n = new VueI18n(config.i18n); const i18n = new VueI18n(config.i18n);
const props = {tplPath: this.path, ...this.args};
this._component = new Vue({ this._component = new Vue({
i18n: i18n, i18n: i18n,
render: h => h(component, { render: h => h(component, {
props: this.args props: props
}) })
}); });

View File

@ -1,5 +1,6 @@
const mysql = require('mysql2/promise'); const mysql = require('mysql2/promise');
const config = require('./config.js'); const config = require('./config.js');
const fs = require('fs-extra');
module.exports = { module.exports = {
init() { init() {
@ -10,6 +11,7 @@ module.exports = {
}); });
} }
}, },
/** /**
* Makes a query from a raw sql * Makes a query from a raw sql
* @param {String} query - The raw SQL query * @param {String} query - The raw SQL query
@ -22,6 +24,20 @@ module.exports = {
return rows; return rows;
}); });
}, },
/**
* Makes a query from a SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
rawSqlFromDef(queryName, params) {
const query = fs.readFileSync(`${queryName}.sql`, 'utf8');
return this.rawSql(query, params);
},
/** /**
* Returns the first row from a given raw sql * Returns the first row from a given raw sql
* @param {String} query - The raw SQL query * @param {String} query - The raw SQL query
@ -32,6 +48,19 @@ module.exports = {
findOne(query, params) { findOne(query, params) {
return this.rawSql(query, params).then(([row]) => row); return this.rawSql(query, params).then(([row]) => row);
}, },
/**
* Returns the first row from a given SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findOneFromDef(queryName, params) {
return this.rawSqlFromDef(queryName, params)
.then(([row]) => row);
},
/** /**
* Returns the first property from a given raw sql * Returns the first property from a given raw sql
* @param {String} query - The raw SQL query * @param {String} query - The raw SQL query
@ -44,7 +73,17 @@ module.exports = {
return Object.values(row)[0]; return Object.values(row)[0];
}); });
}, },
findFromDef() {
/**
* Returns the first property from a given SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findValueFromDef(queryName, params) {
return this.findOneFromDef(queryName, params).then(row => {
return Object.values(row)[0];
});
} }
}; };

View File

@ -0,0 +1,74 @@
const Vue = require('vue');
const path = require('path');
const db = require('../database');
const dbHelper = {
methods: {
/**
* Makes a query from a raw sql
* @param {String} query - The raw SQL query
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
rawSql: db.rawSql,
/**
* Makes a query from a SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
rawSqlFromDef(queryName, params) {
const absolutePath = path.join(__dirname, '../', this.tplPath, 'sql', queryName);
return db.rawSqlFromDef(absolutePath, params);
},
/**
* Returns the first row from a given raw sql
* @param {String} query - The raw SQL query
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findOne: db.findOne,
/**
* Returns the first row from a given SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findOneFromDef(queryName, params) {
return this.rawSqlFromDef(queryName, params)
.then(([row]) => row);
},
/**
* Returns the first property from a given raw sql
* @param {String} query - The raw SQL query
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findValue: db.findValue,
/**
* Returns the first property from a given SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findValueFromDef(queryName, params) {
return this.findOneFromDef(queryName, params).then(row => {
return Object.values(row)[0];
});
}
},
props: ['tplPath']
};
Vue.mixin(dbHelper);

View File

@ -2,3 +2,4 @@
require('./image-src'); require('./image-src');
require('./user-locale'); require('./user-locale');
require('./prop-validator'); require('./prop-validator');
require('./db-helper');

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
@ -10,18 +9,7 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(clientId) {
return db.findOne(` return this.findOneFromDef('client', [clientId]);
SELECT
c.id,
u.name AS userName,
CONCAT(w.lastName, ' ', w.firstName) salesPersonName,
w.phone AS salesPersonPhone,
CONCAT(wu.name, '@verdnatura.es') AS salesPersonEmail
FROM client c
JOIN account.user u ON u.id = c.id
LEFT JOIN worker w ON w.id = c.salesPersonFk
LEFT JOIN account.user wu ON wu.id = w.userFk
WHERE c.id = ?`, [clientId]);
}, },
}, },
components: { components: {

View File

@ -0,0 +1,11 @@
SELECT
c.id,
u.name AS userName,
CONCAT(w.lastName, ' ', w.firstName) salesPersonName,
w.phone AS salesPersonPhone,
CONCAT(wu.name, '@verdnatura.es') AS salesPersonEmail
FROM client c
JOIN account.user u ON u.id = c.id
LEFT JOIN worker w ON w.id = c.salesPersonFk
LEFT JOIN account.user wu ON wu.id = w.userFk
WHERE c.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
const attachment = new Component('attachment'); const attachment = new Component('attachment');
@ -18,17 +17,7 @@ module.exports = {
}, },
methods: { methods: {
fetchDebtor(clientId, companyId) { fetchDebtor(clientId, companyId) {
return db.findOne(` return this.findOneFromDef('client', [clientId, companyId]);
SELECT
c.dueDay,
c.iban,
sa.iban,
be.name AS bankName
FROM client c
JOIN company AS cny
JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ?`, [clientId, companyId]);
} }
}, },
components: { components: {

View File

@ -0,0 +1,10 @@
SELECT
c.dueDay,
c.iban,
sa.iban,
be.name AS bankName
FROM client c
JOIN company AS cny
JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ?`

View File

@ -18,17 +18,7 @@ module.exports = {
}, },
methods: { methods: {
fetchDebtor(clientId, companyId) { fetchDebtor(clientId, companyId) {
return db.findOne(` return this.findOneFromDef('client', [clientId, companyId]);
SELECT
c.dueDay,
c.iban,
sa.iban,
be.name AS bankName
FROM client c
JOIN company AS cny
JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ?`, [clientId, companyId]);
} }
}, },
components: { components: {

View File

@ -0,0 +1,10 @@
SELECT
c.dueDay,
c.iban,
sa.iban,
be.name AS bankName
FROM client c
JOIN company AS cny
JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
@ -18,15 +17,7 @@ module.exports = {
}, },
methods: { methods: {
fetchPayMethod(clientId) { fetchPayMethod(clientId) {
return db.findOne( return this.findOneFromDef('payMethod', {clientId: clientId});
`SELECT
c.dueDay,
c.iban,
pm.name,
pm.code
FROM client c
JOIN payMethod pm ON pm.id = c.payMethodFk
WHERE c.id = :clientId`, {clientId: clientId});
} }
}, },
components: { components: {

View File

@ -0,0 +1,8 @@
SELECT
c.dueDay,
c.iban,
pm.name,
pm.code
FROM client c
JOIN payMethod pm ON pm.id = c.payMethodFk
WHERE c.id = :clientId

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
const attachment = new Component('attachment'); const attachment = new Component('attachment');
@ -15,20 +14,7 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(clientId) {
return db.findOne(` return this.findOneFromDef('client', [clientId]);
SELECT
c.id,
u.lang locale,
u.name AS userName,
c.email recipient,
CONCAT(w.lastName, ' ', w.firstName) salesPersonName,
w.phone AS salesPersonPhone,
CONCAT(wu.name, '@verdnatura.es') AS salesPersonEmail
FROM client c
JOIN account.user u ON u.id = c.id
LEFT JOIN worker w ON w.id = c.salesPersonFk
LEFT JOIN account.user wu ON wu.id = w.userFk
WHERE c.id = ?`, [clientId]);
} }
}, },
components: { components: {

View File

@ -0,0 +1,12 @@
SELECT
c.id,
u.name AS userName,
c.email recipient,
CONCAT(w.lastName, ' ', w.firstName) salesPersonName,
w.phone AS salesPersonPhone,
CONCAT(wu.name, '@verdnatura.es') AS salesPersonEmail
FROM client c
JOIN account.user u ON u.id = c.id
LEFT JOIN worker w ON w.id = c.salesPersonFk
LEFT JOIN account.user wu ON wu.id = w.userFk
WHERE c.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -14,44 +13,10 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(clientId) {
return db.findOne( return this.findOneFromDef('client', [clientId]);
`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 = ?`, [clientId]);
}, },
fetchSales(clientId, from, to) { fetchSales(clientId, from, to) {
return db.rawSql( return this.rawSqlFromDef('sales', [clientId, from, to]);
`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`, [clientId, from, to]);
}, },
}, },
components: { components: {

View File

@ -0,0 +1,13 @@
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

@ -0,0 +1,20 @@
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

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -21,37 +20,10 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(claimId) { fetchClient(claimId) {
return db.findOne( return this.findOneFromDef('client', [claimId]);
`SELECT
c.id,
c.socialName,
c.name,
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) { fetchSales(claimId) {
return db.rawSql( return this.rawSqlFromDef('sales', [claimId]);
`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: { components: {

View File

@ -0,0 +1,19 @@
SELECT
c.id,
c.socialName,
c.name,
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 = ?

View File

@ -0,0 +1,8 @@
SELECT
s.id,
s.quantity,
s.concept,
cb.quantity claimQuantity
FROM claimBeginning cb
JOIN sale s ON s.id = cb.saleFk
WHERE cb.claimFk = ?

View File

@ -16,4 +16,8 @@
h3 { h3 {
font-weight: 100; font-weight: 100;
color: #555 color: #555
}
.ticket-info {
font-size: 20px
} }

View File

@ -16,7 +16,7 @@
<div class="size50"> <div class="size50">
<div class="size75"> <div class="size75">
<h1 class="title uppercase">{{$t('title')}}</h1> <h1 class="title uppercase">{{$t('title')}}</h1>
<table class="row-oriented"> <table class="row-oriented ticket-info">
<tbody> <tbody>
<tr> <tr>
<td class="font gray uppercase">{{$t('clientId')}}</td> <td class="font gray uppercase">{{$t('clientId')}}</td>

View File

@ -1,5 +1,4 @@
const config = require(`${appPath}/core/config`); const config = require(`${appPath}/core/config`);
const db = require(`${appPath}/core/database`);
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -42,132 +41,30 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(ticketId) { fetchClient(ticketId) {
return db.findOne( return this.findOneFromDef('client', [ticketId]);
`SELECT
c.id,
c.socialName,
c.street,
c.fi
FROM ticket t
JOIN client c ON c.id = t.clientFk
WHERE t.id = ?`, [ticketId]);
}, },
fetchTicket(ticketId) { fetchTicket(ticketId) {
return db.findOne( return this.findOneFromDef('ticket', [ticketId]);
`SELECT
t.id,
t.shipped,
c.code companyCode
FROM ticket t
JOIN company c ON c.id = t.companyFk
WHERE t.id = ?`, [ticketId]);
}, },
fetchAddress(ticketId) { fetchAddress(ticketId) {
return db.findOne( return this.findOneFromDef(`address`, [ticketId]);
`SELECT
a.nickname,
a.street,
a.postalCode,
a.city,
p.name province
FROM ticket t
JOIN address a ON a.clientFk = t.clientFk
AND a.id = t.addressFk
LEFT JOIN province p ON p.id = a.provinceFk
WHERE t.id = ?`, [ticketId]);
},
fetchSales(ticketId) {
return db.rawSql(
`SELECT
s.id,
s.itemFk,
s.concept,
s.quantity,
s.price,
s.price - SUM(IF(ctr.id = 6,
sc.value,
0)) netPrice,
s.discount,
i.size,
i.stems,
i.category,
it.id itemTypeId,
o.code AS origin,
i.inkFk,
s.ticketFk,
tcl.code vatType,
ibwg.ediBotanic, ppa.denomination, pp.number passportNumber,
be.isProtectedZone, c.code AS countryCode,
i.tag5, i.value5,
i.tag6, i.value6, i.tag7, i.value7
FROM vn.sale s
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
LEFT JOIN component cr ON cr.id = sc.componentFk
LEFT JOIN componentType ctr ON ctr.id = cr.typeFk
LEFT JOIN item i ON i.id = s.itemFk
LEFT JOIN ticket t ON t.id = s.ticketFk
LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN country c ON c.id = o.countryFk
LEFT JOIN supplier sp ON sp.id = t.companyFk
LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id
AND itc.countryFk = sp.countryFk
LEFT JOIN taxClass tcl ON tcl.id = itc.taxClassFk
LEFT JOIN plantpassport pp ON pp.producerFk = i.producerFk
LEFT JOIN plantpassportAuthority ppa ON ppa.id = pp.plantpassportAuthorityFk
LEFT JOIN itemBotanicalWithGenus ibwg ON ibwg.itemFk = i.id
LEFT JOIN botanicExport be ON be.restriction = 'pasaporte fitosanitario'
LEFT JOIN ediGenus eg ON eg.id = be.ediGenusFk
LEFT JOIN ediSpecie es ON es.id = be.ediSpecieFk
AND ibwg.ediBotanic LIKE CONCAT(
IFNULL(eg.latinGenusName, ''),
IF(es.latinSpeciesName > '',
CONCAT(' ', es.latinSpeciesName), ''),
'%')
WHERE s.ticketFk = ?
GROUP BY s.id
ORDER BY (it.isPackaging), s.concept, s.itemFk`, [ticketId]);
},
fetchTaxes(ticketId) {
return db.rawSql(`CALL vn.ticketGetTaxAdd(?)`, [ticketId]).then(rows => {
return rows[0];
});
},
fetchPackagings(ticketId) {
return db.rawSql(
`SELECT
tp.quantity,
i.name,
p.itemFk
FROM ticketPackaging tp
JOIN packaging p ON p.id = tp.packagingFk
JOIN item i ON i.id = p.itemFk
WHERE tp.ticketFk = ?
ORDER BY itemFk`, [ticketId]);
},
fetchServices(ticketId) {
return db.rawSql(
`SELECT
tc.description taxDescription,
ts.description,
ts.quantity,
ts.price
FROM ticketService ts
JOIN taxClass tc ON tc.id = ts.taxClassFk
WHERE ts.ticketFk = ?`, [ticketId]);
}, },
fetchSignature(ticketId) { fetchSignature(ticketId) {
return db.findOne( return this.findOneFromDef('signature', [ticketId]);
`SELECT
d.id,
d.created
FROM ticket t
JOIN ticketDms dt ON dt.ticketFk = t.id
JOIN dms d ON d.id = dt.dmsFk
AND d.file LIKE '%.png'
WHERE t.id = ?`, [ticketId]);
}, },
fetchTaxes(ticketId) {
return this.findOneFromDef(`taxes`, [ticketId]);
},
fetchSales(ticketId) {
return this.rawSqlFromDef('sales', [ticketId]);
},
fetchPackagings(ticketId) {
return this.rawSqlFromDef('packagings', [ticketId]);
},
fetchServices(ticketId) {
return this.rawSqlFromDef('services', [ticketId]);
},
getSubTotal() { getSubTotal() {
let subTotal = 0.00; let subTotal = 0.00;
this.sales.forEach(sale => { this.sales.forEach(sale => {
@ -194,7 +91,7 @@ module.exports = {
}, },
getTotal() { getTotal() {
return this.getTotalBase() + this.getTotalTax(); return this.getTotalBase() + this.getTotalTax();
}, }
}, },
components: { components: {
'report-header': reportHeader.build(), 'report-header': reportHeader.build(),

View File

@ -0,0 +1,11 @@
SELECT
a.nickname,
a.street,
a.postalCode,
a.city,
p.name province
FROM ticket t
JOIN address a ON a.clientFk = t.clientFk
AND a.id = t.addressFk
LEFT JOIN province p ON p.id = a.provinceFk
WHERE t.id = ?

View File

@ -0,0 +1,8 @@
SELECT
c.id,
c.socialName,
c.street,
c.fi
FROM ticket t
JOIN client c ON c.id = t.clientFk
WHERE t.id = ?

View File

@ -0,0 +1,9 @@
SELECT
tp.quantity,
i.name,
p.itemFk
FROM ticketPackaging tp
JOIN packaging p ON p.id = tp.packagingFk
JOIN item i ON i.id = p.itemFk
WHERE tp.ticketFk = ?
ORDER BY itemFk

View File

@ -0,0 +1,53 @@
SELECT
s.id,
s.itemFk,
s.concept,
s.quantity,
s.price,
s.price - SUM(IF(ctr.id = 6, sc.value, 0)) netPrice,
s.discount,
i.size,
i.stems,
i.category,
it.id itemTypeId,
o.code AS origin,
i.inkFk,
s.ticketFk,
tcl.code vatType,
ibwg.ediBotanic,
ppa.denomination,
pp.number passportNumber,
be.isProtectedZone, c.code AS countryCode,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM vn.sale s
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
LEFT JOIN component cr ON cr.id = sc.componentFk
LEFT JOIN componentType ctr ON ctr.id = cr.typeFk
LEFT JOIN item i ON i.id = s.itemFk
LEFT JOIN ticket t ON t.id = s.ticketFk
LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN country c ON c.id = o.countryFk
LEFT JOIN supplier sp ON sp.id = t.companyFk
LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id
AND itc.countryFk = sp.countryFk
LEFT JOIN taxClass tcl ON tcl.id = itc.taxClassFk
LEFT JOIN plantpassport pp ON pp.producerFk = i.producerFk
LEFT JOIN plantpassportAuthority ppa ON ppa.id = pp.plantpassportAuthorityFk
LEFT JOIN itemBotanicalWithGenus ibwg ON ibwg.itemFk = i.id
LEFT JOIN botanicExport be ON be.restriction = 'pasaporte fitosanitario'
LEFT JOIN ediGenus eg ON eg.id = be.ediGenusFk
LEFT JOIN ediSpecie es ON es.id = be.ediSpecieFk
AND ibwg.ediBotanic LIKE CONCAT(
IFNULL(eg.latinGenusName, ''),
IF(es.latinSpeciesName > '',
CONCAT(' ', es.latinSpeciesName), ''),
'%')
WHERE s.ticketFk = ?
GROUP BY s.id
ORDER BY (it.isPackaging), s.concept, s.itemFk

View File

@ -0,0 +1,8 @@
SELECT
tc.description taxDescription,
ts.description,
ts.quantity,
ts.price
FROM ticketService ts
JOIN taxClass tc ON tc.id = ts.taxClassFk
WHERE ts.ticketFk = ?

View File

@ -0,0 +1,8 @@
SELECT
d.id,
d.created
FROM ticket t
JOIN ticketDms dt ON dt.ticketFk = t.id
JOIN dms d ON d.id = dt.dmsFk
AND d.file LIKE '%.png'
WHERE t.id = ?

View File

@ -0,0 +1 @@
CALL vn.ticketGetTaxAdd(?)

View File

@ -0,0 +1,7 @@
SELECT
t.id,
t.shipped,
c.code companyCode
FROM ticket t
JOIN company c ON c.id = t.companyFk
WHERE t.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -28,60 +27,10 @@ module.exports = {
}, },
methods: { methods: {
fetchRoutes(routesId) { fetchRoutes(routesId) {
return db.rawSql( return this.rawSqlFromDef('routes', {routesId});
`SELECT
r.id,
r.m3,
r.created,
r.time,
u.nickName userNickName,
v.tradeMark vehicleTradeMark,
v.model vehicleModel,
v.numberPlate plateNumber,
am.name agencyName
FROM route r
LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk
LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
WHERE r.id IN(:routesId)`, {routesId});
}, },
fetchTickets(routesId) { fetchTickets(routesId) {
return db.rawSql( return this.rawSqlFromDef('tickets', {routesId});
`SELECT
t.nickname addressName,
t.packages,
t.priority,
t.id,
t.clientFk,
t.companyFk,
t.routeFk,
if(a.phone, a.phone, c.phone) AS phone,
if(a.mobile, a.mobile, c.mobile) AS mobile,
wh.name warehouseName,
a.city,
a.street,
a.postalCode,
LPAD(a.id, 5, '0') AS addressFk,
p.name province,
0 AS import,
am.name ticketAgency,
tob.description,
s.shipFk,
u.nickName salesPersonName
FROM route r
LEFT JOIN ticket t ON t.routeFk = r.id
LEFT JOIN address a ON a.id = t.addressFk
LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker w ON w.id = client_getSalesPerson(t.clientFk, CURDATE())
LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 3
LEFT JOIN province p ON a.provinceFk = p.id
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN stowaway s ON s.id = t.id
WHERE r.id IN(:routesId)
ORDER BY t.priority, t.id`, {routesId});
} }
}, },
components: { components: {

View File

@ -0,0 +1,16 @@
SELECT
r.id,
r.m3,
r.created,
r.time,
u.nickName userNickName,
v.tradeMark vehicleTradeMark,
v.model vehicleModel,
v.numberPlate plateNumber,
am.name agencyName
FROM route r
LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk
LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
WHERE r.id IN(:routesId)

View File

@ -0,0 +1,34 @@
SELECT
t.nickname addressName,
t.packages,
t.priority,
t.id,
t.clientFk,
t.companyFk,
t.routeFk,
if(a.phone, a.phone, c.phone) AS phone,
if(a.mobile, a.mobile, c.mobile) AS mobile,
wh.name warehouseName,
a.city,
a.street,
a.postalCode,
LPAD(a.id, 5, '0') AS addressFk,
p.name province,
0 AS import,
am.name ticketAgency,
tob.description,
s.shipFk,
u.nickName salesPersonName
FROM route r
LEFT JOIN ticket t ON t.routeFk = r.id
LEFT JOIN address a ON a.id = t.addressFk
LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker w ON w.id = client_getSalesPerson(t.clientFk, CURDATE())
LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 3
LEFT JOIN province p ON a.provinceFk = p.id
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN stowaway s ON s.id = t.id
WHERE r.id IN(:routesId)
ORDER BY t.priority, t.id

View File

@ -1,4 +1,3 @@
const db = require(`${appPath}/core/database`);
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -18,50 +17,13 @@ module.exports = {
}, },
methods: { methods: {
fetchSupplier(entryId) { fetchSupplier(entryId) {
return db.findOne( return this.findOneFromDef('supplier', [entryId]);
`SELECT
s.name,
s.street,
s.nif,
s.postCode,
s.city,
p.name province
FROM supplier s
JOIN entry e ON e.supplierFk = s.id
LEFT JOIN province p ON p.id = s.provinceFk
WHERE e.id = ?`, [entryId]);
}, },
fetchEntry(entryId) { fetchEntry(entryId) {
return db.findOne( return this.findOneFromDef('entry', [entryId]);
`SELECT
e.id,
e.ref,
e.notes,
c.code companyCode,
t.landed
FROM entry e
JOIN travel t ON t.id = e.travelFk
JOIN company c ON c.id = e.companyFk
WHERE e.id = ?`, [entryId]);
}, },
fetchBuys(entryId) { fetchBuys(entryId) {
return db.rawSql( return this.rawSqlFromDef('buys', [entryId]);
`SELECT
b.itemFk,
b.quantity,
b.buyingValue,
b.stickers box,
b.packing,
i.name itemName,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM buy b
JOIN item i ON i.id = b.itemFk
WHERE b.entryFk = ?`, [entryId]);
}, },
getTotal() { getTotal() {
let total = 0.00; let total = 0.00;

View File

@ -0,0 +1,16 @@
SELECT
b.itemFk,
b.quantity,
b.buyingValue,
b.stickers box,
b.packing,
i.name itemName,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM buy b
JOIN item i ON i.id = b.itemFk
WHERE b.entryFk = ?

View File

@ -0,0 +1,10 @@
SELECT
e.id,
e.ref,
e.notes,
c.code companyCode,
t.landed
FROM entry e
JOIN travel t ON t.id = e.travelFk
JOIN company c ON c.id = e.companyFk
WHERE e.id = ?

View File

@ -0,0 +1,11 @@
SELECT
s.name,
s.street,
s.nif,
s.postCode,
s.city,
p.name province
FROM supplier s
JOIN entry e ON e.supplierFk = s.id
LEFT JOIN province p ON p.id = s.provinceFk
WHERE e.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
const qrcode = require('qrcode'); const qrcode = require('qrcode');
@ -30,26 +29,10 @@ module.exports = {
}, },
methods: { methods: {
fetchItem(id, warehouseId) { fetchItem(id, warehouseId) {
return db.findOne( return this.findOneFromDef('item', [id, warehouseId]);
`SELECT
i.id,
i.name,
i.stems,
i.size,
b.packing
FROM vn.item i
JOIN cache.last_buy clb ON clb.item_id = i.id
JOIN vn.buy b ON b.id = clb.buy_id
JOIN vn.entry e ON e.id = b.entryFk
WHERE i.id = ? AND clb.warehouse_id = ?`, [id, warehouseId]);
}, },
fetchItemTags(itemId) { fetchItemTags(itemId) {
return db.rawSql( return this.rawSqlFromDef('itemTags', [itemId]).then(rows => {
`SELECT t.code, t.name, it.value
FROM vn.itemTag it
JOIN vn.tag t ON t.id = it.tagFk
WHERE it.itemFk = ?
`, [itemId]).then(rows => {
const tags = {}; const tags = {};
rows.forEach(row => tags[row.code] = row.value); rows.forEach(row => tags[row.code] = row.value);

View File

@ -0,0 +1,11 @@
SELECT
i.id,
i.name,
i.stems,
i.size,
b.packing
FROM vn.item i
JOIN cache.last_buy clb ON clb.item_id = i.id
JOIN vn.buy b ON b.id = clb.buy_id
JOIN vn.entry e ON e.id = b.entryFk
WHERE i.id = ? AND clb.warehouse_id = ?

View File

@ -0,0 +1,4 @@
SELECT t.code, t.name, it.value
FROM vn.itemTag it
JOIN vn.tag t ON t.id = it.tagFk
WHERE it.itemFk = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -24,28 +23,12 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(clientId) {
return db.findOne( return this.findOneFromDef('client', [clientId]);
`SELECT
c.id,
c.socialName,
c.street,
c.postcode,
c.city,
c.fi,
p.name AS province,
ct.country
FROM client c
JOIN country ct ON ct.id = c.countryFk
LEFT JOIN province p ON p.id = c.provinceFk
WHERE c.id = ?`, [clientId]);
}, },
fetchSales(clientId, companyId) { fetchSales(clientId, companyId) {
return db.rawSql( return this.findOneFromDef('sales', {
`CALL vn.clientGetDebtDiary(:clientId, :companyId)`, { clientId: clientId,
clientId: clientId, companyId: companyId,
companyId: companyId,
}).then(rows => {
return rows[0];
}); });
}, },
getBalance(sale) { getBalance(sale) {

View File

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

View File

@ -0,0 +1 @@
CALL vn.clientGetDebtDiary(:clientId, :companyId)

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -14,27 +13,10 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(receiptId) { fetchClient(receiptId) {
return db.findOne( return this.findOneFromDef('client', [receiptId]);
`SELECT
c.id,
c.socialName,
u.lang locale
FROM receipt r
JOIN client c ON c.id = r.clientFk
JOIN account.user u ON u.id = c.id
WHERE r.id = ?`, [receiptId]);
}, },
fetchReceipt(receiptId) { fetchReceipt(receiptId) {
return db.findOne( return this.findOneFromDef('receipt', [receiptId]);
`SELECT
r.id,
r.amountPaid,
r.amountUnpaid,
r.payed,
r.companyFk
FROM receipt r
JOIN client c ON c.id = r.clientFk
WHERE r.id = ?`, [receiptId]);
} }
}, },
components: { components: {

View File

@ -0,0 +1,8 @@
SELECT
c.id,
c.socialName,
u.lang locale
FROM receipt r
JOIN client c ON c.id = r.clientFk
JOIN account.user u ON u.id = c.id
WHERE r.id = ?

View File

@ -0,0 +1,9 @@
SELECT
r.id,
r.amountPaid,
r.amountUnpaid,
r.payed,
r.companyFk
FROM receipt r
JOIN client c ON c.id = r.clientFk
WHERE r.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -21,46 +20,10 @@ const rptSepaCore = {
}, },
methods: { methods: {
fetchClient(clientId, companyId) { fetchClient(clientId, companyId) {
return db.findOne( return this.findOneFromDef('client', {companyId, clientId});
`SELECT
c.id,
m.code mandateCode,
c.socialName,
c.street,
c.postcode,
c.city,
c.fi,
p.name AS province,
ct.country,
ct.code AS countryCode,
ct.ibanLength AS ibanLength
FROM client c
JOIN country ct ON ct.id = c.countryFk
LEFT JOIN mandate m ON m.clientFk = c.id
AND m.companyFk = :companyId AND m.finished IS NULL
LEFT JOIN province p ON p.id = c.provinceFk
WHERE (m.companyFk = :companyId OR m.companyFk IS NULL) AND c.id = :clientId
ORDER BY m.created DESC LIMIT 1`, {companyId, clientId});
}, },
fetchSupplier(clientId, companyId) { fetchSupplier(clientId, companyId) {
return db.findOne( return this.findOneFromDef('supplier', {companyId, clientId});
`SELECT
m.code mandateCode,
s.name,
s.street,
sc.country,
s.postCode,
s.city,
sp.name province
FROM client c
LEFT JOIN mandate m ON m.clientFk = c.id
AND m.companyFk = :companyId AND m.finished IS NULL
LEFT JOIN supplier s ON s.id = m.companyFk
LEFT JOIN country sc ON sc.id = s.countryFk
LEFT JOIN province sp ON sp.id = s.provinceFk
LEFT JOIN province p ON p.id = c.provinceFk
WHERE (m.companyFk = :companyId OR m.companyFk IS NULL) AND c.id = :clientId
ORDER BY m.created DESC LIMIT 1`, {companyId, clientId});
} }
}, },
components: { components: {

View File

@ -0,0 +1,19 @@
SELECT
c.id,
m.code mandateCode,
c.socialName,
c.street,
c.postcode,
c.city,
c.fi,
p.name AS province,
ct.country,
ct.code AS countryCode,
ct.ibanLength AS ibanLength
FROM client c
JOIN country ct ON ct.id = c.countryFk
LEFT JOIN mandate m ON m.clientFk = c.id
AND m.companyFk = :companyId AND m.finished IS NULL
LEFT JOIN province p ON p.id = c.provinceFk
WHERE (m.companyFk = :companyId OR m.companyFk IS NULL) AND c.id = :clientId
ORDER BY m.created DESC LIMIT 1

View File

@ -0,0 +1,17 @@
SELECT
m.code mandateCode,
s.name,
s.street,
sc.country,
s.postCode,
s.city,
sp.name province
FROM client c
LEFT JOIN mandate m ON m.clientFk = c.id
AND m.companyFk = :companyId AND m.finished IS NULL
LEFT JOIN supplier s ON s.id = m.companyFk
LEFT JOIN country sc ON sc.id = s.countryFk
LEFT JOIN province sp ON sp.id = s.provinceFk
LEFT JOIN province p ON p.id = c.provinceFk
WHERE (m.companyFk = :companyId OR m.companyFk IS NULL) AND c.id = :clientId
ORDER BY m.created DESC LIMIT 1

View File

@ -2,8 +2,9 @@ div.text {
font-family: Tahoma; font-family: Tahoma;
font-weight: bold; font-weight: bold;
color: white; color: white;
font-size: 7.5em; font-size: 12em;
text-align: center; text-align: center;
background-color: black; background-color: black;
margin-bottom: 0.2em margin: 0.30em;
padding: 30px 0
} }

View File

@ -0,0 +1,4 @@
{
"landscape": true,
"format": "A4"
}

View File

@ -0,0 +1,9 @@
SELECT
r.id,
r.time,
am.name agencyName,
v.numberPlate plateNumber
FROM route r
JOIN agencyMode am ON am.id = r.agencyModeFk
JOIN vehicle v ON v.id = r.vehicleFk
WHERE r.id = :routeId

View File

@ -1,5 +1,3 @@
const db = require(`${appPath}/core/database`);
module.exports = { module.exports = {
name: 'zone', name: 'zone',
async serverPrefetch() { async serverPrefetch() {
@ -10,16 +8,7 @@ module.exports = {
}, },
methods: { methods: {
fetchZone(routeId) { fetchZone(routeId) {
return db.findOne( return this.findOneFromDef('zone', {routeId});
`SELECT
r.id,
r.time,
am.name agencyName,
v.numberPlate plateNumber
FROM route r
JOIN agencyMode am ON am.id = r.agencyModeFk
JOIN vehicle v ON v.id = r.vehicleFk
WHERE r.id = :routeId`, {routeId});
} }
}, },
props: { props: {