Add transferclient
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Pau 2022-10-25 09:23:46 +02:00
parent 04be661b68
commit a43e642ff7
4 changed files with 65 additions and 1 deletions

View File

@ -93,9 +93,42 @@
icon="icon-basketadd"> icon="icon-basketadd">
</vn-quick-link> </vn-quick-link>
</div> </div>
<div ng-transclude="btnFour">
<vn-quick-link
tooltip="Transfer client"
icon="people"
ng-click="transferClient.show()">
</vn-quick-link>
</div> </div>
</slot-body> </slot-body>
</vn-descriptor-content> </vn-descriptor-content>
<vn-dialog
vn-id="transferClient"
title="transferClient"
size="sm"
on-accept="$ctrl.transferClient($client)">
<tpl-body>
<vn-autocomplete
vn-one
vn-id="client"
required="true"
url="Clients"
label="Client"
show-field="name"
value-field="id"
search-function="{or: [{id: $search}, {name: {like: '%'+ $search +'%'}}]}"
ng-model="$ctrl.ticket.client.id"
initial-data="$ctrl.ticket.client.id"
order="id">
<tpl-item>
#{{id}} - {{::name}}
</tpl-item>
</vn-autocomplete>
</tpl-body>
<tpl-buttons>
<button response="accept" translate>Transfer client</button>
</tpl-buttons>
</vn-dialog>
<vn-worker-descriptor-popover <vn-worker-descriptor-popover
vn-id="workerDescriptor"> vn-id="workerDescriptor">
</vn-worker-descriptor-popover> </vn-worker-descriptor-popover>

View File

@ -69,6 +69,22 @@ class Controller extends Descriptor {
// Prevents error when not defined // Prevents error when not defined
} }
transferClient() {
this.$http.get(`Clients/${this.ticket.client.id}`).then(client => {
const ticket = this.ticket;
let params =
{
clientFk: client.data.id,
addressFk: client.data.defaultAddressFk,
};
this.$http.patch(`Tickets/${ticket.id}`, params);
this.cardReload();
});
}
get filter() { get filter() {
return this.ticket ? return this.ticket ?
JSON.stringify({clientFk: this.ticket.clientFk}) : null; JSON.stringify({clientFk: this.ticket.clientFk}) : null;

View File

@ -42,4 +42,18 @@ describe('Ticket Component vnTicketDescriptor', () => {
$httpBackend.flush(); $httpBackend.flush();
}); });
}); });
describe('transferClient()', () => {
it(`should perform two queries, a get to obtain the clientData and a patch to update the ticket`, () => {
let client =
{
clientFk: 1101,
addressFk: 1,
};
$httpBackend.expect('GET', `Clients/${ticket.client.id}`).respond(client);
$httpBackend.expect('PATCH', `Tickets/${ticket.id}`).respond();
controller.transferClient();
$httpBackend.flush();
});
});
}); });

View File

@ -23,3 +23,4 @@ Restore ticket: Restaurar ticket
You are going to restore this ticket: Vas a restaurar este ticket You are going to restore this ticket: Vas a restaurar este ticket
Are you sure you want to restore this ticket?: ¿Seguro que quieres restaurar el ticket? Are you sure you want to restore this ticket?: ¿Seguro que quieres restaurar el ticket?
Are you sure you want to refund all?: ¿Seguro que quieres abonar todo? Are you sure you want to refund all?: ¿Seguro que quieres abonar todo?
Transfer client: Transferir cliente