#6703 refactor saleRefund #1954

Merged
jorgep merged 16 commits from 6703-refactorSaleRefund into dev 2024-02-05 07:51:18 +00:00
4 changed files with 42 additions and 3 deletions
Showing only changes of commit e6eac54709 - Show all commits

View File

@ -67,4 +67,42 @@ describe('Ticket cloning - clone function', () => {
expect(services.length).toBeGreaterThan(0);
}
});
it('should create a ticket without sales', async() => {
const servicesIds = [4];
const tx = await models.Sale.beginTransaction({});
const options = {transaction: tx};
try {
const tickets = await models.Sale.clone(ctx, null, servicesIds, false, options);
const refundedTicket = await getTicketRefund(tickets[0].id, options);
expect(refundedTicket).toBeDefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});
async function getTicketRefund(id, options) {
return models.Ticket.findOne({
where: {
id
},
include: [
{
relation: 'ticketSales',
scope: {
include: {
relation: 'components'
}
}
},
{
relation: 'ticketServices',
}
]
}, options);
}

View File

@ -523,7 +523,7 @@ class Controller extends Section {
if (!sales) return;
const salesIds = sales.map(sale => sale.id);
const params = {salesIds: salesIds, withWarehouse: withWarehouse,};
const params = {salesIds: salesIds, withWarehouse: withWarehouse, negative: true};
const query = 'Sales/clone';
jorgep marked this conversation as resolved
Review

aqui imagino que deberas pasar a true el parametro negative

aqui imagino que deberas pasar a true el parametro negative
this.$http.post(query, params).then(res => {
const [refundTicket] = res.data;

View File

@ -727,6 +727,7 @@ describe('Ticket', () => {
jest.spyOn(controller.$state, 'go');
const params = {
salesIds: [1, 4],
negative: true
};
const refundTicket = {id: 99};
$httpBackend.expect('POST', 'Sales/clone', params).respond(200, [refundTicket]);

View File

@ -55,10 +55,10 @@ class Controller extends Section {
createRefund() {
if (!this.checkeds.length) return;
const params = {servicesIds: this.checkeds, withWarehouse: false};
const params = {servicesIds: this.checkeds, withWarehouse: false, negative: true};
const query = 'Sales/clone';
jorgep marked this conversation as resolved
Review

aqui imagino que deberas pasar a true el parametro negative

aqui imagino que deberas pasar a true el parametro negative
this.$http.post(query, params).then(res => {
const refundTicket = res.data;
const [refundTicket] = res.data;
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', {
ticketId: refundTicket.id
}));