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';
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2019-12-31 09:38:19 +00:00
|
|
|
export default class Controller extends Component {
|
2019-06-13 11:08:11 +00:00
|
|
|
onSubmit() {
|
2019-12-31 09:38:19 +00:00
|
|
|
const orgData = this.$.watcher.orgData;
|
|
|
|
if (orgData.isEqualizated != this.client.isEqualizated)
|
2018-07-18 10:00:06 +00:00
|
|
|
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);
|
|
|
|
});
|
2018-12-11 12:16:33 +00:00
|
|
|
}
|
2018-07-18 10:00:06 +00:00
|
|
|
|
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();
|
2018-12-11 12:16:33 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2019-09-02 07:11:40 +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,
|
2018-07-03 09:13:33 +00:00
|
|
|
require: {card: '^vnClientCard'},
|
2017-01-31 13:13:06 +00:00
|
|
|
bindings: {
|
|
|
|
client: '<'
|
2017-02-07 11:58:25 +00:00
|
|
|
}
|
2017-06-03 11:01:47 +00:00
|
|
|
});
|