recargo y vies movidos de vista

This commit is contained in:
Daniel Herrero 2017-11-15 08:41:54 +01:00
parent dce3ae7520
commit 78fd0d4d16
5 changed files with 77 additions and 60 deletions

View File

@ -22,27 +22,13 @@
<vn-textfield vn-one label="Vencimiento" field="$ctrl.client.dueDay" vn-acl="administrative"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Descuento" field="$ctrl.client.discount" vn-acl="administrative"></vn-textfield>
<vn-textfield vn-one label="Crédito" field="$ctrl.client.credit" vn-acl="administrative"></vn-textfield>
<vn-textfield vn-one label="Crédito asegurado" field="$ctrl.client.creditInsurance" vn-acl="administrative"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-one>
<vn-check label="Equalization tax" field="$ctrl.client.equalizationTax" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Vies" field="$ctrl.client.vies" vn-acl="administrative"></vn-check>
</vn-one>
<vn-horizontal margin-medium-bottom>
<vn-one>
<vn-check label="Invoice by address" field="$ctrl.client.hasToInvoiceByAddress" vn-acl="administrative"></vn-check>
</vn-one>
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-card margin-small-bottom>
<vn-vertical pad-large>
<vn-title>Documentación</vn-title>
<vn-horizontal>
<vn-one>
<vn-check label="Recibido core VNH" field="$ctrl.client.coreVnh" vn-acl="administrative"></vn-check>
</vn-one>
@ -55,6 +41,7 @@
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-button-bar>
<vn-submit label="Guardar" vn-acl="administrative"></vn-submit>
</vn-button-bar>
@ -72,18 +59,4 @@
<button response="CANCEL" translate>No</button>
<button response="ACCEPT" translate>Yes, notify</button>
</tpl-buttons>
</vn-dialog>
<vn-dialog
vn-id="propagate-equalizationTax"
on-response="$ctrl.returnDialogEt(response)">
<tpl-body>
<vn-vertical>
<vn-one text-center translate>You changes the equivalent tax</vn-one>
<vn-one text-center translate>Do you want to spread the change to their consignees?</vn-one>
</vn-vertical>
</tpl-body>
<tpl-buttons>
<button response="CANCEL" translate>No</button>
<button response="ACCEPT" translate>Yes, propagate</button>
</tpl-buttons>
</vn-dialog>

View File

@ -9,11 +9,9 @@ export default class Controller {
this.billData = {};
this.copyData();
}
$onChanges() {
this.copyData();
}
copyData() {
if (this.client) {
this.billData.payMethodFk = this.client.payMethodFk;
@ -22,15 +20,12 @@ export default class Controller {
this.billData.discount = this.client.discount;
this.billData.credit = this.client.credit;
this.billData.creditInsurance = this.client.creditInsurance;
this.equalizationTax = this.client.equalizationTax;
}
}
submit() {
return this.$.watcher.submit().then(
() => this.checkPaymentChanges());
}
checkPaymentChanges() {
let equals = true;
Object.keys(this.billData).forEach(
@ -42,13 +37,10 @@ export default class Controller {
}
);
if (equals) {
this.checkEtChanges();
} else {
if (!equals) {
this.$.sendMail.show();
}
}
returnDialog(response) {
if (response === 'ACCEPT') {
this.$http.post(`/mailer/manuscript/payment-update/${this.client.id}`).then(
@ -57,27 +49,6 @@ export default class Controller {
this.checkEtChanges();
}
);
} else {
this.checkEtChanges();
}
}
checkEtChanges() {
let equals = this.equalizationTax == this.client.equalizationTax;
this.equalizationTax = this.client.equalizationTax;
if (!equals)
this.$.propagateEqualizationTax.show();
}
returnDialogEt(response) {
if (response === 'ACCEPT') {
this.$http.patch(`/client/api/Clients/${this.client.id}/addressesPropagateRe`, {isEqualizated: this.client.equalizationTax}).then(
res => {
if (res.data)
this.vnApp.showMessage(this.translate.instant('Equivalent tax spreaded'));
}
);
}
}
}

View File

@ -5,7 +5,7 @@
form="form"
save="patch">
</vn-watcher>
<form name="form" ng-submit="watcher.submit()" pad-medium>
<form name="form" ng-submit="$ctrl.submit()" pad-medium>
<vn-card margin-small-bottom>
<vn-vertical pad-large>
<vn-title>Fiscal data</vn-title>
@ -16,6 +16,12 @@
<vn-one>
<vn-check label="Invoice by mail" field="$ctrl.client.invoiceByEmail"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Equalization tax" field="$ctrl.client.equalizationTax" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Vies" field="$ctrl.client.vies" vn-acl="administrative"></vn-check>
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-two label="Street" field="$ctrl.client.street" vn-focus></vn-textfield>
@ -47,3 +53,18 @@
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</form>
<vn-dialog
vn-id="propagate-equalizationTax"
on-response="$ctrl.returnDialogEt(response)"
>
<tpl-body>
<vn-vertical>
<vn-one text-center translate>You changes the equivalent tax</vn-one>
<vn-one text-center translate>Do you want to spread the change to their consignees?</vn-one>
</vn-vertical>
</tpl-body>
<tpl-buttons>
<button response="CANCEL" translate>No</button>
<button response="ACCEPT" translate>Yes, propagate</button>
</tpl-buttons>
</vn-dialog>

View File

@ -1,7 +1,54 @@
import ngModule from '../module';
export default class ClientFiscalData {
constructor($scope, $http, vnApp, $translate) {
this.$ = $scope;
this.$http = $http;
this.vnApp = vnApp;
this.translate = $translate;
this.equalizationTax = undefined;
this.copyData();
}
$onChanges() {
this.copyData();
}
copyData() {
if (this.client) {
this.equalizationTax = this.client.equalizationTax;
}
}
submit() {
return this.$.watcher.submit().then(
() => this.checkEtChanges());
}
checkEtChanges() {
let equals = this.equalizationTax == this.client.equalizationTax;
this.equalizationTax = this.client.equalizationTax;
if (!equals)
this.$.propagateEqualizationTax.show();
}
returnDialogEt(response) {
if (response === 'ACCEPT') {
this.$http.patch(`/client/api/Clients/${this.client.id}/addressesPropagateRe`, {isEqualizated: this.client.equalizationTax}).then(
res => {
if (res.data)
this.vnApp.showMessage(this.translate.instant('Equivalent tax spreaded'));
}
);
}
}
}
ClientFiscalData.$inject = ['$scope', '$http', 'vnApp', '$translate'];
ngModule.component('vnClientFiscalData', {
template: require('./fiscal-data.html'),
controller: ClientFiscalData,
bindings: {
client: '<'
}

View File

@ -39,6 +39,11 @@ export default class Paging {
this.pageChange();
}
}
$doCheck() {
if (this.index && this.index.filter && this.index.filter.page && this.index.filter.page != this.currentPage) {
this.currentPage = this.index.filter.page;
}
}
}
Paging.$inject = ['$http', '$scope'];