Merge branch 'dev' into 8487-deprecateAppointmentFromTravel
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Ivan Mas 2025-01-30 13:24:08 +00:00
commit 85c3dc54fa
9 changed files with 117 additions and 23 deletions

View File

@ -52,7 +52,7 @@
},
"payMethod": {
"type": "belongsTo",
"model": "PayMethodFk",
"model": "PayMethod",
"foreignKey": "payMethodFk"
},
"company": {
@ -61,4 +61,4 @@
"foreignKey": "companyFk"
}
}
}
}

View File

@ -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),

View File

@ -1,5 +1,5 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_transfer`(
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_transfer`(
vOriginalEntry INT,
OUT vNewEntryFk INT
)

View File

@ -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,
a.bank,
p.companyFk,
NULL,
p.id,
@ -109,6 +111,7 @@ BEGIN
AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated)
UNION ALL
SELECT NULL,
NULL bankFk,
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),

View File

@ -0,0 +1,2 @@
INSERT IGNORE INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES('Entry', 'transfer', 'WRITE', 'ALLOW', 'ROLE', 'coolerBoss');

View File

@ -1,6 +1,7 @@
module.exports = Self => {
Self.remoteMethodCtx('transfer', {
description: 'Transfer merchandise from one entry to the next day',
accessType: 'WRITE',
accepts: [
{
arg: 'id',

View File

@ -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 = [];
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;
};
};

View File

@ -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);

View File

@ -1,5 +1,4 @@
module.exports = Self => {
const validateTin = require('vn-loopback/util/validateTin');
require('../methods/worker/filter')(Self);
require('../methods/worker/mySubordinates')(Self);
require('../methods/worker/isSubordinate')(Self);
@ -23,26 +22,10 @@ module.exports = Self => {
require('../methods/worker/getAvailablePda')(Self);
require('../methods/worker/myTeam')(Self);
Self.validateAsync('fi', tinIsValid, {
message: 'Invalid TIN'
});
Self.canModifyAbsenceInPast = async(ctx, time) => {
const hasPrivs = await Self.app.models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE');
const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
return hasPrivs || today.getTime() < time;
};
async function tinIsValid(err, done) {
const country = await Self.app.models.Country.findOne({
fields: ['code'],
where: {id: this.originCountryFk}
});
const code = country ? country.code.toLowerCase() : null;
if (!this.fi || !validateTin(this.fi, code))
err();
done();
}
};