fixes #4928 Supplier payMethod notify #1202

Merged
alexandre merged 13 commits from 4928-supplier-payMethod-notify into dev 2022-12-20 07:07:38 +00:00
Contributor
No description provided.
alexandre added the
CR / Tests passed
label 2022-12-13 12:28:08 +00:00
alexandre added 1 commit 2022-12-13 12:28:10 +00:00
gitea/salix/pipeline/head There was a failure building this commit Details
95967a29db
refs #4928 email template added and proc modified
alexandre requested review from alexm 2022-12-13 13:40:55 +00:00
alexm requested changes 2022-12-14 06:37:39 +00:00
@ -0,0 +17,4 @@
FROM payMethod
WHERE id = NEW.payMethodFk;
SET vHasChange = (NEW.payMethodFk <=> OLD.payMethodFk);
Member

Deuria ser NOT(...) Aixina despres no fiques !vHasChange

Deuria ser NOT(...) Aixina despres no fiques !vHasChange
alexm marked this conversation as resolved
@ -0,0 +37,4 @@
SET vHasChange = (NEW.payDemFk <=> OLD.payDemFk) OR (NEW.payDay <=> OLD.payDay);
IF vPayMethodHasVerified AND !vHasChange THEN
SET vHasChange = (NEW.payMethodFk <=> OLD.payMethodFk);
Member

Com esta, se repetiria este SET.

He estat refactoritzant i crec q aixina se qdaria mes curt

CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_beforeUpdate`
	BEFORE UPDATE ON `supplier`
	FOR EACH ROW
BEGIN
	DECLARE vHasChange BOOL;
	DECLARE vPayMethodChanged BOOL;
	DECLARE vPayMethodHasVerified BOOL;
    DECLARE vParams JSON;
	DECLARE vOldPayMethodName VARCHAR(20);
	DECLARE vNewPayMethodName VARCHAR(20);

	SELECT hasVerified INTO vPayMethodHasVerified
		FROM payMethod
			WHERE id = NEW.payMethodFk;

	SET vPayMethodChanged = NOT(NEW.payMethodFk <=> OLD.payMethodFk);

	IF vPayMethodChanged THEN
		SELECT name INTO vOldPayMethodName
			FROM payMethod
				WHERE id = OLD.payMethodFk;
		SELECT name INTO vNewPayMethodName
			FROM payMethod
				WHERE id = NEW.payMethodFk;
			
		SET vParams = JSON_OBJECT(
					'name', NEW.name,
					'oldPayMethod', vOldPayMethodName,
					'newPayMethod', vNewPayMethodName
				);
		SELECT util.notification_send('supplier-pay-method-update', vParams, NULL) INTO @id;
	END IF;

	SET vHasChange =  NOT(NEW.payDemFk <=> OLD.payDemFk AND NEW.payDay <=> OLD.payDay) OR vPayMethodChanged;

	IF vHasChange AND vPayMethodHasVerified THEN
		SET NEW.isPayMethodChecked = FALSE;
	END IF;

END

Ho he provat i va be, pero provau per si de cas

Com esta, se repetiria este SET. He estat refactoritzant i crec q aixina se qdaria mes curt ``` CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_beforeUpdate` BEFORE UPDATE ON `supplier` FOR EACH ROW BEGIN DECLARE vHasChange BOOL; DECLARE vPayMethodChanged BOOL; DECLARE vPayMethodHasVerified BOOL; DECLARE vParams JSON; DECLARE vOldPayMethodName VARCHAR(20); DECLARE vNewPayMethodName VARCHAR(20); SELECT hasVerified INTO vPayMethodHasVerified FROM payMethod WHERE id = NEW.payMethodFk; SET vPayMethodChanged = NOT(NEW.payMethodFk <=> OLD.payMethodFk); IF vPayMethodChanged THEN SELECT name INTO vOldPayMethodName FROM payMethod WHERE id = OLD.payMethodFk; SELECT name INTO vNewPayMethodName FROM payMethod WHERE id = NEW.payMethodFk; SET vParams = JSON_OBJECT( 'name', NEW.name, 'oldPayMethod', vOldPayMethodName, 'newPayMethod', vNewPayMethodName ); SELECT util.notification_send('supplier-pay-method-update', vParams, NULL) INTO @id; END IF; SET vHasChange = NOT(NEW.payDemFk <=> OLD.payDemFk AND NEW.payDay <=> OLD.payDay) OR vPayMethodChanged; IF vHasChange AND vPayMethodHasVerified THEN SET NEW.isPayMethodChecked = FALSE; END IF; END ``` Ho he provat i va be, pero provau per si de cas
alexandre added 1 commit 2022-12-14 07:06:15 +00:00
gitea/salix/pipeline/head There was a failure building this commit Details
f00fdcff7c
refactor sql
alexandre added 1 commit 2022-12-14 07:30:51 +00:00
alexandre requested review from alexm 2022-12-14 07:31:32 +00:00
alexm approved these changes 2022-12-14 07:31:33 +00:00
alexandre added 1 commit 2022-12-15 07:32:08 +00:00
gitea/salix/pipeline/head This commit looks good Details
33196acac6
refs #4928 fixture notification, fix test supplier
alexandre requested review from alexm 2022-12-15 07:36:09 +00:00
alexm requested changes 2022-12-15 08:16:25 +00:00
@ -0,0 +45,4 @@
END$$
DELIMITER ;
INSERT INTO `util`.`notification` (`id`, `name`,`description`)
Member

