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

This commit is contained in:
Robert Ferrús 2024-07-09 06:24:05 +00:00
commit 9892b37ed0
23 changed files with 192 additions and 105 deletions

View File

@ -60,15 +60,17 @@ module.exports = Self => {
if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions);
for (let ticket of tickets) {
let observations = ticket.observaciones.split(' ');
if (ticket.observaciones) {
let observations = ticket.observaciones.split(' ');
for (let observation of observations) {
const salesPerson = ticket.salesPersonFk;
if (observation.startsWith('#') || observation.startsWith('@')) {
await models.Chat.send(ctx,
observation,
$t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson})
);
for (let observation of observations) {
const salesPerson = ticket.salesPersonFk;
if (observation.startsWith('#') || observation.startsWith('@')) {
await models.Chat.send(ctx,
observation,
$t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson})
);
}
}
}
}

View File

@ -3,7 +3,7 @@
<soap:Header>
<mrw:AuthInfo>
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
<mrw:CodigoAbonado><%= expeditionData.clientType %></mrw:CodigoAbonado>
<mrw:CodigoDepartamento/>
<mrw:UserName><%= mrw.user %></mrw:UserName>
<mrw:Password><%= mrw.password %></mrw:Password>

View File

@ -50,9 +50,10 @@ module.exports = Self => {
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
t.shipped,
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType,
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType,
IF(mw.weekdays, 'S', 'N') weekDays,
oa.description deliveryObservation
oa.description deliveryObservation,
LPAD(ms.clientType, mc.clientTypeWidth, '0') clientType
FROM expedition e
JOIN ticket t ON e.ticketFk = t.id
JOIN agencyMode am ON am.id = t.agencyModeFk

View File

@ -3911,3 +3911,19 @@ VALUES(1, '');
INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode,
truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments)
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL);
INSERT INTO vn.accountDetail
(id, value, accountDetailTypeFk, supplierAccountFk)
VALUES
(21, 'ES12345B12345678', 3, 241),
(35, 'ES12346B12345679', 3, 241);
INSERT INTO vn.accountDetailType
(id, description)
VALUES
(1, 'IBAN'),
(2, 'SWIFT'),
(3, 'Referencia Remesas'),
(4, 'Referencia Transferencias'),
(5, 'Referencia Nominas'),
(6, 'ABA');

View File

@ -18,7 +18,7 @@ BEGIN
AND e.id = vSelf;
IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
CALL util.throw('Entry is not editable');
CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable'));
END IF;
END$$
DELIMITER ;

View File

@ -13,20 +13,32 @@ BEGIN
* @param vBookEntry Id de asiento, si es NULL se genera uno nuevo
*/
DECLARE vFiscalYear INT;
DECLARE vHasDistinctTransactions INT;
DECLARE vDistinctTransactions INT;
DECLARE vHasRepeatedTransactions BOOL;
SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions
SELECT COUNT(DISTINCT iit.transactionTypeSageFk) INTO vDistinctTransactions
FROM invoiceIn ii
JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
JOIN invoiceInSerial iis ON iis.code = ii.serial
WHERE ii.id = vSelf
WHERE iit.invoiceInFk = vSelf
AND iis.taxAreaFk = 'CEE'
AND transactionTypeSageFk;
AND iit.transactionTypeSageFk;
IF vHasDistinctTransactions > 1 THEN
IF vDistinctTransactions > 1 THEN
CALL util.throw ('This invoice does not allow different types of transactions');
END IF;
SELECT TRUE INTO vHasRepeatedTransactions
FROM invoiceInTax
WHERE invoiceInFk = vSelf
GROUP BY transactionTypeSageFk
HAVING COUNT(transactionTypeSageFk) > 1
LIMIT 1;
IF vHasRepeatedTransactions THEN
CALL util.throw ('This invoice contains repeated types of transactions');
END IF;
CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn
ENGINE = MEMORY
SELECT ii.bookEntried,

View File

