1import{a as F}from"./chunk-ULIVDXWZ.js";import{a as A}from"./chunk-K3747WXK.js";import{a as Q}from"./chunk-2OGD2EVK.js";import{a as I}from"./chunk-EZRCIEZS.js";import{b as B}from"./chunk-GEVNHRO5.js";import"./chunk-LHGCWX2R.js";import"./chunk-UIWY7XVB.js";import"./chunk-XPK55CJV.js";import"./chunk-EI7S76MX.js";import"./chunk-H53OZVLL.js";import"./chunk-3RO65GPC.js";import"./chunk-7UG5WIEB.js";import"./chunk-JTGAFH3Q.js";import"./chunk-M5AYQI3W.js";import"./chunk-FWHBGNFB.js";import"./chunk-I6OTESFY.js";import"./chunk-KSV4K5L7.js";import"./chunk-G24DUSEI.js";import{a as N}from"./chunk-WBKEXQKE.js";import"./chunk-GBI3J4AK.js";import"./chunk-7RJ7KBOV.js";import"./chunk-EOY6SAP7.js";import"./chunk-ZGCK3FI7.js";import"./chunk-GFCJRNG7.js";import"./chunk-RVGGNFAO.js";import"./chunk-3C3AINZY.js";import"./chunk-CLDDMLFW.js";import"./chunk-TZCA4BMQ.js";import"./chunk-E653UENJ.js";import"./chunk-YY5ENN77.js";import"./chunk-MZ3B3AQU.js";import"./chunk-GJ3HPRCZ.js";import"./chunk-L77O44AU.js";import"./chunk-XZDAMPUP.js";import"./chunk-L27WCSZV.js";import"./chunk-UWULTQAP.js";import"./chunk-RB2YP5E2.js";import"./chunk-QIIVFJNA.js";import"./chunk-KO7CD6JP.js";import"./chunk-6D27RETG.js";import{C as D}from"./chunk-DJ7NG7WZ.js";import{c as M}from"./chunk-KI4XJKCH.js";import"./chunk-NERRRF6P.js";import{a as k}from"./chunk-SXBT3OYT.js";import"./chunk-SN3EPBFH.js";import"./chunk-EHPYMWXB.js";import"./chunk-EUX7SKJZ.js";import"./chunk-5SQV5IIR.js";import{a as y}from"./chunk-NVPTMCVP.js";import"./chunk-7ZFPQAIH.js";import{pa as E}from"./chunk-7NPDSOWV.js";import"./chunk-R5IULLQ2.js";import"./chunk-LEKN3M5J.js";import"./chunk-KFHTLBNQ.js";import"./chunk-YV5TISNX.js";import"./chunk-IDF3EASQ.js";import"./chunk-WJESYQVL.js";import{$c as S,Bc as _,Cc as f,Dc as C,F as r,Fa as m,Ib as w,La as o,Lc as g,Ma as d,Uc as u,Wc as s,Xa as l,Zb as x,_c as V,aa as T,ad as P,l as c,uc as p,wc as h,wd as v}from"./chunk-K6IHZUMJ.js";var R=["paymentSettingsCard"],q=["paymentTermsTableCard"],L=["paymentMethodTableCard"],U=()=>["name","description","financialAccountId","exchangeRateGainsId","exchangeRateLossesId","bankFeesId","isDefault"],W=()=>["name","description","days","termType"];function $(a,b){if(a&1){let e=g();f(0,"yon-entity-fields-card",5),u("entityChange",function(){o(e);let t=s();return d(t.paymentSettings())})("saveClicked",function(t){o(e);let n=s();return d(n.onSaveSettings(t))})("editClicked",function(t){return t}),C()}if(a&2){let e=s();_("fieldNames",e.fieldNamesPaymentSettings())("entity",e.paymentSettings())("editPermission",e.ApplicationPermissions.PaymentSettingsViewUpdate)("disableEditButton",e.disableEditButtons())}}function O(a,b){if(a&1){let e=g();f(0,"yon-entity-table-with-add-edit-delete-card",6,0),u("addClicked",function(t){o(e);let n=s();return d(n.onAddPaymentMethodClicked(t))})("editClicked",function(t){o(e);let n=s();return d(n.onEditPaymentMethodClicked(t))})("deleteClicked",function(t){o(e);let n=s();return d(n.onDeletePaymentMethodClicked(t))}),C()}if(a&2){let e=s();_("fieldNames",v(2,U))("emptyEntity",e.paymentMethodService.createEntity())}}function j(a,b){if(a&1){let e=g();f(0,"yon-entity-table-with-add-edit-delete-card",7,1),u("addClicked",function(t){o(e);let n=s();return d(n.onAddPaymentTermClicked(t))})("editClicked",function(t){o(e);let n=s();return d(n.onEditPaymentTermClicked(t))})("deleteClicked",function(t){o(e);let n=s();return d(n.onDeletePaymentTermClicked(t))}),C()}if(a&2){let e=s();_("fieldNames",v(2,W))("emptyEntity",e.paymentTermService.createEntity())}}var de=(()=>{class a{constructor(){this.ApplicationEnums=E,this.ApplicationPermissions=y,this.paymentSettings=l(void 0),this.fieldNamesPaymentSettings=l([]),this.disableEditButtons=l(!1),this.hasPaymentMethodViewPermission=l(!1),this.hasPaymentTermViewPermission=l(!1),this.hasPaymentSettingsViewPermission=l(!1),this.notificationService=m(M),this.dialogService=m(N),this.paymentService=m(B),this.permissionService=m(k),this.paymentMethodService=m(I),this.paymentTermService=m(Q)}ngOnInit(){this.fieldNamesPaymentSettings.set(["paymentToleranceAmount","paymentToleranceAccountId"]),this.hasPaymentMethodViewPermission.set(this.permissionService.hasPermission(y.PaymentMethodView)),this.hasPaymentTermViewPermission.set(this.permissionService.hasPermission(y.PaymentTermView)),this.hasPaymentSettingsViewPermission.set(this.permissionService.hasPermission(y.PaymentSettingsView)),this.paymentService.paymentSettings().pipe(T(1)).subscribe(e=>{e&&this.paymentSettings.set(e)})}onSaveSettings(e){return c(this,null,function*(){this.paymentSettings.set(e),this.paymentService.updatePaymentSettings(this.paymentSettings()).pipe(T(1)).subscribe({error:i=>{this.notificationService.error(i.error.message),this.paymentSettings.set(this.paymentSettingsCard.getEntityBeforeEdited())}})})}onAddPaymentMethodClicked(e){return c(this,null,function*(){if((yield r(this.paymentMethodService.isAnyDefault()))&&e.isDefault)if(yield this.userConfirmIfDefaultExists(e.name))e.isDefault=!1;else return;r(this.paymentMethodService.create(e)).then(t=>{t.name?this.paymentMethodTableCard.refreshTableAndNotify():this.notificationService.error("Something went wrong when creating new payment method")})})}onEditPaymentMethodClicked(e){return c(this,null,function*(){if((yield r(this.paymentMethodService.isAnyDefault()))&&!(yield r(this.paymentMethodService.fetchById(e.id))).isDefault&&e.isDefault)if(yield this.userConfirmIfDefaultExists(e.name))e.isDefault=!1;else return;r(this.paymentMethodService.update(e)).then(t=>{t.name?this.paymentMethodTableCard.refreshTableAndNotify():this.notificationService.error(`Something went wrong when updating payment method ${e.name}`)})})}onDeletePaymentMethodClicked(e){return c(this,null,function*(){r(this.paymentMethodService.delete(e)).then(()=>{this.paymentMethodTableCard.refreshTableAndNotify()},i=>this.notificationService.error(i.error.message))})}userConfirmIfDefaultExists(e){return c(this,null,function*(){let i=`Only one payment method can be set to default. Default is set to false on payment method ${e}`;return this.dialogService.createConfirmDialog(i,"DEFAULT ALREADY EXISTS","I Understand","Cancel")})}onAddPaymentTermClicked(e){r(this.paymentTermService.create(e)).then(()=>{this.paymentTermsTableCard.refreshTableAndNotify()},i=>this.notificationService.error(i.error.message))}onEditPaymentTermClicked(e){r(this.paymentTermService.update(e)).then(()=>{this.paymentTermsTableCard.refreshTableAndNotify()},i=>this.notificationService.error(`Something went wrong when updating product feature '${e.name}'`))}onDeletePaymentTermClicked(e){r(this.paymentTermService.delete(e)).then(()=>{this.paymentTermsTableCard.refreshTableAndNotify()},i=>this.notificationService.error(i.error.message))}static{this.\u0275fac=function(i){return new(i||a)}}static{this.\u0275cmp=x({type:a,selectors:[["yon-settings-payment-settings"]],viewQuery:function(i,t){if(i&1&&V(R,5)(q,5)(L,5),i&2){let n;
1S(n=P())&&(t.paymentSettingsCard=n.first),S(n=P())&&(t.paymentTermsTableCard=n.first),S(n=P())&&(t.paymentMethodTableCard=n.first)}},decls:3,vars:3,consts:[["paymentMethodTableCard",""],["paymentTermsTableCard",""],["header","Payment settings","entityName","paymentsettings",3,"fieldNames","entity","editPermission","disableEditButton"],["entityTitle","Payment methods","entityName","paymentmethod","permissionPrefix","PaymentMethodView",3,"fieldNames","emptyEntity"],["entityTitle","Payment terms","entityName","paymentterm","permissionPrefix","PaymentTermView",3,"fieldNames","emptyEntity"],["header","Payment settings","entityName","paymentsettings",3,"entityChange","saveClicked","editClicked","fieldNames","entity","editPermission","disableEditButton"],["entityTitle","Payment methods","entityName","paymentmethod","permissionPrefix","PaymentMethodView",3,"addClicked","editClicked","deleteClicked","fieldNames","emptyEntity"],["entityTitle","Payment terms","entityName","paymentterm","permissionPrefix","PaymentTermView",3,"addClicked","editClicked","deleteClicked","fieldNames","emptyEntity"]],template:function(i,t){i&1&&(p(0,$,1,4,"yon-entity-fields-card",2),p(1,O,2,3,"yon-entity-table-with-add-edit-delete-card",3),p(2,j,2,3,"yon-entity-table-with-add-edit-delete-card",4)),i&2&&(h(t.hasPaymentSettingsViewPermission()?0:-1),w(),h(t.hasPaymentMethodViewPermission()?1:-1),w(),h(t.hasPaymentTermViewPermission()?2:-1))},dependencies:[D,A,F],encapsulation:2})}}return a})();export{de as SettingsPaymentSettingsComponent};
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.