diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html
index db1581c4f..33e92db40 100644
--- a/modules/item/front/diary/index.html
+++ b/modules/item/front/diary/index.html
@@ -22,7 +22,7 @@
- Date
+ Date
Ticket/Entry
State
Reference
@@ -40,7 +40,7 @@
ng-repeat="sale in sales"
vn-repeat-last
on-last="$ctrl.scrollToLine()">
-
+
{{::sale.date | dateTime:'dd/MM/yyyy' }}
diff --git a/print/report/rpt-delivery-note/index.js b/print/report/rpt-delivery-note/index.js
index 68450252c..410b149c9 100755
--- a/print/report/rpt-delivery-note/index.js
+++ b/print/report/rpt-delivery-note/index.js
@@ -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
diff --git a/print/report/rpt-sepa-core/index.js b/print/report/rpt-sepa-core/index.js
index c98ddbcb4..66b60cf3e 100755
--- a/print/report/rpt-sepa-core/index.js
+++ b/print/report/rpt-sepa-core/index.js
@@ -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());