Compare commits

...

36 Commits

Author SHA1 Message Date
Robert Ferrús 4b309d7dc3 Merge branch 'dev' into 8077-sumDefaulter
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-18 12:20:15 +00:00
Guillermo Bonet cdcc5051d2 feat: refs #8057 Fix version
gitea/salix/pipeline/head This commit looks good Details
2024-11-18 13:09:33 +01:00
Guillermo Bonet 2b770c0201 feat: refs #8057 Fix version
gitea/salix/pipeline/head There was a failure building this commit Details
2024-11-18 12:56:37 +01:00
Guillermo Bonet aed4bc89c7 feat: refs #8057 Fix version
gitea/salix/pipeline/head There was a failure building this commit Details
2024-11-18 12:53:36 +01:00
Guillermo Bonet baadd621e1 Merge pull request 'feat: refs #8057 Added geoFk columns' (!3204) from 8057-geoFk into dev
gitea/salix/pipeline/head There was a failure building this commit Details
Reviewed-on: #3204
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
Reviewed-by: Pako Natek <pako@verdnatura.es>
2024-11-18 11:47:53 +00:00
Javier Segarra 3f6a23fe35 Merge pull request '#7289 Sales already moved' (!3212) from 7289_sales_already_moved into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3212
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-11-18 10:40:54 +00:00
Javier Segarra 4b64b27ca7 Merge branch 'dev' into 7289_sales_already_moved
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-18 10:39:17 +00:00
Jorge Penadés 433f883700 Merge pull request 'feat: refs #6869 define model' (!3172) from 6869-createGetDetails into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3172
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
Reviewed-by: Guillermo Bonet <guillermo@verdnatura.es>
2024-11-18 10:08:20 +00:00
Guillermo Bonet 66009ee0dd Merge branch 'dev' into 8057-geoFk
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-18 09:52:55 +00:00
Guillermo Bonet 754c0cb9ab Merge branch '8057-geoFk' of https://gitea.verdnatura.es/verdnatura/salix into 8057-geoFk
gitea/salix/pipeline/pr-dev Build queued... Details
2024-11-18 10:52:44 +01:00
Guillermo Bonet a64f9b74ec feat: refs #8057 Requested changes 2024-11-18 10:52:41 +01:00
Jorge Penadés dd637b9333 fix: refs #6869 use id as primaryKey
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-18 10:34:23 +01:00
Jorge Penadés 5e78317b5e Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6869-createGetDetails
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-18 10:15:35 +01:00
Javier Segarra f471f7e76c Merge branch 'dev' into 7289_sales_already_moved
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-18 10:10:57 +01:00
Javier Segarra 9558d030ff feat: refs #7289 #7289 remove bad translation 2024-11-18 10:10:30 +01:00
Robert Ferrús 5e21e4e368 Merge pull request 'feat: refs #8127 entry_getCommission' (!3128) from 8127-entry_updateComission into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3128
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-11-18 08:48:50 +00:00
Robert Ferrús 329488d700 Merge branch 'dev' into 8127-entry_updateComission
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-18 08:46:49 +00:00
Guillermo Bonet 2b97c18412 Merge branch 'dev' into 6869-createGetDetails
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-18 08:34:11 +00:00
Sergio De la torre 7d5928bc3d Merge pull request 'feat: refs #8135 refs#8135 updateTicketACL' (!3210) from 8135-ticketACL into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3210
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-11-18 08:21:18 +00:00
Guillermo Bonet e81727f3f8 Merge branch 'dev' into 8057-geoFk
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-18 07:58:51 +00:00
Guillermo Bonet 353ca659cd feat: refs #8057 Requested changes
gitea/salix/pipeline/pr-dev Build queued... Details
2024-11-18 08:58:38 +01:00
Javier Segarra 6c00efae89 feat: refs #7289 #7289 apply option 1
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-17 17:57:54 +01:00
Robert Ferrús 923296e85e Merge branch 'dev' into 8127-entry_updateComission
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-15 10:34:34 +00:00
Robert Ferrús c5f1b05671 feat: refs #8127 quitar esquemas
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-11-15 11:32:20 +01:00
Robert Ferrús f7a5fc7e31 Merge branch 'dev' into 8127-entry_updateComission
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-15 10:06:45 +00:00
Sergio De la torre 07318656b7 feat: refs #8135 refs#8135 updateTicketACL
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-15 08:47:30 +01:00
Sergio De la torre 7a4455d6d0 feat: refs #6869 refs#6869 itemShelving_get
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-15 08:12:16 +01:00
Guillermo Bonet b9397c527d feat: refs #8057 Added data updates
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-14 09:32:02 +01:00
Guillermo Bonet bde192966e feat: refs #8057 Added data updates
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-14 09:30:36 +01:00
Guillermo Bonet cba1abad68 feat: refs #8057 Added data updates
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-14 09:27:38 +01:00
Guillermo Bonet d4b0da50d0 feat: refs #8057 Added data updates
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-14 09:00:19 +01:00
Guillermo Bonet b7655b4f92 feat: refs #8057 Added geoFk columns
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-14 08:24:42 +01:00
Jorge Penadés a41fc36f90 feat: refs #6869 define model
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-11 13:02:09 +01:00
Jorge Penadés e0ffc2840b Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6869-createGetDetails 2024-11-11 12:49:10 +01:00
Jorge Penadés 5c054fe0d3 feat: refs #6869 add back
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-11-11 09:09:51 +01:00
Robert Ferrús 7e0f19b368 feat: refs #8127 entry_getCommission
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-10-18 08:21:09 +02:00
22 changed files with 240 additions and 56 deletions

