Merge pull request '6784-delete-clientTypeFk' (!2059) from 6784-delete-clientTypeFk into dev
gitea/salix/pipeline/head There was a failure building this commit Details
gitea/salix/pipeline/pr-dev This commit looks good Details

Reviewed-on: #2059
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Ivan Mas 2024-02-23 08:25:41 +00:00
commit bf85aa1e9d
15 changed files with 45 additions and 68 deletions

View File

@ -352,12 +352,12 @@ INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`)
('46600', 4, 7), ('46600', 4, 7),
('EC170150', 5, 8); ('EC170150', 5, 8);
INSERT INTO `vn`.`clientType`(`id`, `code`, `type`) INSERT INTO `vn`.`clientType`(`code`, `type`)
VALUES VALUES
(1, 'normal', 'Normal'), ('normal', 'Normal'),
(2, 'internalUse', 'Autoconsumo'), ('internalUse', 'Autoconsumo'),
(3, 'handMaking', 'Confección'), ('handMaking', 'Confección'),
(4, 'loses', 'Mermas'); ('loses', 'Mermas');
INSERT INTO `vn`.`cplusTerIdNif`(`id`, `description`) INSERT INTO `vn`.`cplusTerIdNif`(`id`, `description`)
VALUES VALUES
@ -371,20 +371,20 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`)
(4, 'GCN Channel'), (4, 'GCN Channel'),
(5, 'The Newspaper'); (5, 'The Newspaper');
INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`,`typeFk`) INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`,`typeFk`)
VALUES VALUES
(1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
(1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
(1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
(1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
(1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist','normal'), (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
(1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'), (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
(1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'), (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
(1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist','normal'), (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
(1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist','normal'), (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist','normal'),
(1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist','normal'), (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist','normal'),
(1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'), (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'),
(1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'); (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses');
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1

View File

@ -19,7 +19,7 @@ BEGIN
itemFk, itemFk,
itemTypeFk, itemTypeFk,
floor(sum(value)) as total, floor(sum(value)) as total,
floor(sum(IF(clientTypeFk = 'loses', value, 0))) as mermas floor(sum(IF(typeFk = 'loses', value, 0))) as mermas
FROM vn.saleValue FROM vn.saleValue
where year = vYear and week = vWeek where year = vYear and week = vWeek

View File

@ -47,12 +47,11 @@ BEGIN
JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN itemCategory ic ON ic.id = tp.categoryFk
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
JOIN client c ON c.id = t.clientFk JOIN client c ON c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
JOIN warehouse w ON w.id = t.warehouseFk JOIN warehouse w ON w.id = t.warehouseFk
JOIN address ad ON ad.id = t.addressFk JOIN address ad ON ad.id = t.addressFk
LEFT JOIN province p ON p.id = ad.provinceFk LEFT JOIN province p ON p.id = ad.provinceFk
WHERE tm.period BETWEEN vMaxPeriod AND vPeriod WHERE tm.period BETWEEN vMaxPeriod AND vPeriod
AND ct.code <> 'loses' AND c.typeFk <> 'loses'
AND NOT w.code = 'inv' AND NOT w.code = 'inv'
GROUP BY p.countryFk, s.itemFk, tm.period, t.warehouseFk; GROUP BY p.countryFk, s.itemFk, tm.period, t.warehouseFk;
END IF; END IF;

View File

@ -44,10 +44,9 @@ proc:BEGIN
LEFT JOIN saleTracking st ON st.saleFk = s.id LEFT JOIN saleTracking st ON st.saleFk = s.id
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
JOIN client c on c.id = t.clientFk JOIN client c on c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND st.saleFk IS NULL AND st.saleFk IS NULL
AND ct.code IN ('normal', 'trust') AND c.typeFk IN ('normal', 'trust')
GROUP BY s.itemFk GROUP BY s.itemFk
) sub2 ON sub2.itemFk = sub.itemFk ) sub2 ON sub2.itemFk = sub.itemFk
UNION ALL UNION ALL
@ -70,10 +69,9 @@ proc:BEGIN
LEFT JOIN saleTracking st ON st.saleFk = s.id LEFT JOIN saleTracking st ON st.saleFk = s.id
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
JOIN client c on c.id = t.clientFk JOIN client c on c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND st.saleFk IS NULL AND st.saleFk IS NULL
AND ct.code IN ('normal', 'trust') AND c.typeFk IN ('normal', 'trust')
GROUP BY s.itemFk GROUP BY s.itemFk
) sub5 ON sub5.itemFk = v.item_id ) sub5 ON sub5.itemFk = v.item_id
WHERE v.calc_id = vCalcVisibleFk WHERE v.calc_id = vCalcVisibleFk

View File

@ -120,7 +120,7 @@ BEGIN
TRUE, TRUE,
s.id, s.id,
st.`order`, st.`order`,
ct.`code`, c.typeFk,
cb.claimFk, cb.claimFk,
NULL NULL
FROM sale s FROM sale s
@ -128,7 +128,6 @@ BEGIN
LEFT JOIN ticketState ts ON ts.ticketFk = t.id LEFT JOIN ticketState ts ON ts.ticketFk = t.id
LEFT JOIN state st ON st.`code` = ts.`code` LEFT JOIN state st ON st.`code` = ts.`code`
JOIN client c ON c.id = t.clientFk JOIN client c ON c.id = t.clientFk
JOIN clientType ct ON ct.id = c.clientTypeFk
JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
'DELIVERED', 'DELIVERED',
IF (t.shipped > util.dayEnd(util.VN_CURDATE()), IF (t.shipped > util.dayEnd(util.VN_CURDATE()),

View File

@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
VIEW `vn`.`saleValue` VIEW `vn`.`saleValue`
AS SELECT `wh`.`name` AS `warehouse`, AS SELECT `wh`.`name` AS `warehouse`,
`c`.`name` AS `client`, `c`.`name` AS `client`,
`c`.`typeFk` AS `clientTypeFk`, `c`.`typeFk` AS `typeFk`,
`u`.`name` AS `buyer`, `u`.`name` AS `buyer`,
`it`.`id` AS `itemTypeFk`, `it`.`id` AS `itemTypeFk`,
`it`.`name` AS `family`, `it`.`name` AS `family`,

View File

@ -34,7 +34,6 @@ AS SELECT `c`.`id` AS `id_cliente`,
`c`.`hasLcr` AS `hasLcr`, `c`.`hasLcr` AS `hasLcr`,
`c`.`defaultAddressFk` AS `default_address`, `c`.`defaultAddressFk` AS `default_address`,
`c`.`riskCalculated` AS `risk_calculated`, `c`.`riskCalculated` AS `risk_calculated`,
`c`.`clientTypeFk` AS `clientes_tipo_id`,
`c`.`hasToInvoiceByAddress` AS `invoiceByAddress`, `c`.`hasToInvoiceByAddress` AS `invoiceByAddress`,
`c`.`isTaxDataChecked` AS `contabilizado`, `c`.`isTaxDataChecked` AS `contabilizado`,
`c`.`isFreezed` AS `congelado`, `c`.`isFreezed` AS `congelado`,

View File

@ -0,0 +1,6 @@
ALTER TABLE vn.client DROP FOREIGN KEY tipos_de_cliente;
ALTER TABLE vn.client CHANGE COLUMN clientTypeFk clientTypeFk__ INT NOT NULL DEFAULT 1 COMMENT '@deprecated 2024-02-20 refs #6784';
ALTER TABLE vn.clientType CHANGE COLUMN id id__ INT NOT NULL COMMENT '@deprecated 2024-02-20 refs #6784';
ALTER TABLE vn.clientType DROP PRIMARY KEY;
ALTER TABLE vn.clientType ADD PRIMARY KEY (code);

View File

@ -7,12 +7,9 @@
} }
}, },
"properties": { "properties": {
"id": {
"type": "number",
"id": true
},
"code": { "code": {
"type": "string" "type": "string",
"id": true
}, },
"type": { "type": {
"type": "string" "type": "string"

View File

@ -197,7 +197,7 @@
"type": { "type": {
"type": "belongsTo", "type": "belongsTo",
"model": "ClientType", "model": "ClientType",
"foreignKey": "clientTypeFk" "foreignKey": "typeFk"
}, },
"businessType": { "businessType": {
"type": "belongsTo", "type": "belongsTo",

View File

@ -29,17 +29,11 @@ module.exports = Self => {
where: {id: orderId}, where: {id: orderId},
fields: ['isConfirmed', 'clientFk'], fields: ['isConfirmed', 'clientFk'],
include: [ include: [
{relation: 'client', {relation: 'client'}
scope: {
include: {
relation: 'type'
}
}
}
] ]
}, myOptions); }, myOptions);
if (exists && exists.client().type().code !== 'normal') if (exists && exists.client().typeFk !== 'normal')
return true; return true;
if (!exists || exists.isConfirmed === 1) if (!exists || exists.isConfirmed === 1)

View File

@ -49,17 +49,12 @@ module.exports = Self => {
where: {id: addressId}, where: {id: addressId},
fields: ['clientFk'], fields: ['clientFk'],
include: [ include: [
{relation: 'client', {relation: 'client'
scope: {
include: {
relation: 'type'
}
}
} }
] ]
}, myOptions); }, myOptions);
if (address.client().type().code === 'normal') { if (address.client().typeFk === 'normal') {
if (!address.client().isActive) if (!address.client().isActive)
throw new UserError(`You can't create an order for an inactive client`); throw new UserError(`You can't create an order for an inactive client`);
} }

View File

@ -17,21 +17,16 @@ module.exports = Self => {
const alertLevel = state ? state.alertLevel : null; const alertLevel = state ? state.alertLevel : null;
const ticket = await models.Ticket.findById(id, { const ticket = await models.Ticket.findById(id, {
fields: ['clientFk'], fields: ['clientFk'],
include: [{
relation: 'client',
scope: {
include: { include: {
relation: 'type' relation: 'client'
} }
}
}]
}, myOptions); }, myOptions);
const isLocked = await models.Ticket.isLocked(id, myOptions); const isLocked = await models.Ticket.isLocked(id, myOptions);
const isWeekly = await models.TicketWeekly.findOne({where: {ticketFk: id}}, myOptions); const isWeekly = await models.TicketWeekly.findOne({where: {ticketFk: id}}, myOptions);
const alertLevelGreaterThanZero = (alertLevel && alertLevel > 0); const alertLevelGreaterThanZero = (alertLevel && alertLevel > 0);
const isNormalClient = ticket && ticket.client().type().code == 'normal'; const isNormalClient = ticket && ticket.client().typeFk == 'normal';
const isEditable = !(alertLevelGreaterThanZero && isNormalClient); const isEditable = !(alertLevelGreaterThanZero && isNormalClient);
if (!ticket) if (!ticket)

View File

@ -77,12 +77,7 @@ module.exports = Self => {
where: {id: args.addressId}, where: {id: args.addressId},
fields: ['id', 'clientFk'], fields: ['id', 'clientFk'],
include: { include: {
relation: 'client', relation: 'client'
scope: {
include: {
relation: 'type'
}
}
} }
}, myOptions); }, myOptions);
@ -93,7 +88,7 @@ module.exports = Self => {
if (args.agencyModeId) if (args.agencyModeId)
agencyMode = await models.AgencyMode.findById(args.agencyModeId, null, myOptions); agencyMode = await models.AgencyMode.findById(args.agencyModeId, null, myOptions);
if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.code != 'refund')) { if (address.client().typeFk === 'normal' && (!agencyMode || agencyMode.code != 'refund')) {
const canCreateTicket = await models.Client.canCreateTicket(args.clientId, myOptions); const canCreateTicket = await models.Client.canCreateTicket(args.clientId, myOptions);
if (!canCreateTicket) if (!canCreateTicket)
throw new UserError(`You can't create a ticket for an inactive client`); throw new UserError(`You can't create a ticket for an inactive client`);

View File

@ -41,7 +41,7 @@ module.exports = Self => {
include: { include: {
relation: 'client', relation: 'client',
scope: { scope: {
fields: ['id', 'clientTypeFk'], fields: ['id', 'typeFk'],
include: { include: {
relation: 'type', relation: 'type',
scope: { scope: {
@ -52,7 +52,7 @@ module.exports = Self => {
} }
}, },
ctx.options); ctx.options);
if (ticket?.client()?.type()?.code === 'loses') return; if (ticket?.client()?.typeFk === 'loses') return;
const isRefund = await models.TicketRefund.findOne({ const isRefund = await models.TicketRefund.findOne({
fields: ['id'], fields: ['id'],