diff --git a/front/core/components/button/style.scss b/front/core/components/button/style.scss index 032c88cbb..f799a21ae 100644 --- a/front/core/components/button/style.scss +++ b/front/core/components/button/style.scss @@ -50,6 +50,17 @@ } } } + &.message { + color: white; + background-color: $color-bg-dark; + + &:not(.disabled) { + &:hover, + &:focus { + background-color: lighten($color-bg-dark, 10%); + } + } + } &.flat { color: $color-button; background-color: transparent; @@ -75,6 +86,22 @@ & > button > span { display: none; } + + &.xs { + font-size: 0.5em; + } + + &.sm { + font-size: 0.7em; + } + + &.md { + font-size: 0.9em; + } + + &.lg { + font-size: 1.2em; + } } &.disabled { opacity: .7; diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js index af956650d..153036e05 100644 --- a/modules/client/back/methods/sms/send.js +++ b/modules/client/back/methods/sms/send.js @@ -47,7 +47,6 @@ module.exports = Self => { let xmlParsed; let status; - try { if (process.env.NODE_ENV !== 'production') { status = { diff --git a/modules/ticket/front/index/index.html b/modules/ticket/front/index/index.html index b303c3ae7..ee218df56 100644 --- a/modules/ticket/front/index/index.html +++ b/modules/ticket/front/index/index.html @@ -8,17 +8,6 @@ - - - - - - - + +
+ + + + + + + + + +
+ diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 05dc23c08..563265ab3 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -1,4 +1,5 @@ import ngModule from '../module'; +import UserError from 'core/lib/user-error'; import './style.scss'; export default class Controller { @@ -9,33 +10,45 @@ export default class Controller { this.$stateParams = $stateParams; this.$state = $state; this.selectedTicket = null; - this.moreOptions = [ - { - name: 'Payment on account...', - always: true, - callback: () => { - this.setBalanceCreateDialog(); - this.$.balanceCreateDialog.show(); - } - } - ]; } - setBalanceCreateDialog() { - let data = this.$.tickets; - let description = []; + openBalanceDialog() { + const checkedTickets = this.checked; + const description = []; this.$.balanceCreateDialog.amountPaid = 0; - if (data) { - for (let i = 0; i < data.length; i++) { - if (data[i].checked) { - this.$.balanceCreateDialog.amountPaid += data[i].total; - this.$.balanceCreateDialog.clientFk = data[i].clientFk; - description.push(`${data[i].id}`); - } - } + + const firstTicketClientId = checkedTickets[0].clientFk; + const isSameClient = checkedTickets.every(ticket => { + return ticket.clientFk == firstTicketClientId; + }); + + if (!isSameClient) + throw new UserError('You cannot make a payment on account from multiple clients'); + + for (let ticket of checkedTickets) { + this.$.balanceCreateDialog.amountPaid += ticket.total; + this.$.balanceCreateDialog.clientFk = ticket.clientFk; + description.push(`${ticket.id}`); } + this.$.balanceCreateDialog.description = 'Albaran: '; this.$.balanceCreateDialog.description += description.join(', '); + this.$.balanceCreateDialog.show(); + } + + get checked() { + const tickets = this.$.tickets || []; + const checkedLines = []; + for (let ticket of tickets) { + if (ticket.checked) + checkedLines.push(ticket); + } + + return checkedLines; + } + + get totalChecked() { + return this.checked.length; } getScopeDates(days) { @@ -51,7 +64,7 @@ export default class Controller { onSearch(params) { if (params) { - if (typeof(params.scopeDays) === 'number') + if (typeof (params.scopeDays) === 'number') Object.assign(params, this.getScopeDates(params.scopeDays)); // Set default params to 1 scope days else if (Object.entries(params).length == 0) diff --git a/modules/ticket/front/index/index.spec.js b/modules/ticket/front/index/index.spec.js index 987accd02..6b0b42ffd 100644 --- a/modules/ticket/front/index/index.spec.js +++ b/modules/ticket/front/index/index.spec.js @@ -82,12 +82,14 @@ describe('Component vnTicketIndex', () => { }); }); - describe('setBalanceCreateDialog()', () => { + describe('openBalanceDialog()', () => { it('should fill the object for the component balanceCreateDialog', () => { + controller.$.balanceCreateDialog = {show: () => {}}; + jest.spyOn(controller.$.balanceCreateDialog, 'show').mockReturnThis(); + controller.$.tickets = tickets; - controller.$.balanceCreateDialog = {}; controller.$.balanceCreateDialog.amountPaid = 0; - controller.setBalanceCreateDialog(); + controller.openBalanceDialog(); let description = controller.$.balanceCreateDialog.description; let amountPaid = controller.$.balanceCreateDialog.amountPaid; @@ -96,4 +98,26 @@ describe('Component vnTicketIndex', () => { expect(amountPaid).toEqual(50.5); }); }); + + describe('checked()', () => { + it('should return an array of checked tickets', () => { + controller.$.tickets = tickets; + const result = controller.checked; + const firstRow = result[0]; + const secondRow = result[1]; + + expect(result.length).toEqual(2); + expect(firstRow.id).toEqual(2); + expect(secondRow.id).toEqual(3); + }); + }); + + describe('totalChecked()', () => { + it('should return the total number of checked tickets', () => { + controller.$.tickets = tickets; + const result = controller.checked; + + expect(result.length).toEqual(2); + }); + }); });