refactor: code
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
b406551f52
commit
7b8a9791b4
|
@ -1,18 +1,16 @@
|
||||||
<div class="vn-w-md">
|
<h3 ng-if="$ctrl.packageInvoicing" translate style="text-align: center;">{{'Calculating packages to invoice...'}}</h3>
|
||||||
<vn-data-viewer
|
<vn-card class="vn-w-lg">
|
||||||
data="data"
|
<vn-table ng-if="data.length">
|
||||||
class="vn-w-md vn-mb-xl">
|
|
||||||
<vn-card>
|
|
||||||
<vn-table>
|
|
||||||
<vn-thead>
|
<vn-thead>
|
||||||
<vn-tr>
|
<vn-tr>
|
||||||
<vn-th field="id">Id</vn-th>
|
<vn-th field="id">Id</vn-th>
|
||||||
|
<vn-th field="id">Address</vn-th>
|
||||||
<vn-th field="name">Status</vn-th>
|
<vn-th field="name">Status</vn-th>
|
||||||
</vn-tr>
|
</vn-tr>
|
||||||
</vn-thead>
|
</vn-thead>
|
||||||
<vn-tbody>
|
<vn-tbody>
|
||||||
<vn-tr
|
<vn-tr
|
||||||
ng-repeat="client in data track by client.id">
|
ng-repeat="client in data">
|
||||||
<vn-td>
|
<vn-td>
|
||||||
<span
|
<span
|
||||||
vn-click-stop="clientDescriptor.show($event, client.id)"
|
vn-click-stop="clientDescriptor.show($event, client.id)"
|
||||||
|
@ -20,6 +18,9 @@
|
||||||
{{::client.id}}
|
{{::client.id}}
|
||||||
</span>
|
</span>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
<vn-td>
|
||||||
|
{{::client.address}}
|
||||||
|
</vn-td>
|
||||||
<vn-td>
|
<vn-td>
|
||||||
<vn-spinner
|
<vn-spinner
|
||||||
ng-if="client.status == 'waiting'"
|
ng-if="client.status == 'waiting'"
|
||||||
|
@ -39,8 +40,7 @@
|
||||||
</vn-tbody>
|
</vn-tbody>
|
||||||
</vn-table>
|
</vn-table>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</vn-data-viewer>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<vn-side-menu side="right">
|
<vn-side-menu side="right">
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-submit vn-id="invoiceButton" ng-click="$ctrl.makeInvoice()" label="Invoice" class="vn-mt-sm" ></vn-submit>
|
<vn-submit vn-id="invoiceButton" ng-click="$ctrl.makeInvoice()" label="Invoice" class="vn-mt-sm" ></vn-submit>
|
||||||
<vn-button ng-click="$ctrl.clean()" label="Clean" class="vn-mt-sm"></vn-button>
|
<vn-button ng-click="$ctrl.clean()" label="Clean" class="vn-mt-sm" disabled="!data.length"></vn-button>
|
||||||
</form>
|
</form>
|
||||||
</vn-side-menu>
|
</vn-side-menu>
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
restartValues() {
|
restartValues() {
|
||||||
this.lastClientId = null;
|
|
||||||
this.$.invoiceButton.disabled = false;
|
this.$.invoiceButton.disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +51,6 @@ class Controller extends Section {
|
||||||
invoiceOut(invoice, clientsAndAddresses) {
|
invoiceOut(invoice, clientsAndAddresses) {
|
||||||
const [clientAndAddress] = clientsAndAddresses;
|
const [clientAndAddress] = clientsAndAddresses;
|
||||||
if (!clientAndAddress) return;
|
if (!clientAndAddress) return;
|
||||||
this.currentClientId = clientAndAddress.clientId;
|
|
||||||
const params = {
|
const params = {
|
||||||
clientId: clientAndAddress.clientId,
|
clientId: clientAndAddress.clientId,
|
||||||
addressId: clientAndAddress.addressId,
|
addressId: clientAndAddress.addressId,
|
||||||
|
@ -63,7 +61,14 @@ class Controller extends Section {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const index = this.$.data.findIndex(element => element.id == clientAndAddress.clientId);
|
this.$.data.push({
|
||||||
|
id: clientAndAddress.clientId,
|
||||||
|
address: clientAndAddress.addressId,
|
||||||
|
status: 'waiting'
|
||||||
|
});
|
||||||
|
const index = this.$.data.findIndex(
|
||||||
|
client => client.id == clientAndAddress.clientId && client.address == clientAndAddress.addressId
|
||||||
|
);
|
||||||
return this.$http.post(`InvoiceOuts/invoiceClient`, params)
|
return this.$http.post(`InvoiceOuts/invoiceClient`, params)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$.data[index].status = 'ok';
|
this.$.data[index].status = 'ok';
|
||||||
|
@ -84,26 +89,13 @@ class Controller extends Section {
|
||||||
throw new Error('Choose a valid clients range');
|
throw new Error('Choose a valid clients range');
|
||||||
|
|
||||||
this.$.invoiceButton.disabled = true;
|
this.$.invoiceButton.disabled = true;
|
||||||
|
this.$.data = [];
|
||||||
this.packageInvoicing = true;
|
this.packageInvoicing = true;
|
||||||
|
|
||||||
this.$http.post(`InvoiceOuts/clientsToInvoice`, this.invoice)
|
this.$http.post(`InvoiceOuts/clientsToInvoice`, this.invoice)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.packageInvoicing = false;
|
this.packageInvoicing = false;
|
||||||
const invoice = res.data.invoice;
|
const invoice = res.data.invoice;
|
||||||
|
|
||||||
const clientsIds = [];
|
|
||||||
for (const clientAndAddress of res.data.clientsAndAddresses)
|
|
||||||
clientsIds.push(clientAndAddress.clientId);
|
|
||||||
const dataArr = new Set(clientsIds);
|
|
||||||
const clientsIdsNoRepeat = [...dataArr];
|
|
||||||
const clients = clientsIdsNoRepeat.map(clientId => {
|
|
||||||
return {
|
|
||||||
id: clientId,
|
|
||||||
status: 'waiting'
|
|
||||||
};
|
|
||||||
});
|
|
||||||
this.$.data = clients;
|
|
||||||
|
|
||||||
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`);
|
||||||
return this.invoiceOut(invoice, clientsAndAddresses);
|
return this.invoiceOut(invoice, clientsAndAddresses);
|
||||||
|
|
|
@ -4,4 +4,6 @@ Invoice date: Fecha de factura
|
||||||
Invoice date and the max date should be filled: La fecha de factura y la fecha límite deben rellenarse
|
Invoice date and the max date should be filled: La fecha de factura y la fecha límite deben rellenarse
|
||||||
Choose a valid clients range: Selecciona un rango válido de clientes
|
Choose a valid clients range: Selecciona un rango válido de clientes
|
||||||
Clients range: Rango de clientes
|
Clients range: Rango de clientes
|
||||||
|
All clients: Todos los clientes
|
||||||
Calculating packages to invoice...: Calculando paquetes a factura...
|
Calculating packages to invoice...: Calculando paquetes a factura...
|
||||||
|
Clean: Limpiar
|
||||||
|
|
Loading…
Reference in New Issue