fixed core with correct mandate code #1288
gitea/salix/test This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-04-01 07:05:37 +02:00
parent 05eea132cd
commit 2c22ee9c2e
2 changed files with 27 additions and 32 deletions

View File

@ -82,7 +82,8 @@ module.exports = {
return database.pool.query(
`SELECT
t.id,
t.shipped
t.shipped,
t.companyFk
FROM ticket t
JOIN client c ON c.id = t.clientFk
JOIN account.user u ON u.id = c.id
@ -105,34 +106,27 @@ module.exports = {
fetchSales(ticketFk) {
return database.pool.query(
`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,
ita.tag1,
ita.val1,
ita.tag2,
ita.val2,
ita.tag3,
ita.val3
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 componentRate cr ON cr.id = sc.componentFk
@ -146,7 +140,6 @@ module.exports = {
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 itemTagArranged ita ON ita.itemFk = s.itemFk
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

View File

@ -46,12 +46,14 @@ module.exports = {
FROM client c
JOIN account.user u ON u.id = c.id
JOIN country ct ON ct.id = c.countryFk
JOIN mandate m ON m.clientFk = c.id AND m.finished IS NULL
JOIN mandate m ON m.clientFk = c.id
AND m.companyFk = ? AND m.finished IS NULL
JOIN supplier s ON s.id = m.companyFk
JOIN country sc ON sc.id = s.countryFk
JOIN province sp ON sp.id = s.provinceFk
LEFT JOIN province p ON p.id = c.provinceFk
WHERE m.companyFk = ? AND c.id = ?`, [companyFk, clientFk]);
WHERE m.companyFk = ? AND c.id = ?
ORDER BY m.created DESC LIMIT 1`, [companyFk, companyFk, clientFk]);
},
dated: () => {
return strftime('%d-%m-%Y', new Date());