feat: añadido contador y porcetaje
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2023-01-24 09:45:52 +01:00
parent 1154179ddf
commit facaee6f95
4 changed files with 35 additions and 6 deletions

View File

@ -64,6 +64,18 @@
order="code"> order="code">
</vn-crud-model> </vn-crud-model>
<form class="vn-pa-md"> <form class="vn-pa-md">
<vn-vertical text-center
class="progress vn-my-sm"
ng-if="$ctrl.lastClientId">
<h5 class="vn-mb-md vn-mt-lg" translate>Invoicing</h5>
<div>
{{'Id Client' | translate}}: {{$ctrl.currentClientId}}
{{'of' | translate}} {{::$ctrl.lastClientId}}
</div>
<div>
{{($ctrl.percentage / 100) | percentage: 0}}
</div>
</vn-vertical>
<vn-vertical> <vn-vertical>
<vn-date-picker <vn-date-picker
vn-one vn-one

View File

@ -11,6 +11,7 @@ class Controller extends Section {
companyFk: this.vnConfig.companyFk companyFk: this.vnConfig.companyFk
}; };
this.clientsNumber = 'allClients'; this.clientsNumber = 'allClients';
this.currentClient = 0;
} }
$onInit() { $onInit() {
@ -39,19 +40,22 @@ class Controller extends Section {
return this.$http.get('Clients/findOne', {params}); return this.$http.get('Clients/findOne', {params});
} }
restartValues() { getPercentage() {
this.$.invoiceButton.disabled = false; this.percentage = (this.currentClient * 100) / this.clients.length;
this.packageInvoicing = false;
} }
cancelRequest() { restartValues() {
this.canceler = this.$q.defer(); this.lastClientId = null;
return {timeout: this.canceler.promise}; this.$.invoiceButton.disabled = false;
this.packageInvoicing = false;
} }
invoiceOut(invoice, clientsAndAddresses) { invoiceOut(invoice, clientsAndAddresses) {
const [clientAndAddress] = clientsAndAddresses; const [clientAndAddress] = clientsAndAddresses;
if (!clientAndAddress) return; if (!clientAndAddress) return;
this.currentClientId = clientAndAddress.clientId;
this.currentClient = ++this.currentClient;
this.getPercentage();
const params = { const params = {
clientId: clientAndAddress.clientId, clientId: clientAndAddress.clientId,
addressId: clientAndAddress.addressId, addressId: clientAndAddress.addressId,
@ -115,6 +119,12 @@ class Controller extends Section {
const invoice = res.data.invoice; const invoice = res.data.invoice;
const clientsAndAddresses = res.data.clientsAndAddresses; const clientsAndAddresses = res.data.clientsAndAddresses;
if (!clientsAndAddresses.length) throw new UserError(`There aren't clients to invoice`); if (!clientsAndAddresses.length) throw new UserError(`There aren't clients to invoice`);
this.clients = [];
for (const clientAndAddress of clientsAndAddresses)
this.clients.push(clientAndAddress.clientId);
this.lastClientId = clientsAndAddresses[clientsAndAddresses.length - 1].clientId;
return this.invoiceOut(invoice, clientsAndAddresses); return this.invoiceOut(invoice, clientsAndAddresses);
}) })
.then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) .then(() => this.vnApp.showSuccess(this.$t('Data saved!')))

View File

@ -13,3 +13,6 @@ From client: Desde cliente
To client: Hasta cliente To client: Hasta cliente
Address id: Id dirección Address id: Id dirección
Printer: Impresora Printer: Impresora
of: de
Id Client: Id Cliente
Invoicing: Facturando

View File

@ -8,3 +8,7 @@ vn-td {
color: $color-success; color: $color-success;
} }
} }
h5{
color: $color-primary;
}