1"use strict";(self["webpackChunkcrm"]=self["webpackChunkcrm"]||[]).push([[5464],{45460(t,e,u){u.r(e),u.d(e,{default:()=>E});var i=function(){var t=this,e=t.$createElement,u=t._self._c||e;return u("fisca-sheet-base",{ref:"base",attrs:{fisca:t.fisca,position:t.position,"is-normal-mode":t.isNormalMode,id:t.id,"sheet-label":t.sheet?t.sheet.label:"","cee-cumac":t.CEECoupDePouceCumac,"cee-euros":t.CEECoupDePouceEuros,sheet:t.sheet,"loaded-component":t.loadedComponent},on:{deleteSheet:t.deleteSheet,"create-sub-product":t.openNewSubProduct,"product-list-input":t.updateAssociatedSubProductList,"validate-sub-product":t.validateEditSubProduct,"delete-sub-product":t.onDeleteSubProduct}})},d=[],o=u(28161),a=u(59258),s=u(3604),r=u(30388),n=u(41034),c=(u(52675),u(89463),u(28706),u(88431),u(2008),u(50113),u(48980),u(51629),u(74423),u(62062),u(44114),u(72712),u(15086),u(62010),u(18111),u(81148),u(22489),u(20116),u(7588),u(61701),u(18237),u(13579),u(2892),u(26099),u(16034),u(23500),u(55548)),l=u(95353),f=u(1611);const p={name:"barTh173",components:{FiscaSheetBase:c.A},inject:["fiscaApi"],props:{allPolueurs:{type:Array,required:!0},fisca:{type:Object,required:!0},position:{type:Number,required:!0},discountCouponMap:{type:Object,required:!0},fiscaAdvantagesTypeList:{type:Array,required:!0},fiscalAdvantageTypeEnum:{type:Object,required:!0},sheetId:{type:Number,required:!0},isNormalMode:{type:Boolean,required:!0},householdStatusCEE:{type:String,default:""},id:{type:Number,required:!0},widgetMapForm:{type:Object,default:function(){return{}}}},data:function(){return{loadedComponent:!1,sheet:null,vatPercentDefautProduct:5.5,CEECoupDePouceBasis:8e4,CEECoupDePouceDefaultMultiplierIndex:.0065,defaultProductsBarTH173List:[],defaultProductsByPolueurList:[]}},computed:(0,n.A)((0,n.A)((0,n.A)((0,n.A)({},(0,l.L8)("translator",["msg"])),(0,l.L8)("fisca",["getMySheet","getHouseholdStatusCEEEnum"])),(0,l.L8)("forms",["getProductDynaFieldTagEnum"])),{},{CEECoupDePouceCorrectionFactorByArea:function(){var t=Number(this.fisca.heatedArea);return t<=0?0:t<35?.5:t<60?.6:t<70?.7:t<90?.8:t<110?1:t<=130?1.1:1.2},CEECoupDePouceCumac:function(){return(0,f.dx)(this.CEECoupDePouceBasis*this.CEECoupDePouceCorrectionFactorByArea)},CEECoupDePouceMultiplierIndex:function(){var t,e=this;if(null!=this.fisca.pollueurIdLinked&&this.fisca.pollueurIdLinked>0&&null!==(t=this.allPolueurs)&&void 0!==t&&t.length){var u=this.allPolueurs.find(function(t){return t.id===e.fisca.pollueurIdLinked});if(null!=u){if(this.householdStatusCEE===this.getHouseholdStatusCEEEnum.PRECAIRE.label&&u.facturePrice>0)return Number(u.facturePrice);if(u.price>0)return Number(u.price)}}return this.CEECoupDePouceDefaultMultiplierIndex},CEECoupDePouceEuros:function(){return(0,f.dx)(this.CEECoupDePouceCumac*this.CEECoupDePouceMultiplierIndex)},currentFiscalProduct:function(){var t=this;return this.fisca.selectedFiscalProduct.find(function(e){return e.id===t.id})},currentSubProductsTotalTTC:function(){var t,e,u=null!==(t=null===(e=this.currentFiscalProduct)||void 0===e?void 0:e.associatedSubProductList)&&void 0!==t?t:[];return u.reduce(function(t,e){var u;return t+(null!==(u=e.totalTTC)&&void 0!==u?u:0)},0)},discountCouponCEE:function(){var t,e,u=this;if(!this.loadedComponent)return null;var i=this.fiscaAdvantagesTypeList.find(function(t){return t.id===u.fiscalAdvantageTypeEnum.CEE.id}),d=this.fisca.fiscalAdvantages.find(function(t){return t.faTypeId===u.fiscalAdvantageTypeEnum.CEE.id&&t.f2fAdvantageProductId===u.id}),o=null!==(t=null===d||void 0===d?void 0:d.value)&&void 0!==t?t:0,a=this.allPolueurs.find(function(t){return t.id===u.fisca.pollueurIdLinked});return(0,f.LJ)({fiscalProductId:this.id,sheet:this.sheet,advantage:i,totalTTC:this.currentSubProductsTotalTTC,value:o,pollueurName:null!==(e=null===a||void 0===a?void 0:a.name)&&void 0!==e?e:null,advantageTypeId:this.fiscalAdvantageTypeEnum.CEE.id,tokens:null})}}),methods:(0,n.A)((0,n.A)({},(0,l.i0)("products",["getProductGlobalById"])),{},{deleteSheet:function(){this.$emit("deleteSheet",{sheetId:this.sheet.id,id:this.id})},isNotInitializedSheet:function(){var t=this;return!this.fisca.selectedFiscalProduct.some(function(e){return e.id===t.id})},isDefaultProduct:function(t){var e,u=this;if(null==this.sheet)return!1;var i=[this.sheet.defaultSubProductId];if(this.fisca.pollueurIdLinked>0&&null!==(e=this.allPolueurs)&&void 0!==e&&e.length){var d,o=this.defaultProductsByPolueurList.find(function(t){return t.polueurId===u.fisca.pollueurIdLinked});(null===o||void 0===o||null===(d=o.products)||void 0===d?void 0:d.length)>0&&i.push(o.products[0].id)}return i.includes(t)},loadDefaultProductsByPolueur:function(){var t=this;return(0,r.A)((0,o.A)().m(function e(){var u,i,d,r,n,c;return(0,o.A)().w(function(e){while(1)switch(e.p=e.n){case 0:u=t.allPolueurs.filter(function(t){return t.defaultSubProductIdBarTh173>0}
1),i=(0,s.A)(u),e.p=1,i.s();case 2:if((d=i.n()).done){e.n=5;break}return r=d.value,e.n=3,t.getProductGlobalById({id:r.defaultSubProductIdBarTh173,withChild:!0});case 3:n=e.v,t.defaultProductsByPolueurList.push({products:[n].concat((0,a.A)(n.children)),polueurId:r.id});case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,c=e.v,i.e(c);case 7:return e.p=7,i.f(),e.f(7);case 8:return e.a(2)}},e,null,[[1,6,7,8]])}))()},getDefaultSubProductList:function(){var t,e=this,u=[];if(this.fisca.pollueurIdLinked>0&&null!==(t=this.allPolueurs)&&void 0!==t&&t.length){var i=this.allPolueurs.find(function(t){return t.id===e.fisca.pollueurIdLinked});if((null===i||void 0===i?void 0:i.defaultSubProductIdBarTh173)>0){var d=this.defaultProductsByPolueurList.find(function(t){return t.polueurId===e.fisca.pollueurIdLinked});null!==d&&void 0!==d&&d.products&&(u=d.products)}}return 0===u.length&&this.defaultProductsBarTH173List.length>0&&(u=this.defaultProductsBarTH173List),u.map(function(t){return e.buildDefaultPricedSubProduct(t)})},buildDefaultPricedSubProduct:function(t){var e=(0,f.dx)(this.CEECoupDePouceEuros/(1+.01*this.vatPercentDefautProduct)),u=this.CEECoupDePouceEuros;return{productId:t.id,productSource:f.or.FROM_DB.id,model:t.model,brand:t.brand,description:t.description,ref:t.ref,vatPercent:this.vatPercentDefautProduct,uht:e,uttc:u,quantity:1,totalHT:e,totalTTC:u}},getDefaultFiscalProduct:function(){return{cifId:this.fisca.id,fapId:this.sheet.id,id:this.id,lot:null,position:this.position,status:1,associatedSubProductList:this.getDefaultSubProductList()}},buildSubProduct:function(t){if(null==t){var e,u,i=null!==(e=null===(u=this.currentFiscalProduct)||void 0===u?void 0:u.associatedSubProductList)&&void 0!==e?e:[];return(0,f.O4)(i.length,f.or.FROM_WIDGET.id)}return this.isDefaultProduct(t.id)?this.buildDefaultPricedSubProduct(t):(0,f.X8)(t,f.or.FROM_DB.id,!1)},openNewSubProduct:function(){this.$refs.base.openNewProductDialog(this.buildSubProduct(null))},updateAssociatedSubProductList:function(t){var e=this,u=[];t.forEach(function(t){var i;if((null===(i=t.multiFieldList)||void 0===i?void 0:i.length)>0){var d,o,s=t.multiFieldList.findIndex(function(t){return t.label===e.getProductDynaFieldTagEnum.SELLING_PRICE}),r=null===(d=t.multiFieldList[s])||void 0===d?void 0:d.dataField,n=r?null===(o=e.widgetMapForm[r])||void 0===o?void 0:o.newValue:null;n&&(t.sellPrice=n)}u.push(t),u.push.apply(u,(0,a.A)(t.children))});var i=u.map(function(t){return e.buildSubProduct(t)});this.fiscaApi.addSubProducts(this.id,i)},validateEditSubProduct:function(t){var e=t.productSelected,u=t.productSelectedIndex,i=t.validState,d=t.close;""===e.uht&&(e.uht=null),i.productUht=(0,f.gs)(e.uht,!0,0,null);var o=Object.values(i).every(function(t){return null==t||t});o&&((0,f.NL)(e),-1!==u?this.fiscaApi.replaceSubProduct(this.id,u,e):this.fiscaApi.addSubProducts(this.id,[e]),d())},onDeleteSubProduct:function(t){this.fiscaApi.removeSubProduct(this.id,t)},addTotalHTAndTotalTTCToAssociatedSubProductList:function(){var t,e,u=this,i=null!==(t=null===(e=this.currentFiscalProduct)||void 0===e?void 0:e.associatedSubProductList)&&void 0!==t?t:[],d=i.map(function(t){var e=(0,n.A)({},t);if(u.isDefaultProduct(t.productId)){var i=(0,f.dx)(u.CEECoupDePouceEuros/(1+.01*u.vatPercentDefautProduct));e.uht=e.totalHT=i,e.uttc=e.totalTTC=u.CEECoupDePouceEuros}else(0,f.W6)(e);return e});this.fiscaApi.replaceSubProducts(this.id,d)},replaceAssociatedListWithDefaults:function(){this.fiscaApi.replaceSubProducts(this.id,this.getDefaultSubProductList())},updateDiscountCouponMap:function(){this.loadedComponent&&(this.fiscaApi.upsertDiscountCoupon({fiscalProductId:this.id,advantageTypeId:this.fiscalAdvantageTypeEnum.CEE.id,coupon:this.discountCouponCEE}),this.$emit("onCouponUpdated",{onProductsUpdated:!1}))}}),created:function(){var t=this;return(0,r.A)((0,o.A)().m(function e(){var u,i,d,s;return(0,o.A)().w(function(e){while(1)switch(e.n){case 0:return t.sheet=t.getMySheet(t.sheetId),e.n=1,t.getProductGlobalById({id:t.sheet.defaultSubProductId,withChild:!0});case 1:if(d=e.v,(u=t.defaultProductsBarTH173List).push.apply(u,[d].concat((0,a.A)(d.children))),null===(i=t.allPolueurs)||void 0===i||!i.length){e.n=2;break}return e.n=2,t.loadDefaultProductsByPolueur();case 2:t.isNotInitializedSheet()?(t.fiscaApi.initFiscalSheet({fiscalProductId:t.id,faProductId:t.sheet.id,position:t.position,defaultProduct:t.getDefaultFiscalProduct(),advantages:[{typeId:t.fiscalAdvantageTypeEnum.METER.id,value:t.fisca.heatedArea},{typeId:t.fiscalAdvantageTypeEnum.CEE.id,value:t.CEECoupDePouceEuros},{typeId:t.fiscalAdvantageTypeEnum.CUMAC.id,value:t.CEECoupDePouceCumac}]}),t.loadedComponent=!0):(t.addTotalHTAndTotalTTCToAssociatedSubProductList(),t.loadedComponent=!0,s=t.fisca.fiscalAdvantages.find(function(e){return e.f2fAdvantageProductId===t.id&&e.faTypeId===t.fiscalAdvantageTypeEnum.METER.id}),null!=s&&s.value!==t.fisca.heatedArea&&(t.fiscaApi.upsertFiscalAdvantage({fiscalProductId:t.id,typeId:t.fiscalAdvantageTypeEnum.METER.id,value:t.fisca.heatedArea,faProductId:t.sheet.id}),t.fiscaApi.upsertFiscalAdvantage({fiscalProductId:t.id,typeId:t.fiscalAdvantageTypeEnum.CUMAC.id,value:t.CEECoupDePouceCumac,faProductId:t.sheet.id}),t.addTotalHTAndTotalTTCToAssociatedSubProductList())),t.updateDiscountCouponMap();case 3:return e.a(2)}},e)}))()},watch:{CEECoupDePouceCumac:function(t){this.loadedComponent&&this.fiscaApi.upsertFiscalAdvantage({fiscalProductId:this.id,typeId:this.fiscalAdvantageTypeEnum.CUMAC.id,value:t,faProductId:this.sheet.id})},CEECoupDePouceEuros:function(t){this.loadedComponent&&(this.fiscaApi.upsertFiscalAdvantage({fiscalProductId:this.id,typeId:this.fiscalAdvantageTypeEnum.CEE.id,value:t,faProductId:this.sheet.id}),this.addTotalHTAndTotalTTCToAssociatedSubProductList(),this.updateDiscountCouponMap())},"fisca.heatedArea":function(t){this.loadedComponent&&this.fiscaApi.upsertFiscalAdvantage({fiscalProductId:this.id,typeId:this.fiscalAdvantageTypeEnum.METER.id,value:t,faProductId:this.sheet.id})},"fisca.pollueurIdLinked":function(){this.loadedComponent&&this.replaceAssociatedListWithDefaults(),this.updateDiscountCouponMap()},fisca:function(){this.loadedComponent&&0!==this.fisca.id&&!this.isNotInitializedSheet()&&this.addTotalHTAndTotalTTCToAssociatedSubProductList()},"discountCouponCEE.value":function(){this.updateDiscountCouponMap()}}},h=p;var P=u(81656),v=(0,P.A)(h,i,d,!1,null,null,null);const E=v.exports}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.