diff --git a/modules/client/front/summary/index.html b/modules/client/front/summary/index.html
index 8a4f6eec7..956f9d198 100644
--- a/modules/client/front/summary/index.html
+++ b/modules/client/front/summary/index.html
@@ -1,3 +1,12 @@
+
+
+
+
-
\ No newline at end of file
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/client/front/summary/index.js b/modules/client/front/summary/index.js
index 8ef724061..40c000118 100644
--- a/modules/client/front/summary/index.js
+++ b/modules/client/front/summary/index.js
@@ -39,6 +39,43 @@ class Controller extends Summary {
if (rate)
return rate * 100;
}
+
+ stateColor(ticket) {
+ if (ticket.alertLevelCode === 'OK')
+ return 'success';
+ else if (ticket.alertLevelCode === 'FREE')
+ return 'notice';
+ else if (ticket.alertLevel === 1)
+ return 'warning';
+ else if (ticket.alertLevel === 0)
+ return 'alert';
+ }
+
+ chipColor(date) {
+ const today = new Date();
+ today.setHours(0, 0, 0, 0);
+
+ const ticketShipped = new Date(date);
+ ticketShipped.setHours(0, 0, 0, 0);
+
+ const difference = today - ticketShipped;
+
+ if (difference == 0)
+ return 'warning';
+ if (difference < 0)
+ return 'success';
+ }
+
+ totalPriceColor(ticket) {
+ const total = parseInt(ticket.totalWithVat);
+ if (total > 0 && total < 50)
+ return 'warning';
+ }
+
+ preview(ticket) {
+ this.selectedTicket = ticket;
+ this.$.summary.show();
+ }
}
ngModule.vnComponent('vnClientSummary', {
diff --git a/modules/client/front/summary/index.spec.js b/modules/client/front/summary/index.spec.js
index 05491267c..08f3f8554 100644
--- a/modules/client/front/summary/index.spec.js
+++ b/modules/client/front/summary/index.spec.js
@@ -4,15 +4,15 @@ describe('Client', () => {
describe('Component vnClientSummary', () => {
let controller;
let $httpBackend;
- let $scope;
+ let $window;
beforeEach(ngModule('client'));
- beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
+ beforeEach(inject(($componentController, _$httpBackend_, _$window_) => {
+ $window = _$window_;
$httpBackend = _$httpBackend_;
- $scope = $rootScope.$new();
const $element = angular.element('');
- controller = $componentController('vnClientSummary', {$element, $scope});
+ controller = $componentController('vnClientSummary', {$element});
controller.client = {id: 101};
}));
@@ -48,5 +48,82 @@ describe('Client', () => {
expect(result).toEqual(300);
});
});
+
+ describe('chipColor()', () => {
+ it('should return warning when the date is the present', () => {
+ let today = new Date();
+ let result = controller.chipColor(today);
+
+ expect(result).toEqual('warning');
+ });
+
+ it('should return success when the date is in the future', () => {
+ let futureDate = new Date();
+ futureDate = futureDate.setDate(futureDate.getDate() + 10);
+ let result = controller.chipColor(futureDate);
+
+ expect(result).toEqual('success');
+ });
+
+ it('should return undefined when the date is in the past', () => {
+ let pastDate = new Date();
+ pastDate = pastDate.setDate(pastDate.getDate() - 10);
+ let result = controller.chipColor(pastDate);
+
+ expect(result).toEqual(undefined);
+ });
+ });
+
+ describe('stateColor()', () => {
+ it('should return "success" when the alertLevelCode property is "OK"', () => {
+ const result = controller.stateColor({alertLevelCode: 'OK'});
+
+ expect(result).toEqual('success');
+ });
+
+ it('should return "notice" when the alertLevelCode property is "FREE"', () => {
+ const result = controller.stateColor({alertLevelCode: 'FREE'});
+
+ expect(result).toEqual('notice');
+ });
+
+ it('should return "warning" when the alertLevel property is "1', () => {
+ const result = controller.stateColor({alertLevel: 1});
+
+ expect(result).toEqual('warning');
+ });
+
+ it('should return "alert" when the alertLevel property is "0"', () => {
+ const result = controller.stateColor({alertLevel: 0});
+
+ expect(result).toEqual('alert');
+ });
+ });
+
+ describe('totalPriceColor()', () => {
+ it('should return "warning" when the ticket amount is less than 50€', () => {
+ const result = controller.totalPriceColor({totalWithVat: '8.50'});
+
+ expect(result).toEqual('warning');
+ });
+ });
+
+ describe('preview()', () => {
+ it('should show the dialog summary', () => {
+ controller.$.summary = {show: () => {}};
+ jest.spyOn(controller.$.summary, 'show');
+
+ const ticket = {id: 1, clientFk: 101};
+
+ const event = new MouseEvent('click', {
+ view: $window,
+ bubbles: true,
+ cancelable: true
+ });
+ controller.preview(event, ticket);
+
+ expect(controller.$.summary.show).toHaveBeenCalledWith();
+ });
+ });
});
});
diff --git a/modules/client/front/summary/locale/es.yml b/modules/client/front/summary/locale/es.yml
index 6d1c3b4f6..b6233d4b3 100644
--- a/modules/client/front/summary/locale/es.yml
+++ b/modules/client/front/summary/locale/es.yml
@@ -19,3 +19,4 @@ Solunion's maximum risk: Riesgo máximo asumido por Solunion
Invoices minus payments: Facturas menos recibos
Deviated invoices minus payments: Facturas fuera de plazo menos recibos
Go to the client: Ir al cliente
+Latest tickets: Últimos tickets
diff --git a/modules/client/front/summary/style.scss b/modules/client/front/summary/style.scss
index 1520659d2..79708b361 100644
--- a/modules/client/front/summary/style.scss
+++ b/modules/client/front/summary/style.scss
@@ -1,6 +1,8 @@
@import "variables";
-vn-client-summary {
+vn-client-summary .summary {
+ max-width: $width-lg;
+
.alert span {
color: $color-alert !important
}