Poner en fixture pq es siempre necesario y poner aparte cuando se suba a producción

Poner en fixture pq es siempre necesario y poner aparte cuando se suba a producción
@ -2,13 +2,7 @@ const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('loopback model Supplier', () => {
let supplierOne;
Member

Volver a poner

Volver a poner
alexandre added 1 commit 2022-12-15 08:23:10 +00:00
alexandre added 1 commit 2022-12-15 08:53:13 +00:00
gitea/salix/pipeline/head There was a failure building this commit Details
522000cd04
refs #4928 fix fixtures
alexm added 1 commit 2022-12-15 12:54:28 +00:00
gitea/salix/pipeline/head There was a failure building this commit Details
5cc8764a3f
acquireTimeout 10000
alexm added 1 commit 2022-12-15 13:02:30 +00:00
gitea/salix/pipeline/head This commit looks good Details
bab6fa0c9d
acquireTimeout: 60000
alexandre requested review from alexm 2022-12-15 13:59:03 +00:00
alexm added 1 commit 2022-12-16 07:08:46 +00:00
gitea/salix/pipeline/head This commit looks good Details
b8a0d179f1
Merge branch 'dev' into 4928-supplier-payMethod-notify
alexm added 1 commit 2022-12-16 10:43:48 +00:00
gitea/salix/pipeline/head This commit looks good Details
0a18c855e7
Merge branch 'dev' into 4928-supplier-payMethod-notify
alexm requested changes 2022-12-16 10:44:10 +00:00
@ -62,2 +73,3 @@
await supplierTwo.updateAttribute('isPayMethodChecked', true, options);
await supplierTwo.updateAttribute('payMethodFk', 5, options);
const result = await models.Supplier.findById(442);
Member

Utilizar byId

Utilizar byId
alexandre added 2 commits 2022-12-16 11:50:24 +00:00
alexandre requested review from alexm 2022-12-16 11:50:39 +00:00
alexm approved these changes 2022-12-19 06:26:30 +00:00
alexandre added 1 commit 2022-12-20 07:01:52 +00:00
gitea/salix/pipeline/head This commit looks good Details
cd71a59dfe
Merge branch 'dev' into 4928-supplier-payMethod-notify
alexandre scheduled this pull request to auto merge when all checks succeed 2022-12-20 07:03:17 +00:00
alexandre merged commit 2bb37e733a into dev 2022-12-20 07:07:38 +00:00
alexandre deleted branch 4928-supplier-payMethod-notify 2022-12-20 07:17:47 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: verdnatura/salix#1202
No description provided.