#7134 SupplierBalance #3173
|
@ -52,7 +52,7 @@
|
|||
},
|
||||
"payMethod": {
|
||||
"type": "belongsTo",
|
||||
"model": "PayMethodFk",
|
||||
"model": "PayMethod",
|
||||
"foreignKey": "payMethodFk"
|
||||
},
|
||||
"company": {
|
||||
|
@ -61,4 +61,4 @@
|
|||
"foreignKey": "companyFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2641,9 +2641,9 @@ REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issu
|
|||
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1,util.VN_CURDATE()),
|
||||
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1,util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`)
|
||||
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`, `balanceStartingDate`)
|
||||
VALUES
|
||||
(1, -2, '2% retention', 2, 45);
|
||||
(1, -2, '2% retention', 2, 45, '2000-01-01');
|
||||
|
||||
INSERT INTO `vn`.`invoiceInDueDay`(`invoiceInFk`, `dueDated`, `bankFk`, `amount`)
|
||||
VALUES
|
||||
|
@ -4052,6 +4052,9 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
|
|||
INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate)
|
||||
VALUES (1106,'26493101E','2019-09-20');
|
||||
|
||||
|
||||
INSERT INTO vn.payment (received, supplierFk, amount, currencyFk, divisa, bankFk, payMethodFk, bankingFees, concept, companyFk, created, isConciliated, dueDated, workerFk) VALUES
|
||||
(util.VN_CURDATE(), 1, 1000.00, 1, NULL, 1, 1, 0.0, 'n/pago', 442, util.VN_CURDATE(), 1, util.VN_CURDATE(), 9);
|
||||
|
||||
INSERT INTO vn.referenceRate (currencyFk, dated, value)
|
||||
VALUES (2, '2000-12-01', 1.0495),
|
||||
(2, '2001-01-01', 1.0531),
|
||||
|
|
|
@ -41,6 +41,7 @@ BEGIN
|
|||
) currencyBalance
|
||||
FROM (
|
||||
SELECT NULL bankFk,
|
||||
NULL bank,
|
||||
ii.companyFk,
|
||||
ii.serial,
|
||||
ii.id,
|
||||
|
@ -74,6 +75,7 @@ BEGIN
|
|||
GROUP BY iid.id, ii.id
|
||||
UNION ALL
|
||||
SELECT p.bankFk,
|
||||
jgallego marked this conversation as resolved
Outdated
jgallego
commented
'bank' sobra 'bank' sobra
jsegarra
commented
He añadido bank para que en la tabla se vea el valor del banco en vez del id He añadido bank para que en la tabla se vea el valor del banco en vez del id
|
||||
a.bank,
|
||||
jsegarra marked this conversation as resolved
Outdated
jgallego
commented
`a.bank,`
el alias al ser un union all usa el de arriba
|
||||
p.companyFk,
|
||||
NULL,
|
||||
p.id,
|
||||
|
@ -109,6 +111,7 @@ BEGIN
|
|||
AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated)
|
||||
UNION ALL
|
||||
SELECT NULL,
|
||||
NULL bankFk,
|
||||
jgallego
commented
sin bankFk y salta de linea como el resto de campos sin bankFk y salta de linea como el resto de campos
jsegarra
commented
Así se muestra el valor del bank en la tabla Así se muestra el valor del bank en la tabla
|
||||
companyFk,
|
||||
NULL,
|
||||
se.id,
|
||||
|
@ -136,6 +139,7 @@ BEGIN
|
|||
AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated)
|
||||
UNION ALL
|
||||
SELECT NULL bankFk,
|
||||
NULL,
|
||||
e.companyFk,
|
||||
'E' serial,
|
||||
e.invoiceNumber id,
|
||||
|
@ -154,7 +158,7 @@ BEGIN
|
|||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN currency c ON c.id = e.currencyFk
|
||||
WHERE e.supplierFk = vSupplierFk
|
||||
AND tr.landed >= CURDATE()
|
||||
AND tr.landed >= util.VN_CURDATE()
|
||||
AND e.invoiceInFk IS NULL
|
||||
AND vHasEntries
|
||||
ORDER BY (dated IS NULL AND NOT isBooked),
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const {buildFilter, mergeFilters} = require('vn-loopback/util/filter');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('receipts', {
|
||||
description: 'Find all suppliers matched by the filter',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
|
||||
http: {source: 'query'}
|
||||
}, {
|
||||
arg: 'supplierId',
|
||||
type: 'number',
|
||||
description: 'The supplier id',
|
||||
},
|
||||
{
|
||||
arg: 'companyId',
|
||||
type: 'number',
|
||||
description: 'The company id',
|
||||
},
|
||||
{
|
||||
arg: 'currencyFk',
|
||||
type: 'number',
|
||||
description: 'The currency',
|
||||
default: 1,
|
||||
},
|
||||
{
|
||||
arg: 'bankFk',
|
||||
type: 'number',
|
||||
description: 'The bank',
|
||||
default: 1,
|
||||
},
|
||||
{
|
||||
arg: 'orderBy',
|
||||
type: 'string',
|
||||
description: 'The supplier fiscal id',
|
||||
enum: ['issued', ' bookEntried', ' booked', ' dueDate'],
|
||||
},
|
||||
{
|
||||
arg: 'isConciliated',
|
||||
default: false,
|
||||
type: 'boolean',
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/receipts`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.receipts = async(ctx, filter, options) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
const args = ctx.args;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const where = buildFilter(ctx.args, (param, value) => {
|
||||
switch (param) {
|
||||
case 'bankFk':
|
||||
return {[param]: value};
|
||||
}
|
||||
});
|
||||
|
||||
let stmts = [];
|
||||
|
||||
jsegarra marked this conversation as resolved
Outdated
jgallego
commented
si no ponen currency no pasamos nada, no se ponen numero en el codigo si no ponen currency no pasamos nada, no se ponen numero en el codigo
|
||||
stmts.push(new ParameterizedSQL('CALL vn.supplier_statementWithEntries(?,?,?,?,?,?)', [
|
||||
args.supplierId,
|
||||
args.currencyFk,
|
||||
args.companyId,
|
||||
args.orderBy ?? 'issued',
|
||||
args.isConciliated ?? false,
|
||||
false
|
||||
]));
|
||||
|
||||
const stmt = new ParameterizedSQL(`
|
||||
SELECT *
|
||||
FROM tmp.supplierStatement`);
|
||||
|
||||
filter = mergeFilters(args.filter, {where});
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
stmts.push(stmt);
|
||||
stmts.push(`DROP TEMPORARY TABLE tmp.supplierStatement`);
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const results = await conn.executeStmt(sql);
|
||||
const resultsIndex = stmts.length - 2;
|
||||
const result = results[resultsIndex];
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -8,6 +8,7 @@ module.exports = Self => {
|
|||
require('../methods/supplier/updateFiscalData')(Self);
|
||||
require('../methods/supplier/consumption')(Self);
|
||||
require('../methods/supplier/freeAgencies')(Self);
|
||||
require('../methods/supplier/receipts')(Self);
|
||||
require('../methods/supplier/campaignMetricsPdf')(Self);
|
||||
require('../methods/supplier/campaignMetricsEmail')(Self);
|
||||
require('../methods/supplier/newSupplier')(Self);
|
||||
|
|
Loading…
Reference in New Issue
2024 no, ponlo en el 2001
si el supplier tiene una entrada, pon el pago posterior para que tenga sentido
GRRRR...lo tenia en stash, no me preguntes por que