Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5120-reports_loopback
This commit is contained in:
commit
b24b6d4121
25
CHANGELOG.md
25
CHANGELOG.md
|
@ -5,10 +5,34 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2310.01] - 2023-03-23
|
||||
|
||||
### Added
|
||||
-
|
||||
|
||||
### Changed
|
||||
-
|
||||
|
||||
### Fixed
|
||||
- (Clientes -> Listado extendido) Resuelto error al filtrar por clientes inactivos desde la columna "Activo"
|
||||
- (General) Al pasar el ratón por encima del icono de "Borrar" en un campo, se hacía más grande afectando a la interfaz
|
||||
|
||||
## [2308.01] - 2023-03-09
|
||||
|
||||
### Added
|
||||
- (Proveedores -> Datos fiscales) Añadido checkbox 'Vies'
|
||||
- (Client -> Descriptor) Nuevo icono $ con barrotes para los clientes con impago
|
||||
- (Trabajador -> Datos Básicos) Añadido nuevo campo Taquilla
|
||||
- (Trabajador -> PDA) Nueva sección
|
||||
|
||||
### Changed
|
||||
- (Ticket -> Borrar ticket) Restringido el borrado de tickets con abono
|
||||
|
||||
## [2306.01] - 2023-02-23
|
||||
|
||||
### Added
|
||||
- (Tickets -> Datos Básicos) Mensaje de confirmación al intentar generar tickets con negativos
|
||||
- (Artículos) El visible y disponible se calcula a partir de un almacén diferente dependiendo de la sección en la que te encuentres. Se ha añadido un icono que informa sobre a partir de que almacén se esta calculando.
|
||||
|
||||
### Changed
|
||||
- (General -> Inicio) Ahora permite recuperar la contraseña tanto con el correo de recuperación como el usuario
|
||||
|
@ -16,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
- (Monitor de tickets) Cuando ordenas por columna, ya no se queda deshabilitado el botón de 'Actualizar'
|
||||
- (Zone -> Días de entrega) Al hacer click en un día, muestra correctamente las zonas
|
||||
- (Artículos) El disponible en la vista previa se muestra correctamente
|
||||
|
||||
## [2304.01] - 2023-02-09
|
||||
|
||||
|
|
|
@ -74,10 +74,13 @@ module.exports = Self => {
|
|||
const container = await models.ImageContainer.getContainer(collection);
|
||||
const rootPath = container.client.root;
|
||||
const fileSrc = path.join(rootPath, collection, size);
|
||||
|
||||
const ext = image.name.substring((image.name.length - 4));
|
||||
const fileName = ext !== '.png' ? `${image.name}.png` : image.name;
|
||||
const file = {
|
||||
path: `${fileSrc}/${image.name}.png`,
|
||||
path: `${fileSrc}/${fileName}`,
|
||||
contentType: 'image/png',
|
||||
name: `${image.name}.png`
|
||||
name: image.name
|
||||
};
|
||||
|
||||
if (!fs.existsSync(file.path)) return [];
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const uuid = require('uuid');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('upload', {
|
||||
|
@ -18,12 +19,6 @@ module.exports = Self => {
|
|||
type: 'string',
|
||||
description: 'The collection name',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'fileName',
|
||||
type: 'string',
|
||||
description: 'The file name',
|
||||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: 'Object',
|
||||
|
@ -56,10 +51,12 @@ module.exports = Self => {
|
|||
const [uploadedFile] = Object.values(uploaded.files).map(file => {
|
||||
return file[0];
|
||||
});
|
||||
|
||||
const file = await TempContainer.getFile(tempContainer.name, uploadedFile.name);
|
||||
srcFile = path.join(file.client.root, file.container, file.name);
|
||||
|
||||
await models.Image.registerImage(args.collection, srcFile, args.fileName, args.id);
|
||||
const fileName = `${uuid.v4()}.png`;
|
||||
await models.Image.registerImage(args.collection, srcFile, fileName, args.id);
|
||||
} catch (e) {
|
||||
if (fs.existsSync(srcFile))
|
||||
await fs.unlink(srcFile);
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
"type": "date"
|
||||
}
|
||||
},
|
||||
|
||||
"scope": {
|
||||
"where" :{
|
||||
"expired": null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,9 +84,8 @@ module.exports = Self => {
|
|||
const container = await models.ImageContainer.container(collectionName);
|
||||
const rootPath = container.client.root;
|
||||
const collectionDir = path.join(rootPath, collectionName);
|
||||
const file = `${fileName}.png`;
|
||||
const dstDir = path.join(collectionDir, 'full');
|
||||
const dstFile = path.join(dstDir, file);
|
||||
const dstFile = path.join(dstDir, fileName);
|
||||
|
||||
const buffer = readChunk.sync(srcFilePath, 0, 12);
|
||||
const type = imageType(buffer);
|
||||
|
@ -102,7 +101,8 @@ module.exports = Self => {
|
|||
width: bmpData.width,
|
||||
height: bmpData.height,
|
||||
channels: 4
|
||||
}
|
||||
},
|
||||
failOn: 'none'
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ module.exports = Self => {
|
|||
const sizes = collection.sizes();
|
||||
for (let size of sizes) {
|
||||
const dstDir = path.join(collectionDir, `${size.width}x${size.height}`);
|
||||
const dstFile = path.join(dstDir, file);
|
||||
const dstFile = path.join(dstDir, fileName);
|
||||
const resizeOpts = {
|
||||
withoutEnlargement: true,
|
||||
fit: size.crop ? 'cover' : 'inside'
|
||||
|
|
|
@ -30,7 +30,10 @@ async function test() {
|
|||
|
||||
const bootOptions = {dataSources};
|
||||
const app = require('vn-loopback/server/server');
|
||||
app.boot(bootOptions);
|
||||
await new Promise((resolve, reject) => {
|
||||
app.boot(bootOptions,
|
||||
err => err ? reject(err) : resolve());
|
||||
});
|
||||
|
||||
const Jasmine = require('jasmine');
|
||||
const jasmine = new Jasmine();
|
||||
|
|
|
@ -3,7 +3,3 @@ ALTER TABLE `vn`.`itemConfig` ADD CONSTRAINT itemConfig_FK FOREIGN KEY (defaultT
|
|||
ALTER TABLE `vn`.`itemConfig` ADD validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL;
|
||||
ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 NOT NULL;
|
||||
ALTER TABLE `vn`.`item` MODIFY COLUMN relevancy tinyint(1) DEFAULT 0 NOT NULL COMMENT 'La web ordena de forma descendiente por este campo para mostrar los artículos';
|
||||
|
||||
INSERT INTO `salix`.`ACL`
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('ItemConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer');
|
|
@ -3,7 +3,3 @@ ALTER TABLE `vn`.`itemConfig` ADD CONSTRAINT itemConfig_FK FOREIGN KEY (defaultT
|
|||
ALTER TABLE `vn`.`itemConfig` ADD validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL;
|
||||
ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 NOT NULL;
|
||||
ALTER TABLE `vn`.`item` MODIFY COLUMN relevancy tinyint(1) DEFAULT 0 NOT NULL COMMENT 'La web ordena de forma descendiente por este campo para mostrar los artículos';
|
||||
|
||||
INSERT INTO `salix`.`ACL`
|
||||
(model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('ItemConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer');
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
DROP FUNCTION IF EXISTS `vn`.`invoiceOut_getWeight`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceOut_getWeight`(vInvoice VARCHAR(15)) RETURNS decimal(10,2)
|
||||
READS SQL DATA
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula el peso de una factura emitida
|
||||
*
|
||||
* @param vInvoice Id de la factura
|
||||
* @return vTotalWeight peso de la factura
|
||||
*/
|
||||
DECLARE vTotalWeight DECIMAL(10,2);
|
||||
|
||||
SELECT SUM(CAST(IFNULL(i.stems, 1)
|
||||
* s.quantity
|
||||
* IF(ic.grams, ic.grams, IFNULL(i.weightByPiece, 0)) / 1000 AS DECIMAL(10,2)))
|
||||
INTO vTotalWeight
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN itemCost ic ON ic.itemFk = i.id
|
||||
AND ic.warehouseFk = t.warehouseFk
|
||||
WHERE t.refFk = vInvoice
|
||||
AND i.intrastatFk;
|
||||
|
||||
RETURN vTotalWeight;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Client', 'getClientOrSupplierReference', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,127 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`ticket_canAdvance`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar.
|
||||
*
|
||||
* @param vDateFuture Fecha de los tickets que se quieren adelantar.
|
||||
* @param vDateToAdvance Fecha a cuando se quiere adelantar.
|
||||
* @param vWarehouseFk Almacén
|
||||
*/
|
||||
|
||||
DECLARE vDateInventory DATE;
|
||||
|
||||
SELECT inventoried INTO vDateInventory FROM config;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.stock;
|
||||
CREATE TEMPORARY TABLE tmp.stock
|
||||
(itemFk INT PRIMARY KEY,
|
||||
amount INT)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
INSERT INTO tmp.stock(itemFk, amount)
|
||||
SELECT itemFk, SUM(quantity) amount FROM
|
||||
(
|
||||
SELECT itemFk, quantity
|
||||
FROM itemTicketOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryIn
|
||||
WHERE landed >= vDateInventory
|
||||
AND landed < vDateFuture
|
||||
AND isVirtualStock = FALSE
|
||||
AND warehouseInFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseOutFk = vWarehouseFk
|
||||
) t
|
||||
GROUP BY itemFk HAVING amount != 0;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.filter;
|
||||
CREATE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
|
||||
SELECT
|
||||
origin.ticketFk futureId,
|
||||
dest.ticketFk id,
|
||||
dest.state,
|
||||
origin.futureState,
|
||||
origin.futureIpt,
|
||||
dest.ipt,
|
||||
origin.workerFk,
|
||||
origin.futureLiters,
|
||||
origin.futureLines,
|
||||
dest.shipped,
|
||||
origin.shipped futureShipped,
|
||||
dest.totalWithVat,
|
||||
origin.totalWithVat futureTotalWithVat,
|
||||
dest.agency,
|
||||
origin.futureAgency,
|
||||
dest.lines,
|
||||
dest.liters,
|
||||
origin.futureLines - origin.hasStock AS notMovableLines,
|
||||
(origin.futureLines = origin.hasStock) AS isFullMovable
|
||||
FROM (
|
||||
SELECT
|
||||
s.ticketFk,
|
||||
t.workerFk,
|
||||
t.shipped,
|
||||
t.totalWithVat,
|
||||
st.name futureState,
|
||||
t.addressFk,
|
||||
am.name futureAgency,
|
||||
count(s.id) futureLines,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt,
|
||||
CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters,
|
||||
SUM((s.quantity <= IFNULL(st.amount,0))) hasStock
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN state st ON st.id = ts.stateFk
|
||||
JOIN agencyMode am ON t.agencyModeFk = am.id
|
||||
LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
LEFT JOIN tmp.stock st ON st.itemFk = i.id
|
||||
WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id
|
||||
) origin
|
||||
JOIN (
|
||||
SELECT
|
||||
t.id ticketFk,
|
||||
t.addressFk,
|
||||
st.name state,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt,
|
||||
t.shipped,
|
||||
t.totalWithVat,
|
||||
am.name agency,
|
||||
CAST(SUM(litros) AS DECIMAL(10,0)) liters,
|
||||
CAST(COUNT(*) AS DECIMAL(10,0)) `lines`
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN saleVolume sv ON sv.saleFk = s.id
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN state st ON st.id = ts.stateFk
|
||||
JOIN agencyMode am ON t.agencyModeFk = am.id
|
||||
LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
AND st.order <= 5
|
||||
GROUP BY t.id
|
||||
) dest ON dest.addressFk = origin.addressFk
|
||||
WHERE origin.hasStock != 0;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.stock;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,6 @@
|
|||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES('ClaimBeginning', 'isEditable', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
|
||||
DELETE FROM `salix`.`ACL`
|
||||
WHERE model='Claim' AND property='isEditable';
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE `vn`.`itemConfig` ADD warehouseFk smallint(6) unsigned NULL;
|
||||
UPDATE `vn`.`itemConfig`
|
||||
SET warehouseFk=60
|
||||
WHERE id=0;
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('ItemConfig', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,16 @@
|
|||
ALTER TABLE `vn`.`supplier` ADD `isVies` tinyint(4) DEFAULT 0 NOT NULL;
|
||||
|
||||
UPDATE `vn`.`supplier` s
|
||||
JOIN vn.country c ON c.id = s.countryFk
|
||||
SET s.nif = MID(s.nif, 3, LENGTH(s.nif)-1), s.isVies = TRUE
|
||||
WHERE s.nif <> TRIM(IF(c.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif)-1), s.nif));
|
||||
|
||||
INSERT IGNORE INTO `vn`.`chat`
|
||||
(senderFk, recipient, checkUserStatus, message, status, attempts)
|
||||
VALUES(19263, '#informatica-cau', 0, '
|
||||
```
|
||||
UPDATE `vn`.`supplier` s
|
||||
JOIN vn.country c ON c.id = s.countryFk
|
||||
SET s.nif = MID(s.nif, 3, LENGTH(s.nif)-1), s.isVies = TRUE
|
||||
WHERE s.nif <> TRIM(IF(c.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif)-1), s.nif));
|
||||
```', 0, 0);
|
|
@ -0,0 +1,15 @@
|
|||
ALTER TABLE `vn`.`worker` ADD locker INT UNSIGNED NULL UNIQUE;
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('DeviceProduction', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('DeviceProductionModels', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('DeviceProductionState', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('DeviceProductionUser', '*', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('DeviceProduction', '*', '*', 'ALLOW', 'ROLE', 'productionAssi'),
|
||||
('DeviceProductionModels', '*', '*', 'ALLOW', 'ROLE', 'productionAssi'),
|
||||
('DeviceProductionState', '*', '*', 'ALLOW', 'ROLE', 'productionAssi'),
|
||||
('DeviceProductionUser', '*', '*', 'ALLOW', 'ROLE', 'productionAssi'),
|
||||
('Worker', 'deallocatePDA', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('Worker', 'allocatePDA', '*', 'ALLOW', 'ROLE', 'hr'),
|
||||
('Worker', 'deallocatePDA', '*', 'ALLOW', 'ROLE', 'productionAssi'),
|
||||
('Worker', 'allocatePDA', '*', 'ALLOW', 'ROLE', 'productionAssi');
|
|
@ -0,0 +1,127 @@
|
|||
DROP PROCEDURE IF EXISTS `sage`.`clientSupplier_add`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` PROCEDURE `sage`.`clientSupplier_add`(vCompanyFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Prepara los datos de clientes y proveedores para exportarlos a Sage
|
||||
* @vCompanyFk Empresa dela que se quiere trasladar datos
|
||||
*/
|
||||
DECLARE vCountryCeutaMelillaFk INT;
|
||||
DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2);
|
||||
|
||||
SELECT SiglaNacion INTO vCountryCanariasCode
|
||||
FROM Naciones
|
||||
WHERE Nacion ='ISLAS CANARIAS';
|
||||
|
||||
SELECT CodigoNacion, SiglaNacion INTO vCountryCeutaMelillaFk, vCountryCeutaMelillaCode
|
||||
FROM Naciones
|
||||
WHERE Nacion ='CEUTA Y MELILLA';
|
||||
|
||||
TRUNCATE TABLE clientesProveedores;
|
||||
|
||||
INSERT INTO clientesProveedores
|
||||
(CodigoEmpresa,
|
||||
ClienteOProveedor,
|
||||
CodigoClienteProveedor,
|
||||
RazonSocial,
|
||||
Nombre,
|
||||
Domicilio,
|
||||
CodigoCuenta,
|
||||
CifDni,
|
||||
CifEuropeo,
|
||||
CodigoPostal,
|
||||
Municipio,
|
||||
CodigoProvincia,
|
||||
Provincia,
|
||||
CodigoNacion,
|
||||
SiglaNacion,
|
||||
PersonaFisicaJuridica,
|
||||
TipoDocumentoPersona,
|
||||
CodigoIva,
|
||||
Nacion,
|
||||
Telefono,
|
||||
Telefono2,
|
||||
CodigoTransaccion,
|
||||
CodigoRetencion,
|
||||
Email1,
|
||||
iban)
|
||||
SELECT
|
||||
company_getCode(vCompanyFk),
|
||||
'C',
|
||||
c.id,
|
||||
c.socialName,
|
||||
c.socialName,
|
||||
IFNULL(c.street, ''),
|
||||
c.accountingAccount,
|
||||
TRIM(IF(c.isVies, CONCAT(cu.code,c.fi), c.fi)),
|
||||
IF(n.NacionCEE,TRIM(IF(cu.code = LEFT(c.fi, 2), c.fi, CONCAT(cu.code,c.fi))) , ''),
|
||||
IFNULL(c.postcode, ''),
|
||||
IFNULL(c.city, ''),
|
||||
IFNULL(pr.CodigoProvincia, ''),
|
||||
IFNULL(p.name, ''),
|
||||
IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8mb3_unicode_ci, IF(@isCeutaMelilla := IF(pr.Provincia IN ('CEUTA', 'MELILLA'), TRUE, FALSE), vCountryCeutaMelillaFk, IF (@isCanarias, vCountryCanariasCode, n.CodigoNacion)), n.CodigoNacion),
|
||||
IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8mb3_unicode_ci, IF(@isCeutaMelilla, vCountryCeutaMelillaCode, IF (@isCanarias, vCountryCanariasCode, n.SiglaNacion)), n.SiglaNacion),
|
||||
IF((c.fi REGEXP '^([[:blank:]]|[[:digit:]])'), 'J','F'),
|
||||
IF(cu.code IN('ES','EX'),
|
||||
1,
|
||||
IF((cu.isUeeMember AND c.isVies), 2, 4)),
|
||||
IFNULL(c.taxTypeSageFk,0),
|
||||
IF(n.SiglaNacion = vCountryCanariasCode COLLATE utf8mb3_unicode_ci,
|
||||
IF(@isCeutaMelilla, 'CEUTA Y MELILLA', IF (@isCanarias, 'ISLAS CANARIAS', n.Nacion)),
|
||||
n.Nacion),
|
||||
IFNULL(c.phone, ''),
|
||||
IFNULL(c.mobile, ''),
|
||||
IFNULL(c.transactionTypeSageFk, 0),
|
||||
'0',
|
||||
IFNULL(SUBSTR(c.email, 1, LOCATE(',', CONCAT(c.email, ','))-1), ''),
|
||||
IFNULL(c.iban, '')
|
||||
FROM vn.`client` c
|
||||
JOIN clientLastTwoMonths clm ON clm.clientFk = c.id
|
||||
LEFT JOIN vn.country cu ON cu.id = c.countryFk
|
||||
LEFT JOIN Naciones n ON n.countryFk = cu.id
|
||||
LEFT JOIN vn.province p ON p.id = c.provinceFk
|
||||
LEFT JOIN Provincias pr ON pr.provinceFk = p.id
|
||||
WHERE c.isRelevant
|
||||
AND clm.companyFk = vCompanyFk
|
||||
UNION ALL
|
||||
SELECT company_getCode(vCompanyFk),
|
||||
'P',
|
||||
s.id,
|
||||
s.name,
|
||||
s.name,
|
||||
IFNULL(s.street, ''),
|
||||
s.account,
|
||||
TRIM(IF(s.isVies, CONCAT(co.code,s.nif), s.nif)),
|
||||
IF(n.NacionCEE, TRIM(CONCAT(co.code, IF(co.code = LEFT(s.nif, 2), MID(s.nif, 3, LENGTH(s.nif) - 1), s.nif))), ''),
|
||||
IFNULL(s.postCode,''),
|
||||
IFNULL(s.city, ''),
|
||||
IFNULL(pr.CodigoProvincia, ''),
|
||||
IFNULL(p.name, ''),
|
||||
n.CodigoNacion,
|
||||
n.SiglaNacion COLLATE utf8mb3_unicode_ci,
|
||||
IF((s.nif REGEXP '^([[:blank:]]|[[:digit:]])'),'J','F'),
|
||||
IF(co.country IN ('España', 'España exento'), 1,IF(co.isUeeMember = 1, 2, 4)),
|
||||
IFNULL(s.taxTypeSageFk, 0),
|
||||
n.Nacion,
|
||||
IFNULL(sc.phone, ''),
|
||||
IFNULL(sc.mobile, ''),
|
||||
IFNULL(s.transactionTypeSageFk, 0),
|
||||
IFNULL(s.withholdingSageFk, '0'),
|
||||
IFNULL(SUBSTR(sc.email, 1, (COALESCE(NULLIF(LOCATE(',', sc.email), 0), 99) - 1)), ''),
|
||||
IFNULL(iban, '')
|
||||
FROM vn.supplier s
|
||||
JOIN supplierLastThreeMonths pl ON pl.supplierFk = s.id
|
||||
LEFT JOIN vn.country co ON co.id = s.countryFk
|
||||
LEFT JOIN Naciones n ON n.countryFk = co.id
|
||||
LEFT JOIN vn.province p ON p.id = s.provinceFk
|
||||
LEFT JOIN Provincias pr ON pr.provinceFk = p.id
|
||||
LEFT JOIN vn.supplierContact sc ON sc.supplierFk = s.id
|
||||
LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id
|
||||
WHERE pl.companyFk = vCompanyFk AND
|
||||
s.isActive AND
|
||||
s.nif <> ''
|
||||
GROUP BY pl.supplierFk, pl.companyFk;
|
||||
END$$
|
||||
DELIMITER ;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue