-
-
|
@@ -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 f92378d08..b4a9df184 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 c3e1d4e19..fe06a15a1 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/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js
index d76944c42..acad38185 100644
--- a/modules/client/front/fiscal-data/index.js
+++ b/modules/client/front/fiscal-data/index.js
@@ -2,6 +2,10 @@ import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller extends Section {
+ $onInit() {
+ this.card.reload();
+ }
+
onSubmit() {
const orgData = this.$.watcher.orgData;
delete this.client.despiteOfClient;
diff --git a/modules/item/front/request-search-panel/index.html b/modules/item/front/request-search-panel/index.html
index 8c9d04b64..a431d4fd6 100644
--- a/modules/item/front/request-search-panel/index.html
+++ b/modules/item/front/request-search-panel/index.html
@@ -38,6 +38,19 @@
url="Warehouses">
+
+
+ {{firstName}} {{lastName}}
+
+
+
{
type: 'number',
description: `Search requests attended by a given worker id`
},
+ {
+ arg: 'requesterFk',
+ type: 'number'
+ },
{
arg: 'mine',
type: 'boolean',
@@ -89,6 +93,8 @@ module.exports = Self => {
return {'t.id': value};
case 'attenderFk':
return {'tr.attenderFk': value};
+ case 'requesterFk':
+ return {'tr.requesterFk': value};
case 'state':
switch (value) {
case 'pending':
@@ -125,6 +131,7 @@ module.exports = Self => {
tr.description,
tr.response,
tr.saleFk,
+ tr.requesterFk,
tr.isOk,
s.quantity AS saleQuantity,
s.itemFk,