3427-ticket_line-abono #827
|
@ -1,2 +1,2 @@
|
||||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||||
VALUES ('Sale','payment','WRITE','ALLOW','ROLE','employee');
|
VALUES ('Sale','payBack','WRITE','ALLOW','ROLE','employee');
|
||||||
|
|
|
@ -558,7 +558,7 @@ export default {
|
||||||
moreMenuUnmarkReseved: 'vn-item[name="unreserve"]',
|
moreMenuUnmarkReseved: 'vn-item[name="unreserve"]',
|
||||||
moreMenuUpdateDiscount: 'vn-item[name="discount"]',
|
moreMenuUpdateDiscount: 'vn-item[name="discount"]',
|
||||||
moreMenuRecalculatePrice: 'vn-item[name="calculatePrice"]',
|
moreMenuRecalculatePrice: 'vn-item[name="calculatePrice"]',
|
||||||
moreMenuPayment: 'vn-item[name="payment"]',
|
moreMenuPayBack: 'vn-item[name="payBack"]',
|
||||||
moreMenuUpdateDiscountInput: 'vn-input-number[ng-model="$ctrl.edit.discount"] input',
|
moreMenuUpdateDiscountInput: 'vn-input-number[ng-model="$ctrl.edit.discount"] input',
|
||||||
transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text',
|
transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text',
|
||||||
transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable',
|
transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable',
|
||||||
|
|
|
@ -206,7 +206,16 @@ describe('Ticket Edit sale path', () => {
|
||||||
expect(message.text).toContain('Data saved!');
|
expect(message.text).toContain('Data saved!');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should select the third sale and create a pay back', async() => {
|
||||||
|
await page.waitToClick(selectors.ticketSales.firstSaleCheckbox);
|
||||||
|
await page.waitToClick(selectors.ticketSales.moreMenu);
|
||||||
|
await page.waitToClick(selectors.ticketSales.moreMenuPayBack);
|
||||||
|
await page.waitForState('ticket.card.sale');
|
||||||
|
});
|
||||||
|
|
||||||
it('should select the third sale and create a claim of it', async() => {
|
it('should select the third sale and create a claim of it', async() => {
|
||||||
|
await page.accessToSearchResult('16');
|
||||||
|
await page.accessToSection('ticket.card.sale');
|
||||||
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
|
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
|
||||||
await page.waitToClick(selectors.ticketSales.moreMenu);
|
await page.waitToClick(selectors.ticketSales.moreMenu);
|
||||||
await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim);
|
await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('payment', {
|
Self.remoteMethodCtx('payBack', {
|
||||||
description: 'Create ticket with the selected lines changing the sign to the quantites',
|
description: 'Create ticket with the selected lines changing the sign to the quantites',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [{
|
accepts: [{
|
||||||
|
@ -19,12 +19,12 @@ module.exports = Self => {
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
path: `/payment`,
|
path: `/payBack`,
|
||||||
verb: 'post'
|
verb: 'post'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.payment = async(ctx, sales, ticketId, options) => {
|
Self.payBack = async(ctx, sales, ticketId, options) => {
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ module.exports = Self => {
|
||||||
await Self.rawSql(query, salesIds, myOptions);
|
await Self.rawSql(query, salesIds, myOptions);
|
||||||
const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions);
|
const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions);
|
||||||
ticketId = newTicket.id;
|
ticketId = newTicket.id;
|
||||||
console.log(ticketId);
|
|
||||||
/*
|
/*
|
||||||
const message = $t('Deleted sales from ticket', {
|
const message = $t('Deleted sales from ticket', {
|
||||||
ticketId: ticketId,
|
ticketId: ticketId,
|
|
@ -0,0 +1,26 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
describe('sale payBack()', () => {
|
||||||
|
it('should create ticket with the selected lines changing the sign to the quantites', async() => {
|
||||||
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
const ticketId = 11;
|
||||||
|
const sales = [
|
||||||
|
{id: 7, ticketFk: 11},
|
||||||
|
{id: 8, ticketFk: 11}
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}};
|
||||||
|
const response = await models.Sale.payBack(ctx, sales, ticketId, options);
|
||||||
|
const [newTicketId] = await models.Sale.rawSql('SELECT MAX(t.id) id FROM vn.ticket t;', null, options);
|
||||||
|
|
||||||
|
expect(response).toEqual(newTicketId.id);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -6,7 +6,7 @@ module.exports = Self => {
|
||||||
require('../methods/sale/updateQuantity')(Self);
|
require('../methods/sale/updateQuantity')(Self);
|
||||||
require('../methods/sale/updateConcept')(Self);
|
require('../methods/sale/updateConcept')(Self);
|
||||||
require('../methods/sale/recalculatePrice')(Self);
|
require('../methods/sale/recalculatePrice')(Self);
|
||||||
require('../methods/sale/payment')(Self);
|
require('../methods/sale/payBack')(Self);
|
||||||
require('../methods/sale/canEdit')(Self);
|
require('../methods/sale/canEdit')(Self);
|
||||||
|
|
||||||
Self.validatesPresenceOf('concept', {
|
Self.validatesPresenceOf('concept', {
|
||||||
|
|
|
@ -491,8 +491,8 @@
|
||||||
Unmark as reserved
|
Unmark as reserved
|
||||||
</vn-item>
|
</vn-item>
|
||||||
<vn-item translate
|
<vn-item translate
|
||||||
name="payment"
|
name="payBack"
|
||||||
ng-click="$ctrl.createPayment()">
|
ng-click="$ctrl.createPayBack()">
|
||||||
Payment
|
Pay Back
|
||||||
</vn-item>
|
</vn-item>
|
||||||
</vn-menu>
|
</vn-menu>
|
|
@ -460,12 +460,12 @@ class Controller extends Section {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createPayment() {
|
createPayBack() {
|
||||||
const sales = this.selectedValidSales();
|
const sales = this.selectedValidSales();
|
||||||
if (!sales) return;
|
if (!sales) return;
|
||||||
|
|
||||||
const params = {sales: sales, ticketId: this.ticket.id};
|
const params = {sales: sales, ticketId: this.ticket.id};
|
||||||
const query = `Sales/payment`;
|
const query = `Sales/payBack`;
|
||||||
this.resetChanges();
|
this.resetChanges();
|
||||||
this.$http.post(query, params).then(res => {
|
this.$http.post(query, params).then(res => {
|
||||||
this.$state.go('ticket.card.sale', {id: res.data});
|
this.$state.go('ticket.card.sale', {id: res.data});
|
||||||
|
|
|
@ -2,7 +2,7 @@ import './index.js';
|
||||||
import watcher from 'core/mocks/watcher';
|
import watcher from 'core/mocks/watcher';
|
||||||
import crudModel from 'core/mocks/crud-model';
|
import crudModel from 'core/mocks/crud-model';
|
||||||
|
|
||||||
describe('Ticket', () => {
|
fdescribe('Ticket', () => {
|
||||||
describe('Component vnTicketSale', () => {
|
describe('Component vnTicketSale', () => {
|
||||||
let controller;
|
let controller;
|
||||||
let $scope;
|
let $scope;
|
||||||
|
@ -701,24 +701,19 @@ describe('Ticket', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('createPayment()', () => {
|
describe('createPayBack()', () => {
|
||||||
it('should make an HTTP POST query and then call to the $state go() method', () => {
|
it('should make an HTTP POST query and then call to the $state go() method', () => {
|
||||||
jest.spyOn(controller, 'resetChanges').mockReturnThis();
|
jest.spyOn(controller, 'selectedValidSales').mockReturnValue(controller.sales);
|
||||||
jest.spyOn(controller.$state, 'go').mockReturnThis();
|
jest.spyOn(controller, 'resetChanges');
|
||||||
|
jest.spyOn(controller.$state, 'go');
|
||||||
|
|
||||||
const ticketId = 13;
|
const expectedId = 9999;
|
||||||
const expectedResponse = {id: ticketId};
|
$httpBackend.expect('POST', `Sales/payBack`).respond(200, expectedId);
|
||||||
const params = {
|
controller.createPayBack();
|
||||||
sales: controller.sales,
|
|
||||||
ticketId: 13
|
|
||||||
};
|
|
||||||
|
|
||||||
$httpBackend.expect('POST', `Sales/payment`, params).respond(expectedResponse);
|
|
||||||
controller.createPayment();
|
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.resetChanges).toHaveBeenCalledWith();
|
expect(controller.resetChanges).toHaveBeenCalledWith();
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: ticketId});
|
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: expectedId});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -36,4 +36,4 @@ Warehouse: Almacen
|
||||||
Agency: Agencia
|
Agency: Agencia
|
||||||
Shipped: F. envio
|
Shipped: F. envio
|
||||||
Packaging: Encajado
|
Packaging: Encajado
|
||||||
Payment: Abono
|
Pay Back: Abono
|
Loading…
Reference in New Issue