diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 498a9dc7c..bb33487a3 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -35,7 +35,7 @@ INSERT INTO `vn`.`packagingConfig`(`upperGap`) UPDATE `account`.`role` SET id = 100 WHERE id = 0; INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`) - SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'EN' + SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'en' FROM `account`.`role` WHERE id <> 20 ORDER BY id; @@ -55,18 +55,18 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`) VALUES - (101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'ES'), - (102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'EN'), - (103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'FR'), - (104, 'TonyStark', 'Tony Stark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'ES'), - (105, 'MaxEisenhardt', 'Max Eisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'PT'), - (106, 'DavidCharlesHaller', 'David Charles Haller', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'EN'), - (107, 'HankPym', 'Hank Pym', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'EN'), - (108, 'CharlesXavier', 'Charles Xavier', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'EN'), - (109, 'BruceBanner', 'Bruce Banner', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'EN'), - (110, 'JessicaJones', 'Jessica Jones', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'EN'), - (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'EN'), - (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'EN'); + (101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es'), + (102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en'), + (103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr'), + (104, 'TonyStark', 'Tony Stark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'es'), + (105, 'MaxEisenhardt', 'Max Eisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt'), + (106, 'DavidCharlesHaller', 'David Charles Haller', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en'), + (107, 'HankPym', 'Hank Pym', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'HankPym@mydomain.com', 'en'), + (108, 'CharlesXavier', 'Charles Xavier', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'CharlesXavier@mydomain.com', 'en'), + (109, 'BruceBanner', 'Bruce Banner', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'BruceBanner@mydomain.com', 'en'), + (110, 'JessicaJones', 'Jessica Jones', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'JessicaJones@mydomain.com', 'en'), + (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'), + (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'); INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) VALUES diff --git a/print/templates/reports/entry-order/assets/css/import.js b/print/templates/reports/entry-order/assets/css/import.js new file mode 100644 index 000000000..fd8796c2b --- /dev/null +++ b/print/templates/reports/entry-order/assets/css/import.js @@ -0,0 +1,9 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css new file mode 100644 index 000000000..4215e7181 --- /dev/null +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -0,0 +1,6 @@ + + +h3 { + font-weight: 100; + color: #555 +} \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html new file mode 100644 index 000000000..cbb0de0d5 --- /dev/null +++ b/print/templates/reports/entry-order/entry-order.html @@ -0,0 +1,146 @@ + + + + + + + + + +
+ +
+
+ + +
+
+ +
+
+
+
+
+
+

{{$t('title')}}

+ + + + + + + + + + + + + + + +
{{$t('entryId')}}{{entry.id}}
{{$t('date')}}{{entry.landed | date('%d-%m-%Y')}}
{{$t('ref')}}{{entry.ref}}
+
+
+
+
+
+
{{$t('supplierData')}}
+
+

{{supplier.name}}

+
+ {{supplier.street}} +
+
+ {{supplier.postCode}}, {{supplier.city}}, ({{supplier.province}}) +
+
+ {{supplier.nif}} +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
{{$t('boxes')}}{{$t('packing')}}{{$t('concept')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
+ {{$t('total')}} + {{getTotal() | currency('EUR', locale)}}
+ +
+
+
+
+

{{$t('notes')}}

+
+ {{entry.notes}} +
+
+
+
+
+
+
+ +
+
+ + +
+
+
+ + \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.js b/print/templates/reports/entry-order/entry-order.js new file mode 100755 index 000000000..55492fbaf --- /dev/null +++ b/print/templates/reports/entry-order/entry-order.js @@ -0,0 +1,85 @@ +const db = require(`${appPath}/core/database`); +const Component = require(`${appPath}/core/component`); +const reportHeader = new Component('report-header'); +const reportFooter = new Component('report-footer'); + +module.exports = { + name: 'entry-order', + async serverPrefetch() { + this.supplier = await this.fetchSupplier(this.entryId); + this.entry = await this.fetchEntry(this.entryId); + this.buys = await this.fetchBuys(this.entryId); + + if (!this.entry) + throw new Error('Something went wrong'); + }, + data() { + return {totalBalance: 0.00}; + }, + methods: { + fetchSupplier(entryId) { + return db.findOne( + `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) { + return db.findOne( + `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) { + return db.rawSql( + `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() { + let total = 0.00; + this.buys.forEach(buy => { + total += buy.quantity * buy.buyingValue; + }); + + return total; + } + }, + components: { + 'report-header': reportHeader.build(), + 'report-footer': reportFooter.build() + }, + props: { + entryId: { + type: String, + required: true + } + } +}; diff --git a/print/templates/reports/entry-order/locale/en.yml b/print/templates/reports/entry-order/locale/en.yml new file mode 100644 index 000000000..e69de29bb diff --git a/print/templates/reports/entry-order/locale/es.yml b/print/templates/reports/entry-order/locale/es.yml new file mode 100644 index 000000000..3c29d6401 --- /dev/null +++ b/print/templates/reports/entry-order/locale/es.yml @@ -0,0 +1,16 @@ +title: Pedido +supplierName: Proveedor +supplierStreet: Dirección +entryId: Referencia interna +date: Fecha +ref: Nº Factura +boxes: Cajas +packing: U/C +quantity: Cantidad +price: Precio +amount: Importe +concept: Descripción +total: Total +entry: Entrada {0} +supplierData: Datos del proveedor +notes: Notas \ No newline at end of file