@ -40,8 +40,7 @@ proc: BEGIN
(PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT itemFk,
SUM(quantity) quantity,
SUM(quantity) visible
SUM(quantity) quantity
FROM (
SELECT s.itemFk, - s.quantity quantity
FROM sale s
@ -75,56 +74,59 @@ proc: BEGIN
) sub
GROUP BY itemFk;
-- Cálculo del visible
UPDATE tItemInventoryCalc iic
JOIN (
SELECT itemFk, SUM(quantity) visible
FROM (
SELECT s.itemFk, s.quantity
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN warehouse w ON w.id = t.warehouseFk
WHERE t.shipped >= vDate
AND t.shipped < vDateTomorrow
AND (NOT isPicked AND NOT t.isLabeled AND t.refFk IS NULL)
AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
AND w.isComparative
UNION ALL
SELECT b.itemFk, - b.quantity
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
JOIN warehouse w ON w.id = t.warehouseInFk
WHERE t.landed = vDate
AND NOT t.isReceived
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
AND w.isComparative
UNION ALL
SELECT b.itemFk, b.quantity
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
JOIN warehouse w ON w.id = t.warehouseOutFk
WHERE t.shipped = vDate
AND NOT t.isReceived
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
AND w.isComparative
) sub2
GROUP BY itemFk
) sub ON sub.itemFk = iic.itemFk
SET iic.visible = iic.visible + sub.visible;
UPDATE tmp.itemInventory ai
JOIN tItemInventoryCalc iic ON iic.itemFk = ai.id
SET ai.inventory = iic.quantity,
ai.visible = iic.visible,
ai.visible = iic.quantity,
ai.avalaible = iic.quantity,
ai.sd = iic.quantity;
-- Cálculo del visible
CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc
(PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT itemFk, SUM(quantity) visible
FROM (
SELECT s.itemFk, s.quantity
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN warehouse w ON w.id = t.warehouseFk
WHERE t.shipped >= vDate
AND t.shipped < vDateTomorrow
AND (NOT isPicked AND NOT t.isLabeled AND t.refFk IS NULL)
AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk
AND w.isComparative
UNION ALL
SELECT b.itemFk, - b.quantity
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
JOIN warehouse w ON w.id = t.warehouseInFk
WHERE t.landed = vDate
AND NOT t.isReceived
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk
AND w.isComparative
UNION ALL
SELECT b.itemFk, b.quantity
FROM buy b
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
JOIN warehouse w ON w.id = t.warehouseOutFk
WHERE t.shipped = vDate
AND NOT t.isReceived
AND NOT e.isExcludedFromAvailable
AND NOT e.isRaid
AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk
AND w.isComparative
) sub2
GROUP BY itemFk;
UPDATE tmp.itemInventory ai
JOIN tItemVisibleCalc ivc ON ivc.itemFk = ai.id
SET ai.visible = ai.visible + ivc.visible;
-- Calculo del disponible
CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
(INDEX (itemFk, warehouseFk))
@ -195,6 +197,7 @@ proc: BEGIN
tmp.itemTravel,
tmp.itemCalc,
tItemInventoryCalc,
tItemVisibleCalc,
tmp.itemAtp;
END$$
DELIMITER ;

View File

@ -11,11 +11,9 @@ BEGIN
IF NEW.isBooked = OLD.isBooked AND (
NOT (NEW.supplierFk <=> OLD.supplierFk) OR
NOT (NEW.dated <=> OLD.dated) OR
NOT (NEW.invoiceNumber <=> OLD.invoiceNumber) OR
NOT (NEW.travelFk <=> OLD.travelFk) OR
NOT (NEW.companyFk <=> OLD.companyFk) OR
NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) OR
NOT (NEW.invoiceAmount <=> OLD.invoiceAmount) OR
NOT (NEW.typeFk <=> OLD.typeFk)
) THEN

View File

@ -0,0 +1,42 @@
USE `vn`;
CREATE TABLE IF NOT EXISTS vn.`tillSerial` (
`code` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL,
`description` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`account` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
PRIMARY KEY (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES(' S', 'Saldos final / inicial', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('A', 'Factura cliente', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('B', 'Factura cliente', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('C', 'Facturas Contado', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CC', 'Cuadre caja', '6780000000');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CD', 'Cuenta Director Comercial', '5510000002');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CH', 'Cheques', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CM', 'Cambio', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CR', 'Ingreso/Reintegro Caja Rural', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CT', 'Correos y telégrafos', '6290000005');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DC', 'Dietas conductores', '6290000010');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DH', 'Deudas Holland', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DT', 'Dietas', '6290000011');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('E', 'Entrada mercancia', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('EN', 'Enric Martinez', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GC', 'Cuenta con dto. Comercial', '5510000003');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GP', 'Gastos de personal', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GR', 'Gastos RRPP dpto comercial', '6290001002');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GS', 'Gasoil', '6280000002');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GV', 'Gastos viaje', '6290001000');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('JV', 'Juanvi', '6290000553');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('MB', 'Movimiento bancario', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('MP', 'Materias Primas', '6000000000');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('OG', 'Otros gastos', '6290000000');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('PM', 'Pequeño material', '6290000007');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('R', 'Factura proveedor', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('RC', 'Ingreso/Reintegro Ruralcaja', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('RN', 'Reparación nave', '6220000004');
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('SS', 'Gastos Silla', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('T', 'Ticket', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TA', 'Factura rapida', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TC', 'Ticket contado', NULL);
INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TR', 'Traspaso', NULL);

View File

@ -0,0 +1,4 @@
ALTER TABLE vn.expeditionState
MODIFY COLUMN userFk INT(10) UNSIGNED,
ADD CONSTRAINT expeditionState_userFk FOREIGN KEY (userFk)
REFERENCES account.`user`(id);

View File

@ -0,0 +1,8 @@
ALTER TABLE `vn`.`claimDestination`
ADD COLUMN `code` varchar(45) DEFAULT NULL;
UPDATE IGNORE vn.claimDestination SET code='Good' WHERE description= 'Bueno';
UPDATE IGNORE vn.claimDestination SET code='Garbage/Loss' WHERE description = 'Basura/Perd.';
UPDATE IGNORE vn.claimDestination SET code='Manufacturing' WHERE description = 'Confeccion';
UPDATE IGNORE vn.claimDestination SET code='Claim' WHERE description = 'Reclam.PRAG';
UPDATE IGNORE vn.claimDestination SET code='Corrected' WHERE description = 'Corregido';

View File

@ -0,0 +1,6 @@
-- Place your SQL code here
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS clientTypeWidth int(10) unsigned NULL
COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.';
UPDATE vn.mrwConfig
SET clientTypeWidth = 6;

View File

@ -146,10 +146,11 @@ module.exports = Self => {
});
filter = mergeFilters(ctx.args.filter, {where});
const userId = ctx.req.accessToken.userId;
const isSupplier = await Self.app.models.Supplier.findById(userId, myOptions);
if (isSupplier) {
const client = await Self.app.models.Client.findById(userId, myOptions);
const supplier = await Self.app.models.Supplier.findOne({where: {nif: client.fi}}, myOptions);
if (supplier) {
if (!filter.where) filter.where = {};
filter.where[`e.supplierFk`] = ctx.req.accessToken.userId;
filter.where[`e.supplierFk`] = supplier.id;
}
const stmts = [];
let stmt;

View File

@ -36,9 +36,10 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
const isSupplier = await Self.app.models.Supplier.findById(userId, myOptions);
if (isSupplier) {
const isEntryOwner = (await Self.findById(id)).supplierFk === userId;
const client = await Self.app.models.Client.findById(userId, myOptions);
const supplier = await Self.app.models.Supplier.findOne({where: {nif: client.fi}}, myOptions);
if (supplier) {
const isEntryOwner = (await Self.findById(id)).supplierFk === supplier.id;
if (!isEntryOwner) throw new UserError('Access Denied');
}

View File

@ -56,7 +56,7 @@ describe('Entry filter()', () => {
try {
const ctx = {
args: {},
req: {accessToken: {userId: 2}}
req: {accessToken: {userId: 1102}}
};
const result = await models.Entry.filter(ctx, options);
@ -79,7 +79,7 @@ describe('Entry filter()', () => {
args: {
supplierFk: 1
},
req: {accessToken: {userId: 2}}
req: {accessToken: {userId: 1102}}
};
const result = await models.Entry.filter(ctx, options);

View File

@ -40,7 +40,7 @@ describe('entry getBuys()', () => {
args: {
search: 1
},
req: {accessToken: {userId: 2}}
req: {accessToken: {userId: 1102}}
};
const result = await models.Entry.getBuys(ctx, entryId, options);

View File

@ -63,7 +63,7 @@ module.exports = Self => {
FROM tItemShelving ti
JOIN tItemInSector tis ON tis.itemFk = ti.itemFk
JOIN vn.productionConfig pc
WHERE ti.created > tis.created + INTERVAL pc.itemOlderReviewHours HOUR;`,
WHERE ti.created + INTERVAL pc.itemOlderReviewHours HOUR < tis.created ;`,
[shelvingFk, shelvingFk], myOptions);
return result;
};

View File

@ -3,29 +3,16 @@ const {models} = require('vn-loopback/server/server');
describe('itemShelving getListItemNewer()', () => {
it('should return true because there is an older item', async() => {
const shelving = 'NCC';
const parking = 'A-47-1';
const shelving = 'NBB';
const parking = '700-01';
const sectorCamHighCode = 'CAMARA SECTOR D';
const sectorCamCode = 'NAVE ALGEMESI';
const sectorCamCodeHighId = 1;
const sectorCamCodeId = 9991;
const sectorCamHighCode = 'FIRST';
const sectorCamCode = 'NS';
const tx = await models.Sector.beginTransaction({});
const myOptions = {transaction: tx};
try {
const sectorHighCam = await models.Sector.findById(sectorCamCodeHighId, null, myOptions);
await sectorHighCam.updateAttributes({
code: sectorCamHighCode
});
const sectorCam = await models.Sector.findById(sectorCamCodeId, null, myOptions);
await sectorCam.updateAttributes({
code: sectorCamCode
});
const config = await models.ProductionConfig.findOne();
await config.updateAttributes({
@ -35,7 +22,7 @@ describe('itemShelving getListItemNewer()', () => {
const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions);
expect(result.length).toEqual(2);
expect(result.length).toEqual(3);
await tx.rollback();
} catch (e) {
await tx.rollback();

View File

@ -59,7 +59,7 @@
<tr>
<td colspan="3" class="barcode">
<div v-html="getBarcode(buy.id)"></div>
<span>{{buy.id}}</span>
<span>{{buy.itemFk}}</span>
</td>
</tr>
<tr>

View File

@ -8,6 +8,7 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum,
b.`grouping`,
i.stems,
b.id,
b.itemFk,
p.name producer
FROM buy b
JOIN item i ON i.id = b.itemFk

View File

@ -27,8 +27,7 @@
<tr>
<td>{{$t('supplier.identifier')}}</td>
<th>
<div>{{supplier.iban}}</div>
<div>{{supplier.nif}}</div>
<div>{{supplier.accountDetailValue.join(', ')}}</div>
</th>
</tr>
<tr>

View File

@ -7,7 +7,11 @@ module.exports = {
async serverPrefetch() {
this.client = await this.findOneFromDef('client', [this.companyId, this.companyId, this.id]);
this.checkMainEntity(this.client);
this.supplier = await this.findOneFromDef('supplier', [this.companyId, this.companyId, this.id]);
const suppliers = await this.rawSqlFromDef('supplier', [this.companyId, this.companyId, this.id]);
this.supplier = {
...suppliers[0],
accountDetailValue: suppliers.map(val => val?.accountDetailValue)
};
},
props: {
id: {
@ -23,11 +27,11 @@ module.exports = {
methods: {
getSupplierCif() {
return db.findOne(`
SELECT sa.iban, s.nif
SELECT DISTINCT ad.value
FROM supplierAccount sa
JOIN company co ON co.supplierAccountFk = sa.id
JOIN supplier s ON sa.supplierFk = s.id
WHERE co.id = ?`) [this.companyId];
JOIN accountDetail ad ON ad.supplierAccountFk = sa.id
JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk AND adt.id = 3
WHERE sa.supplierFk = ?`) [this.companyId];
}
}

View File

@ -7,9 +7,9 @@ SELECT
s.city,
sp.name province,
s.nif,
sa.iban,
sa.supplierFk,
be.name bankName
be.name bankName,
ad.value accountDetailValue
FROM
client c
LEFT JOIN mandate m ON m.clientFk = c.id AND m.companyFk = ? AND m.finished IS NULL
@ -19,9 +19,11 @@ FROM
LEFT JOIN province p ON p.id = c.provinceFk
LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
LEFT JOIN bankEntity be ON sa.bankEntityFk = be.id
LEFT JOIN accountDetail ad ON ad.supplierAccountFk = sa.id
JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk AND adt.id = 3
WHERE
(m.companyFk = ? OR m.companyFk IS NULL)
AND (c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk))
GROUP BY ad.value
ORDER BY
m.created DESC
LIMIT 1;
m.created DESC;