refs #5561 fix: saleGroupDetail.saleFk UNIQUE
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-07-21 12:01:01 +02:00
parent f52b398596
commit cf0b6f8c6e
4 changed files with 14 additions and 7 deletions

View File

@ -0,0 +1,7 @@
DELETE FROM `vn`.`saleGroupDetail` WHERE id IN (468106,468104,468107,468105,495210,495208,495207,495209,462879,462880,447186,450623,450622,455606,455605,455827,455829,455828,459067,460689,460691,460690,460692,462408,463403,463405,463404,463129,463127,463126,463128,468098,468096,468099,468097,468310,468314,468313,475654,468325,473248,474803,474739,475042,475052,475047,475041,475051,475046,475040,475050,475045,475039,475049,475044,475038,475048,475043,474888,474892,474890,474887,474891,474889,481109,481107,481105,481108,481106,481110,479008,490787,490792,490791,485295,485294,485293,485528,490796,487853,487959,491303,490789,490914,490913,492305,492310,492307,492304,492309,492306,492303,492308,494111,494110,494480,494482,494481,494483,495202,495200,495199,495201,497209,499765,499763,499767,499764,499768,499766,502014,502013,508820,508819,508818,463133,463131,463130,463132,468102,468100,468103,468101,468311,468316,468315,468327,474894,474898,474896,474893,474897,474895,495206,495204,495203,495205,499771,499769,499773,499770,499774,499772)
ALTER TABLE `vn`.`saleGroupDetail` ADD CONSTRAINT saleGroupDetail_UN UNIQUE KEY (saleFk);
INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalId`)
VALUES
('SaleGroupDetail','deleteById','WRITE','ALLOW','employee');

View File

@ -38,9 +38,11 @@ module.exports = Self => {
} }
try { try {
const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions); if (stateCode === 'PREPARED') {
for (let itemShelvingSale of itemShelvingSales) const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions);
await itemShelvingSale.destroy(myOptions); for (let itemShelvingSale of itemShelvingSales)
await itemShelvingSale.destroy(myOptions);
}
const state = await models.State.findOne({ const state = await models.State.findOne({
where: {code: stateCode} where: {code: stateCode}

View File

@ -55,6 +55,7 @@ module.exports = Self => {
stPrevious.isChecked as isPrevious, stPrevious.isChecked as isPrevious,
stPrepared.isChecked as isPrepared, stPrepared.isChecked as isPrepared,
stControled.isChecked as isControled, stControled.isChecked as isControled,
sgd.id saleGroupDetailFk,
(MAX(sgd.id) IS NOT NULL) AS hasSaleGroupDetail, (MAX(sgd.id) IS NOT NULL) AS hasSaleGroupDetail,
p.code AS parkingCode, p.code AS parkingCode,
i.value5, i.value5,

View File

@ -30,10 +30,7 @@ class Controller extends Section {
clickSaleGroupDetail(index) { clickSaleGroupDetail(index) {
const sale = this.sales[index]; const sale = this.sales[index];
const params = { return this.$http.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`)
saleFk: sale.saleFk
};
return this.$http.post('SaleTrackings/deleteSaleGroupDetail', params)
.then(() => { .then(() => {
sale.hasSaleGroupDetail = false; sale.hasSaleGroupDetail = false;
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));