View File

@ -79,6 +79,9 @@
"ImageCollectionSize": {
"dataSource": "vn"
},
"ImageConfig": {
"dataSource": "vn"
},
"ImageContainer": {
"dataSource": "imageStorage"
},

View File

@ -0,0 +1,22 @@
{
"name": "ImageConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "hedera.imageConfig"
}
},
"properties": {
"url": {
"type": "string"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}
]
}

View File

@ -14,9 +14,11 @@ BEGIN
SELECT p.geoFk INTO vGeoFk
FROM address a
JOIN town t ON t.provinceFk = a.provinceFk
JOIN postCode p ON p.townFk = t.id AND p.`code` = a.postalCode
JOIN postCode p ON p.townFk = t.id
JOIN zoneGeo zg ON zg.id = p.geoFk
WHERE a.id = vSelf
ORDER BY (a.city SOUNDS LIKE t.`name`) DESC
ORDER BY (a.city SOUNDS LIKE t.name) DESC,
(p.code = a.postalCode) DESC
LIMIT 1;
RETURN vGeoFk;

View File

@ -0,0 +1,26 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getGeo`(vSelf INT)
RETURNS int(11)
DETERMINISTIC
BEGIN
/**
* Returns the geo for the passed client.
*
* @param vSelf The address id
* @return The geo id
*/
DECLARE vGeoFk INT;
SELECT p.geoFk INTO vGeoFk
FROM client c
JOIN town t ON t.provinceFk = c.provinceFk
JOIN postCode p ON p.townFk = t.id
JOIN zoneGeo zg ON zg.id = p.geoFk
WHERE c.id = vSelf
ORDER BY (c.city SOUNDS LIKE t.name) DESC,
(p.code = c.postcode) DESC
LIMIT 1;
RETURN vGeoFk;
END$$
DELIMITER ;

View File

@ -1,58 +1,51 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCommission`(vTravelFk INT,
vCurrencyFk INT,
vSupplierFk INT
vCurrencyFk INT,
vSupplierFk INT
)
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
BEGIN
DECLARE vCommission INT;
DECLARE vCurrentCommission INT;
DECLARE vIsCurrencyUsd INT;
DECLARE vLastEntryFk INT;
SELECT count(*) INTO vIsCurrencyUsd
FROM currency c
WHERE c.code = 'USD' AND id = vCurrencyFk;
IF NOT vIsCurrencyUsd THEN
SELECT e.id INTO vLastEntryFk
FROM vn.entry e
JOIN vn.travel tr ON tr.id = e.travelFk
WHERE e.supplierFk = vSupplierFk
ORDER BY tr.landed DESC
LIMIT 1;
IF vLastEntryFk THEN
SELECT commission INTO vCurrentCommission
FROM vn.entry
WHERE id = vLastEntryFk;
ELSE
SELECT commission INTO vCurrentCommission
FROM supplier s
WHERE s.id = vSupplierFk;
END IF;
RETURN vCurrentCommission;
ELSE
DECLARE vCommission INT;
DECLARE vCurrentCommission INT;
DECLARE vIsNotEUR INT;
DECLARE vLastEntryFk INT;
SELECT count(*) INTO vIsNotEUR
FROM currency c
WHERE c.code <> 'EUR' AND id = vCurrencyFk;
IF vIsNotEUR THEN
SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission
FROM travel t
LEFT JOIN referenceCurrent r ON r.currencyFk = vCurrencyFk AND r.`dated` <= t.shipped
WHERE t.id = vTravelFk
ORDER BY r.`dated` DESC
LIMIT 1;
RETURN IFNULL(vCommission, 0);
END IF;
ELSE
SELECT e.id INTO vLastEntryFk
FROM `entry` e
JOIN travel tr ON tr.id = e.travelFk
WHERE e.supplierFk = vSupplierFk
ORDER BY tr.landed DESC
LIMIT 1;
IF vLastEntryFk THEN
SELECT commission INTO vCurrentCommission
FROM `entry`
WHERE id = vLastEntryFk;
ELSE
SELECT commission INTO vCurrentCommission
FROM supplier s
WHERE s.id = vSupplierFk;
END IF;
RETURN vCurrentCommission;
END IF;
END$$
DELIMITER ;

