xdiario test ok
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Javi Gallego 2020-12-22 10:08:11 +01:00
parent 36bace2a94
commit 0c7ddd863d
2 changed files with 8 additions and 13 deletions

BIN
e2e/dms/8f1/7.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -58,9 +58,11 @@ module.exports = function(Self) {
delete args.ctx; // Remove unwanted properties
const newReceipt = await models.Receipt.create(args, options);
const clientOriginal = await models.Client.findById(args.clientFk);
const bank = await models.Bank.findById(args.bankFk);
const accountingType = await models.AccountingType.findById(bank.accountingTypeFk);
if (args.compensationAccount) {
const clientOriginal = await models.Client.findById(args.clientFk);
const supplierCompensation = await models.Supplier.findOne({
where: {
account: args.compensationAccount
@ -77,12 +79,6 @@ module.exports = function(Self) {
if (!supplierCompensation && !clientCompensation)
throw new UserError('Invalid account');
const accountingType = await models.AccountingType.findOne({
where: {
code: 'compensation'
}
});
await Self.rawSql(
`CALL vn.ledger_doCompensation(?, ?, ?, ?, ?, ?, ?)`,
[
@ -96,15 +92,14 @@ module.exports = function(Self) {
],
options);
} else {
const bank = await models.Bank.findById(args.bankFk);
const ledger = await Self.rawSql(
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`,
const [xdiarioNew] = await Self.rawSql(
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`,
[
null,
Date(),
bank.account,
clientOriginal.accountingAccount,
clientOriginal.id + ':' + clientOriginal.nickname, '-', accountingType.receiptDescription,
clientOriginal.id + ':' + clientOriginal.nickname + '-' + accountingType.receiptDescription,
args.amountPaid,
0,
0,
@ -120,11 +115,11 @@ module.exports = function(Self) {
await Self.rawSql(
`SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`,
[
ledger,
xdiarioNew.ledger,
Date(),
clientOriginal.accountingAccount,
bank.account,
clientOriginal.id + ':' + clientOriginal.nickname, '-', accountingType.receiptDescription,
clientOriginal.id + ':' + clientOriginal.nickname + '-' + accountingType.receiptDescription,
0,
args.amountPaid,
0,