salix/modules/client/front/fiscal-data/index.js

50 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-06-03 11:01:47 +00:00
import ngModule from '../module';
2019-12-31 09:38:19 +00:00
import Component from 'core/lib/component';
2019-12-31 09:38:19 +00:00
export default class Controller extends Component {
onSubmit() {
2019-12-31 09:38:19 +00:00
const orgData = this.$.watcher.orgData;
if (orgData.isEqualizated != this.client.isEqualizated)
this.client.hasToInvoiceByAddress = false;
2019-12-31 09:38:19 +00:00
if (!orgData.isTaxDataChecked && this.client.isTaxDataChecked) {
const serializedParams = {email: this.client.email, phone: 111};
const query = `Clients/byNameOrEmail?filter=${serializedParams}`;
this.$http.get(query).then(res => {
console.log(res);
});
}
2019-12-31 09:38:19 +00:00
return this.checkEtChanges().then(
() => this.$.watcher.submit());
2017-11-15 07:41:54 +00:00
}
checkEtChanges() {
2019-12-31 09:38:19 +00:00
const orgData = this.$.watcher.orgData;
const equalizatedHasChanged = orgData.isEqualizated != this.client.isEqualizated;
2017-11-15 07:41:54 +00:00
2019-12-31 09:38:19 +00:00
if (equalizatedHasChanged && !orgData.hasToInvoiceByAddress)
2017-11-22 07:59:21 +00:00
this.$.propagateIsEqualizated.show();
2019-12-31 09:38:19 +00:00
else if (equalizatedHasChanged)
return this.onAcceptEt();
2019-12-31 09:38:19 +00:00
return this.$q.resolve();
2017-11-15 07:41:54 +00:00
}
2019-12-31 09:38:19 +00:00
onAcceptEt() {
const query = `Clients/${this.client.id}/addressesPropagateRe`;
return this.$http.patch(query, {isEqualizated: this.client.isEqualizated}).then(
() => this.vnApp.showMessage(this.$translate.instant('Equivalent tax spreaded'))
);
2017-11-15 07:41:54 +00:00
}
}
2017-06-03 11:01:47 +00:00
ngModule.component('vnClientFiscalData', {
2018-05-23 12:26:51 +00:00
template: require('./index.html'),
controller: Controller,
require: {card: '^vnClientCard'},
bindings: {
client: '<'
}
2017-06-03 11:01:47 +00:00
});