View File

@ -0,0 +1,28 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`supplier_getGeo`(vSelf INT)
RETURNS int(11)
DETERMINISTIC
BEGIN
/**
* Returns the geo for the passed supplier.
*
* @param vSelf The address id
* @return The geo id
*/
DECLARE vGeoFk INT;
SELECT p.geoFk INTO vGeoFk
FROM supplier s
JOIN town t ON t.provinceFk = s.provinceFk
JOIN postCode p ON p.townFk = t.id
LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id
JOIN zoneGeo zg ON zg.id = p.geoFk
WHERE s.id = vSelf
ORDER BY (s.city SOUNDS LIKE t.name) DESC,
(p.code = s.postCode) DESC,
(p.code = sad.postalCode) DESC
LIMIT 1;
RETURN vGeoFk;
END$$
DELIMITER ;

View File

@ -22,7 +22,7 @@ BEGIN
FROM vn.entry e
JOIN vn.travel t ON t.id = e.travelFk
JOIN vn.warehouse w ON w.id = t.warehouseInFk
WHERE t.shipped >= util.VN_CURDATE()
WHERE t.landed >= util.VN_CURDATE()
AND e.currencyFk = vCurrency
AND NOT e.isBooked;
@ -33,7 +33,7 @@ BEGIN
SET e.commission = vComission;
SELECT `name` INTO vCurrencyName
FROM currency
FROM currency
WHERE id = vCurrency;
CALL entry_recalc();

View File

@ -6,6 +6,7 @@ BEGIN
DECLARE vIsEqualizated BOOL;
SET NEW.editorFk = account.myUser_getId();
SET NEW.geoFk = address_getGeo(NEW.id);
IF (NEW.phone <> '') THEN
CALL pbx.phone_isValid(NEW.phone);

View File

@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_beforeUpdate`
BEFORE UPDATE ON `address`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN
@ -14,5 +13,10 @@ BEGIN
CALL pbx.phone_isValid(NEW.mobile);
END IF;
IF NOT (NEW.provinceFk <=> OLD.provinceFk)
OR (NEW.postalCode <=> OLD.postalCode) THEN
SET NEW.geoFk = address_getGeo(NEW.id);
END IF;
END$$
DELIMITER ;

View File

@ -3,8 +3,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_beforeInsert`
BEFORE INSERT ON `client`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
SET NEW.accountingAccount = 4300000000 + NEW.id;
SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
SET NEW.geoFk = client_getGeo(NEW.id);
IF (NEW.phone <> '') THEN
CALL pbx.phone_isValid(NEW.phone);
@ -13,9 +15,5 @@ BEGIN
IF (NEW.mobile <> '') THEN
CALL pbx.phone_isValid(NEW.mobile);
END IF;
SET NEW.accountingAccount = 4300000000 + NEW.id;
SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
END$$
DELIMITER ;

View File

@ -72,5 +72,11 @@ BEGIN
IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN
SET NEW.isTaxDataChecked = 0;
END IF;
IF NOT (NEW.provinceFk <=> OLD.provinceFk)
OR (NEW.postcode <=> OLD.postcode) THEN
SET NEW.geoFk = client_getGeo(NEW.id);
END IF;
END$$
DELIMITER ;

View File

