diff --git a/db/changes/233201/00-saleGroupDetail.sql b/db/changes/233201/00-saleGroupDetail.sql new file mode 100644 index 000000000..e25c4f35c --- /dev/null +++ b/db/changes/233201/00-saleGroupDetail.sql @@ -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'); + diff --git a/modules/ticket/back/methods/sale-tracking/delete.js b/modules/ticket/back/methods/sale-tracking/delete.js index 30956228b..b8754d48c 100644 --- a/modules/ticket/back/methods/sale-tracking/delete.js +++ b/modules/ticket/back/methods/sale-tracking/delete.js @@ -38,9 +38,11 @@ module.exports = Self => { } try { - const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions); - for (let itemShelvingSale of itemShelvingSales) - await itemShelvingSale.destroy(myOptions); + if (stateCode === 'PREPARED') { + const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions); + for (let itemShelvingSale of itemShelvingSales) + await itemShelvingSale.destroy(myOptions); + } const state = await models.State.findOne({ where: {code: stateCode} diff --git a/modules/ticket/back/methods/sale-tracking/filter.js b/modules/ticket/back/methods/sale-tracking/filter.js index 09101a47a..2fa21cb1a 100644 --- a/modules/ticket/back/methods/sale-tracking/filter.js +++ b/modules/ticket/back/methods/sale-tracking/filter.js @@ -55,6 +55,7 @@ module.exports = Self => { stPrevious.isChecked as isPrevious, stPrepared.isChecked as isPrepared, stControled.isChecked as isControled, + sgd.id saleGroupDetailFk, (MAX(sgd.id) IS NOT NULL) AS hasSaleGroupDetail, p.code AS parkingCode, i.value5, diff --git a/modules/ticket/front/sale-tracking/index.js b/modules/ticket/front/sale-tracking/index.js index 0237428c8..6ea7778b1 100644 --- a/modules/ticket/front/sale-tracking/index.js +++ b/modules/ticket/front/sale-tracking/index.js @@ -30,10 +30,7 @@ class Controller extends Section { clickSaleGroupDetail(index) { const sale = this.sales[index]; - const params = { - saleFk: sale.saleFk - }; - return this.$http.post('SaleTrackings/deleteSaleGroupDetail', params) + return this.$http.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`) .then(() => { sale.hasSaleGroupDetail = false; this.vnApp.showSuccess(this.$t('Data saved!'));