This commit is contained in:
parent
6c3cea56aa
commit
a81e705251
|
@ -1 +1,2 @@
|
|||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (162, 'InvoiceOut', 'delete', 'WRITE', 'ALLOW', 'ROLE', 'invoicing');
|
||||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (163, 'InvoiceOut', 'book', 'WRITE', 'ALLOW', 'ROLE', 'invoicing');
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('book', {
|
||||
description: 'Book a invoiceOut',
|
||||
accessType: 'WRITE',
|
||||
accepts: {
|
||||
arg: 'ref',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The invoiceOut ref',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:ref/book`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.book = async ref => {
|
||||
return Self.rawSql(`CALL vn.invoiceOutAgain(?)`, [ref]);
|
||||
};
|
||||
};
|
|
@ -0,0 +1,32 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('invoiceOut book()', () => {
|
||||
const invoiceOutId = 5;
|
||||
let invoiceOutRef;
|
||||
let OriginalInvoiceOut;
|
||||
let updatedInvoiceOut;
|
||||
afterAll(async done => {
|
||||
updatedInvoiceOut.updateAttributes({booked: OriginalInvoiceOut.booked, hasPdf: OriginalInvoiceOut.hasPdf});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should check that invoice out booked is untainted', async() => {
|
||||
const invoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||
|
||||
expect(invoiceOut.booked).toBeNull();
|
||||
expect(invoiceOut.hasPdf).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should confirm the book property have been updated`, async() => {
|
||||
OriginalInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||
invoiceOutRef = OriginalInvoiceOut.ref;
|
||||
|
||||
await app.models.InvoiceOut.book(invoiceOutRef);
|
||||
|
||||
updatedInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||
|
||||
expect(updatedInvoiceOut.booked).toEqual(jasmine.any(Object));
|
||||
expect(updatedInvoiceOut.hasPdf).toBeFalsy();
|
||||
});
|
||||
});
|
|
@ -4,4 +4,5 @@ module.exports = Self => {
|
|||
require('../methods/invoiceOut/download')(Self);
|
||||
require('../methods/invoiceOut/regenerate')(Self);
|
||||
require('../methods/invoiceOut/delete')(Self);
|
||||
require('../methods/invoiceOut/book')(Self);
|
||||
};
|
||||
|
|
|
@ -57,4 +57,9 @@
|
|||
vn-id="deleteConfirmation"
|
||||
on-response="$ctrl.deleteInvoiceOut(response)"
|
||||
question="Are you sure you want to delete this invoice?">
|
||||
</vn-confirm>
|
||||
<vn-confirm
|
||||
vn-id="bookConfirmation"
|
||||
on-response="$ctrl.bookInvoiceOut(response)"
|
||||
question="Are you sure you want to book this invoice?">
|
||||
</vn-confirm>
|
|
@ -11,7 +11,8 @@ class Controller {
|
|||
this.aclService = aclService;
|
||||
this.moreOptions = [
|
||||
{callback: this.showInvoiceOutPdf, name: 'Show invoice out PDF'},
|
||||
{callback: this.showDeleteInvoiceOutDialog, name: 'Delete InvoiceOut', acl: 'invoicing'}
|
||||
{callback: this.showDeleteInvoiceOutDialog, name: 'Delete InvoiceOut', acl: 'invoicing'},
|
||||
{callback: this.showBookInvoiceOutDialog, name: 'Book invoice', acl: 'invoicing'}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -60,6 +61,10 @@ class Controller {
|
|||
this.$scope.deleteConfirmation.show();
|
||||
}
|
||||
|
||||
showBookInvoiceOutDialog() {
|
||||
this.$scope.bookConfirmation.show();
|
||||
}
|
||||
|
||||
deleteInvoiceOut(response) {
|
||||
if (response === 'ACCEPT') {
|
||||
const query = `/invoiceOut/api/InvoiceOuts/${this.invoiceOut.id}/delete`;
|
||||
|
@ -70,6 +75,16 @@ class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
bookInvoiceOut(response) {
|
||||
if (response === 'ACCEPT') {
|
||||
const query = `/invoiceOut/api/InvoiceOuts/${this.invoiceOut.ref}/book`;
|
||||
this.$http.post(query).then(() => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('InvoiceOut booked'));
|
||||
this.$state.go('invoiceOut.index');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
set quicklinks(value = {}) {
|
||||
this._quicklinks = Object.assign(value, this._quicklinks);
|
||||
}
|
||||
|
|
|
@ -5,4 +5,7 @@ Invoice ticket list: Listado de tickets de la factura
|
|||
Show invoice out PDF: Ver factura emitida en PDF
|
||||
Delete InvoiceOut: Borrar factura
|
||||
InvoiceOut deleted: Factura eliminada
|
||||
Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura?
|
||||
Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura?
|
||||
Book invoice: Asentar factura
|
||||
InvoiceOut booked: Factura asentada
|
||||
Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura?
|
Loading…
Reference in New Issue