@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplier_beforeInsert`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
SET NEW.geoFk = supplier_getGeo(NEW.id);
END$$
DELIMITER ;

View File

@ -40,5 +40,10 @@ BEGIN
SET NEW.isPayMethodChecked = FALSE;
END IF;
IF NOT (NEW.provinceFk <=> OLD.provinceFk)
OR (NEW.postCode <=> OLD.postCode) THEN
SET NEW.geoFk = supplier_getGeo(NEW.id);
END IF;
END$$
DELIMITER ;

View File

@ -0,0 +1,22 @@
ALTER TABLE vn.address
ADD geoFk int(11) DEFAULT NULL NULL AFTER isLogifloraAllowed,
ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk)
REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT a.id, p.geoFk
FROM vn.address a
JOIN vn.town t ON t.provinceFk = a.provinceFk
JOIN vn.postCode p ON p.townFk = t.id
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
GROUP BY a.id
ORDER BY (a.city SOUNDS LIKE t.`name`) DESC,
(p.code = a.postalCode) DESC;
UPDATE vn.address a
JOIN tmp.tAddressGeo tag ON tag.id = a.id
SET a.geoFk = tag.geoFk;
DROP TEMPORARY TABLE tmp.tAddressGeo;

View File

@ -0,0 +1,25 @@
ALTER TABLE vn.client
CHANGE hasDailyInvoice hasDailyInvoice tinyint(1) DEFAULT 0 NOT NULL
COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice'
AFTER recommendedCredit,
ADD geoFk int(11) DEFAULT NULL NULL AFTER hasDailyInvoice,
ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk)
REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT c.id, p.geoFk
FROM vn.client c
JOIN vn.town t ON t.provinceFk = c.provinceFk
JOIN vn.postCode p ON p.townFk = t.id
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
GROUP BY c.id
ORDER BY (c.city SOUNDS LIKE t.`name`) DESC,
(p.code = c.postcode) DESC;
UPDATE vn.client c
JOIN tmp.tClientGeo tcg ON tcg.id = c.id
SET c.geoFk = tcg.geoFk;
DROP TEMPORARY TABLE tmp.tClientGeo;

View File

@ -0,0 +1,26 @@
ALTER TABLE vn.supplier
CHANGE companySize companySize enum('small','medium','big') CHARACTER SET utf8mb3
COLLATE utf8mb3_general_ci DEFAULT NULL NULL AFTER stamp,
ADD geoFk int(11) DEFAULT NULL NULL AFTER companySize,
ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk)
REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT s.id, p.geoFk
FROM vn.supplier s
JOIN vn.town t ON t.provinceFk = s.provinceFk
JOIN vn.postCode p ON p.townFk = t.id
LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
GROUP BY s.id
ORDER BY (s.city SOUNDS LIKE t.`name`) DESC,
(p.code = s.postCode) DESC,
(p.code = sad.postalCode) DESC;
UPDATE vn.supplier s
JOIN tmp.tSupplierGeo tsg ON tsg.id = s.id
SET s.geoFk = tsg.geoFk;
DROP TEMPORARY TABLE tmp.tSupplierGeo;

View File

@ -0,0 +1,7 @@
UPDATE salix.ACL
SET principalId = 'deliveryAssistant'
WHERE model = 'Ticket'
AND property = 'updateAttributes'
AND principalId = "delivery";

View File

@ -244,5 +244,7 @@
"Invalid or expired verification code": "Invalid or expired verification code",
"There are tickets for this area, delete them first": "There are tickets for this area, delete them first",
"ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}",
"Payment method is required": "Payment method is required"
"Payment method is required": "Payment method is required",
"Sales already moved": "Sales already moved"
}

View File

@ -387,5 +387,6 @@
"There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero",
"There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén",
"ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}",
"The web user's email already exists": "El correo del usuario web ya existe"
}
"The web user's email already exists": "El correo del usuario web ya existe",
"Sales already moved": "Ya han sido transferidas"
}

View File

@ -41,6 +41,9 @@
},
"available": {
"type": "number"
},
"buyFk": {
"type": "number"
}
},
"relations": {

View File

@ -1,6 +1,6 @@
{
"name": "Shelving",
"base": "VnModel",
"base": "VnModel",
"mixins": {
"Loggable": true
},
@ -44,6 +44,11 @@
"type": "belongsTo",
"model": "Worker",
"foreignKey": "id"
},
"itemShelving": {
"type": "hasMany",
"model": "ItemShelving",
"foreignKey": "shelvingFk"
}
}
}
}

View File

@ -81,6 +81,10 @@ module.exports = Self => {
if (ticketId != id && hasClaimedSales)
throw new UserError(`Can't transfer claimed sales`);
const missingSales = sales.some(({id}) => !map.has(id));
if (missingSales)
throw new UserError($t('Sales already moved'));
for (const sale of sales) {
const originalSale = map.get(sale.id);
if (sale.quantity == originalSale?.quantity) {