-
-
|
@@ -56,25 +57,25 @@
Comercial
|
-
Balance D.
|
-
Author
|
Last observation
|
-
L. O. Date
|
-
@@ -88,8 +89,9 @@
|
-
|
@@ -150,7 +152,7 @@
-
+
@@ -160,7 +162,7 @@
id !== clientId) : [...this.checkedDefaulers, clientId];
+ }
+
+ reCheck() {
+ if (!this.$.model.data || !this.checkedDefaulers.length) return;
+
+ this.$.model.data.forEach(defaulter => {
+ defaulter.checked = this.checkedDefaulers.includes(defaulter.clientFk);
+ });
+ }
+
getBalanceDueTotal() {
this.$http.get('Defaulters/filter')
.then(res => {
@@ -109,11 +123,20 @@ export default class Controller extends Section {
}
this.$http.post(`ClientObservations`, params) .then(() => {
- this.vnApp.showMessage(this.$t('Observation saved!'));
+ this.vnApp.showSuccess(this.$t('Observation saved!'));
+ this.sendMail();
this.$state.reload();
});
}
+ sendMail() {
+ const params = {
+ defaulters: this.checked,
+ observation: this.defaulter.observation
+ };
+ this.$http.post(`Defaulters/observationEmail`, params);
+ }
+
exprBuilder(param, value) {
switch (param) {
case 'creditInsurance':
@@ -122,8 +145,25 @@ export default class Controller extends Section {
case 'workerFk':
case 'salesPersonFk':
return {[`d.${param}`]: value};
+ case 'created':
+ return {'d.created': {
+ between: this.dateRange(value)}
+ };
+ case 'defaulterSinced':
+ return {'d.defaulterSinced': {
+ between: this.dateRange(value)}
+ };
}
}
+
+ dateRange(value) {
+ const minHour = new Date(value);
+ minHour.setHours(0, 0, 0, 0);
+ const maxHour = new Date(value);
+ maxHour.setHours(23, 59, 59, 59);
+
+ return [minHour, maxHour];
+ }
}
ngModule.vnComponent('vnClientDefaulter', {
diff --git a/modules/client/front/defaulter/index.spec.js b/modules/client/front/defaulter/index.spec.js
index f92378d087..b4a9df1849 100644
--- a/modules/client/front/defaulter/index.spec.js
+++ b/modules/client/front/defaulter/index.spec.js
@@ -81,14 +81,15 @@ describe('client defaulter', () => {
const params = [{text: controller.defaulter.observation, clientFk: data[1].clientFk}];
- jest.spyOn(controller.vnApp, 'showMessage');
+ jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expect('GET', `Defaulters/filter`).respond(200);
$httpBackend.expect('POST', `ClientObservations`, params).respond(200, params);
+ $httpBackend.expect('POST', `Defaulters/observationEmail`).respond(200);
controller.onResponse();
$httpBackend.flush();
- expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Observation saved!');
+ expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Observation saved!');
});
});
@@ -117,5 +118,62 @@ describe('client defaulter', () => {
expect(controller.balanceDueTotal).toEqual(875);
});
});
+
+ describe('dateRange()', () => {
+ it('should return two dates with the hours at the start and end of the given date', () => {
+ const now = Date.vnNew();
+
+ const today = now.getDate();
+
+ const dateRange = controller.dateRange(now);
+ const start = dateRange[0].toString();
+ const end = dateRange[1].toString();
+
+ expect(start).toContain(today);
+ expect(start).toContain('00:00:00');
+
+ expect(end).toContain(today);
+ expect(end).toContain('23:59:59');
+ });
+ });
+
+ describe('reCheck()', () => {
+ it(`should recheck buys`, () => {
+ controller.$.model.data = [
+ {checked: false, clientFk: 1},
+ {checked: false, clientFk: 2},
+ {checked: false, clientFk: 3},
+ {checked: false, clientFk: 4},
+ ];
+ controller.checkedDefaulers = [1, 2];
+
+ controller.reCheck();
+
+ expect(controller.$.model.data[0].checked).toEqual(true);
+ expect(controller.$.model.data[1].checked).toEqual(true);
+ expect(controller.$.model.data[2].checked).toEqual(false);
+ expect(controller.$.model.data[3].checked).toEqual(false);
+ });
+ });
+
+ describe('saveChecked()', () => {
+ it(`should check buy`, () => {
+ const buyCheck = 3;
+ controller.checkedDefaulers = [1, 2];
+
+ controller.saveChecked(buyCheck);
+
+ expect(controller.checkedDefaulers[2]).toEqual(buyCheck);
+ });
+
+ it(`should uncheck buy`, () => {
+ const buyUncheck = 3;
+ controller.checkedDefaulers = [1, 2, 3];
+
+ controller.saveChecked(buyUncheck);
+
+ expect(controller.checkedDefaulers[2]).toEqual(undefined);
+ });
+ });
});
});
diff --git a/modules/client/front/defaulter/locale/es.yml b/modules/client/front/defaulter/locale/es.yml
index c3e1d4e19c..fe06a15a11 100644
--- a/modules/client/front/defaulter/locale/es.yml
+++ b/modules/client/front/defaulter/locale/es.yml
@@ -6,4 +6,6 @@ Last observation: Última observación
L. O. Date: Fecha Ú. O.
Last observation date: Fecha última observación
Search client: Buscar clientes
-Worker who made the last observation: Trabajador que ha realizado la última observación
\ No newline at end of file
+Worker who made the last observation: Trabajador que ha realizado la última observación
+Email sended!: Email enviado!
+Observation saved!: Observación añadida!
diff --git a/modules/supplier/front/agency-term/locale/es.yml b/modules/supplier/front/agency-term/locale/es.yml
index f4ba7d87df..cdbd7c2ca5 100644
--- a/modules/supplier/front/agency-term/locale/es.yml
+++ b/modules/supplier/front/agency-term/locale/es.yml
@@ -5,4 +5,5 @@ M3 Price: Precio M3
Route Price: Precio ruta
Minimum Km: Km minimos
Remove row: Eliminar fila
-Add row: Añadir fila
\ No newline at end of file
+Add row: Añadir fila
+New autonomous: Nuevo autónomo