{{::buy.buyingValue | currency: 'EUR':2}} | -{{::buy.freightValue | currency: 'EUR':2}} | -{{::buy.comissionValue | currency: 'EUR':2}} | -{{::buy.packageValue | currency: 'EUR':2}} | +{{::buy.buyingValue | currency: 'EUR':3}} | +{{::buy.freightValue | currency: 'EUR':3}} | +{{::buy.comissionValue | currency: 'EUR':3}} | +{{::buy.packageValue | currency: 'EUR':3}} |
|
- {{::buy.price2 | currency: 'EUR':2}} | -{{::buy.price3 | currency: 'EUR':2}} | -{{::buy.minPrice | currency: 'EUR':2}} | +{{::buy.price2 | currency: 'EUR':3}} | +{{::buy.price3 | currency: 'EUR':3}} | +{{::buy.minPrice | currency: 'EUR':3}} | {{::buy.ektFk | dashIfEmpty}} | {{::buy.weight}} | {{::buy.packageFk}} | diff --git a/modules/invoiceIn/back/methods/invoice-in/negativeBasesCsv.js b/modules/invoiceIn/back/methods/invoice-in/negativeBasesCsv.js deleted file mode 100644 index 963151b7d..000000000 --- a/modules/invoiceIn/back/methods/invoice-in/negativeBasesCsv.js +++ /dev/null @@ -1,53 +0,0 @@ -const {toCSV} = require('vn-loopback/util/csv'); - -module.exports = Self => { - Self.remoteMethodCtx('negativeBasesCsv', { - description: 'Returns the negative bases as .csv', - accessType: 'READ', - accepts: [{ - arg: 'negativeBases', - type: ['object'], - required: true - }, - { - arg: 'from', - type: 'date', - description: 'From date' - }, - { - arg: 'to', - type: 'date', - description: 'To date' - }], - returns: [ - { - arg: 'body', - type: 'file', - root: true - }, { - arg: 'Content-Type', - type: 'String', - http: {target: 'header'} - }, { - arg: 'Content-Disposition', - type: 'String', - http: {target: 'header'} - } - ], - http: { - path: '/negativeBasesCsv', - verb: 'GET' - } - }); - - Self.negativeBasesCsv = async ctx => { - const args = ctx.args; - const content = toCSV(args.negativeBases); - - return [ - content, - 'text/csv', - `attachment; filename="negative-bases-${new Date(args.from).toLocaleDateString()}-${new Date(args.to).toLocaleDateString()}.csv"` - ]; - }; -}; diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 167f2ac34..51905ccb8 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -7,6 +7,4 @@ module.exports = Self => { require('../methods/invoice-in/invoiceInPdf')(Self); require('../methods/invoice-in/invoiceInEmail')(Self); require('../methods/invoice-in/getSerial')(Self); - require('../methods/invoice-in/negativeBases')(Self); - require('../methods/invoice-in/negativeBasesCsv')(Self); }; diff --git a/modules/invoiceIn/front/index.js b/modules/invoiceIn/front/index.js index c0374e996..e257cfee3 100644 --- a/modules/invoiceIn/front/index.js +++ b/modules/invoiceIn/front/index.js @@ -15,4 +15,3 @@ import './create'; import './log'; import './serial'; import './serial-search-panel'; -import './negative-bases'; diff --git a/modules/invoiceIn/front/negative-bases/locale/es.yml b/modules/invoiceIn/front/negative-bases/locale/es.yml deleted file mode 100644 index 9095eee22..000000000 --- a/modules/invoiceIn/front/negative-bases/locale/es.yml +++ /dev/null @@ -1,14 +0,0 @@ -Has To Invoice: Facturar -Download as CSV: Descargar como CSV -company: Compañía -country: País -clientId: Id Cliente -clientSocialName: Cliente -amount: Importe -taxableBase: Base -ticketFk: Id Ticket -isActive: Activo -hasToInvoice: Facturar -isTaxDataChecked: Datos comprobados -comercialId: Id Comercial -comercialName: Comercial diff --git a/modules/invoiceIn/front/routes.json b/modules/invoiceIn/front/routes.json index 40d061d1b..6f4d3d1a3 100644 --- a/modules/invoiceIn/front/routes.json +++ b/modules/invoiceIn/front/routes.json @@ -10,8 +10,7 @@ "menus": { "main": [ { "state": "invoiceIn.index", "icon": "icon-invoice-in"}, - { "state": "invoiceIn.serial", "icon": "icon-invoice-in"}, - { "state": "invoiceIn.negative-bases", "icon": "icon-ticket"} + { "state": "invoiceIn.serial", "icon": "icon-invoice-in"} ], "card": [ { @@ -53,15 +52,6 @@ "administrative" ] }, - { - "url": "/negative-bases", - "state": "invoiceIn.negative-bases", - "component": "vn-negative-bases", - "description": "Negative bases", - "acl": [ - "administrative" - ] - }, { "url": "/serial", "state": "invoiceIn.serial", diff --git a/modules/invoiceIn/back/methods/invoice-in/negativeBases.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js similarity index 93% rename from modules/invoiceIn/back/methods/invoice-in/negativeBases.js rename to modules/invoiceOut/back/methods/invoiceOut/negativeBases.js index 4c9a8984b..ae9c404af 100644 --- a/modules/invoiceIn/back/methods/invoice-in/negativeBases.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js @@ -96,16 +96,18 @@ module.exports = Self => { SELECT f.* FROM tmp.filter f`); - stmt.merge(conn.makeWhere(args.filter.where)); - stmt.merge(conn.makeOrderBy(args.filter.order)); - stmt.merge(conn.makeLimit(args.filter)); + if (args.filter) { + stmt.merge(conn.makeWhere(args.filter.where)); + stmt.merge(conn.makeOrderBy(args.filter.order)); + stmt.merge(conn.makeLimit(args.filter)); + } const negativeBasesIndex = stmts.push(stmt) - 1; stmts.push(`DROP TEMPORARY TABLE tmp.filter, tmp.ticket, tmp.ticketTax, tmp.ticketAmount`); const sql = ParameterizedSQL.join(stmts, ';'); - const result = await conn.executeStmt(sql, myOptions); + const result = await conn.executeStmt(sql); return negativeBasesIndex === 0 ? result : result[negativeBasesIndex]; }; diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js new file mode 100644 index 000000000..d70a8fce5 --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js @@ -0,0 +1,68 @@ +const {toCSV} = require('vn-loopback/util/csv'); + +module.exports = Self => { + Self.remoteMethodCtx('negativeBasesCsv', { + description: 'Returns the negative bases as .csv', + accessType: 'READ', + accepts: [ + { + arg: 'from', + type: 'date', + description: 'From date', + required: true + }, + { + arg: 'to', + type: 'date', + description: 'To date', + required: true + }], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/negativeBasesCsv', + verb: 'GET' + } + }); + + Self.negativeBasesCsv = async(ctx, options) => { + const $t = ctx.req.__; // $translate + const args = ctx.args; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const negativeBases = await Self.app.models.InvoiceOut.negativeBases(ctx, myOptions); + const locatedFields = []; + negativeBases.forEach(element => { + locatedFields.push(Object.keys(element).map(key => { + return {newName: $t(key), value: element[key]}; + }).filter(item => item !== null) + .reduce((result, item) => { + result[item.newName] = item.value; + return result; + }, {})); + }); + const content = toCSV(locatedFields); + + return [ + content, + 'text/csv', + `attachment; filename="negative-bases-${new Date(args.from).toLocaleDateString()}-${new Date(args.to).toLocaleDateString()}.csv"` + ]; + }; +}; diff --git a/modules/invoiceOut/back/methods/invoiceOut/refund.js b/modules/invoiceOut/back/methods/invoiceOut/refund.js index ba1fdfedd..ad480dc7d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/refund.js +++ b/modules/invoiceOut/back/methods/invoiceOut/refund.js @@ -35,7 +35,7 @@ module.exports = Self => { const tickets = await models.Ticket.find(filter, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); - const refundedTickets = await models.Ticket.refund(ticketsIds, true, myOptions); + const refundedTickets = await models.Ticket.refund(ticketsIds, myOptions); if (tx) await tx.commit(); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/negativeBases.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/negativeBases.spec.js similarity index 71% rename from modules/invoiceIn/back/methods/invoice-in/specs/negativeBases.spec.js rename to modules/invoiceOut/back/methods/invoiceOut/specs/negativeBases.spec.js index a5c6e3102..1164e894b 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/negativeBases.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/negativeBases.spec.js @@ -1,19 +1,18 @@ const models = require('vn-loopback/server/server').models; -describe('invoiceIn negativeBases()', () => { +describe('invoiceOut negativeBases()', () => { it('should return all negative bases in a date range', async() => { - const tx = await models.InvoiceIn.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; const ctx = { args: { from: new Date().setMonth(new Date().getMonth() - 12), - to: new Date(), - filter: {} + to: new Date() } }; try { - const result = await models.InvoiceIn.negativeBases(ctx, options); + const result = await models.InvoiceOut.negativeBases(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -26,7 +25,7 @@ describe('invoiceIn negativeBases()', () => { it('should throw an error if a date range is not in args', async() => { let error; - const tx = await models.InvoiceIn.beginTransaction({}); + const tx = await models.InvoiceOut.beginTransaction({}); const options = {transaction: tx}; const ctx = { args: { @@ -35,7 +34,7 @@ describe('invoiceIn negativeBases()', () => { }; try { - await models.InvoiceIn.negativeBases(ctx, options); + await models.InvoiceOut.negativeBases(ctx, options); await tx.rollback(); } catch (e) { error = e; diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js index c5a1ac603..35f2b4023 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/refund.spec.js @@ -17,7 +17,7 @@ describe('InvoiceOut refund()', () => { try { const result = await models.InvoiceOut.refund('T1111111', options); - expect(result.length).toEqual(1); + expect(result).toBeDefined(); await tx.rollback(); } catch (e) { diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index 6205abe7b..5fcef7744 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -17,4 +17,6 @@ module.exports = Self => { require('../methods/invoiceOut/invoiceCsvEmail')(Self); require('../methods/invoiceOut/invoiceOutPdf')(Self); require('../methods/invoiceOut/getInvoiceDate')(Self); + require('../methods/invoiceOut/negativeBases')(Self); + require('../methods/invoiceOut/negativeBasesCsv')(Self); }; diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index 456939119..57ea653a8 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -118,8 +118,11 @@ class Controller extends Section { const query = 'InvoiceOuts/refund'; const params = {ref: this.invoiceOut.ref}; this.$http.post(query, params).then(res => { - const ticketIds = res.data.map(ticket => ticket.id).join(', '); - this.vnApp.showSuccess(this.$t('The following refund tickets have been created', {ticketIds})); + const refundTicket = res.data; + this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { + ticketId: refundTicket.id + })); + this.$state.go('ticket.card.sale', {id: refundTicket.id}); }); } } diff --git a/modules/invoiceOut/front/index.js b/modules/invoiceOut/front/index.js index f7cebc0d0..723e3be5a 100644 --- a/modules/invoiceOut/front/index.js +++ b/modules/invoiceOut/front/index.js @@ -10,3 +10,4 @@ import './descriptor-popover'; import './descriptor-menu'; import './index/manual'; import './global-invoicing'; +import './negative-bases'; diff --git a/modules/invoiceIn/front/negative-bases/index.html b/modules/invoiceOut/front/negative-bases/index.html similarity index 96% rename from modules/invoiceIn/front/negative-bases/index.html rename to modules/invoiceOut/front/negative-bases/index.html index 5da8e7aad..26f67c7d4 100644 --- a/modules/invoiceIn/front/negative-bases/index.html +++ b/modules/invoiceOut/front/negative-bases/index.html @@ -1,6 +1,6 @@- Id Client + Client id | Client @@ -55,7 +55,7 @@ Base | - Id Ticket + Ticket id |
Active
diff --git a/modules/invoiceIn/front/negative-bases/index.js b/modules/invoiceOut/front/negative-bases/index.js
similarity index 79%
rename from modules/invoiceIn/front/negative-bases/index.js
rename to modules/invoiceOut/front/negative-bases/index.js
index 0f6f04692..1a838507c 100644
--- a/modules/invoiceIn/front/negative-bases/index.js
+++ b/modules/invoiceOut/front/negative-bases/index.js
@@ -58,18 +58,7 @@ export default class Controller extends Section {
}
downloadCSV() {
- const data = [];
- this.$.model._orgData.forEach(element => {
- data.push(Object.keys(element).map(key => {
- return {newName: this.$t(key), value: element[key]};
- }).filter(item => item !== null)
- .reduce((result, item) => {
- result[item.newName] = item.value;
- return result;
- }, {}));
- });
- this.vnReport.show('InvoiceIns/negativeBasesCsv', {
- negativeBases: data,
+ this.vnReport.show('InvoiceOuts/negativeBasesCsv', {
from: this.params.from,
to: this.params.to
});
diff --git a/modules/invoiceOut/front/negative-bases/locale/es.yml b/modules/invoiceOut/front/negative-bases/locale/es.yml
new file mode 100644
index 000000000..dd3432592
--- /dev/null
+++ b/modules/invoiceOut/front/negative-bases/locale/es.yml
@@ -0,0 +1,2 @@
+Has To Invoice: Facturar
+Download as CSV: Descargar como CSV
diff --git a/modules/invoiceIn/front/negative-bases/style.scss b/modules/invoiceOut/front/negative-bases/style.scss
similarity index 100%
rename from modules/invoiceIn/front/negative-bases/style.scss
rename to modules/invoiceOut/front/negative-bases/style.scss
diff --git a/modules/invoiceOut/front/routes.json b/modules/invoiceOut/front/routes.json
index c396a5334..f7f589b01 100644
--- a/modules/invoiceOut/front/routes.json
+++ b/modules/invoiceOut/front/routes.json
@@ -7,8 +7,8 @@
"menus": {
"main": [
{"state": "invoiceOut.index", "icon": "icon-invoice-out"},
- {"state": "invoiceOut.global-invoicing", "icon": "contact_support"}
-
+ {"state": "invoiceOut.global-invoicing", "icon": "contact_support"},
+ { "state": "invoiceOut.negative-bases", "icon": "icon-ticket"}
]
},
"routes": [
@@ -46,6 +46,15 @@
"state": "invoiceOut.card",
"abstract": true,
"component": "vn-invoice-out-card"
+ },
+ {
+ "url": "/negative-bases",
+ "state": "invoiceOut.negative-bases",
+ "component": "vn-negative-bases",
+ "description": "Negative bases",
+ "acl": [
+ "administrative"
+ ]
}
]
}
diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html
index a431d4fd6..dfafb02f3 100644
--- a/modules/item/front/request-search-panel/index.html
+++ b/modules/item/front/request-search-panel/index.html
@@ -42,7 +42,7 @@
{{centerText}}
-
+ + + + diff --git a/print/core/components/report-footer/report-footer.js b/print/core/components/report-footer/report-footer.js index 1ba36b1d7..0eaab8ce4 100755 --- a/print/core/components/report-footer/report-footer.js +++ b/print/core/components/report-footer/report-footer.js @@ -1,4 +1,17 @@ +/* eslint-disable no-tabs */ +const db = require('../../database'); + module.exports = { name: 'report-footer', - props: ['leftText', 'centerText'] + async serverPrefetch() { + this.company = await db.findOne( + `SELECT + ci.footnotes + FROM companyI18n ci + JOIN company c ON c.id = ci.companyFk + WHERE c.code = ? AND ci.lang = (SELECT lang FROM account.user WHERE id = ?)`, + [this.companyCode, this.recipientId]); + }, + + props: ['leftText', 'companyCode', 'recipientId', 'centerText'] }; diff --git a/print/core/components/report-header/report-header.html b/print/core/components/report-header/report-header.html index 0479e5caf..22f2068e2 100644 --- a/print/core/components/report-header/report-header.html +++ b/print/core/components/report-header/report-header.html @@ -8,7 +8,7 @@ {{companyName}}. {{company.street}}. {{company.postCode}} {{company.city}}. ☎ {{companyPhone}} - · {{$t('company.contactData')}} + · {{company.web}} - {{company.email}}
+
+
+
+ {{ $t('total') }}: {{tickets.length}}++
+
+ {{ $t('ticketId') }}: {{ticket.ticketId}} +{{ $t('clientId') }}: {{ticket.clientId}} +{{ $t('description') }}: {{ticket.description}} +{{ $t('amount') }}: {{ticket.amount}} € ++ + Puedes descargarlo haciendo clic en el adjunto de este correo. diff --git a/print/templates/email/receipt/receipt.html b/print/templates/email/receipt/receipt.html new file mode 100644 index 000000000..734552014 --- /dev/null +++ b/print/templates/email/receipt/receipt.html @@ -0,0 +1,9 @@ +
+
+
+
+ {{ $t('title') }}+{{$t('dear')}}, + +
+
@@ -242,7 +242,7 @@
|
---|