diff --git a/back/methods/dms/uploadFile.js b/back/methods/dms/uploadFile.js index 220f944d8..e137ca8ff 100644 --- a/back/methods/dms/uploadFile.js +++ b/back/methods/dms/uploadFile.js @@ -69,12 +69,22 @@ module.exports = Self => { if (!hasWriteRole) throw new UserError(`You don't have enough privileges`); + // Create final folder if not exists + const dmsType = await models.DmsType.findById(args.dmsTypeId); + await models.Container.getContainer(dmsType.path).catch(async err => { + if (err.code === 'ENOENT') { + await models.Container.createContainer({ + name: dmsType.path + }); + } + }); + + // Upload file to temporary path const uploaded = await models.Container.upload('temp', ctx.req, ctx.result, fileOptions); const files = Object.values(uploaded.files).map(file => { return file[0]; }); - const dmsType = await models.DmsType.findById(args.dmsTypeId); const promises = []; files.forEach(file => { diff --git a/db/changes/10050-pentecostes/00-dmsType.sql b/db/changes/10050-pentecostes/00-dmsType.sql deleted file mode 100644 index 1692c6f50..000000000 --- a/db/changes/10050-pentecostes/00-dmsType.sql +++ /dev/null @@ -1,4 +0,0 @@ -UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='5'; -UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='12'; -UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='14'; -UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='13'; diff --git a/db/changes/10050-pentecostes/02-dmsType.sql b/db/changes/10050-pentecostes/02-dmsType.sql new file mode 100644 index 000000000..24d88903f --- /dev/null +++ b/db/changes/10050-pentecostes/02-dmsType.sql @@ -0,0 +1,24 @@ +UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='5'; +UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='12'; +UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='14'; +UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='13'; +UPDATE `vn2008`.`gesttip` SET `code`='invoiceIn' WHERE `id`='1'; +UPDATE `vn2008`.`gesttip` SET `code`='officialDoc' WHERE `id`='2'; +UPDATE `vn2008`.`gesttip` SET `code`='hhrrData' WHERE `id`='3'; +UPDATE `vn2008`.`gesttip` SET `code`='deliveryNote' WHERE `id`='4'; +UPDATE `vn2008`.`gesttip` SET `code`='miscellaneous' WHERE `id`='5'; +UPDATE `vn2008`.`gesttip` SET `code`='tests' WHERE `id`='6'; +UPDATE `vn2008`.`gesttip` SET `code`='economicActivitiesTax' WHERE `id`='7'; +UPDATE `vn2008`.`gesttip` SET `code`='fiscal' WHERE `id`='8'; +UPDATE `vn2008`.`gesttip` SET `code`='vehicles' WHERE `id`='9'; +UPDATE `vn2008`.`gesttip` SET `code`='templates' WHERE `id`='10'; +UPDATE `vn2008`.`gesttip` SET `code`='contracts' WHERE `id`='11'; +UPDATE `vn2008`.`gesttip` SET `code`='paymentsLaw' WHERE `id`='12'; +UPDATE `vn2008`.`gesttip` SET `code`='trash' WHERE `id`='13'; +UPDATE `vn2008`.`gesttip` SET `code`='ticket' WHERE `id`='14'; +UPDATE `vn2008`.`gesttip` SET `code`='budgets' WHERE `id`='15'; +UPDATE `vn2008`.`gesttip` SET `code`='logistics' WHERE `id`='16'; +UPDATE `vn2008`.`gesttip` SET `code`='cmr' WHERE `id`='17'; +UPDATE `vn2008`.`gesttip` SET `code`='dua' WHERE `id`='18'; +UPDATE `vn2008`.`gesttip` SET `code`='fixedAssets' WHERE `id`='19'; + diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index fe9d40669..fc125872a 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -332,9 +332,9 @@ INSERT INTO `vn`.`observationType`(`id`,`description`) INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`) VALUES - (1, 1, 1, 'under the floor'), - (2, 1, 2, 'wears leather and goes out at night'), - (3, 1, 3, 'care with the dog'); + (1, 121, 1, 'under the floor'), + (2, 121, 2, 'wears leather and goes out at night'), + (3, 121, 3, 'care with the dog'); INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`) VALUES diff --git a/db/tests/cache/last_buy_refresh.spec.js b/db/tests/cache/last_buy_refresh.spec.js index e6203a00a..485c725bb 100644 --- a/db/tests/cache/last_buy_refresh.spec.js +++ b/db/tests/cache/last_buy_refresh.spec.js @@ -20,21 +20,27 @@ describe('last_buy_refresh()', () => { let lastBuyTable = result[lastBuyTableIndex]; - expect(lastBuyTable.length).toEqual(4); + expect(lastBuyTable.length).toEqual(6); expect(lastBuyTable[0].item_id).toEqual(1); expect(lastBuyTable[1].item_id).toEqual(2); expect(lastBuyTable[2].item_id).toEqual(3); expect(lastBuyTable[3].item_id).toEqual(4); + expect(lastBuyTable[4].item_id).toEqual(8); + expect(lastBuyTable[5].item_id).toEqual(9); expect(lastBuyTable[0].warehouse_id).toEqual(1); expect(lastBuyTable[1].warehouse_id).toEqual(1); expect(lastBuyTable[2].warehouse_id).toEqual(1); expect(lastBuyTable[3].warehouse_id).toEqual(1); + expect(lastBuyTable[4].warehouse_id).toEqual(1); + expect(lastBuyTable[5].warehouse_id).toEqual(1); expect(lastBuyTable[1].buy_id).toEqual(4); expect(lastBuyTable[0].buy_id).toEqual(3); expect(lastBuyTable[2].buy_id).toEqual(5); - expect(lastBuyTable[3].buy_id).toEqual(6); + expect(lastBuyTable[3].buy_id).toEqual(8); + expect(lastBuyTable[4].buy_id).toEqual(6); + expect(lastBuyTable[5].buy_id).toEqual(7); }); }); diff --git a/db/tests/vn/buyUltimate.spec.js b/db/tests/vn/buyUltimate.spec.js index 4ff6c4708..8a5e6a3df 100644 --- a/db/tests/vn/buyUltimate.spec.js +++ b/db/tests/vn/buyUltimate.spec.js @@ -29,21 +29,27 @@ describe('buyUltimate()', () => { let buyUltimateTable = result[buyUltimateTableIndex]; - expect(buyUltimateTable.length).toEqual(4); + expect(buyUltimateTable.length).toEqual(6); expect(buyUltimateTable[0].itemFk).toEqual(1); expect(buyUltimateTable[1].itemFk).toEqual(2); expect(buyUltimateTable[2].itemFk).toEqual(3); expect(buyUltimateTable[3].itemFk).toEqual(4); + expect(buyUltimateTable[4].itemFk).toEqual(8); + expect(buyUltimateTable[5].itemFk).toEqual(9); expect(buyUltimateTable[0].warehouseFk).toEqual(1); expect(buyUltimateTable[1].warehouseFk).toEqual(1); expect(buyUltimateTable[2].warehouseFk).toEqual(1); expect(buyUltimateTable[3].warehouseFk).toEqual(1); + expect(buyUltimateTable[4].warehouseFk).toEqual(1); + expect(buyUltimateTable[5].warehouseFk).toEqual(1); expect(buyUltimateTable[1].buyFk).toEqual(4); expect(buyUltimateTable[0].buyFk).toEqual(3); expect(buyUltimateTable[2].buyFk).toEqual(5); - expect(buyUltimateTable[3].buyFk).toEqual(6); + expect(buyUltimateTable[3].buyFk).toEqual(8); + expect(buyUltimateTable[4].buyFk).toEqual(6); + expect(buyUltimateTable[5].buyFk).toEqual(7); }); }); diff --git a/db/tests/vn/ticketCalculateClon.spec.js b/db/tests/vn/ticketCalculateClon.spec.js index 0b3969f1f..4015d57db 100644 --- a/db/tests/vn/ticketCalculateClon.spec.js +++ b/db/tests/vn/ticketCalculateClon.spec.js @@ -86,18 +86,20 @@ describe('ticket ticketCalculateClon()', () => { stmt = new ParameterizedSQL('CALL vn.ticketCalculateClon(@result, ?)', [params.originalTicketId]); stmts.push(stmt); - - let orderIndex = stmts.push(`SELECT * FROM vn.orderTicket WHERE ticketFk = @result`) - 1; - stmts.push('ROLLBACK'); let sql = ParameterizedSQL.join(stmts, ';'); - let result = await app.models.Ticket.rawStmt(sql); - let expectedOrder = 11; - let newestTicketIdInFixtures = 21; + let error; - expect(result[orderIndex][0].orderFk).toEqual(expectedOrder); - expect(result[orderIndex][0].ticketFk).toBeGreaterThan(newestTicketIdInFixtures); + try { + await app.models.Ticket.rawStmt(sql); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + expect(error.statusCode).toBe(500); + expect(error.code).toBe('ER_SIGNAL_EXCEPTION'); }); }); diff --git a/db/tests/vn/ticketCreateWithUser.spec.js b/db/tests/vn/ticketCreateWithUser.spec.js index e45d95f78..623f23422 100644 --- a/db/tests/vn/ticketCreateWithUser.spec.js +++ b/db/tests/vn/ticketCreateWithUser.spec.js @@ -14,8 +14,8 @@ describe('ticket ticketCreateWithUser()', () => { shipped: today, warehouseFk: 1, companyFk: 442, - addressFk: 1, - agencyModeFk: 2, + addressFk: 121, + agencyModeFk: 1, routeFk: null, landed: today, userId: 18 @@ -64,8 +64,8 @@ describe('ticket ticketCreateWithUser()', () => { shipped: today, warehouseFk: 1, companyFk: 442, - addressFk: 1, - agencyModeFk: 2, + addressFk: 121, + agencyModeFk: 1, routeFk: null, landed: today, userId: 18 @@ -91,7 +91,6 @@ describe('ticket ticketCreateWithUser()', () => { let sql = ParameterizedSQL.join(stmts, ';'); let result = await app.models.Ticket.rawStmt(sql); - let firstTicketObservation = result[ticketObsevationsIndex][0]; let secondTicketObservation = result[ticketObsevationsIndex][1]; let thirdTicketObservation = result[ticketObsevationsIndex][2]; @@ -116,7 +115,7 @@ describe('ticket ticketCreateWithUser()', () => { warehouseFk: 1, companyFk: 442, addressFk: 0, - agencyModeFk: 2, + agencyModeFk: 1, routeFk: null, landed: today, userId: 18 @@ -162,8 +161,8 @@ describe('ticket ticketCreateWithUser()', () => { shipped: today, warehouseFk: 1, companyFk: 442, - addressFk: 0, - agencyModeFk: 2, + addressFk: 121, + agencyModeFk: 1, routeFk: null, landed: today, userId: 18 @@ -186,7 +185,8 @@ describe('ticket ticketCreateWithUser()', () => { params.userId ]); stmts.push(stmt); - + let ticket = stmts.push(`select @newTicketId`); + console.log('NUm ticket', ticket); let ticketStateCodeIndex = stmts.push(`SELECT code FROM vn.ticketState WHERE ticketFk = @newTicketId`) - 1; stmts.push('ROLLBACK'); @@ -196,6 +196,6 @@ describe('ticket ticketCreateWithUser()', () => { let ticketStateCode = result[ticketStateCodeIndex][0].code; - expect(ticketStateCode).toEqual('DELIVERED'); + expect(ticketStateCode).toEqual('FREE'); }); }); diff --git a/e2e/paths/03-worker-module/01_pbx.spec.js b/e2e/paths/03-worker-module/01_pbx.spec.js index 73c37643a..49d4db133 100644 --- a/e2e/paths/03-worker-module/01_pbx.spec.js +++ b/e2e/paths/03-worker-module/01_pbx.spec.js @@ -28,6 +28,6 @@ describe('Worker pbx path', () => { .waitToClick(selectors.workerPbx.saveButton) .waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); + expect(result).toEqual('Data saved! User must access web'); }); }); diff --git a/front/core/components/autocomplete/autocomplete.html b/front/core/components/autocomplete/autocomplete.html index ecb21fe2f..c616c794a 100755 --- a/front/core/components/autocomplete/autocomplete.html +++ b/front/core/components/autocomplete/autocomplete.html @@ -14,7 +14,10 @@ translate-attr="{title: 'Clear'}"> - + - +
diff --git a/front/core/components/textfield/textfield.js b/front/core/components/textfield/textfield.js index fcf823c6b..bf6d5bfd5 100644 --- a/front/core/components/textfield/textfield.js +++ b/front/core/components/textfield/textfield.js @@ -84,6 +84,7 @@ ngModule.component('vnTextfield', { label: '@?', name: '@?', disabled: ' { expect(refundTicketSales.length).toEqual(2); expect(refundTicketSales[0].quantity).toEqual(-5); expect(refundTicketSales[1].quantity).toEqual(-4); - expect(refundTicketObservations[0].description).toEqual('Reclama ticket: 11'); + expect(refundTicketObservations[3].description).toEqual('Reclama ticket: 11'); expect(refundTicketState.stateFk).toEqual(16); expect(salesInsertedInClaimEnd[0].saleFk).toEqual(refundTicketSales[0].id); expect(salesInsertedInClaimEnd[1].saleFk).toEqual(refundTicketSales[1].id); diff --git a/modules/claim/front/detail/index.html b/modules/claim/front/detail/index.html index a7031e31a..ba7a34ffd 100644 --- a/modules/claim/front/detail/index.html +++ b/modules/claim/front/detail/index.html @@ -146,9 +146,7 @@

New price

-

{{($ctrl.saleClaimed.quantity * $ctrl.saleClaimed.sale.price) - - (($ctrl.newDiscount * ($ctrl.saleClaimed.quantity * $ctrl.saleClaimed.sale.price))/100) - | currency: 'EUR':2}} +

{{$ctrl.newPrice | currency: 'EUR':2}}

diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js index ef457807a..137ad4d70 100644 --- a/modules/claim/front/detail/index.js +++ b/modules/claim/front/detail/index.js @@ -37,6 +37,15 @@ class Controller { return this._salesClaimed; } + get newDiscount() { + return this._newDiscount; + } + + set newDiscount(value) { + this._newDiscount = value; + this.updateNewPrice(); + } + openAddSalesDialog() { this.getClaimableFromTicket(); this.$.addSales.show(); @@ -140,6 +149,11 @@ class Controller { } } + updateNewPrice() { + this.newPrice = (this.saleClaimed.quantity * this.saleClaimed.sale.price) - + ((this.newDiscount * (this.saleClaimed.quantity * this.saleClaimed.sale.price)) / 100); + } + clearDiscount() { this.newDiscount = null; } diff --git a/modules/claim/front/detail/index.spec.js b/modules/claim/front/detail/index.spec.js index 9312ef2fc..ee44e5761 100644 --- a/modules/claim/front/detail/index.spec.js +++ b/modules/claim/front/detail/index.spec.js @@ -95,10 +95,14 @@ describe('claim', () => { describe('updateDiscount()', () => { it('should perform a query if the new discount differs from the claim discount', () => { + controller.saleClaimed = {sale: { + discount: 5, + id: 7, + ticketFk: 1, + price: 2, + quantity: 10}}; controller.newDiscount = 10; - controller.saleClaimed = {sale: {discount: 5}}; - controller.saleClaimed = {sale: {id: 7}}; - controller.saleClaimed = {sale: {ticketFk: 1}}; + spyOn(controller.vnApp, 'showSuccess'); spyOn(controller, 'clearDiscount'); diff --git a/modules/client/back/methods/address/filter.js b/modules/client/back/methods/address/filter.js new file mode 100644 index 000000000..f84499695 --- /dev/null +++ b/modules/client/back/methods/address/filter.js @@ -0,0 +1,53 @@ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +module.exports = Self => { + Self.remoteMethod('filter', { + description: 'Find all instances of the model matched by filter from the data source.', + accessType: 'READ', + accepts: [ + { + arg: 'filter', + type: 'Object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', + http: {source: 'query'} + } + + ], + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/filter`, + verb: 'GET' + } + }); + + Self.filter = async filter => { + let conn = Self.dataSource.connector; + + let stmts = []; + let stmt; + + filter.order = [ + 'c.defaultAddressFk DESC', + 'a.isActive DESC', + 'a.nickname ASC' + ]; + + stmt = new ParameterizedSQL( + `SELECT a.* + FROM vn.address a + LEFT JOIN vn.client c ON c.defaultAddressFk = a.id` + ); + + stmt.merge(conn.makeSuffix(filter)); + let itemsIndex = stmts.push(stmt) - 1; + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await conn.executeStmt(sql); + return itemsIndex === 0 ? result : result[itemsIndex]; + }; +}; + diff --git a/modules/client/back/models/address.js b/modules/client/back/models/address.js index d0cfd0900..f0f1efa35 100644 --- a/modules/client/back/models/address.js +++ b/modules/client/back/models/address.js @@ -5,6 +5,7 @@ let isMultiple = require('vn-loopback/util/hook').isMultiple; module.exports = Self => { // Methods require('../methods/address/createDefaultAddress')(Self); + require('../methods/address/filter')(Self); Self.validateAsync('isEqualizated', cannotHaveET, { message: 'Cannot check Equalization Tax in this NIF/CIF' diff --git a/modules/client/back/models/bank-entity.js b/modules/client/back/models/bank-entity.js new file mode 100644 index 000000000..7a2cad594 --- /dev/null +++ b/modules/client/back/models/bank-entity.js @@ -0,0 +1,5 @@ +module.exports = Self => { + Self.validatesPresenceOf('name', { + message: 'Name cannot be blank' + }); +}; diff --git a/modules/client/front/address/index/index.html b/modules/client/front/address/index/index.html index d8971cd35..cdfd4d5a7 100644 --- a/modules/client/front/address/index/index.html +++ b/modules/client/front/address/index/index.html @@ -1,72 +1,74 @@ + auto-load="false">
- - - - - - - - - - - - - - - -
{{::address.nickname}}
-
{{::address.street}}
-
{{::address.city}}, {{::address.province}}
-
{{::address.phone}}, {{::address.mobile}}
-
- - - - -
-
- - - {{::observation.observationType.description}}: - {{::observation.description}} + + + + + + + + + + + + + + + + +
{{::address.nickname}}
+
{{::address.street}}
+
{{::address.city}}, {{::address.province}}
+
{{::address.phone}}, {{::address.mobile}}
+
+ + + + +
-
- - - -
-
-
+ + + {{::observation.observationType.description}}: + {{::observation.description}} + + + + + + + + +
+
diff --git a/modules/client/front/address/index/index.js b/modules/client/front/address/index/index.js index eeabaf5d8..3bc77ec62 100644 --- a/modules/client/front/address/index/index.js +++ b/modules/client/front/address/index/index.js @@ -5,30 +5,6 @@ class Controller { this.$http = $http; this.$scope = $scope; this.$stateParams = $stateParams; - this.filter = { - include: { - observations: 'observationType' - }, - order: ['isActive DESC', 'nickname ASC'] - }; - } - - get client() { - return this._client; - } - - set client(value) { - this._client = value; - this.sortAddresses(); - } - - get addresses() { - return this._addresses; - } - - set addresses(value) { - this._addresses = value; - this.sortAddresses(); } setDefault(address) { @@ -43,8 +19,8 @@ class Controller { } isDefaultAddress(address) { - if (!this.client) return; - return this.client.defaultAddressFk === address.id; + if (this.client) + return this.client.defaultAddressFk === address.id; } /** @@ -52,7 +28,7 @@ class Controller { */ sortAddresses() { if (!this.client || !this.addresses) return; - this.$scope.model.data = this.addresses.sort((a, b) => { + this.addresses = this.addresses.sort((a, b) => { return this.isDefaultAddress(b) - this.isDefaultAddress(a); }); } diff --git a/modules/client/front/billing-data/index.html b/modules/client/front/billing-data/index.html index b17f5dbf1..a7bcb71bd 100644 --- a/modules/client/front/billing-data/index.html +++ b/modules/client/front/billing-data/index.html @@ -98,28 +98,33 @@ + model="$ctrl.newBankEntity.name" + required="true"> - + show-field="country" + required="true"> + label="Entity Code" + model="$ctrl.newBankEntity.id" + ng-show="country.selection.code === 'ES'"> + model="$ctrl.newBankEntity.bic" + required="true"> diff --git a/modules/client/front/billing-data/index.js b/modules/client/front/billing-data/index.js index 761877600..edd6db654 100644 --- a/modules/client/front/billing-data/index.js +++ b/modules/client/front/billing-data/index.js @@ -59,8 +59,6 @@ export default class Controller { try { if (!this.newBankEntity.name) throw new Error(`Name can't be empty`); - if (!this.newBankEntity.id) - throw new Error(`Code can't be empty`); if (!this.newBankEntity.bic) throw new Error(`Swift / BIC can't be empty`); diff --git a/modules/client/front/billing-data/index.spec.js b/modules/client/front/billing-data/index.spec.js index 7ce5440df..de4c6acc2 100644 --- a/modules/client/front/billing-data/index.spec.js +++ b/modules/client/front/billing-data/index.spec.js @@ -71,18 +71,6 @@ describe('Client', () => { expect(vnApp.showError).toHaveBeenCalledWith(`Swift / BIC can't be empty`); }); - it(`should throw an error if id property is empty`, () => { - controller.newBankEntity = { - name: 'My new bank entity', - bic: 'ES123', - countryFk: 1, - id: null - }; - controller.onBankEntityResponse('ACCEPT'); - - expect(vnApp.showError).toHaveBeenCalledWith(`Code can't be empty`); - }); - it('should request to create a new bank entity', () => { let newBankEntity = { name: 'My new bank entity', diff --git a/modules/client/front/billing-data/locale/es.yml b/modules/client/front/billing-data/locale/es.yml index 84de93695..15373914e 100644 --- a/modules/client/front/billing-data/locale/es.yml +++ b/modules/client/front/billing-data/locale/es.yml @@ -16,4 +16,4 @@ Save: Guardar New bank entity: Nueva entidad bancaria Name can't be empty: El nombre no puede quedar vacío Swift / BIC can't be empty: El Swift / BIC no puede quedar vacío -Code: Código \ No newline at end of file +Entity Code: Código \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index 1ffd10b0e..3c9924fc3 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -36,7 +36,7 @@ module.exports = Self => { Self.download = async function(id) { let file; let env = process.env.NODE_ENV; - let [invoice] = await Self.rawSql(`SELECT hedera.invoiceGetPath(?) path`, [id]); + let [invoice] = await Self.rawSql(`SELECT invoiceOut_getPath(?) path`, [id]); if (env && env != 'development') { file = { diff --git a/modules/ticket/front/request/create/index.html b/modules/ticket/front/request/create/index.html index 95ea8b550..b03e87f6a 100644 --- a/modules/ticket/front/request/create/index.html +++ b/modules/ticket/front/request/create/index.html @@ -27,7 +27,8 @@ field="$ctrl.ticketRequest.quantity"> diff --git a/modules/ticket/front/sale/editDiscount.html b/modules/ticket/front/sale/editDiscount.html index 7648d2ddc..e4c7cf9cd 100644 --- a/modules/ticket/front/sale/editDiscount.html +++ b/modules/ticket/front/sale/editDiscount.html @@ -13,8 +13,6 @@

New price

-

{{($ctrl.edit[0].quantity * $ctrl.edit[0].price) - - (($ctrl.newDiscount * ($ctrl.edit[0].quantity * $ctrl.edit[0].price))/100) - | currency: 'EUR':2}}

+

{{$ctrl.newPrice | currency: 'EUR':2}}

\ No newline at end of file diff --git a/modules/ticket/front/sale/editDiscount.js b/modules/ticket/front/sale/editDiscount.js index 2ad12b159..e623e2eba 100644 --- a/modules/ticket/front/sale/editDiscount.js +++ b/modules/ticket/front/sale/editDiscount.js @@ -28,6 +28,20 @@ class Controller { return this._bulk; } + get newDiscount() { + return this._newDiscount; + } + + set newDiscount(value) { + this._newDiscount = value; + this.updateNewPrice(); + } + + updateNewPrice() { + if (this.newDiscount && this.edit[0]) + this.newPrice = (this.edit[0].quantity * this.edit[0].price) - ((this.newDiscount * (this.edit[0].quantity * this.edit[0].price)) / 100); + } + setNewDiscount() { if (!this.newDiscount && this.edit[0]) this.newDiscount = this.edit[0].discount; diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 682c60aeb..56b168760 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -186,9 +186,7 @@

New price

-

{{($ctrl.sale.quantity * $ctrl.editedPrice) - - (($ctrl.sale.discount * ($ctrl.sale.quantity * $ctrl.editedPrice))/100) - | currency: 'EUR':2}}

+

{{$ctrl.newPrice | currency: 'EUR':2}}

diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 0293f12d0..c5c70998f 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -21,16 +21,25 @@ class Controller { this.imagesPath = '//verdnatura.es/vn-image-data/catalog'; } + get sales() { + return this._sales; + } set sales(value) { this._sales = value; this.refreshTotal(); } - get sales() { - return this._sales; + get editedPrice() { + return this._editedPrice; } + set editedPrice(value) { + this._editedPrice = value; + this.updateNewPrice(); + } + + refreshTotal() { this.loadSubTotal(); this.loadVAT(); @@ -270,6 +279,10 @@ class Controller { this.$scope.editPricePopover.hide(); } + updateNewPrice() { + this.newPrice = this.sale.quantity * this.editedPrice - ((this.sale.discount * (this.sale.quantity * this.editedPrice)) / 100); + } + showEditPopover(event, sale) { this.sale = sale; this.edit = [{ diff --git a/modules/worker/front/locale/es.yml b/modules/worker/front/locale/es.yml index fb8108e4e..3fa727801 100644 --- a/modules/worker/front/locale/es.yml +++ b/modules/worker/front/locale/es.yml @@ -16,4 +16,5 @@ User name: Usuario Departments: Departamentos Calendar: Calendario Search workers by id, firstName, lastName or user name: Buscar trabajadores por el identificador, nombre, apellidos o nombre de usuario -Time control: Control de horario \ No newline at end of file +Time control: Control de horario +Data saved! User must access web: ¡Datos guardados! El usuario deberá acceder con su contraseña a la web para que los cambios surtan efecto. diff --git a/modules/worker/front/pbx/index.html b/modules/worker/front/pbx/index.html index e8889704d..c0b34a73b 100644 --- a/modules/worker/front/pbx/index.html +++ b/modules/worker/front/pbx/index.html @@ -10,7 +10,6 @@ label="Extension" model="$ctrl.worker.sip.extension"> - diff --git a/modules/worker/front/pbx/index.js b/modules/worker/front/pbx/index.js index 46afe5d68..28b4b24d0 100644 --- a/modules/worker/front/pbx/index.js +++ b/modules/worker/front/pbx/index.js @@ -1,9 +1,11 @@ import ngModule from '../module'; class Controller { - constructor($scope, $http) { + constructor($scope, $http, vnApp, $translate) { this.$scope = $scope; this.$http = $http; + this.vnApp = vnApp; + this._ = $translate; } onSubmit() { @@ -15,12 +17,12 @@ class Controller { this.$scope.watcher.check(); this.$http.patch('/api/Sips', params).then(() => { this.$scope.watcher.updateOriginalData(); - this.$scope.watcher.notifySaved(); + this.vnApp.showSuccess(this._.instant('Data saved! User must access web')); }); } } -Controller.$inject = ['$scope', '$http']; +Controller.$inject = ['$scope', '$http', 'vnApp', '$translate']; ngModule.component('vnWorkerPbx', { template: require('./index.html'),