Merge pull request '4490-transfer-tickets-between-clients' (!1104) from 4490-transfer-tickets-between-clients into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1104
Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
Pau 2022-11-08 08:52:11 +00:00
commit 5dafdd5daa
5 changed files with 70 additions and 2 deletions

View File

@ -5,6 +5,13 @@
<vn-menu vn-id="menu">
<vn-list>
<vn-item
vn-acl="administrative"
vn-acl-action="remove"
ng-click="transferClient.show()"
translate>
Transfer client
</vn-item>
<vn-item
ng-click="addTurn.show()"
vn-acl="buyer"
@ -242,6 +249,36 @@
</tpl-buttons>
</vn-dialog>
<!-- Transfer Client popup -->
<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>
<!-- Send SMS popup -->
<vn-ticket-sms
vn-id="sms"

View File

@ -95,6 +95,23 @@ class Controller extends Section {
});
}
transferClient() {
this.$http.get(`Clients/${this.ticket.client.id}`).then(client => {
const ticket = this.ticket;
const params =
{
clientFk: client.data.id,
addressFk: client.data.defaultAddressFk,
};
this.$http.patch(`Tickets/${ticket.id}`, params).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.reload();
});
});
}
isTicketEditable() {
if (!this.ticket) return;

View File

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

View File

@ -9,4 +9,5 @@ Send CSV Delivery Note: Enviar albarán en CSV
Send PDF Delivery Note: Enviar albarán en PDF
Show Proforma: Ver proforma
Refund all: Abonar todo
The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}"
The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}"
Transfer client: Transferir cliente

View File

@ -22,4 +22,4 @@ SMS Pending payment: 'SMS Pago pendiente'
Restore ticket: Restaurar 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 refund all?: ¿Seguro que quieres abonar todo?
Are you sure you want to refund all?: ¿Seguro que quieres abonar todo?