faltan test
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
e5c9ea850b
commit
4f1fd5412d
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('InvoiceInDueDay', '*', '*', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -0,0 +1,52 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getTotals', {
|
||||
description: 'Return totals for an invoiceIn',
|
||||
accessType: 'READ',
|
||||
accepts: {
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'invoiceIn id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: '/:id/getTotals',
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getTotals = async(ctx, id, options) => {
|
||||
let tx;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
return (await Self.rawSql(`
|
||||
SELECT iit.*,
|
||||
SUM(iidd.amount) totalDueDay
|
||||
FROM vn.invoiceIn ii
|
||||
LEFT JOIN (SELECT SUM(iit.taxableBase) totalTaxableBase,
|
||||
SUM(iit.taxableBase * (1 + (ti.PorcentajeIva / 100))) totalVat
|
||||
FROM vn.invoiceInTax iit
|
||||
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
|
||||
WHERE iit.invoiceInFk = ?) iit ON TRUE
|
||||
LEFT JOIN vn.invoiceInDueDay iidd ON iidd.invoiceInFk = ii.id
|
||||
WHERE
|
||||
ii.id = ?`, [id, id]))[0];
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -39,13 +39,6 @@ module.exports = Self => {
|
|||
if (totals.totalDueDay != totals.totalTaxableBase && totals.totalDueDay != totals.totalVal)
|
||||
throw new UserError(`Amounts do not match`);
|
||||
|
||||
/* const now = new Date();
|
||||
const hasFuturePayments = await models.InvoiceInDueDay.findOne({
|
||||
where: {
|
||||
invoiceInFk: id,
|
||||
dueDated: {gte: now}
|
||||
}
|
||||
});*/
|
||||
await Self.rawSql(`CALL vn.invoiceInBookingMain(?)`, [id], myOptions);
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
|
|
|
@ -3,19 +3,5 @@ module.exports = Self => {
|
|||
require('../methods/invoice-in/summary')(Self);
|
||||
require('../methods/invoice-in/clone')(Self);
|
||||
require('../methods/invoice-in/toBook')(Self);
|
||||
|
||||
Self.getTotals = async function getTotals(invoiceInFk) {
|
||||
return (await Self.rawSql(`
|
||||
SELECT iit.*,
|
||||
SUM(iidd.amount) totalDueDay
|
||||
FROM vn.invoiceIn ii
|
||||
LEFT JOIN (SELECT SUM(iit.taxableBase) totalTaxableBase,
|
||||
SUM(iit.taxableBase * (1 + (ti.PorcentajeIva / 100))) totalVat
|
||||
FROM vn.invoiceInTax iit
|
||||
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
|
||||
WHERE iit.invoiceInFk = ?) iit ON TRUE
|
||||
LEFT JOIN vn.invoiceInDueDay iidd ON iidd.invoiceInFk = ii.id
|
||||
WHERE
|
||||
ii.id = ?`, [invoiceInFk, invoiceInFk]))[0];
|
||||
};
|
||||
require('../methods/invoice-in/getTotals')(Self);
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<vn-descriptor-content module="invoiceIn" description="$ctrl.invoiceIn.supplierRef">
|
||||
<slot-menu>
|
||||
<vn-item
|
||||
ng-click="$ctrl.toBook()"
|
||||
ng-click="$ctrl.checktoBook()"
|
||||
vn-acl="administrative"
|
||||
ng-hide="$ctrl.invoiceIn.isBooked == true"
|
||||
translate>
|
||||
|
@ -72,3 +72,8 @@
|
|||
<vn-supplier-descriptor-popover
|
||||
vn-id="supplierDescriptor">
|
||||
</vn-supplier-descriptor-popover>
|
||||
<vn-confirm
|
||||
vn-id="confirm-toBookAnyway"
|
||||
message="???"
|
||||
on-accept="$ctrl.onAcceptToBook()">
|
||||
</vn-confirm>
|
|
@ -51,9 +51,38 @@ class Controller extends Descriptor {
|
|||
return this.getData(`InvoiceIns/${this.id}`, {filter})
|
||||
.then(res => this.entity = res.data);
|
||||
}
|
||||
toBook() {
|
||||
return this.$http.post(`InvoiceIns/${this.id}/toBook`)
|
||||
.then(() => this.vnApp.showSuccess(this.$t('InvoiceIn booked')));
|
||||
checktoBook() {
|
||||
let message = '';
|
||||
const id = this.invoiceIn.id;
|
||||
this.$q.all([
|
||||
this.$http.get(`InvoiceIns/${this.id}/getTotals`)
|
||||
.then(res => {
|
||||
if (res.data.totalDueDay != res.data.totalTaxableBase && res.data.totalDueDay != res.data.totalVat)
|
||||
message += 'amountsNotMatch';
|
||||
}),
|
||||
this.$http.get('InvoiceInDueDays/count', {
|
||||
filter: {
|
||||
where: {
|
||||
invoiceInFk: id,
|
||||
dueDated: {gte: new Date()}
|
||||
}
|
||||
}})
|
||||
.then(res => {
|
||||
if (res)
|
||||
message += 'future payments';
|
||||
})
|
||||
|
||||
]).finally(() => {
|
||||
if (message > '')
|
||||
this.$.confirmToBookAnyway.show();
|
||||
else
|
||||
onAcceptToBook();
|
||||
});
|
||||
}
|
||||
|
||||
onAcceptToBook() {
|
||||
this.$http.post(`InvoiceIns/${this.id}/toBook`);
|
||||
this.vnApp.showSuccess(this.$t('InvoiceIn booked'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue