@openmrs/esm-billing-app 1.3.2-pre.2111 → 1.3.2-pre.2113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/3784.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["3784"],{8843(e,t,a){a.r(t),a.d(t,{getAvailablePaymentModes:()=>g,default:()=>h,normalizePrice:()=>y,transformServiceToFormData:()=>_});var l=a(5275),n=a.n(l),r=a(1752),i=a(9785),s=a(8395),c=a(5576),o=a(2137),m=a(4476),d=a(3285),p=a(3137),u=a(6994);let b={form:"-esm-billing__billable-service-form__form___RvKJG",paymentButtons:"-esm-billing__billable-service-form__paymentButtons___p6dOI",paymentMethodContainer:"-esm-billing__billable-service-form__paymentMethodContainer___YZDax",removeButtonContainer:"-esm-billing__billable-service-form__removeButtonContainer___KORBv",removeButton:"-esm-billing__billable-service-form__removeButton___KuSDN",service:"-esm-billing__billable-service-form__service___noVRg",conceptsList:"-esm-billing__billable-service-form__conceptsList___r9PAZ",emptyResults:"-esm-billing__billable-service-form__emptyResults___fhVkz",conceptLabel:"-esm-billing__billable-service-form__conceptLabel___xIMo-",errorMessage:"-esm-billing__billable-service-form__errorMessage___hhc8c",loader:"-esm-billing__billable-service-form__loader___SOEop",serviceNameLabel:"-esm-billing__billable-service-form__serviceNameLabel___QYDpl",button:"-esm-billing__billable-service-form__button___wwBaw",tablet:"-esm-billing__billable-service-form__tablet___FYnpZ",desktop:"-esm-billing__billable-service-form__desktop___RqqyR",stack:"-esm-billing__billable-service-form__stack___SVpGz"},v={paymentMode:"",price:""},_=e=>e?{name:e.name||"",shortName:e.shortName||"",serviceType:e.serviceType||null,concept:e.concept?{uuid:e.concept.uuid,display:e.concept.display}:null,payment:e.servicePrices?.map(e=>({paymentMode:e.paymentMode?.uuid||"",price:e.price??""}))||[v]}:{name:"",shortName:"",serviceType:null,concept:null,payment:[v]},y=e=>"number"==typeof e?e:parseFloat(String(e)),g=(e,t,a,l)=>{let n=t.map((e,t)=>t!==a?e.paymentMode:null).filter(Boolean);return e.filter(e=>!n.includes(e.uuid)||e.uuid===l)},h=({workspaceProps:{serviceToEdit:e,closeWorkspaceWithSavedChanges:t,onWorkspaceClose:a},closeWorkspace:h})=>{let{t:E}=(0,s.useTranslation)(),S=(0,p.useLayoutType)(),{paymentModes:N,isLoadingPaymentModes:f}=(0,u.WJ)(),{serviceTypes:T,isLoadingServiceTypes:M}=(0,u.MH)(),C=(0,l.useMemo)(()=>{let e;return e=m.z.object({paymentMode:m.z.string({required_error:E("paymentModeRequired","Payment mode is required")}).trim().min(1,E("paymentModeRequired","Payment mode is required")),price:m.z.union([m.z.number(),m.z.string(),m.z.undefined()]).superRefine((e,t)=>{if(null==e||""===e)return void t.addIssue({code:m.z.ZodIssueCode.custom,message:E("priceIsRequired","Price is required")});let a="number"==typeof e?e:parseFloat(e);(isNaN(a)||a<=0)&&t.addIssue({code:m.z.ZodIssueCode.custom,message:E("priceMustBePositive","Price must be greater than 0")})})}),m.z.object({name:m.z.string({required_error:E("serviceNameRequired","Service name is required")}).trim().min(1,E("serviceNameRequired","Service name is required")).max(255,E("serviceNameExceedsLimit","Service name cannot exceed {{MAX_NAME_LENGTH}} characters",{MAX_NAME_LENGTH:255})),shortName:m.z.string().trim().max(255,E("shortNameExceedsLimit","Short name cannot exceed {{MAX_NAME_LENGTH}} characters",{MAX_NAME_LENGTH:255})).optional(),serviceType:m.z.object({uuid:m.z.string(),display:m.z.string()}).nullable().refine(e=>null!==e,E("serviceTypeRequired","Service type is required")),concept:m.z.object({uuid:m.z.string(),display:m.z.string()}).nullable().optional(),payment:m.z.array(e).min(1,E("paymentOptionRequired","At least one payment option is required"))})},[E]),{control:B,handleSubmit:L,formState:{errors:x,isDirty:k},setValue:z,reset:P}=(0,i.mN)({mode:"all",defaultValues:_(e),resolver:(0,d.u)(C)}),{fields:I,remove:R,append:q}=(0,i.jz)({name:"payment",control:B}),A=(0,l.useRef)(null),[F,$]=(0,l.useState)(!1),w=(0,i.FH)({control:B,name:"concept"}),[O,j]=(0,l.useState)(""),D=(0,p.useDebounce)(O.trim()),{searchResults:U,isSearching:H}=(0,u.bb)(D);(0,l.useEffect)(()=>{!e||f||M||P(_(e))},[e,f,M,P]);let G=async l=>{$(!0);let n={name:l.name,shortName:l.shortName??"",serviceType:l.serviceType.uuid,servicePrices:l.payment.map(e=>{let t=N.find(t=>t.uuid===e.paymentMode);return{paymentMode:e.paymentMode,name:t?.name||"Unknown",price:y(e.price)}}),serviceStatus:"ENABLED",concept:l.concept?.uuid};try{e?await (0,u.OS)(e.uuid,n):await (0,u.j2)(n),(0,p.showSnackbar)({title:e?E("billableServiceUpdated","Billable service updated"):E("billableServiceCreated","Billable service created"),subtitle:e?E("billableServiceUpdatedSuccessfully","Billable service updated successfully"):E("billableServiceCreatedSuccessfully","Billable service created successfully"),kind:"success"}),a&&a(),t?t():h({discardUnsavedChanges:!0})}catch(e){(0,p.showSnackbar)({title:E("billPaymentError","Bill payment error"),kind:"error",subtitle:e instanceof Error?e.message:String(e)})}finally{$(!1)}},W=()=>{let e=x.payment;return e&&"string"==typeof e.message?e.message:null},Z=e?E("editBillableService","Edit billable service"):E("addBillableService","Add billable service");return f||M?n().createElement(p.Workspace2,{title:Z,hasUnsavedChanges:k},n().createElement(r.InlineLoading,{status:"active",iconDescription:E("loadingDescription","Loading"),description:E("loading","Loading data")+"..."})):n().createElement(p.Workspace2,{title:Z,hasUnsavedChanges:k},n().createElement(r.Form,{"aria-label":E("billableServiceForm","Billable service form"),className:b.form,id:"billable-service-form",onSubmit:L(G)},n().createElement(r.Stack,{className:b.stack,gap:5},n().createElement("div",{className:b.formGroup},e?n().createElement(r.FormLabel,{className:b.serviceNameLabel},e.name):n().createElement(i.xI,{name:"name",control:B,render:({field:e})=>n().createElement(r.Layer,null,n().createElement(r.TextInput,{...e,enableCounter:!0,id:"serviceName",invalid:!!x.name,invalidText:x.name?.message,labelText:E("serviceName","Service name"),maxCount:255,placeholder:E("enterServiceName","Enter service name"),type:"text"}))})),n().createElement("div",null,n().createElement(i.xI,{name:"shortName",control:B,render:({field:e})=>n().createElement(r.Layer,null,n().createElement(r.TextInput,{...e,enableCounter:!0,id:"serviceShortName",invalid:!!x.shortName,invalidText:x.shortName?.message,labelText:E("shortName","Short name"),maxCount:255,placeholder:E("enterServiceShortName","Enter service short name"),type:"text",value:e.value||""}))})),n().createElement("div",null,n().createElement(r.FormLabel,{className:b.conceptLabel},E("associatedConcept","Associated concept")),n().createElement(p.ResponsiveWrapper,null,n().createElement(r.Search,{id:"conceptsSearch",labelText:E("associatedConcept","Associated concept"),onChange:e=>j(e.target.value),onClear:()=>{j(""),z("concept",null)},placeholder:E("searchConcepts","Search associated concept"),ref:A,value:w?.display||O})),!D||w?null:H?n().createElement(r.InlineLoading,{className:b.loader,description:E("searching","Searching")+"..."}):U&&U.length?n().createElement("ul",{className:b.conceptsList},U?.map(e=>n().createElement("li",{className:b.service,key:e.concept.uuid,onClick:()=>{z("concept",{uuid:e.concept.uuid,display:e.display}),j("")},role:"menuitem"},e.display))):n().createElement(r.Layer,null,n().createElement(r.Tile,{className:b.emptyResults},n().createElement("span",null,E("noResultsFor","No results for {{searchTerm}}",{searchTerm:D}))))),n().createElement("div",null,n().createElement(i.xI,{name:"serviceType",control:B,render:({field:e})=>n().createElement(r.Layer,null,n().createElement(r.ComboBox,{id:"serviceType",items:T??[],titleText:E("serviceType","Service type"),itemToString:e=>e?.display||"",selectedItem:e.value,onChange:({selectedItem:t})=>{e.onChange(t)},placeholder:E("selectServiceType","Select service type"),invalid:!!x.serviceType,invalidText:x.serviceType?.message}))})),n().createElement("section",null,n().createElement("div",null,I.map((e,t)=>n().createElement("div",{key:e.id,className:b.paymentMethodContainer},n().createElement(i.xI,{control:B,name:`payment.${t}.paymentMode`,render:({field:e})=>n().createElement(r.Layer,null,n().createElement(r.Dropdown,{id:`paymentMode-${t}`,invalid:!!x?.payment?.[t]?.paymentMode,invalidText:x?.payment?.[t]?.paymentMode?.message,items:g(N,I,t,e.value),itemToString:e=>e?e.name:"",label:E("selectPaymentMode","Select payment mode"),onChange:({selectedItem:t})=>e.onChange(t.uuid),selectedItem:N.find(t=>t.uuid===e.value)??null,titleText:E("paymentMode","Payment mode")}))}),n().createElement(i.xI,{control:B,name:`payment.${t}.price`,render:({field:e})=>n().createElement(r.Layer,null,n().createElement(r.NumberInput,{allowEmpty:!0,disableWheel:!0,id:`price-${t}`,invalid:!!x?.payment?.[t]?.price,invalidText:x?.payment?.[t]?.price?.message,label:E("sellingPrice","Selling price"),min:0,onChange:(t,{value:a})=>{e.onChange(""===a||void 0===a?"":a)},placeholder:E("enterSellingPrice","Enter selling price"),step:.01,value:void 0===e.value||null===e.value?"":e.value}))}),n().createElement("div",{className:b.removeButtonContainer},n().createElement(c.zH,{onClick:()=>R(t),className:b.removeButton,size:20})))),n().createElement(r.Button,{className:b.paymentButtons,iconDescription:E("add","Add"),kind:"tertiary",onClick:()=>q(v),renderIcon:e=>n().createElement(o.OM,{size:24,...e}),type:"button"},E("addPaymentOption","Add payment option")),W()&&n().createElement("div",{className:b.errorMessage},W())))),n().createElement(r.ButtonSet,{className:"tablet"===S?b.tablet:b.desktop},n().createElement(r.Button,{className:b.button,kind:"secondary",disabled:F,onClick:()=>h()},(0,p.getCoreTranslation)("cancel")),n().createElement(r.Button,{className:b.button,kind:"primary",disabled:F,type:"submit"},F?n().createElement(r.InlineLoading,{description:E("saving","Saving")+"..."}):(0,p.getCoreTranslation)("save")))))}},6994(e,t,a){a.d(t,{MH:()=>c,OS:()=>p,WJ:()=>o,bb:()=>m,cW:()=>u,j2:()=>d,ly:()=>s,vv:()=>b});var l=a(6335),n=a.n(l),r=a(3137),i=a(7003);let s=()=>{let e=`${i.B}billableService?v=custom:(uuid,name,shortName,serviceStatus,concept:(uuid,display,name:(name)),serviceType:(display,uuid),servicePrices:(uuid,name,price,paymentMode:(uuid,name)))`,{data:t,isLoading:a,isValidating:l,error:n,mutate:s}=(0,r.useOpenmrsFetchAll)(e);return{billableServices:t??[],isLoading:a,isValidating:l,error:n,mutate:s}};function c(){let{serviceTypes:e}=(0,r.useConfig)(),t=e.billableService,a=`${r.restBaseUrl}/concept/${t}?v=custom:(setMembers:(uuid,display))`,{data:l,error:i,isLoading:s}=n()(a,r.openmrsFetch);return{serviceTypes:l?.data.setMembers?[...l.data.setMembers].sort((e,t)=>e.display.localeCompare(t.display)):[],error:i,isLoadingServiceTypes:s}}let o=()=>{let e=`${i.B}paymentMode`,{data:t,error:a,isLoading:l,mutate:s}=n()(e,r.openmrsFetch);return{paymentModes:t?.data.results?[...t.data.results].sort((e,t)=>e.name.localeCompare(t.name)):[],error:a,isLoadingPaymentModes:l,mutate:s}};function m(e){let t=`${r.restBaseUrl}/conceptsearch?q=${e}`,{data:a,error:l,isLoading:i}=n()(e?t:null,r.openmrsFetch);return{searchResults:a?.data?.results??[],error:l,isSearching:i}}let d=async e=>{let t=`${i.B}api/billable-service`;return await (0,r.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},p=async(e,t)=>{let a=`${i.B}billableService/${e}`;return await (0,r.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})},u=e=>{let t=`${r.restBaseUrl}/billing/paymentMode`;return(0,r.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},b=(e,t)=>{let a=`${r.restBaseUrl}/billing/paymentMode/${e}`;return(0,r.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})}}}]);
1
+ "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["3784"],{8843(e,t,a){a.r(t),a.d(t,{getAvailablePaymentModes:()=>g,default:()=>h,normalizePrice:()=>y,transformServiceToFormData:()=>_});var l=a(5275),n=a.n(l),r=a(1752),i=a(9785),s=a(8395),c=a(5576),o=a(2137),m=a(4476),d=a(3285),p=a(9124),u=a(6994);let b={form:"-esm-billing__billable-service-form__form___RvKJG",paymentButtons:"-esm-billing__billable-service-form__paymentButtons___p6dOI",paymentMethodContainer:"-esm-billing__billable-service-form__paymentMethodContainer___YZDax",removeButtonContainer:"-esm-billing__billable-service-form__removeButtonContainer___KORBv",removeButton:"-esm-billing__billable-service-form__removeButton___KuSDN",service:"-esm-billing__billable-service-form__service___noVRg",conceptsList:"-esm-billing__billable-service-form__conceptsList___r9PAZ",emptyResults:"-esm-billing__billable-service-form__emptyResults___fhVkz",conceptLabel:"-esm-billing__billable-service-form__conceptLabel___xIMo-",errorMessage:"-esm-billing__billable-service-form__errorMessage___hhc8c",loader:"-esm-billing__billable-service-form__loader___SOEop",serviceNameLabel:"-esm-billing__billable-service-form__serviceNameLabel___QYDpl",button:"-esm-billing__billable-service-form__button___wwBaw",tablet:"-esm-billing__billable-service-form__tablet___FYnpZ",desktop:"-esm-billing__billable-service-form__desktop___RqqyR",stack:"-esm-billing__billable-service-form__stack___SVpGz"},v={paymentMode:"",price:""},_=e=>e?{name:e.name||"",shortName:e.shortName||"",serviceType:e.serviceType||null,concept:e.concept?{uuid:e.concept.uuid,display:e.concept.display}:null,payment:e.servicePrices?.map(e=>({paymentMode:e.paymentMode?.uuid||"",price:e.price??""}))||[v]}:{name:"",shortName:"",serviceType:null,concept:null,payment:[v]},y=e=>"number"==typeof e?e:parseFloat(String(e)),g=(e,t,a,l)=>{let n=t.map((e,t)=>t!==a?e.paymentMode:null).filter(Boolean);return e.filter(e=>!n.includes(e.uuid)||e.uuid===l)},h=({workspaceProps:{serviceToEdit:e,closeWorkspaceWithSavedChanges:t,onWorkspaceClose:a},closeWorkspace:h})=>{let{t:E}=(0,s.useTranslation)(),S=(0,p.useLayoutType)(),{paymentModes:N,isLoadingPaymentModes:f}=(0,u.WJ)(),{serviceTypes:T,isLoadingServiceTypes:M}=(0,u.MH)(),C=(0,l.useMemo)(()=>{let e;return e=m.z.object({paymentMode:m.z.string({required_error:E("paymentModeRequired","Payment mode is required")}).trim().min(1,E("paymentModeRequired","Payment mode is required")),price:m.z.union([m.z.number(),m.z.string(),m.z.undefined()]).superRefine((e,t)=>{if(null==e||""===e)return void t.addIssue({code:m.z.ZodIssueCode.custom,message:E("priceIsRequired","Price is required")});let a="number"==typeof e?e:parseFloat(e);(isNaN(a)||a<=0)&&t.addIssue({code:m.z.ZodIssueCode.custom,message:E("priceMustBePositive","Price must be greater than 0")})})}),m.z.object({name:m.z.string({required_error:E("serviceNameRequired","Service name is required")}).trim().min(1,E("serviceNameRequired","Service name is required")).max(255,E("serviceNameExceedsLimit","Service name cannot exceed {{MAX_NAME_LENGTH}} characters",{MAX_NAME_LENGTH:255})),shortName:m.z.string().trim().max(255,E("shortNameExceedsLimit","Short name cannot exceed {{MAX_NAME_LENGTH}} characters",{MAX_NAME_LENGTH:255})).optional(),serviceType:m.z.object({uuid:m.z.string(),display:m.z.string()}).nullable().refine(e=>null!==e,E("serviceTypeRequired","Service type is required")),concept:m.z.object({uuid:m.z.string(),display:m.z.string()}).nullable().optional(),payment:m.z.array(e).min(1,E("paymentOptionRequired","At least one payment option is required"))})},[E]),{control:B,handleSubmit:L,formState:{errors:x,isDirty:k},setValue:z,reset:P}=(0,i.mN)({mode:"all",defaultValues:_(e),resolver:(0,d.u)(C)}),{fields:I,remove:R,append:q}=(0,i.jz)({name:"payment",control:B}),A=(0,l.useRef)(null),[F,$]=(0,l.useState)(!1),w=(0,i.FH)({control:B,name:"concept"}),[O,j]=(0,l.useState)(""),D=(0,p.useDebounce)(O.trim()),{searchResults:U,isSearching:H}=(0,u.bb)(D);(0,l.useEffect)(()=>{!e||f||M||P(_(e))},[e,f,M,P]);let G=async l=>{$(!0);let n={name:l.name,shortName:l.shortName??"",serviceType:l.serviceType.uuid,servicePrices:l.payment.map(e=>{let t=N.find(t=>t.uuid===e.paymentMode);return{paymentMode:e.paymentMode,name:t?.name||"Unknown",price:y(e.price)}}),serviceStatus:"ENABLED",concept:l.concept?.uuid};try{e?await (0,u.OS)(e.uuid,n):await (0,u.j2)(n),(0,p.showSnackbar)({title:e?E("billableServiceUpdated","Billable service updated"):E("billableServiceCreated","Billable service created"),subtitle:e?E("billableServiceUpdatedSuccessfully","Billable service updated successfully"):E("billableServiceCreatedSuccessfully","Billable service created successfully"),kind:"success"}),a&&a(),t?t():h({discardUnsavedChanges:!0})}catch(e){(0,p.showSnackbar)({title:E("billPaymentError","Bill payment error"),kind:"error",subtitle:e instanceof Error?e.message:String(e)})}finally{$(!1)}},W=()=>{let e=x.payment;return e&&"string"==typeof e.message?e.message:null},Z=e?E("editBillableService","Edit billable service"):E("addBillableService","Add billable service");return f||M?n().createElement(p.Workspace2,{title:Z,hasUnsavedChanges:k},n().createElement(r.InlineLoading,{status:"active",iconDescription:E("loadingDescription","Loading"),description:E("loading","Loading data")+"..."})):n().createElement(p.Workspace2,{title:Z,hasUnsavedChanges:k},n().createElement(r.Form,{"aria-label":E("billableServiceForm","Billable service form"),className:b.form,id:"billable-service-form",onSubmit:L(G)},n().createElement(r.Stack,{className:b.stack,gap:5},n().createElement("div",{className:b.formGroup},e?n().createElement(r.FormLabel,{className:b.serviceNameLabel},e.name):n().createElement(i.xI,{name:"name",control:B,render:({field:e})=>n().createElement(r.Layer,null,n().createElement(r.TextInput,{...e,enableCounter:!0,id:"serviceName",invalid:!!x.name,invalidText:x.name?.message,labelText:E("serviceName","Service name"),maxCount:255,placeholder:E("enterServiceName","Enter service name"),type:"text"}))})),n().createElement("div",null,n().createElement(i.xI,{name:"shortName",control:B,render:({field:e})=>n().createElement(r.Layer,null,n().createElement(r.TextInput,{...e,enableCounter:!0,id:"serviceShortName",invalid:!!x.shortName,invalidText:x.shortName?.message,labelText:E("shortName","Short name"),maxCount:255,placeholder:E("enterServiceShortName","Enter service short name"),type:"text",value:e.value||""}))})),n().createElement("div",null,n().createElement(r.FormLabel,{className:b.conceptLabel},E("associatedConcept","Associated concept")),n().createElement(p.ResponsiveWrapper,null,n().createElement(r.Search,{id:"conceptsSearch",labelText:E("associatedConcept","Associated concept"),onChange:e=>j(e.target.value),onClear:()=>{j(""),z("concept",null)},placeholder:E("searchConcepts","Search associated concept"),ref:A,value:w?.display||O})),!D||w?null:H?n().createElement(r.InlineLoading,{className:b.loader,description:E("searching","Searching")+"..."}):U&&U.length?n().createElement("ul",{className:b.conceptsList},U?.map(e=>n().createElement("li",{className:b.service,key:e.concept.uuid,onClick:()=>{z("concept",{uuid:e.concept.uuid,display:e.display}),j("")},role:"menuitem"},e.display))):n().createElement(r.Layer,null,n().createElement(r.Tile,{className:b.emptyResults},n().createElement("span",null,E("noResultsFor","No results for {{searchTerm}}",{searchTerm:D}))))),n().createElement("div",null,n().createElement(i.xI,{name:"serviceType",control:B,render:({field:e})=>n().createElement(r.Layer,null,n().createElement(r.ComboBox,{id:"serviceType",items:T??[],titleText:E("serviceType","Service type"),itemToString:e=>e?.display||"",selectedItem:e.value,onChange:({selectedItem:t})=>{e.onChange(t)},placeholder:E("selectServiceType","Select service type"),invalid:!!x.serviceType,invalidText:x.serviceType?.message}))})),n().createElement("section",null,n().createElement("div",null,I.map((e,t)=>n().createElement("div",{key:e.id,className:b.paymentMethodContainer},n().createElement(i.xI,{control:B,name:`payment.${t}.paymentMode`,render:({field:e})=>n().createElement(r.Layer,null,n().createElement(r.Dropdown,{id:`paymentMode-${t}`,invalid:!!x?.payment?.[t]?.paymentMode,invalidText:x?.payment?.[t]?.paymentMode?.message,items:g(N,I,t,e.value),itemToString:e=>e?e.name:"",label:E("selectPaymentMode","Select payment mode"),onChange:({selectedItem:t})=>e.onChange(t.uuid),selectedItem:N.find(t=>t.uuid===e.value)??null,titleText:E("paymentMode","Payment mode")}))}),n().createElement(i.xI,{control:B,name:`payment.${t}.price`,render:({field:e})=>n().createElement(r.Layer,null,n().createElement(r.NumberInput,{allowEmpty:!0,disableWheel:!0,id:`price-${t}`,invalid:!!x?.payment?.[t]?.price,invalidText:x?.payment?.[t]?.price?.message,label:E("sellingPrice","Selling price"),min:0,onChange:(t,{value:a})=>{e.onChange(""===a||void 0===a?"":a)},placeholder:E("enterSellingPrice","Enter selling price"),step:.01,value:void 0===e.value||null===e.value?"":e.value}))}),n().createElement("div",{className:b.removeButtonContainer},n().createElement(c.zH,{onClick:()=>R(t),className:b.removeButton,size:20})))),n().createElement(r.Button,{className:b.paymentButtons,iconDescription:E("add","Add"),kind:"tertiary",onClick:()=>q(v),renderIcon:e=>n().createElement(o.OM,{size:24,...e}),type:"button"},E("addPaymentOption","Add payment option")),W()&&n().createElement("div",{className:b.errorMessage},W())))),n().createElement(r.ButtonSet,{className:"tablet"===S?b.tablet:b.desktop},n().createElement(r.Button,{className:b.button,kind:"secondary",disabled:F,onClick:()=>h()},(0,p.getCoreTranslation)("cancel")),n().createElement(r.Button,{className:b.button,kind:"primary",disabled:F,type:"submit"},F?n().createElement(r.InlineLoading,{description:E("saving","Saving")+"..."}):(0,p.getCoreTranslation)("save")))))}},6994(e,t,a){a.d(t,{MH:()=>c,OS:()=>p,WJ:()=>o,bb:()=>m,cW:()=>u,j2:()=>d,ly:()=>s,vv:()=>b});var l=a(6335),n=a.n(l),r=a(9124),i=a(7003);let s=()=>{let e=`${i.B}billableService?v=custom:(uuid,name,shortName,serviceStatus,concept:(uuid,display,name:(name)),serviceType:(display,uuid),servicePrices:(uuid,name,price,paymentMode:(uuid,name)))`,{data:t,isLoading:a,isValidating:l,error:n,mutate:s}=(0,r.useOpenmrsFetchAll)(e);return{billableServices:t??[],isLoading:a,isValidating:l,error:n,mutate:s}};function c(){let{serviceTypes:e}=(0,r.useConfig)(),t=e.billableService,a=`${r.restBaseUrl}/concept/${t}?v=custom:(setMembers:(uuid,display))`,{data:l,error:i,isLoading:s}=n()(a,r.openmrsFetch);return{serviceTypes:l?.data.setMembers?[...l.data.setMembers].sort((e,t)=>e.display.localeCompare(t.display)):[],error:i,isLoadingServiceTypes:s}}let o=()=>{let e=`${i.B}paymentMode`,{data:t,error:a,isLoading:l,mutate:s}=n()(e,r.openmrsFetch);return{paymentModes:t?.data.results?[...t.data.results].sort((e,t)=>e.name.localeCompare(t.name)):[],error:a,isLoadingPaymentModes:l,mutate:s}};function m(e){let t=`${r.restBaseUrl}/conceptsearch?q=${e}`,{data:a,error:l,isLoading:i}=n()(e?t:null,r.openmrsFetch);return{searchResults:a?.data?.results??[],error:l,isSearching:i}}let d=async e=>{let t=`${i.B}api/billable-service`;return await (0,r.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},p=async(e,t)=>{let a=`${i.B}billableService/${e}`;return await (0,r.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})},u=e=>{let t=`${r.restBaseUrl}/billing/paymentMode`;return(0,r.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},b=(e,t)=>{let a=`${r.restBaseUrl}/billing/paymentMode/${e}`;return(0,r.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})}}}]);
package/dist/4263.js CHANGED
@@ -1 +1 @@
1
- (globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["4263"],{4767(e,t,n){var i={"./uk.json":["723","9072"],"./ar.json":["4132","7045"],"./ru_RU.json":["986","8359"],"./uz_UZ.json":["890","7175"],"./fr.json":["4055","6508"],"./sw_KE.json":["8618","903"],"./uz.json":["3584","6377"],"./en.json":["4300","5117"],"./ky.json":["8163","2416"],"./pl.json":["1119","6724"],"./sq.json":["8371","4928"],"./ka.json":["795","1480"],"./si.json":["6859","6904"],"./zh_TW.json":["439","556"],"./de.json":["4944","5145"],"./lg.json":["4618","8695"],"./vi.json":["9214","6371"],"./tr.json":["5241","434"],"./es_MX.json":["8349","1646"],"./tr_TR.json":["9900","1869"],"./zh_CN.json":["9879","5644"],"./en_US.json":["9569","4106"],"./he.json":["4652","2317"],"./id.json":["2690","6047"],"./ku.json":["9895","4348"],"./es.json":["3099","7912"],"./ne.json":["2146","5503"],"./ar_SY.json":["7617","282"],"./uz@Latn.json":["7097","4658"],"./bn.json":["7159","6444"],"./cs.json":["6589","7182"],"./zh.json":["5661","7742"],"./hi_IN.json":["5442","4383"],"./pt_BR.json":["6468","1877"],"./qu.json":["5173","8358"],"./ro_RO.json":["6022","3963"],"./sw.json":["9913","3378"],"./am.json":["1197","9806"],"./pt.json":["6679","5132"],"./it.json":["9538","4111"],"./km.json":["6716","5940"],"./hi.json":["6840","2881"]};function a(e){if(!n.o(i,e))return Promise.resolve().then(function(){var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t});var t=i[e],a=t[0];return n.e(t[1]).then(function(){return n(a)})}a.keys=()=>Object.keys(i),a.id=4767,e.exports=a},6199(e,t,n){"use strict";n.d(t,{DX:()=>y,FR:()=>A,LM:()=>v,N7:()=>L,TS:()=>b,Vs:()=>f,Xn:()=>E,Z5:()=>S,eC:()=>h,fu:()=>p,ly:()=>g,mi:()=>D,u1:()=>m,yj:()=>T});var i=n(6335),a=n.n(i),s=n(4353),l=n.n(s),r=n(3139),o=n(3137),c=n(7003),d=n(5084);let u=e=>{let t=e?.lineItems?.filter(e=>!e.voided)??[],{identifier:n,name:i}=(e=>{if(!e)return{identifier:"",name:""};let t=e.indexOf(" - ");return -1===t?{identifier:"",name:e.trim()}:{identifier:e.substring(0,t).trim(),name:e.substring(t+3).trim()}})(e?.patient?.display);return{...e,patientName:i,identifier:n,patientUuid:e?.patient?.uuid,visitUuid:e?.visit?.uuid,cashPointUuid:e?.cashPoint?.uuid,cashPointName:e?.cashPoint?.name,cashPointLocation:e?.cashPoint?.location?.display,status:e.status,lineItems:t,billingService:t.map(e=>e?.item||e?.billableService||"--").join(" "),totalAmount:e.total,netAmount:e.amountAfterDiscount,tenderedAmount:(e?.payments??[]).map(e=>e.amountTendered??0).reduce((e,t)=>e+t,0)}},p=(e,t,n,i,a)=>{let s=`${c.B}bill?v=custom:(id,uuid,dateCreated,status,receiptNumber,patient:(uuid,display),lineItems:(uuid,item,billableService,voided))&pageSize=${e}`;t&&(s+=`&status=${t}`),n&&(s+=`&patientName=${encodeURIComponent(n)}`),i&&(s+=`&startDate=${encodeURIComponent(l()(i).startOf("day").format(c.U))}`),a&&(s+=`&endDate=${encodeURIComponent(l()(a).endOf("day").format(c.U))}`);let r=!i||!a||i<=a,{data:d,error:p,isLoading:m,isValidating:y,mutate:b,currentPage:h,totalCount:f,goTo:g}=(0,o.useOpenmrsPagination)(r?s:null,e);return{bills:d?.map(e=>u(e))??[],error:p,isLoading:m,isValidating:y,mutate:b,currentPage:h,totalCount:f,goTo:g}},m=(e,t,n)=>{let i=`${c.B}bill?v=full`;e&&(i+=`&patientUuid=${e}`),t&&(i+=`&status=${t}`),n&&(i+=`&visitUuid=${n}`);let{data:a,error:s,isLoading:l,isValidating:d,mutate:p}=(0,o.useOpenmrsFetchAll)(i),m=(0,r.A)(a??[],["dateCreated"]).reverse();return{bills:m?.map(e=>u(e)),error:s,isLoading:l,isValidating:d,mutate:p}};function y(e,t=!0){let n=`${c.B}bill/${e}`,{data:i,error:s,isLoading:l,isValidating:r,mutate:d}=a()(e?n:null,o.openmrsFetch),p=null;return i?.data&&(p=t?u(i.data):i.data),{bill:p,error:s,isLoading:l,isValidating:r,mutate:d}}let b=(e,t)=>{let n=`${c.B}bill/${t}/payment`;return(0,o.openmrsFetch)(n,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})};function h(){let{sessionLocation:e}=(0,o.useSession)();return{data:e}}let f=e=>{let{currentVisit:t}=(0,o.useVisit)(e);return(t?.attributes??[]).map(e=>({name:e.attributeType.name,value:e.value})).filter(({name:e})=>"Insurance scheme"===e||"Policy Number"===e)};function g(){let e=`${c.B}billableService?v=custom:(uuid,name,shortName,serviceStatus,serviceType:(display),servicePrices:(uuid,name,price,paymentMode))`;return(0,o.useOpenmrsFetchAll)(e)}let E=e=>{let t=`${c.B}bill`;return(0,o.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},A=e=>{let t=`${c.B}bill/${e.uuid}`;return(0,o.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},T=e=>{let t=`${c.B}bill/${e}`;return(0,o.openmrsFetch)(t,{method:"POST",body:{status:d.ih.POSTED},headers:{"Content-Type":"application/json"}})},D=(e,t)=>{let n=`${c.B}billLineItem/${e}?reason=${encodeURIComponent(t)}`;return(0,o.openmrsFetch)(n,{method:"DELETE"})},v=(e,t)=>{let n=`${c.B}bill/${e}?reason=${encodeURIComponent(t)}`;return(0,o.openmrsFetch)(n,{method:"DELETE"})},S=e=>`${c.B}patientPaymentStatus/${e}`,L=e=>{let t=S(e),{data:n,error:i,isLoading:s,isValidating:l,mutate:r}=a()(e?t:null,o.openmrsFetch);return{paymentStatus:n?.data,error:i,isLoading:s,isValidating:l,mutate:r}}},7003(e,t,n){"use strict";n.d(t,{B:()=>a,U:()=>s});var i=n(3137);let a=`${i.restBaseUrl}/billing/`,s="YYYY-MM-DDTHH:mm:ss.SSSZZ"},7498(e,t,n){"use strict";let i,a,s,l,r;n.r(t),n.d(t,{refundRequestsLeftPanelLink:()=>ea,deletePaymentModeModal:()=>w,billingDashboardLink:()=>C,billingFormWorkspace:()=>Y,discountRequestsLeftPanelLink:()=>et,importTranslation:()=>R,billingSettingsLeftPanelMenu:()=>x,billingCheckInForm:()=>M,billableServicesCardLink:()=>I,deleteBillConfirmationModal:()=>K,billingSummaryDashboardLink:()=>j,editBillLineItemModal:()=>q,patientPaymentStatusTag:()=>W,finalizeBillConfirmationModal:()=>Q,requestDiscountModal:()=>Z,requestRefundModal:()=>en,visitBillsPanel:()=>O,billableServicesLeftPanelLink:()=>X,billingPatientSummary:()=>B,startupApp:()=>N,paymentModeFormModal:()=>F,reviewBillRefundsModal:()=>ei,billableServicesHome:()=>$,addCashPointModal:()=>z,deleteLineItemConfirmationModal:()=>H,reviewBillDiscountsModal:()=>ee,visitAttributeTags:()=>V,requirePaymentModal:()=>k,billableServiceFormWorkspace:()=>J,root:()=>G});var o=n(2383),c=n(4499),d=n(3989),u=n(771),p=n(3137),m=n(5275),y=n.n(m),b=n(9335),h=n(8395);function f({config:e}){let{t}=(0,h.useTranslation)(),{name:n,title:i}=e,a=(0,b.useLocation)(),s=window.getOpenmrsSpaBase()+"home",l=(0,m.useMemo)(()=>a.pathname.split("/").map(e=>decodeURIComponent(e)).includes(n),[a.pathname,n]);return y().createElement(p.ConfigurableLink,{to:s+"/"+n,className:`cds--side-nav__link ${l&&"active-left-nav-link"}`},t(i))}var g=n(1752);function E({config:e}){let{title:t,path:n,icon:i,privilege:a}=e,{t:s}=(0,h.useTranslation)(),l=(0,b.useLocation)(),r=`${window.spaBase}/billable-services`,o=(0,m.useMemo)(()=>{let e=l.pathname.replace(r,"");return""===n||"/"===n?""===e||"/"===e:e.startsWith(`/${n}`)},[l.pathname,n,r]),c=y().createElement(g.SideNavLink,{onClick:()=>{(0,p.navigate)({to:`${r}/${n}`})},renderIcon:i,isActive:o},s(t));return a?y().createElement(p.UserHasAccess,{privilege:a},c):c}function A({config:e}){let{title:t,icon:n,items:i,privilege:a}=e,{t:s}=(0,h.useTranslation)(),l=(0,b.useLocation)(),r=`${window.spaBase}/billable-services`,o=l.pathname.replace(r,""),c=y().createElement(g.SideNavMenu,{defaultExpanded:!0,title:s(t),renderIcon:n},i.map(e=>y().createElement(g.SideNavMenuItem,{key:e.name,isActive:o.startsWith(`/${e.path}`),onClick:()=>{var t;return t=e.path,void(0,p.navigate)({to:`${r}/${t}`})}},s(e.title))));return a?y().createElement(p.UserHasAccess,{privilege:a},c):c}function T({config:e}){let{title:t,path:n,icon:i}=e,{t:a}=(0,h.useTranslation)(),s=(0,b.useLocation)(),l=`${window.spaBase}/billable-services`,r=(0,m.useMemo)(()=>{let e=s.pathname.replace(l,"");return""===n||"/"===n?""===e||"/"===e:e.startsWith(`/${n}`)},[s.pathname,n,l]);return y().createElement(g.SideNavLink,{onClick:()=>{(0,p.navigate)({to:`${l}/${n}`})},renderIcon:i,isActive:r},a(t))}function D({config:e}){let{title:t,path:n,icon:i}=e,{t:a}=(0,h.useTranslation)(),s=(0,b.useLocation)(),l=`${globalThis.spaBase}/billable-services`,r=(0,m.useMemo)(()=>{let e=s.pathname.replace(l,"");return""===n||"/"===n?""===e||"/"===e:e.startsWith(`/${n}`)},[s.pathname,n,l]);return y().createElement(g.SideNavLink,{onClick:()=>{(0,p.navigate)({to:`${l}/${n}`})},renderIcon:i,isActive:r},a(t))}var v=n(2137),S=n(6199);let L=({patientUuid:e})=>{let{t}=(0,h.useTranslation)(),{paymentStatus:n,isLoading:i,error:a}=(0,S.N7)(e);return i||a||!n||"UNKNOWN"===n.status?null:y().createElement(g.Toggletip,{className:"-esm-billing__payment-status-tag__tag___Sfz+y"},y().createElement(g.ToggletipButton,{label:t(n.status,n.status)},y().createElement(g.Tag,{type:"PAID"===n.status?"green":"red"},t(n.status,n.status))),y().createElement(g.ToggletipContent,null,y().createElement("div",{role:"tooltip"},y().createElement("p",null,n.reason))))},U={logo:{src:{_type:p.Type.String,_default:"",_description:"The path or URL to the logo image. If set to an empty string, the alt text will be used.",_validators:[p.validators.isUrl]},alt:{_type:p.Type.String,_default:"",_description:"The alternative text for the logo image, displayed when the image cannot be loaded or on hover. If not provided and src is empty, the default OpenMRS SVG sprite will be used."}},country:{_type:p.Type.String,_description:"The text that gets printed on the top right of the invoice, typically the name of the country",_default:"Kenya"},patientCategory:{_type:p.Type.Object,_description:"Visit Attribute Type UUIDs - These are custom attribute types that can be attached to patient visits. Each UUID represents a Visit Attribute Type in OpenMRS that stores payment-related information for the visit.",_default:{paymentDetails:"fbc0702d-b4c9-4968-be63-af8ad3ad6239",paymentMethods:"8553afa0-bdb9-4d3c-8a98-05fa9350aa85",policyNumber:"aac48226-d143-4274-80e0-264db4e368ee",insuranceScheme:"3a988e33-a6c0-4b76-b924-01abb998944b",patientCategory:"3b9dfac8-9e4d-11ee-8c90-0242ac120002",formPayloadPending:"919b51c9-8e2e-468f-8354-181bf3e55786"}},categoryConcepts:{_type:p.Type.Object,_description:"Concept UUIDs - These are OpenMRS Concept UUIDs that represent the actual values/options for payment categories. These concepts are stored as values in the visit attributes defined in patientCategory.",_default:{payingDetails:"44b34972-6630-4e5a-a9f6-a6eb0f109650",nonPayingDetails:"f3fb2d88-cccd-422c-8766-be101ba7bd2e",insuranceDetails:"beac329b-f1dc-4a33-9e7c-d95821a137a6"}},nonPayingPatientCategories:{_type:p.Type.Object,_description:"Concept UUIDs for non-paying patient categories - These are OpenMRS Concept UUIDs that identify specific patient categories eligible for non-paying status (e.g., children under 5, students). These are used as values when a patient is categorized as non-paying.",_default:{childUnder5:"1528AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",student:"159465AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}},postBilledItems:{_type:p.Type.Object,_description:"Default UUIDs used when creating bills - These UUIDs identify default resources (cash points, cashier providers) that are used when submitting a bill if not explicitly provided.",_default:{cashPoint:"54065383-b4d4-42d2-af4d-d250a1fd2590",cashier:"f9badd80-ab76-11e2-9e96-0800200c9a66",priceUuid:"7b9171ac-d3c1-49b4-beff-c9902aee5245"}},serviceTypes:{_type:p.Type.Object,_description:"Service Type Concept Set UUID - This is an OpenMRS Concept Set UUID. The set members of this concept represent the different types of services that can be billed (e.g., Consultation, Lab Test, Procedure).",_default:{billableService:"21b8cf43-9f9f-4d02-9f4a-d710ece54261"}},defaultCurrency:{_type:p.Type.String,_description:"The default currency for the application. Specify the currency code (e.g., KES, UGX, GBP).",_default:"KES"},pageSize:{_type:p.Type.Number,_description:"The default page size",_default:10}},P="@openmrs/esm-billing-app",_={featureName:"billing",moduleName:P},R=n(4767),C=(0,p.getSyncLifecycle)((i={name:"billing",title:"billing"},()=>y().createElement(b.BrowserRouter,null,y().createElement(f,{config:i}))),_);function N(){(0,p.defineConfigSchema)(P,U)}let j=(0,p.getSyncLifecycle)((0,p.createDashboard)({slot:"patient-chart-billing-dashboard-slot",columns:1,title:"billingHistory",hideDashboardTitle:!0,icon:"omrs-icon-money",path:"billing-history"}),_),I=(0,p.getSyncLifecycle)(()=>{let{t:e}=(0,h.useTranslation)(),t=e("manageBilling","Manage billing");return y().createElement(g.Layer,null,y().createElement(g.ClickableTile,{href:`${window.spaBase}/billable-services`},y().createElement("div",null,y().createElement("div",{className:"heading"},t),y().createElement("div",{className:"content"},e("billingAdministration","Billing administration"))),y().createElement("div",{className:"iconWrapper"},y().createElement(v.Qp,{size:16}))))},_),$=(0,p.getAsyncLifecycle)(()=>n.e("350").then(n.bind(n,7485)),_),M=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("319"),n.e("1026")]).then(n.bind(n,5657)),_),B=(0,p.getAsyncLifecycle)(()=>n.e("203").then(n.bind(n,9686)),_),O=(0,p.getAsyncLifecycle)(()=>n.e("9414").then(n.bind(n,501)),_),k=(0,p.getAsyncLifecycle)(()=>n.e("6908").then(n.bind(n,1716)),_),F=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("6328")]).then(n.bind(n,5211)),_),w=(0,p.getAsyncLifecycle)(()=>n.e("7019").then(n.bind(n,2982)),_),z=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("8528")]).then(n.bind(n,6739)),_),q=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("6969")]).then(n.bind(n,8e3)),_),G=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("2109"),n.e("4054"),n.e("7968")]).then(n.bind(n,7283)),_),V=(0,p.getSyncLifecycle)(({patientUuid:e})=>{let t=(0,S.Vs)(e);return y().createElement("div",null,t?.map(e=>y().createElement(y().Fragment,{key:e.name},y().createElement(g.Tag,{type:"gray"},e.name),y().createElement(g.Tag,{type:"cool-gray"},e.value))))},_),W=(0,p.getSyncLifecycle)(({patientUuid:e,renderedFrom:t})=>"patient-chart"!==t?null:y().createElement(L,{patientUuid:e}),_),Y=(0,p.getAsyncLifecycle)(()=>n.e("1899").then(n.bind(n,662)),_),J=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("1617"),n.e("3784")]).then(n.bind(n,8843)),_),X=(0,p.getSyncLifecycle)((a={name:"billable-services",title:"billableServices",path:"",icon:o.uW},()=>y().createElement(b.BrowserRouter,null,y().createElement(E,{config:a}))),_),x=(0,p.getSyncLifecycle)((s={title:"billingSettings",icon:c.wB,privilege:"coreapps.systemAdministration",items:[{name:"cash-point-config",title:"cashPointConfig",path:"cash-point-config"},{name:"payment-modes-config",title:"paymentModesConfig",path:"payment-modes-config"}]},()=>y().createElement(b.BrowserRouter,null,y().createElement(A,{config:s}))),_),H=(0,p.getAsyncLifecycle)(()=>n.e("1564").then(n.bind(n,6903)),_),Q=(0,p.getAsyncLifecycle)(()=>n.e("5390").then(n.bind(n,4829)),_),K=(0,p.getAsyncLifecycle)(()=>n.e("7247").then(n.bind(n,8402)),_),Z=(0,p.getAsyncLifecycle)(()=>n.e("6699").then(n.bind(n,1734)),_),ee=(0,p.getAsyncLifecycle)(()=>n.e("3461").then(n.bind(n,3588)),_),et=(0,p.getSyncLifecycle)((l={name:"discount-requests",title:"discountRequests",path:"discount-requests",icon:d.CR},()=>y().createElement(b.BrowserRouter,null,y().createElement(T,{config:l}))),_),en=(0,p.getAsyncLifecycle)(()=>n.e("6594").then(n.bind(n,3785)),_),ei=(0,p.getAsyncLifecycle)(()=>n.e("2269").then(n.bind(n,2220)),_),ea=(0,p.getSyncLifecycle)((r={name:"refund-requests",title:"refundRequests",path:"refund-requests",icon:u.ds},()=>y().createElement(b.BrowserRouter,null,y().createElement(D,{config:r}))),_)},5084(e,t,n){"use strict";n.d(t,{Bp:()=>l,fH:()=>r,ih:()=>i,nT:()=>s,zk:()=>a});let i={PENDING:"PENDING",POSTED:"POSTED",PAID:"PAID",ADJUSTED:"ADJUSTED",PARTIALLY_REFUNDED:"PARTIALLY_REFUNDED",REFUNDED:"REFUNDED",REFUND_REQUESTED:"REFUND_REQUESTED"},a={PENDING:"PENDING",PAID:"PAID",CANCELLED:"CANCELLED",ADJUSTED:"ADJUSTED",EXEMPTED:"EXEMPTED",REFUND_REQUESTED:"REFUND_REQUESTED",REFUNDED:"REFUNDED",PARTIALLY_REFUNDED:"PARTIALLY_REFUNDED"},s={PENDING:"PENDING",APPROVED:"APPROVED",REJECTED:"REJECTED"},l={PERCENTAGE:"PERCENTAGE",FIXED_AMOUNT:"FIXED_AMOUNT"},r={REQUESTED:"REQUESTED",APPROVED:"APPROVED",REJECTED:"REJECTED",COMPLETED:"COMPLETED"}}}]);
1
+ (globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["4263"],{4767(e,t,n){var i={"./uk.json":["723","9072"],"./ar.json":["4132","7045"],"./ru_RU.json":["986","8359"],"./uz_UZ.json":["890","7175"],"./fr.json":["4055","6508"],"./sw_KE.json":["8618","903"],"./uz.json":["3584","6377"],"./en.json":["4300","5117"],"./ky.json":["8163","2416"],"./pl.json":["1119","6724"],"./sq.json":["8371","4928"],"./ka.json":["795","1480"],"./si.json":["6859","6904"],"./zh_TW.json":["439","556"],"./de.json":["4944","5145"],"./lg.json":["4618","8695"],"./vi.json":["9214","6371"],"./tr.json":["5241","434"],"./es_MX.json":["8349","1646"],"./tr_TR.json":["9900","1869"],"./zh_CN.json":["9879","5644"],"./en_US.json":["9569","4106"],"./he.json":["4652","2317"],"./id.json":["2690","6047"],"./ku.json":["9895","4348"],"./es.json":["3099","7912"],"./ne.json":["2146","5503"],"./ar_SY.json":["7617","282"],"./uz@Latn.json":["7097","4658"],"./bn.json":["7159","6444"],"./cs.json":["6589","7182"],"./zh.json":["5661","7742"],"./hi_IN.json":["5442","4383"],"./pt_BR.json":["6468","1877"],"./qu.json":["5173","8358"],"./ro_RO.json":["6022","3963"],"./sw.json":["9913","3378"],"./am.json":["1197","9806"],"./pt.json":["6679","5132"],"./it.json":["9538","4111"],"./km.json":["6716","5940"],"./hi.json":["6840","2881"]};function a(e){if(!n.o(i,e))return Promise.resolve().then(function(){var t=Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t});var t=i[e],a=t[0];return n.e(t[1]).then(function(){return n(a)})}a.keys=()=>Object.keys(i),a.id=4767,e.exports=a},6199(e,t,n){"use strict";n.d(t,{DX:()=>y,FR:()=>A,LM:()=>v,N7:()=>L,TS:()=>b,Vs:()=>f,Xn:()=>E,Z5:()=>S,eC:()=>h,fu:()=>p,ly:()=>g,mi:()=>D,u1:()=>m,yj:()=>T});var i=n(6335),a=n.n(i),s=n(4353),l=n.n(s),r=n(3139),o=n(9124),c=n(7003),d=n(5084);let u=e=>{let t=e?.lineItems?.filter(e=>!e.voided)??[],{identifier:n,name:i}=(e=>{if(!e)return{identifier:"",name:""};let t=e.indexOf(" - ");return -1===t?{identifier:"",name:e.trim()}:{identifier:e.substring(0,t).trim(),name:e.substring(t+3).trim()}})(e?.patient?.display);return{...e,patientName:i,identifier:n,patientUuid:e?.patient?.uuid,visitUuid:e?.visit?.uuid,cashPointUuid:e?.cashPoint?.uuid,cashPointName:e?.cashPoint?.name,cashPointLocation:e?.cashPoint?.location?.display,status:e.status,lineItems:t,billingService:t.map(e=>e?.item||e?.billableService||"--").join(" "),totalAmount:e.total,netAmount:e.amountAfterDiscount,tenderedAmount:(e?.payments??[]).map(e=>e.amountTendered??0).reduce((e,t)=>e+t,0)}},p=(e,t,n,i,a)=>{let s=`${c.B}bill?v=custom:(id,uuid,dateCreated,status,receiptNumber,patient:(uuid,display),lineItems:(uuid,item,billableService,voided))&pageSize=${e}`;t&&(s+=`&status=${t}`),n&&(s+=`&patientName=${encodeURIComponent(n)}`),i&&(s+=`&startDate=${encodeURIComponent(l()(i).startOf("day").format(c.U))}`),a&&(s+=`&endDate=${encodeURIComponent(l()(a).endOf("day").format(c.U))}`);let r=!i||!a||i<=a,{data:d,error:p,isLoading:m,isValidating:y,mutate:b,currentPage:h,totalCount:f,goTo:g}=(0,o.useOpenmrsPagination)(r?s:null,e);return{bills:d?.map(e=>u(e))??[],error:p,isLoading:m,isValidating:y,mutate:b,currentPage:h,totalCount:f,goTo:g}},m=(e,t,n)=>{let i=`${c.B}bill?v=full`;e&&(i+=`&patientUuid=${e}`),t&&(i+=`&status=${t}`),n&&(i+=`&visitUuid=${n}`);let{data:a,error:s,isLoading:l,isValidating:d,mutate:p}=(0,o.useOpenmrsFetchAll)(i),m=(0,r.A)(a??[],["dateCreated"]).reverse();return{bills:m?.map(e=>u(e)),error:s,isLoading:l,isValidating:d,mutate:p}};function y(e,t=!0){let n=`${c.B}bill/${e}`,{data:i,error:s,isLoading:l,isValidating:r,mutate:d}=a()(e?n:null,o.openmrsFetch),p=null;return i?.data&&(p=t?u(i.data):i.data),{bill:p,error:s,isLoading:l,isValidating:r,mutate:d}}let b=(e,t)=>{let n=`${c.B}bill/${t}/payment`;return(0,o.openmrsFetch)(n,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})};function h(){let{sessionLocation:e}=(0,o.useSession)();return{data:e}}let f=e=>{let{currentVisit:t}=(0,o.useVisit)(e);return(t?.attributes??[]).map(e=>({name:e.attributeType.name,value:e.value})).filter(({name:e})=>"Insurance scheme"===e||"Policy Number"===e)};function g(){let e=`${c.B}billableService?v=custom:(uuid,name,shortName,serviceStatus,serviceType:(display),servicePrices:(uuid,name,price,paymentMode))`;return(0,o.useOpenmrsFetchAll)(e)}let E=e=>{let t=`${c.B}bill`;return(0,o.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},A=e=>{let t=`${c.B}bill/${e.uuid}`;return(0,o.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},T=e=>{let t=`${c.B}bill/${e}`;return(0,o.openmrsFetch)(t,{method:"POST",body:{status:d.ih.POSTED},headers:{"Content-Type":"application/json"}})},D=(e,t)=>{let n=`${c.B}billLineItem/${e}?reason=${encodeURIComponent(t)}`;return(0,o.openmrsFetch)(n,{method:"DELETE"})},v=(e,t)=>{let n=`${c.B}bill/${e}?reason=${encodeURIComponent(t)}`;return(0,o.openmrsFetch)(n,{method:"DELETE"})},S=e=>`${c.B}patientPaymentStatus/${e}`,L=e=>{let t=S(e),{data:n,error:i,isLoading:s,isValidating:l,mutate:r}=a()(e?t:null,o.openmrsFetch);return{paymentStatus:n?.data,error:i,isLoading:s,isValidating:l,mutate:r}}},7003(e,t,n){"use strict";n.d(t,{B:()=>a,U:()=>s});var i=n(9124);let a=`${i.restBaseUrl}/billing/`,s="YYYY-MM-DDTHH:mm:ss.SSSZZ"},7498(e,t,n){"use strict";let i,a,s,l,r;n.r(t),n.d(t,{refundRequestsLeftPanelLink:()=>ea,deletePaymentModeModal:()=>w,billingDashboardLink:()=>C,billingFormWorkspace:()=>Y,discountRequestsLeftPanelLink:()=>et,importTranslation:()=>R,billingSettingsLeftPanelMenu:()=>x,billingCheckInForm:()=>M,billableServicesCardLink:()=>I,deleteBillConfirmationModal:()=>K,billingSummaryDashboardLink:()=>j,editBillLineItemModal:()=>q,patientPaymentStatusTag:()=>W,finalizeBillConfirmationModal:()=>Q,requestDiscountModal:()=>Z,requestRefundModal:()=>en,visitBillsPanel:()=>O,billableServicesLeftPanelLink:()=>X,billingPatientSummary:()=>B,startupApp:()=>N,paymentModeFormModal:()=>F,reviewBillRefundsModal:()=>ei,billableServicesHome:()=>$,addCashPointModal:()=>z,deleteLineItemConfirmationModal:()=>H,reviewBillDiscountsModal:()=>ee,visitAttributeTags:()=>V,requirePaymentModal:()=>k,billableServiceFormWorkspace:()=>J,root:()=>G});var o=n(2383),c=n(4499),d=n(3989),u=n(771),p=n(9124),m=n(5275),y=n.n(m),b=n(9335),h=n(8395);function f({config:e}){let{t}=(0,h.useTranslation)(),{name:n,title:i}=e,a=(0,b.useLocation)(),s=window.getOpenmrsSpaBase()+"home",l=(0,m.useMemo)(()=>a.pathname.split("/").map(e=>decodeURIComponent(e)).includes(n),[a.pathname,n]);return y().createElement(p.ConfigurableLink,{to:s+"/"+n,className:`cds--side-nav__link ${l&&"active-left-nav-link"}`},t(i))}var g=n(1752);function E({config:e}){let{title:t,path:n,icon:i,privilege:a}=e,{t:s}=(0,h.useTranslation)(),l=(0,b.useLocation)(),r=`${window.spaBase}/billable-services`,o=(0,m.useMemo)(()=>{let e=l.pathname.replace(r,"");return""===n||"/"===n?""===e||"/"===e:e.startsWith(`/${n}`)},[l.pathname,n,r]),c=y().createElement(g.SideNavLink,{onClick:()=>{(0,p.navigate)({to:`${r}/${n}`})},renderIcon:i,isActive:o},s(t));return a?y().createElement(p.UserHasAccess,{privilege:a},c):c}function A({config:e}){let{title:t,icon:n,items:i,privilege:a}=e,{t:s}=(0,h.useTranslation)(),l=(0,b.useLocation)(),r=`${window.spaBase}/billable-services`,o=l.pathname.replace(r,""),c=y().createElement(g.SideNavMenu,{defaultExpanded:!0,title:s(t),renderIcon:n},i.map(e=>y().createElement(g.SideNavMenuItem,{key:e.name,isActive:o.startsWith(`/${e.path}`),onClick:()=>{var t;return t=e.path,void(0,p.navigate)({to:`${r}/${t}`})}},s(e.title))));return a?y().createElement(p.UserHasAccess,{privilege:a},c):c}function T({config:e}){let{title:t,path:n,icon:i}=e,{t:a}=(0,h.useTranslation)(),s=(0,b.useLocation)(),l=`${window.spaBase}/billable-services`,r=(0,m.useMemo)(()=>{let e=s.pathname.replace(l,"");return""===n||"/"===n?""===e||"/"===e:e.startsWith(`/${n}`)},[s.pathname,n,l]);return y().createElement(g.SideNavLink,{onClick:()=>{(0,p.navigate)({to:`${l}/${n}`})},renderIcon:i,isActive:r},a(t))}function D({config:e}){let{title:t,path:n,icon:i}=e,{t:a}=(0,h.useTranslation)(),s=(0,b.useLocation)(),l=`${globalThis.spaBase}/billable-services`,r=(0,m.useMemo)(()=>{let e=s.pathname.replace(l,"");return""===n||"/"===n?""===e||"/"===e:e.startsWith(`/${n}`)},[s.pathname,n,l]);return y().createElement(g.SideNavLink,{onClick:()=>{(0,p.navigate)({to:`${l}/${n}`})},renderIcon:i,isActive:r},a(t))}var v=n(2137),S=n(6199);let L=({patientUuid:e})=>{let{t}=(0,h.useTranslation)(),{paymentStatus:n,isLoading:i,error:a}=(0,S.N7)(e);return i||a||!n||"UNKNOWN"===n.status?null:y().createElement(g.Toggletip,{className:"-esm-billing__payment-status-tag__tag___Sfz+y"},y().createElement(g.ToggletipButton,{label:t(n.status,n.status)},y().createElement(g.Tag,{type:"PAID"===n.status?"green":"red"},t(n.status,n.status))),y().createElement(g.ToggletipContent,null,y().createElement("div",{role:"tooltip"},y().createElement("p",null,n.reason))))},U={logo:{src:{_type:p.Type.String,_default:"",_description:"The path or URL to the logo image. If set to an empty string, the alt text will be used.",_validators:[p.validators.isUrl]},alt:{_type:p.Type.String,_default:"",_description:"The alternative text for the logo image, displayed when the image cannot be loaded or on hover. If not provided and src is empty, the default OpenMRS SVG sprite will be used."}},country:{_type:p.Type.String,_description:"The text that gets printed on the top right of the invoice, typically the name of the country",_default:"Kenya"},patientCategory:{_type:p.Type.Object,_description:"Visit Attribute Type UUIDs - These are custom attribute types that can be attached to patient visits. Each UUID represents a Visit Attribute Type in OpenMRS that stores payment-related information for the visit.",_default:{paymentDetails:"fbc0702d-b4c9-4968-be63-af8ad3ad6239",paymentMethods:"8553afa0-bdb9-4d3c-8a98-05fa9350aa85",policyNumber:"aac48226-d143-4274-80e0-264db4e368ee",insuranceScheme:"3a988e33-a6c0-4b76-b924-01abb998944b",patientCategory:"3b9dfac8-9e4d-11ee-8c90-0242ac120002",formPayloadPending:"919b51c9-8e2e-468f-8354-181bf3e55786"}},categoryConcepts:{_type:p.Type.Object,_description:"Concept UUIDs - These are OpenMRS Concept UUIDs that represent the actual values/options for payment categories. These concepts are stored as values in the visit attributes defined in patientCategory.",_default:{payingDetails:"44b34972-6630-4e5a-a9f6-a6eb0f109650",nonPayingDetails:"f3fb2d88-cccd-422c-8766-be101ba7bd2e",insuranceDetails:"beac329b-f1dc-4a33-9e7c-d95821a137a6"}},nonPayingPatientCategories:{_type:p.Type.Object,_description:"Concept UUIDs for non-paying patient categories - These are OpenMRS Concept UUIDs that identify specific patient categories eligible for non-paying status (e.g., children under 5, students). These are used as values when a patient is categorized as non-paying.",_default:{childUnder5:"1528AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",student:"159465AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}},postBilledItems:{_type:p.Type.Object,_description:"Default UUIDs used when creating bills - These UUIDs identify default resources (cash points, cashier providers) that are used when submitting a bill if not explicitly provided.",_default:{cashPoint:"54065383-b4d4-42d2-af4d-d250a1fd2590",cashier:"f9badd80-ab76-11e2-9e96-0800200c9a66",priceUuid:"7b9171ac-d3c1-49b4-beff-c9902aee5245"}},serviceTypes:{_type:p.Type.Object,_description:"Service Type Concept Set UUID - This is an OpenMRS Concept Set UUID. The set members of this concept represent the different types of services that can be billed (e.g., Consultation, Lab Test, Procedure).",_default:{billableService:"21b8cf43-9f9f-4d02-9f4a-d710ece54261"}},defaultCurrency:{_type:p.Type.String,_description:"The default currency for the application. Specify the currency code (e.g., KES, UGX, GBP).",_default:"KES"},pageSize:{_type:p.Type.Number,_description:"The default page size",_default:10}},P="@openmrs/esm-billing-app",_={featureName:"billing",moduleName:P},R=n(4767),C=(0,p.getSyncLifecycle)((i={name:"billing",title:"billing"},()=>y().createElement(b.BrowserRouter,null,y().createElement(f,{config:i}))),_);function N(){(0,p.defineConfigSchema)(P,U)}let j=(0,p.getSyncLifecycle)((0,p.createDashboard)({slot:"patient-chart-billing-dashboard-slot",columns:1,title:"billingHistory",hideDashboardTitle:!0,icon:"omrs-icon-money",path:"billing-history"}),_),I=(0,p.getSyncLifecycle)(()=>{let{t:e}=(0,h.useTranslation)(),t=e("manageBilling","Manage billing");return y().createElement(g.Layer,null,y().createElement(g.ClickableTile,{href:`${window.spaBase}/billable-services`},y().createElement("div",null,y().createElement("div",{className:"heading"},t),y().createElement("div",{className:"content"},e("billingAdministration","Billing administration"))),y().createElement("div",{className:"iconWrapper"},y().createElement(v.Qp,{size:16}))))},_),$=(0,p.getAsyncLifecycle)(()=>n.e("350").then(n.bind(n,7485)),_),M=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("319"),n.e("1026")]).then(n.bind(n,5657)),_),B=(0,p.getAsyncLifecycle)(()=>n.e("203").then(n.bind(n,9686)),_),O=(0,p.getAsyncLifecycle)(()=>n.e("9414").then(n.bind(n,501)),_),k=(0,p.getAsyncLifecycle)(()=>n.e("6908").then(n.bind(n,1716)),_),F=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("6328")]).then(n.bind(n,5211)),_),w=(0,p.getAsyncLifecycle)(()=>n.e("7019").then(n.bind(n,2982)),_),z=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("8528")]).then(n.bind(n,6739)),_),q=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("6969")]).then(n.bind(n,8e3)),_),G=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("2109"),n.e("4054"),n.e("7968")]).then(n.bind(n,7283)),_),V=(0,p.getSyncLifecycle)(({patientUuid:e})=>{let t=(0,S.Vs)(e);return y().createElement("div",null,t?.map(e=>y().createElement(y().Fragment,{key:e.name},y().createElement(g.Tag,{type:"gray"},e.name),y().createElement(g.Tag,{type:"cool-gray"},e.value))))},_),W=(0,p.getSyncLifecycle)(({patientUuid:e,renderedFrom:t})=>"patient-chart"!==t?null:y().createElement(L,{patientUuid:e}),_),Y=(0,p.getAsyncLifecycle)(()=>n.e("1899").then(n.bind(n,662)),_),J=(0,p.getAsyncLifecycle)(()=>Promise.all([n.e("9457"),n.e("1617"),n.e("3784")]).then(n.bind(n,8843)),_),X=(0,p.getSyncLifecycle)((a={name:"billable-services",title:"billableServices",path:"",icon:o.uW},()=>y().createElement(b.BrowserRouter,null,y().createElement(E,{config:a}))),_),x=(0,p.getSyncLifecycle)((s={title:"billingSettings",icon:c.wB,privilege:"coreapps.systemAdministration",items:[{name:"cash-point-config",title:"cashPointConfig",path:"cash-point-config"},{name:"payment-modes-config",title:"paymentModesConfig",path:"payment-modes-config"}]},()=>y().createElement(b.BrowserRouter,null,y().createElement(A,{config:s}))),_),H=(0,p.getAsyncLifecycle)(()=>n.e("1564").then(n.bind(n,6903)),_),Q=(0,p.getAsyncLifecycle)(()=>n.e("5390").then(n.bind(n,4829)),_),K=(0,p.getAsyncLifecycle)(()=>n.e("7247").then(n.bind(n,8402)),_),Z=(0,p.getAsyncLifecycle)(()=>n.e("6699").then(n.bind(n,1734)),_),ee=(0,p.getAsyncLifecycle)(()=>n.e("3461").then(n.bind(n,3588)),_),et=(0,p.getSyncLifecycle)((l={name:"discount-requests",title:"discountRequests",path:"discount-requests",icon:d.CR},()=>y().createElement(b.BrowserRouter,null,y().createElement(T,{config:l}))),_),en=(0,p.getAsyncLifecycle)(()=>n.e("6594").then(n.bind(n,3785)),_),ei=(0,p.getAsyncLifecycle)(()=>n.e("2269").then(n.bind(n,2220)),_),ea=(0,p.getSyncLifecycle)((r={name:"refund-requests",title:"refundRequests",path:"refund-requests",icon:u.ds},()=>y().createElement(b.BrowserRouter,null,y().createElement(D,{config:r}))),_)},5084(e,t,n){"use strict";n.d(t,{Bp:()=>l,fH:()=>r,ih:()=>i,nT:()=>s,zk:()=>a});let i={PENDING:"PENDING",POSTED:"POSTED",PAID:"PAID",ADJUSTED:"ADJUSTED",PARTIALLY_REFUNDED:"PARTIALLY_REFUNDED",REFUNDED:"REFUNDED",REFUND_REQUESTED:"REFUND_REQUESTED"},a={PENDING:"PENDING",PAID:"PAID",CANCELLED:"CANCELLED",ADJUSTED:"ADJUSTED",EXEMPTED:"EXEMPTED",REFUND_REQUESTED:"REFUND_REQUESTED",REFUNDED:"REFUNDED",PARTIALLY_REFUNDED:"PARTIALLY_REFUNDED"},s={PENDING:"PENDING",APPROVED:"APPROVED",REJECTED:"REJECTED"},l={PERCENTAGE:"PERCENTAGE",FIXED_AMOUNT:"FIXED_AMOUNT"},r={REQUESTED:"REQUESTED",APPROVED:"APPROVED",REJECTED:"REJECTED",COMPLETED:"COMPLETED"}}}]);
package/dist/5390.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["5390"],{4352(e,l,i){i.d(l,{A:()=>n});let n={spinner:"-esm-billing__delete-line-item-confirmation__spinner___4aqIs",modalBody:"-esm-billing__delete-line-item-confirmation__modalBody___yKwtP",sectionTitle:"-esm-billing__delete-line-item-confirmation__sectionTitle___u+XCL"}},4829(e,l,i){i.r(l),i.d(l,{default:()=>c});var n=i(5275),a=i.n(n),t=i(1752),o=i(8395),s=i(3137),r=i(6199),d=i(4352);let c=({closeModal:e,bill:l,onMutate:i})=>{let{t:c}=(0,o.useTranslation)(),[m,_]=(0,n.useState)(!1),u=async()=>{if(l?.uuid){_(!0);try{await (0,r.yj)(l.uuid),(0,s.showSnackbar)({title:c("billFinalized","Bill finalized"),subtitle:c("billFinalizedSuccess","Bill has been finalized successfully"),kind:"success"}),i?.(),e()}catch(l){let e=l?.responseBody?.error?.message||l?.message||c("finalizeFailedTryAgain","Unable to finalize bill. Please try again.");console.error("[FinalizeBillModal] Bill finalization failed",l),(0,s.showSnackbar)({title:c("billFinalizeFailed","Failed to finalize bill"),subtitle:e,kind:"error"})}finally{_(!1)}}};return a().createElement(a().Fragment,null,a().createElement(t.ModalHeader,{closeModal:e,title:c("finalizeBill","Finalize bill")}),a().createElement(t.ModalBody,{className:d.A.modalBody},a().createElement("p",null,c("finalizeBillConfirmation","Are you sure you want to finalize this bill? Once finalized, no further modifications to the bill will be allowed."))),a().createElement(t.ModalFooter,null,a().createElement(t.Button,{kind:"secondary",onClick:e,disabled:m},(0,s.getCoreTranslation)("cancel")),a().createElement(t.Button,{kind:"primary",onClick:u,disabled:m},m?a().createElement(t.InlineLoading,{className:d.A.spinner,description:c("finalizing","Finalizing")+"..."}):c("finalize","Finalize"))))}}}]);
1
+ "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["5390"],{4352(e,l,i){i.d(l,{A:()=>n});let n={spinner:"-esm-billing__delete-line-item-confirmation__spinner___4aqIs",modalBody:"-esm-billing__delete-line-item-confirmation__modalBody___yKwtP",sectionTitle:"-esm-billing__delete-line-item-confirmation__sectionTitle___u+XCL"}},4829(e,l,i){i.r(l),i.d(l,{default:()=>c});var n=i(5275),a=i.n(n),t=i(1752),o=i(8395),s=i(9124),r=i(6199),d=i(4352);let c=({closeModal:e,bill:l,onMutate:i})=>{let{t:c}=(0,o.useTranslation)(),[m,_]=(0,n.useState)(!1),u=async()=>{if(l?.uuid){_(!0);try{await (0,r.yj)(l.uuid),(0,s.showSnackbar)({title:c("billFinalized","Bill finalized"),subtitle:c("billFinalizedSuccess","Bill has been finalized successfully"),kind:"success"}),i?.(),e()}catch(l){let e=l?.responseBody?.error?.message||l?.message||c("finalizeFailedTryAgain","Unable to finalize bill. Please try again.");console.error("[FinalizeBillModal] Bill finalization failed",l),(0,s.showSnackbar)({title:c("billFinalizeFailed","Failed to finalize bill"),subtitle:e,kind:"error"})}finally{_(!1)}}};return a().createElement(a().Fragment,null,a().createElement(t.ModalHeader,{closeModal:e,title:c("finalizeBill","Finalize bill")}),a().createElement(t.ModalBody,{className:d.A.modalBody},a().createElement("p",null,c("finalizeBillConfirmation","Are you sure you want to finalize this bill? Once finalized, no further modifications to the bill will be allowed."))),a().createElement(t.ModalFooter,null,a().createElement(t.Button,{kind:"secondary",onClick:e,disabled:m},(0,s.getCoreTranslation)("cancel")),a().createElement(t.Button,{kind:"primary",onClick:u,disabled:m},m?a().createElement(t.InlineLoading,{className:d.A.spinner,description:c("finalizing","Finalizing")+"..."}):c("finalize","Finalize"))))}}}]);
package/dist/6328.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["6328"],{6994(e,t,a){a.d(t,{MH:()=>o,OS:()=>p,WJ:()=>d,bb:()=>m,cW:()=>u,j2:()=>c,ly:()=>l,vv:()=>y});var n=a(6335),r=a.n(n),s=a(3137),i=a(7003);let l=()=>{let e=`${i.B}billableService?v=custom:(uuid,name,shortName,serviceStatus,concept:(uuid,display,name:(name)),serviceType:(display,uuid),servicePrices:(uuid,name,price,paymentMode:(uuid,name)))`,{data:t,isLoading:a,isValidating:n,error:r,mutate:l}=(0,s.useOpenmrsFetchAll)(e);return{billableServices:t??[],isLoading:a,isValidating:n,error:r,mutate:l}};function o(){let{serviceTypes:e}=(0,s.useConfig)(),t=e.billableService,a=`${s.restBaseUrl}/concept/${t}?v=custom:(setMembers:(uuid,display))`,{data:n,error:i,isLoading:l}=r()(a,s.openmrsFetch);return{serviceTypes:n?.data.setMembers?[...n.data.setMembers].sort((e,t)=>e.display.localeCompare(t.display)):[],error:i,isLoadingServiceTypes:l}}let d=()=>{let e=`${i.B}paymentMode`,{data:t,error:a,isLoading:n,mutate:l}=r()(e,s.openmrsFetch);return{paymentModes:t?.data.results?[...t.data.results].sort((e,t)=>e.name.localeCompare(t.name)):[],error:a,isLoadingPaymentModes:n,mutate:l}};function m(e){let t=`${s.restBaseUrl}/conceptsearch?q=${e}`,{data:a,error:n,isLoading:i}=r()(e?t:null,s.openmrsFetch);return{searchResults:a?.data?.results??[],error:n,isSearching:i}}let c=async e=>{let t=`${i.B}api/billable-service`;return await (0,s.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},p=async(e,t)=>{let a=`${i.B}billableService/${e}`;return await (0,s.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})},u=e=>{let t=`${s.restBaseUrl}/billing/paymentMode`;return(0,s.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},y=(e,t)=>{let a=`${s.restBaseUrl}/billing/paymentMode/${e}`;return(0,s.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})}},5211(e,t,a){a.r(t),a.d(t,{default:()=>y});var n=a(5275),r=a.n(n),s=a(8395),i=a(9785),l=a(4476),o=a(3285),d=a(6335),m=a(1752),c=a(3137),p=a(7003),u=a(6994);let y=({closeModal:e,editPaymentMode:t})=>{let{t:a}=(0,s.useTranslation)(),{mutate:n}=(0,d.useSWRConfig)(),y=l.z.object({name:l.z.string().min(1,a("paymentModeNameRequired","Payment mode name is required")),description:l.z.string().optional()}),{control:b,handleSubmit:h,reset:v,formState:{errors:g,isSubmitting:T}}=(0,i.mN)({resolver:(0,o.u)(y),defaultValues:{name:t?.name??"",description:t?.description??""}}),M=async r=>{let s=`${p.B}paymentMode`;try{let i={name:r.name,description:r.description};t?.uuid?await (0,u.vv)(t.uuid,i):await (0,u.cW)(i),n(e=>"string"==typeof e&&e.startsWith(s),void 0,{revalidate:!0}),(0,c.showSnackbar)({title:a("success","Success"),subtitle:a("paymentModeSaved","Payment mode was successfully saved."),kind:"success"}),e(),v({name:"",description:""})}catch(e){(0,c.showSnackbar)({title:(0,c.getCoreTranslation)("error"),subtitle:e?.message||a("errorSavingPaymentMode","An error occurred while saving the payment mode."),kind:"error",isLowContrast:!1})}};return r().createElement(r().Fragment,null,r().createElement(m.ModalHeader,{closeModal:e,title:t?a("editPaymentMode","Edit payment mode"):a("addPaymentMode","Add payment mode")}),r().createElement(m.Form,{onSubmit:h(M)},r().createElement(m.ModalBody,null,r().createElement(m.Stack,{gap:5},r().createElement(i.xI,{name:"name",control:b,render:({field:e})=>r().createElement(m.TextInput,{id:"payment-mode-name",labelText:a("paymentModeNameLabel","Payment mode name"),placeholder:a("paymentModeNamePlaceholder","For example, Cash, Credit Card"),invalid:!!g.name,invalidText:g.name?.message,...e})}),r().createElement(i.xI,{name:"description",control:b,render:({field:e})=>r().createElement(m.TextInput,{id:"payment-mode-description",labelText:a("description","Description"),placeholder:a("descriptionPlaceholder","For example, Used for all cash transactions"),invalid:!!g.description,invalidText:g.description?.message,...e})}))),r().createElement(m.ModalFooter,null,r().createElement(m.Button,{kind:"secondary",onClick:e},(0,c.getCoreTranslation)("cancel")),r().createElement(m.Button,{type:"submit",disabled:T},T?a("saving","Saving")+"...":(0,c.getCoreTranslation)("save")))))}}}]);
1
+ "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["6328"],{6994(e,t,a){a.d(t,{MH:()=>o,OS:()=>p,WJ:()=>d,bb:()=>m,cW:()=>u,j2:()=>c,ly:()=>l,vv:()=>y});var n=a(6335),r=a.n(n),s=a(9124),i=a(7003);let l=()=>{let e=`${i.B}billableService?v=custom:(uuid,name,shortName,serviceStatus,concept:(uuid,display,name:(name)),serviceType:(display,uuid),servicePrices:(uuid,name,price,paymentMode:(uuid,name)))`,{data:t,isLoading:a,isValidating:n,error:r,mutate:l}=(0,s.useOpenmrsFetchAll)(e);return{billableServices:t??[],isLoading:a,isValidating:n,error:r,mutate:l}};function o(){let{serviceTypes:e}=(0,s.useConfig)(),t=e.billableService,a=`${s.restBaseUrl}/concept/${t}?v=custom:(setMembers:(uuid,display))`,{data:n,error:i,isLoading:l}=r()(a,s.openmrsFetch);return{serviceTypes:n?.data.setMembers?[...n.data.setMembers].sort((e,t)=>e.display.localeCompare(t.display)):[],error:i,isLoadingServiceTypes:l}}let d=()=>{let e=`${i.B}paymentMode`,{data:t,error:a,isLoading:n,mutate:l}=r()(e,s.openmrsFetch);return{paymentModes:t?.data.results?[...t.data.results].sort((e,t)=>e.name.localeCompare(t.name)):[],error:a,isLoadingPaymentModes:n,mutate:l}};function m(e){let t=`${s.restBaseUrl}/conceptsearch?q=${e}`,{data:a,error:n,isLoading:i}=r()(e?t:null,s.openmrsFetch);return{searchResults:a?.data?.results??[],error:n,isSearching:i}}let c=async e=>{let t=`${i.B}api/billable-service`;return await (0,s.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},p=async(e,t)=>{let a=`${i.B}billableService/${e}`;return await (0,s.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})},u=e=>{let t=`${s.restBaseUrl}/billing/paymentMode`;return(0,s.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},y=(e,t)=>{let a=`${s.restBaseUrl}/billing/paymentMode/${e}`;return(0,s.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})}},5211(e,t,a){a.r(t),a.d(t,{default:()=>y});var n=a(5275),r=a.n(n),s=a(8395),i=a(9785),l=a(4476),o=a(3285),d=a(6335),m=a(1752),c=a(9124),p=a(7003),u=a(6994);let y=({closeModal:e,editPaymentMode:t})=>{let{t:a}=(0,s.useTranslation)(),{mutate:n}=(0,d.useSWRConfig)(),y=l.z.object({name:l.z.string().min(1,a("paymentModeNameRequired","Payment mode name is required")),description:l.z.string().optional()}),{control:b,handleSubmit:h,reset:v,formState:{errors:g,isSubmitting:T}}=(0,i.mN)({resolver:(0,o.u)(y),defaultValues:{name:t?.name??"",description:t?.description??""}}),M=async r=>{let s=`${p.B}paymentMode`;try{let i={name:r.name,description:r.description};t?.uuid?await (0,u.vv)(t.uuid,i):await (0,u.cW)(i),n(e=>"string"==typeof e&&e.startsWith(s),void 0,{revalidate:!0}),(0,c.showSnackbar)({title:a("success","Success"),subtitle:a("paymentModeSaved","Payment mode was successfully saved."),kind:"success"}),e(),v({name:"",description:""})}catch(e){(0,c.showSnackbar)({title:(0,c.getCoreTranslation)("error"),subtitle:e?.message||a("errorSavingPaymentMode","An error occurred while saving the payment mode."),kind:"error",isLowContrast:!1})}};return r().createElement(r().Fragment,null,r().createElement(m.ModalHeader,{closeModal:e,title:t?a("editPaymentMode","Edit payment mode"):a("addPaymentMode","Add payment mode")}),r().createElement(m.Form,{onSubmit:h(M)},r().createElement(m.ModalBody,null,r().createElement(m.Stack,{gap:5},r().createElement(i.xI,{name:"name",control:b,render:({field:e})=>r().createElement(m.TextInput,{id:"payment-mode-name",labelText:a("paymentModeNameLabel","Payment mode name"),placeholder:a("paymentModeNamePlaceholder","For example, Cash, Credit Card"),invalid:!!g.name,invalidText:g.name?.message,...e})}),r().createElement(i.xI,{name:"description",control:b,render:({field:e})=>r().createElement(m.TextInput,{id:"payment-mode-description",labelText:a("description","Description"),placeholder:a("descriptionPlaceholder","For example, Used for all cash transactions"),invalid:!!g.description,invalidText:g.description?.message,...e})}))),r().createElement(m.ModalFooter,null,r().createElement(m.Button,{kind:"secondary",onClick:e},(0,c.getCoreTranslation)("cancel")),r().createElement(m.Button,{type:"submit",disabled:T},T?a("saving","Saving")+"...":(0,c.getCoreTranslation)("save")))))}}}]);
package/dist/6594.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["6594"],{2373(e,n,a){a.d(n,{Zz:()=>l,aL:()=>r,o_:()=>u});var t=a(3137);function l(e){return Array.isArray(e)?e.reduce((e,n)=>"number"==typeof n.price&&"number"==typeof n.quantity&&!0!==n.voided?e+n.price*n.quantity:e,0):0}let r=(e,n)=>{let a=window.i18next?.language?.substring(0,2)??"",t=new Intl.NumberFormat(a,{style:"currency",currency:n,minimumFractionDigits:2}).format(Math.abs(e));return e<0&&(t=`(${t})`),t},u=(e,n)=>{switch(e){case"male":return(0,t.getCoreTranslation)("male");case"female":return(0,t.getCoreTranslation)("female");case"other":return(0,t.getCoreTranslation)("other");case"unknown":return(0,t.getCoreTranslation)("unknown");default:return e}}},1772(e,n,a){a.d(n,{aL:()=>t.aL,o_:()=>t.o_});var t=a(2373)},8683(e,n,a){a.d(n,{KY:()=>i,eK:()=>o,qC:()=>s,zb:()=>m});var t=a(3137),l=a(7003);let r=`${l.B}billRefund`,u=`${l.B}bill`;function i({statuses:e}){let n=new URLSearchParams({refundStatus:e.join(","),v:"default"}),a=`${u}?${n.toString()}`,{data:l,isLoading:r,error:s,mutate:o,isValidating:m}=(0,t.useOpenmrsFetchAll)(a);return{bills:l??[],isLoading:r,error:s,mutate:o,isValidating:m}}async function s(e){return(await (0,t.openmrsFetch)(r,{method:"POST",headers:{"Content-Type":"application/json"},body:e})).data}async function o(e,n){return(await (0,t.openmrsFetch)(`${r}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:n})).data}async function m(e,n){await (0,t.openmrsFetch)(`${r}/${e}?reason=${encodeURIComponent(n)}`,{method:"DELETE"})}},3785(e,n,a){a.r(n),a.d(n,{default:()=>_});var t=a(5275),l=a.n(t),r=a(1752),u=a(8395),i=a(3137),s=a(1772),o=a(8683);let m="-esm-billing__request-refund-modal__summaryLabel___gyZWr",c="-esm-billing__request-refund-modal__summaryValue___WhBns",d="-esm-billing__request-refund-modal__summaryRefund___3pgfz",_=({closeModal:e,bill:n,lineItem:a,remainingRefundable:_,onMutate:b})=>{let{t:f}=(0,u.useTranslation)(),{defaultCurrency:p}=(0,i.useConfig)(),[y,g]=(0,t.useState)(null),[h,E]=(0,t.useState)(""),[q,N]=(0,t.useState)(!1),T=!!a,v=a?.total??n.total,C=T?v-_:n.amountAfterDiscount-_,w=h.trim(),L=h.length>1e3?f("reasonTooLong","Reason cannot exceed 1000 characters"):null,R=null==y||Number.isNaN(y)?null:_<=0?f("noRefundableAmount","No refundable amount remaining on this bill"):y<=0?f("amountMustBePositive","Amount must be greater than 0"):y>_?f("amountExceedsRefundable","Amount cannot exceed {{max}}",{max:(0,s.aL)(_,p)}):null,A=!q&&null!=y&&y>0&&w.length>0&&!L&&!R,S=async()=>{if(A&&null!=y){N(!0);try{await (0,o.qC)({bill:n.uuid,lineItem:a?.uuid,refundAmount:y,reason:w}),b?.(),(0,i.showSnackbar)({title:f("refundRequested","Refund request submitted"),subtitle:f("refundPendingReview","An admin will review your request"),kind:"success"}),e()}catch(n){let e=n?.responseBody?.error?.message??(n instanceof Error?n.message:void 0);(0,i.showSnackbar)({title:f("refundRequestFailed","Could not submit refund request"),subtitle:e,kind:"error"})}finally{N(!1)}}};return l().createElement(l().Fragment,null,l().createElement(r.ModalHeader,{closeModal:e,title:f("requestRefund","Request refund")}),l().createElement(r.ModalBody,{className:"-esm-billing__request-refund-modal__modalBody___aNYxK"},l().createElement(r.Stack,{gap:5},l().createElement("section",{className:"-esm-billing__request-refund-modal__scopePanel___v5Zjq","aria-label":f("refundScope","Refund scope")},l().createElement("div",{className:"-esm-billing__request-refund-modal__scopePrimary___cDom0"},T?a.display:f("wholeBillScope","Whole bill")),l().createElement("ul",{className:"-esm-billing__request-refund-modal__scopeMeta___Nfwru"},n.receiptNumber&&l().createElement("li",null,f("invoiceLabel","Invoice {{number}}",{number:n.receiptNumber})),T&&null!=a.quantity&&null!=a.price&&l().createElement("li",null,f("qtyTimesPrice","Qty {{quantity}} \xd7 {{price}}",{quantity:a.quantity,price:(0,s.aL)(a.price,p)})),!T&&null!=n.lineItemCount&&l().createElement("li",null,f("lineItemCount","{{count}} line items",{count:n.lineItemCount})),l().createElement("li",{className:"-esm-billing__request-refund-modal__scopeTotal___OHr2-"},T?f("lineTotalLabel","Line total {{total}}",{total:(0,s.aL)(v,p)}):f("billTotalLabel","Bill total {{total}}",{total:(0,s.aL)(v,p)})))),l().createElement(r.NumberInput,{id:"refund-amount",label:f("refundAmountLabel","Refund amount ({{currency}})",{currency:p}),allowEmpty:!0,min:0,max:_,value:y??"",invalid:!!R,invalidText:R??"",onChange:(e,{value:n})=>{if(""===n||null==n)return void g(null);let a="string"==typeof n?Number.parseFloat(n):n;g(Number.isNaN(a)?null:a)}}),null!=y&&y>0&&!R&&l().createElement("section",{className:"-esm-billing__request-refund-modal__summaryCard___E6ZlG","aria-label":f("refundSummary","Refund summary")},l().createElement("span",{className:m},T?f("lineTotal","Line total"):f("billTotal","Bill total")),l().createElement("span",{className:c},(0,s.aL)(T?v:n.amountAfterDiscount,p)),C>0&&l().createElement(l().Fragment,null,l().createElement("span",{className:m},f("alreadyRefunded","Already refunded")),l().createElement("span",{className:`${c} ${d}`},"−",(0,s.aL)(C,p))),l().createElement("span",{className:m},f("refundAmount","Refund amount")),l().createElement("span",{className:`${c} ${d}`},"−",(0,s.aL)(y,p)),l().createElement("span",{className:"-esm-billing__request-refund-modal__summaryDivider___Ay6Ji","aria-hidden":"true"}),l().createElement("span",{className:"-esm-billing__request-refund-modal__summaryTotalLabel___dZa8B"},f("amountAfterRefund","Amount after refund")),l().createElement("span",{className:"-esm-billing__request-refund-modal__summaryTotalValue___FqISP"},(0,s.aL)(_-y,p))),l().createElement(r.TextArea,{id:"refund-reason",labelText:f("reason","Reason"),placeholder:T?f("lineItemReasonPlaceholder","e.g., duplicate charge, wrong item billed"):f("billReasonPlaceholder","e.g., payment made in error, duplicate payment"),maxCount:1e3,enableCounter:!0,required:!0,rows:3,value:h,invalid:!!L,invalidText:L??"",onChange:e=>E(e.target.value)}))),l().createElement(r.ModalFooter,null,l().createElement(r.Button,{kind:"secondary",onClick:e},(0,i.getCoreTranslation)("cancel")),l().createElement(r.Button,{kind:"primary",onClick:S,disabled:!A},q?l().createElement(r.InlineLoading,{description:f("submitting","Submitting")+"..."}):l().createElement("span",null,f("submitRequest","Submit request")))))}}}]);
1
+ "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["6594"],{2373(e,n,a){a.d(n,{Zz:()=>l,aL:()=>r,o_:()=>u});var t=a(9124);function l(e){return Array.isArray(e)?e.reduce((e,n)=>"number"==typeof n.price&&"number"==typeof n.quantity&&!0!==n.voided?e+n.price*n.quantity:e,0):0}let r=(e,n)=>{let a=window.i18next?.language?.substring(0,2)??"",t=new Intl.NumberFormat(a,{style:"currency",currency:n,minimumFractionDigits:2}).format(Math.abs(e));return e<0&&(t=`(${t})`),t},u=(e,n)=>{switch(e){case"male":return(0,t.getCoreTranslation)("male");case"female":return(0,t.getCoreTranslation)("female");case"other":return(0,t.getCoreTranslation)("other");case"unknown":return(0,t.getCoreTranslation)("unknown");default:return e}}},1772(e,n,a){a.d(n,{aL:()=>t.aL,o_:()=>t.o_});var t=a(2373)},8683(e,n,a){a.d(n,{KY:()=>i,eK:()=>o,qC:()=>s,zb:()=>m});var t=a(9124),l=a(7003);let r=`${l.B}billRefund`,u=`${l.B}bill`;function i({statuses:e}){let n=new URLSearchParams({refundStatus:e.join(","),v:"default"}),a=`${u}?${n.toString()}`,{data:l,isLoading:r,error:s,mutate:o,isValidating:m}=(0,t.useOpenmrsFetchAll)(a);return{bills:l??[],isLoading:r,error:s,mutate:o,isValidating:m}}async function s(e){return(await (0,t.openmrsFetch)(r,{method:"POST",headers:{"Content-Type":"application/json"},body:e})).data}async function o(e,n){return(await (0,t.openmrsFetch)(`${r}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:n})).data}async function m(e,n){await (0,t.openmrsFetch)(`${r}/${e}?reason=${encodeURIComponent(n)}`,{method:"DELETE"})}},3785(e,n,a){a.r(n),a.d(n,{default:()=>_});var t=a(5275),l=a.n(t),r=a(1752),u=a(8395),i=a(9124),s=a(1772),o=a(8683);let m="-esm-billing__request-refund-modal__summaryLabel___gyZWr",c="-esm-billing__request-refund-modal__summaryValue___WhBns",d="-esm-billing__request-refund-modal__summaryRefund___3pgfz",_=({closeModal:e,bill:n,lineItem:a,remainingRefundable:_,onMutate:b})=>{let{t:f}=(0,u.useTranslation)(),{defaultCurrency:p}=(0,i.useConfig)(),[y,g]=(0,t.useState)(null),[h,E]=(0,t.useState)(""),[q,N]=(0,t.useState)(!1),T=!!a,v=a?.total??n.total,C=T?v-_:n.amountAfterDiscount-_,w=h.trim(),L=h.length>1e3?f("reasonTooLong","Reason cannot exceed 1000 characters"):null,R=null==y||Number.isNaN(y)?null:_<=0?f("noRefundableAmount","No refundable amount remaining on this bill"):y<=0?f("amountMustBePositive","Amount must be greater than 0"):y>_?f("amountExceedsRefundable","Amount cannot exceed {{max}}",{max:(0,s.aL)(_,p)}):null,A=!q&&null!=y&&y>0&&w.length>0&&!L&&!R,S=async()=>{if(A&&null!=y){N(!0);try{await (0,o.qC)({bill:n.uuid,lineItem:a?.uuid,refundAmount:y,reason:w}),b?.(),(0,i.showSnackbar)({title:f("refundRequested","Refund request submitted"),subtitle:f("refundPendingReview","An admin will review your request"),kind:"success"}),e()}catch(n){let e=n?.responseBody?.error?.message??(n instanceof Error?n.message:void 0);(0,i.showSnackbar)({title:f("refundRequestFailed","Could not submit refund request"),subtitle:e,kind:"error"})}finally{N(!1)}}};return l().createElement(l().Fragment,null,l().createElement(r.ModalHeader,{closeModal:e,title:f("requestRefund","Request refund")}),l().createElement(r.ModalBody,{className:"-esm-billing__request-refund-modal__modalBody___aNYxK"},l().createElement(r.Stack,{gap:5},l().createElement("section",{className:"-esm-billing__request-refund-modal__scopePanel___v5Zjq","aria-label":f("refundScope","Refund scope")},l().createElement("div",{className:"-esm-billing__request-refund-modal__scopePrimary___cDom0"},T?a.display:f("wholeBillScope","Whole bill")),l().createElement("ul",{className:"-esm-billing__request-refund-modal__scopeMeta___Nfwru"},n.receiptNumber&&l().createElement("li",null,f("invoiceLabel","Invoice {{number}}",{number:n.receiptNumber})),T&&null!=a.quantity&&null!=a.price&&l().createElement("li",null,f("qtyTimesPrice","Qty {{quantity}} \xd7 {{price}}",{quantity:a.quantity,price:(0,s.aL)(a.price,p)})),!T&&null!=n.lineItemCount&&l().createElement("li",null,f("lineItemCount","{{count}} line items",{count:n.lineItemCount})),l().createElement("li",{className:"-esm-billing__request-refund-modal__scopeTotal___OHr2-"},T?f("lineTotalLabel","Line total {{total}}",{total:(0,s.aL)(v,p)}):f("billTotalLabel","Bill total {{total}}",{total:(0,s.aL)(v,p)})))),l().createElement(r.NumberInput,{id:"refund-amount",label:f("refundAmountLabel","Refund amount ({{currency}})",{currency:p}),allowEmpty:!0,min:0,max:_,value:y??"",invalid:!!R,invalidText:R??"",onChange:(e,{value:n})=>{if(""===n||null==n)return void g(null);let a="string"==typeof n?Number.parseFloat(n):n;g(Number.isNaN(a)?null:a)}}),null!=y&&y>0&&!R&&l().createElement("section",{className:"-esm-billing__request-refund-modal__summaryCard___E6ZlG","aria-label":f("refundSummary","Refund summary")},l().createElement("span",{className:m},T?f("lineTotal","Line total"):f("billTotal","Bill total")),l().createElement("span",{className:c},(0,s.aL)(T?v:n.amountAfterDiscount,p)),C>0&&l().createElement(l().Fragment,null,l().createElement("span",{className:m},f("alreadyRefunded","Already refunded")),l().createElement("span",{className:`${c} ${d}`},"−",(0,s.aL)(C,p))),l().createElement("span",{className:m},f("refundAmount","Refund amount")),l().createElement("span",{className:`${c} ${d}`},"−",(0,s.aL)(y,p)),l().createElement("span",{className:"-esm-billing__request-refund-modal__summaryDivider___Ay6Ji","aria-hidden":"true"}),l().createElement("span",{className:"-esm-billing__request-refund-modal__summaryTotalLabel___dZa8B"},f("amountAfterRefund","Amount after refund")),l().createElement("span",{className:"-esm-billing__request-refund-modal__summaryTotalValue___FqISP"},(0,s.aL)(_-y,p))),l().createElement(r.TextArea,{id:"refund-reason",labelText:f("reason","Reason"),placeholder:T?f("lineItemReasonPlaceholder","e.g., duplicate charge, wrong item billed"):f("billReasonPlaceholder","e.g., payment made in error, duplicate payment"),maxCount:1e3,enableCounter:!0,required:!0,rows:3,value:h,invalid:!!L,invalidText:L??"",onChange:e=>E(e.target.value)}))),l().createElement(r.ModalFooter,null,l().createElement(r.Button,{kind:"secondary",onClick:e},(0,i.getCoreTranslation)("cancel")),l().createElement(r.Button,{kind:"primary",onClick:S,disabled:!A},q?l().createElement(r.InlineLoading,{description:f("submitting","Submitting")+"..."}):l().createElement("span",null,f("submitRequest","Submit request")))))}}}]);
package/dist/6699.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["6699"],{4571(e,t,n){n.d(t,{GH:()=>r,Zi:()=>u,jb:()=>o,qu:()=>c}),n(6335);var a=n(3137),l=n(7003);let i=`${l.B}billDiscount`,s=`${l.B}bill`;function u({statuses:e}){let t=new URLSearchParams({discountStatus:e.join(","),v:"default"}),n=`${s}?${t.toString()}`,{data:l,isLoading:i,error:o,mutate:r,isValidating:c}=(0,a.useOpenmrsFetchAll)(n);return{bills:l??[],isLoading:i,error:o,mutate:r,isValidating:c}}async function o(e){return(await (0,a.openmrsFetch)(i,{method:"POST",headers:{"Content-Type":"application/json"},body:e})).data}async function r(e,t,n){return(await (0,a.openmrsFetch)(`${i}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:{status:t,approver:n}})).data}async function c(e,t){await (0,a.openmrsFetch)(`${i}/${e}?reason=${encodeURIComponent(t)}`,{method:"DELETE"})}},1734(e,t,n){n.r(t),n.d(t,{default:()=>_});var a=n(5275),l=n.n(a),i=n(1752),s=n(8395),u=n(3137),o=n(1772),r=n(5084),c=n(4571);let m="-esm-billing__request-discount-modal__summaryLabel___VaWqh",d="-esm-billing__request-discount-modal__summaryValue___d6IJk",_=({closeModal:e,bill:t,lineItem:n,onMutate:_})=>{let{t:p}=(0,s.useTranslation)(),{defaultCurrency:b}=(0,u.useConfig)(),[E,g]=(0,a.useState)(r.Bp.PERCENTAGE),[y,h]=(0,a.useState)(null),[T,N]=(0,a.useState)(""),[q,f]=(0,a.useState)(!1),v=!!n,C=n?.total??t.total,L=T.trim(),B=null!=y&&!Number.isNaN(y)&&y>0?E===r.Bp.PERCENTAGE?C*y/100:y:null,w=v?p("lineItemJustificationPlaceholder","e.g., damaged item, wrong quantity billed, expired stock"):p("billJustificationPlaceholder","e.g., hardship assistance, charity case, write-off"),x=T.length>1e3?p("justificationTooLong","Justification cannot exceed 1000 characters"):null,D=null==y||Number.isNaN(y)?null:y<=0?p("valueMustBePositive","Value must be greater than 0"):E===r.Bp.PERCENTAGE&&y>100?p("percentageTooHigh","Percentage cannot exceed 100"):null==B?null:B>t.amountDue?p("discountExceedsAmountDue","Discount cannot exceed the amount due"):n&&B>n.total?p("discountExceedsLineTotal","Discount cannot exceed the line item total"):null,P=!q&&null!=y&&L.length>0&&!x&&!D,S=async()=>{if(P&&null!=y){f(!0);try{await (0,c.jb)({bill:t.uuid,lineItem:n?.uuid,discountType:E,discountValue:y,justification:L}),_?.(),(0,u.showSnackbar)({title:p("discountRequested","Discount request submitted"),subtitle:p("discountPendingReview","An admin will review your request"),kind:"success"}),e()}catch(t){let e=t?.responseBody?.error?.message??(t instanceof Error?t.message:void 0);(0,u.showSnackbar)({title:p("discountRequestFailed","Could not submit discount request"),subtitle:e,kind:"error"})}finally{f(!1)}}};return l().createElement(l().Fragment,null,l().createElement(i.ModalHeader,{closeModal:e,title:p("requestDiscount","Request discount")}),l().createElement(i.ModalBody,{className:"-esm-billing__request-discount-modal__modalBody___GBnye"},l().createElement(i.Stack,{gap:5},l().createElement("section",{className:"-esm-billing__request-discount-modal__scopePanel___3guqY","aria-label":p("discountScope","Discount scope")},l().createElement("div",{className:"-esm-billing__request-discount-modal__scopePrimary___Y71Gc"},v?n.display:p("wholeBillScope","Whole bill")),l().createElement("ul",{className:"-esm-billing__request-discount-modal__scopeMeta___xrhxy"},t.receiptNumber&&l().createElement("li",null,p("invoiceLabel","Invoice {{number}}",{number:t.receiptNumber})),v&&null!=n.quantity&&null!=n.price&&l().createElement("li",null,p("qtyTimesPrice","Qty {{quantity}} \xd7 {{price}}",{quantity:n.quantity,price:(0,o.aL)(n.price,b)})),!v&&null!=t.lineItemCount&&l().createElement("li",null,p("lineItemCount","{{count}} line items",{count:t.lineItemCount})),l().createElement("li",{className:"-esm-billing__request-discount-modal__scopeTotal___2e1eb"},v?p("lineTotalLabel","Line total {{total}}",{total:(0,o.aL)(C,b)}):p("billTotalLabel","Bill total {{total}}",{total:(0,o.aL)(C,b)})))),l().createElement(i.FormGroup,{legendText:p("discount","Discount"),className:"-esm-billing__request-discount-modal__discountGroup___qyLxM"},l().createElement(i.Stack,{gap:4},l().createElement(i.RadioButtonGroup,{legendText:"",name:"discount-type",valueSelected:E,onChange:e=>g(e)},l().createElement(i.RadioButton,{labelText:p("percentage","Percentage"),value:r.Bp.PERCENTAGE}),l().createElement(i.RadioButton,{labelText:p("fixedAmount","Fixed amount"),value:r.Bp.FIXED_AMOUNT})),l().createElement(i.NumberInput,{id:"discount-value",label:E===r.Bp.PERCENTAGE?p("valuePercentLabel","Value (%)"):p("valueAmountLabel","Value ({{currency}})",{currency:b}),allowEmpty:!0,min:0,value:y??"",invalid:!!D,invalidText:D??"",onChange:(e,{value:t})=>{if(""===t||null==t)return void h(null);let n="string"==typeof t?parseFloat(t):t;h(Number.isNaN(n)?null:n)}}))),null!=B&&l().createElement("section",{className:"-esm-billing__request-discount-modal__summaryCard___BjITg","aria-label":p("discountSummary","Discount summary")},l().createElement("span",{className:m},v?p("lineTotal","Line total"):p("billTotal","Bill total")),l().createElement("span",{className:d},(0,o.aL)(C,b)),l().createElement("span",{className:m},E===r.Bp.PERCENTAGE&&null!=y?p("discountWithPercent","Discount ({{percent}}%)",{percent:y}):p("discountLabel","Discount")),l().createElement("span",{className:`${d} -esm-billing__request-discount-modal__summaryDiscount___REJ5I`},"−",(0,o.aL)(B,b)),v&&l().createElement(l().Fragment,null,l().createElement("span",{className:m},p("lineAfterDiscount","Line after discount")),l().createElement("span",{className:d},(0,o.aL)(C-B,b))),l().createElement("span",{className:"-esm-billing__request-discount-modal__summaryDivider___2nBbX","aria-hidden":"true"}),l().createElement("span",{className:m},p("outstanding","Outstanding")),l().createElement("span",{className:d},(0,o.aL)(t.amountDue,b)),l().createElement("span",{className:"-esm-billing__request-discount-modal__summaryTotalLabel___9ESne"},p("amountDueOnBillAfterDiscount","Amount due on bill after discount")),l().createElement("span",{className:"-esm-billing__request-discount-modal__summaryTotalValue___Cwkmg"},(0,o.aL)(t.amountDue-B,b))),l().createElement(i.TextArea,{id:"discount-justification",labelText:p("justification","Justification"),placeholder:w,maxCount:1e3,enableCounter:!0,required:!0,rows:3,value:T,invalid:!!x,invalidText:x??"",onChange:e=>N(e.target.value)}))),l().createElement(i.ModalFooter,null,l().createElement(i.Button,{kind:"secondary",onClick:e},(0,u.getCoreTranslation)("cancel")),l().createElement(i.Button,{kind:"primary",onClick:S,disabled:!P},q?l().createElement(i.InlineLoading,{description:p("submitting","Submitting")+"..."}):l().createElement("span",null,p("submitRequest","Submit request")))))}},2373(e,t,n){n.d(t,{Zz:()=>l,aL:()=>i,o_:()=>s});var a=n(3137);function l(e){return Array.isArray(e)?e.reduce((e,t)=>"number"==typeof t.price&&"number"==typeof t.quantity&&!0!==t.voided?e+t.price*t.quantity:e,0):0}let i=(e,t)=>{let n=window.i18next?.language?.substring(0,2)??"",a=new Intl.NumberFormat(n,{style:"currency",currency:t,minimumFractionDigits:2}).format(Math.abs(e));return e<0&&(a=`(${a})`),a},s=(e,t)=>{switch(e){case"male":return(0,a.getCoreTranslation)("male");case"female":return(0,a.getCoreTranslation)("female");case"other":return(0,a.getCoreTranslation)("other");case"unknown":return(0,a.getCoreTranslation)("unknown");default:return e}}},1772(e,t,n){n.d(t,{aL:()=>a.aL,o_:()=>a.o_});var a=n(2373)}}]);
1
+ "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["6699"],{4571(e,t,n){n.d(t,{GH:()=>r,Zi:()=>u,jb:()=>o,qu:()=>c}),n(6335);var a=n(9124),l=n(7003);let i=`${l.B}billDiscount`,s=`${l.B}bill`;function u({statuses:e}){let t=new URLSearchParams({discountStatus:e.join(","),v:"default"}),n=`${s}?${t.toString()}`,{data:l,isLoading:i,error:o,mutate:r,isValidating:c}=(0,a.useOpenmrsFetchAll)(n);return{bills:l??[],isLoading:i,error:o,mutate:r,isValidating:c}}async function o(e){return(await (0,a.openmrsFetch)(i,{method:"POST",headers:{"Content-Type":"application/json"},body:e})).data}async function r(e,t,n){return(await (0,a.openmrsFetch)(`${i}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:{status:t,approver:n}})).data}async function c(e,t){await (0,a.openmrsFetch)(`${i}/${e}?reason=${encodeURIComponent(t)}`,{method:"DELETE"})}},1734(e,t,n){n.r(t),n.d(t,{default:()=>_});var a=n(5275),l=n.n(a),i=n(1752),s=n(8395),u=n(9124),o=n(1772),r=n(5084),c=n(4571);let m="-esm-billing__request-discount-modal__summaryLabel___VaWqh",d="-esm-billing__request-discount-modal__summaryValue___d6IJk",_=({closeModal:e,bill:t,lineItem:n,onMutate:_})=>{let{t:p}=(0,s.useTranslation)(),{defaultCurrency:b}=(0,u.useConfig)(),[E,g]=(0,a.useState)(r.Bp.PERCENTAGE),[y,h]=(0,a.useState)(null),[T,N]=(0,a.useState)(""),[q,f]=(0,a.useState)(!1),v=!!n,C=n?.total??t.total,L=T.trim(),B=null!=y&&!Number.isNaN(y)&&y>0?E===r.Bp.PERCENTAGE?C*y/100:y:null,w=v?p("lineItemJustificationPlaceholder","e.g., damaged item, wrong quantity billed, expired stock"):p("billJustificationPlaceholder","e.g., hardship assistance, charity case, write-off"),x=T.length>1e3?p("justificationTooLong","Justification cannot exceed 1000 characters"):null,D=null==y||Number.isNaN(y)?null:y<=0?p("valueMustBePositive","Value must be greater than 0"):E===r.Bp.PERCENTAGE&&y>100?p("percentageTooHigh","Percentage cannot exceed 100"):null==B?null:B>t.amountDue?p("discountExceedsAmountDue","Discount cannot exceed the amount due"):n&&B>n.total?p("discountExceedsLineTotal","Discount cannot exceed the line item total"):null,P=!q&&null!=y&&L.length>0&&!x&&!D,S=async()=>{if(P&&null!=y){f(!0);try{await (0,c.jb)({bill:t.uuid,lineItem:n?.uuid,discountType:E,discountValue:y,justification:L}),_?.(),(0,u.showSnackbar)({title:p("discountRequested","Discount request submitted"),subtitle:p("discountPendingReview","An admin will review your request"),kind:"success"}),e()}catch(t){let e=t?.responseBody?.error?.message??(t instanceof Error?t.message:void 0);(0,u.showSnackbar)({title:p("discountRequestFailed","Could not submit discount request"),subtitle:e,kind:"error"})}finally{f(!1)}}};return l().createElement(l().Fragment,null,l().createElement(i.ModalHeader,{closeModal:e,title:p("requestDiscount","Request discount")}),l().createElement(i.ModalBody,{className:"-esm-billing__request-discount-modal__modalBody___GBnye"},l().createElement(i.Stack,{gap:5},l().createElement("section",{className:"-esm-billing__request-discount-modal__scopePanel___3guqY","aria-label":p("discountScope","Discount scope")},l().createElement("div",{className:"-esm-billing__request-discount-modal__scopePrimary___Y71Gc"},v?n.display:p("wholeBillScope","Whole bill")),l().createElement("ul",{className:"-esm-billing__request-discount-modal__scopeMeta___xrhxy"},t.receiptNumber&&l().createElement("li",null,p("invoiceLabel","Invoice {{number}}",{number:t.receiptNumber})),v&&null!=n.quantity&&null!=n.price&&l().createElement("li",null,p("qtyTimesPrice","Qty {{quantity}} \xd7 {{price}}",{quantity:n.quantity,price:(0,o.aL)(n.price,b)})),!v&&null!=t.lineItemCount&&l().createElement("li",null,p("lineItemCount","{{count}} line items",{count:t.lineItemCount})),l().createElement("li",{className:"-esm-billing__request-discount-modal__scopeTotal___2e1eb"},v?p("lineTotalLabel","Line total {{total}}",{total:(0,o.aL)(C,b)}):p("billTotalLabel","Bill total {{total}}",{total:(0,o.aL)(C,b)})))),l().createElement(i.FormGroup,{legendText:p("discount","Discount"),className:"-esm-billing__request-discount-modal__discountGroup___qyLxM"},l().createElement(i.Stack,{gap:4},l().createElement(i.RadioButtonGroup,{legendText:"",name:"discount-type",valueSelected:E,onChange:e=>g(e)},l().createElement(i.RadioButton,{labelText:p("percentage","Percentage"),value:r.Bp.PERCENTAGE}),l().createElement(i.RadioButton,{labelText:p("fixedAmount","Fixed amount"),value:r.Bp.FIXED_AMOUNT})),l().createElement(i.NumberInput,{id:"discount-value",label:E===r.Bp.PERCENTAGE?p("valuePercentLabel","Value (%)"):p("valueAmountLabel","Value ({{currency}})",{currency:b}),allowEmpty:!0,min:0,value:y??"",invalid:!!D,invalidText:D??"",onChange:(e,{value:t})=>{if(""===t||null==t)return void h(null);let n="string"==typeof t?parseFloat(t):t;h(Number.isNaN(n)?null:n)}}))),null!=B&&l().createElement("section",{className:"-esm-billing__request-discount-modal__summaryCard___BjITg","aria-label":p("discountSummary","Discount summary")},l().createElement("span",{className:m},v?p("lineTotal","Line total"):p("billTotal","Bill total")),l().createElement("span",{className:d},(0,o.aL)(C,b)),l().createElement("span",{className:m},E===r.Bp.PERCENTAGE&&null!=y?p("discountWithPercent","Discount ({{percent}}%)",{percent:y}):p("discountLabel","Discount")),l().createElement("span",{className:`${d} -esm-billing__request-discount-modal__summaryDiscount___REJ5I`},"−",(0,o.aL)(B,b)),v&&l().createElement(l().Fragment,null,l().createElement("span",{className:m},p("lineAfterDiscount","Line after discount")),l().createElement("span",{className:d},(0,o.aL)(C-B,b))),l().createElement("span",{className:"-esm-billing__request-discount-modal__summaryDivider___2nBbX","aria-hidden":"true"}),l().createElement("span",{className:m},p("outstanding","Outstanding")),l().createElement("span",{className:d},(0,o.aL)(t.amountDue,b)),l().createElement("span",{className:"-esm-billing__request-discount-modal__summaryTotalLabel___9ESne"},p("amountDueOnBillAfterDiscount","Amount due on bill after discount")),l().createElement("span",{className:"-esm-billing__request-discount-modal__summaryTotalValue___Cwkmg"},(0,o.aL)(t.amountDue-B,b))),l().createElement(i.TextArea,{id:"discount-justification",labelText:p("justification","Justification"),placeholder:w,maxCount:1e3,enableCounter:!0,required:!0,rows:3,value:T,invalid:!!x,invalidText:x??"",onChange:e=>N(e.target.value)}))),l().createElement(i.ModalFooter,null,l().createElement(i.Button,{kind:"secondary",onClick:e},(0,u.getCoreTranslation)("cancel")),l().createElement(i.Button,{kind:"primary",onClick:S,disabled:!P},q?l().createElement(i.InlineLoading,{description:p("submitting","Submitting")+"..."}):l().createElement("span",null,p("submitRequest","Submit request")))))}},2373(e,t,n){n.d(t,{Zz:()=>l,aL:()=>i,o_:()=>s});var a=n(9124);function l(e){return Array.isArray(e)?e.reduce((e,t)=>"number"==typeof t.price&&"number"==typeof t.quantity&&!0!==t.voided?e+t.price*t.quantity:e,0):0}let i=(e,t)=>{let n=window.i18next?.language?.substring(0,2)??"",a=new Intl.NumberFormat(n,{style:"currency",currency:t,minimumFractionDigits:2}).format(Math.abs(e));return e<0&&(a=`(${a})`),a},s=(e,t)=>{switch(e){case"male":return(0,a.getCoreTranslation)("male");case"female":return(0,a.getCoreTranslation)("female");case"other":return(0,a.getCoreTranslation)("other");case"unknown":return(0,a.getCoreTranslation)("unknown");default:return e}}},1772(e,t,n){n.d(t,{aL:()=>a.aL,o_:()=>a.o_});var a=n(2373)}}]);
package/dist/6908.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["6908"],{2373(e,t,r){r.d(t,{Zz:()=>n,aL:()=>a,o_:()=>i});var l=r(3137);function n(e){return Array.isArray(e)?e.reduce((e,t)=>"number"==typeof t.price&&"number"==typeof t.quantity&&!0!==t.voided?e+t.price*t.quantity:e,0):0}let a=(e,t)=>{let r=window.i18next?.language?.substring(0,2)??"",l=new Intl.NumberFormat(r,{style:"currency",currency:t,minimumFractionDigits:2}).format(Math.abs(e));return e<0&&(l=`(${l})`),l},i=(e,t)=>{switch(e){case"male":return(0,l.getCoreTranslation)("male");case"female":return(0,l.getCoreTranslation)("female");case"other":return(0,l.getCoreTranslation)("other");case"unknown":return(0,l.getCoreTranslation)("unknown");default:return e}}},1772(e,t,r){r.d(t,{aL:()=>l.aL,o_:()=>l.o_});var l=r(2373)},1716(e,t,r){r.r(t),r.d(t,{default:()=>d});var l=r(5275),n=r.n(l),a=r(8395),i=r(1752),u=r(3137),c=r(6199),s=r(1772),o=r(5084);let d=({closeModal:e,patientUuid:t})=>{let{t:r}=(0,a.useTranslation)(),{defaultCurrency:l}=(0,u.useConfig)(),{bills:d,isLoading:m}=(0,c.u1)(t),p=d.filter(e=>e?.status!==o.ih.PAID).flatMap(e=>e?.lineItems);return n().createElement(n().Fragment,null,n().createElement(i.ModalHeader,{closeModal:e,title:r("patientBillingAlert","Patient Billing Alert")}),n().createElement(i.ModalBody,null,n().createElement("p",{className:"-esm-billing__require-payment__bodyShort02___JC8LG"},r("billPaymentRequiredMessage","The current patient has a pending bill. Advise the patient to settle the bill before receiving services")),m&&n().createElement(i.InlineLoading,{status:"active",iconDescription:(0,u.getCoreTranslation)("loading"),description:r("loadingBillItems","Loading bill items")+"..."}),n().createElement(i.StructuredListWrapper,{isCondensed:!0},n().createElement(i.StructuredListHead,null,n().createElement(i.StructuredListRow,{head:!0},n().createElement(i.StructuredListCell,{head:!0},r("item","Item")),n().createElement(i.StructuredListCell,{head:!0},r("quantity","Quantity")),n().createElement(i.StructuredListCell,{head:!0},r("unitPrice","Unit price")),n().createElement(i.StructuredListCell,{head:!0},r("total","Total")))),n().createElement(i.StructuredListBody,null,p.map(e=>n().createElement(i.StructuredListRow,{key:e.uuid},n().createElement(i.StructuredListCell,null,e.billableService||e.item),n().createElement(i.StructuredListCell,null,e.quantity),n().createElement(i.StructuredListCell,null,(0,s.aL)(e.price,l)),n().createElement(i.StructuredListCell,null,(0,s.aL)(e.quantity*e.price,l))))))),n().createElement(i.ModalFooter,null,n().createElement(i.Button,{kind:"secondary",onClick:e},(0,u.getCoreTranslation)("cancel")),n().createElement(i.Button,{kind:"primary",onClick:e},r("ok","OK"))))}}}]);
1
+ "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["6908"],{2373(e,t,r){r.d(t,{Zz:()=>n,aL:()=>a,o_:()=>i});var l=r(9124);function n(e){return Array.isArray(e)?e.reduce((e,t)=>"number"==typeof t.price&&"number"==typeof t.quantity&&!0!==t.voided?e+t.price*t.quantity:e,0):0}let a=(e,t)=>{let r=window.i18next?.language?.substring(0,2)??"",l=new Intl.NumberFormat(r,{style:"currency",currency:t,minimumFractionDigits:2}).format(Math.abs(e));return e<0&&(l=`(${l})`),l},i=(e,t)=>{switch(e){case"male":return(0,l.getCoreTranslation)("male");case"female":return(0,l.getCoreTranslation)("female");case"other":return(0,l.getCoreTranslation)("other");case"unknown":return(0,l.getCoreTranslation)("unknown");default:return e}}},1772(e,t,r){r.d(t,{aL:()=>l.aL,o_:()=>l.o_});var l=r(2373)},1716(e,t,r){r.r(t),r.d(t,{default:()=>d});var l=r(5275),n=r.n(l),a=r(8395),i=r(1752),u=r(9124),c=r(6199),s=r(1772),o=r(5084);let d=({closeModal:e,patientUuid:t})=>{let{t:r}=(0,a.useTranslation)(),{defaultCurrency:l}=(0,u.useConfig)(),{bills:d,isLoading:m}=(0,c.u1)(t),p=d.filter(e=>e?.status!==o.ih.PAID).flatMap(e=>e?.lineItems);return n().createElement(n().Fragment,null,n().createElement(i.ModalHeader,{closeModal:e,title:r("patientBillingAlert","Patient Billing Alert")}),n().createElement(i.ModalBody,null,n().createElement("p",{className:"-esm-billing__require-payment__bodyShort02___JC8LG"},r("billPaymentRequiredMessage","The current patient has a pending bill. Advise the patient to settle the bill before receiving services")),m&&n().createElement(i.InlineLoading,{status:"active",iconDescription:(0,u.getCoreTranslation)("loading"),description:r("loadingBillItems","Loading bill items")+"..."}),n().createElement(i.StructuredListWrapper,{isCondensed:!0},n().createElement(i.StructuredListHead,null,n().createElement(i.StructuredListRow,{head:!0},n().createElement(i.StructuredListCell,{head:!0},r("item","Item")),n().createElement(i.StructuredListCell,{head:!0},r("quantity","Quantity")),n().createElement(i.StructuredListCell,{head:!0},r("unitPrice","Unit price")),n().createElement(i.StructuredListCell,{head:!0},r("total","Total")))),n().createElement(i.StructuredListBody,null,p.map(e=>n().createElement(i.StructuredListRow,{key:e.uuid},n().createElement(i.StructuredListCell,null,e.billableService||e.item),n().createElement(i.StructuredListCell,null,e.quantity),n().createElement(i.StructuredListCell,null,(0,s.aL)(e.price,l)),n().createElement(i.StructuredListCell,null,(0,s.aL)(e.quantity*e.price,l))))))),n().createElement(i.ModalFooter,null,n().createElement(i.Button,{kind:"secondary",onClick:e},(0,u.getCoreTranslation)("cancel")),n().createElement(i.Button,{kind:"primary",onClick:e},r("ok","OK"))))}}}]);
package/dist/6969.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["6969"],{8e3(e,t,a){a.r(t),a.d(t,{default:()=>_});var i=a(5275),l=a.n(i),n=a(1752),r=a(8395),s=a(9785),c=a(4476),o=a(3285),u=a(3137),m=a(7661),d=a(6199),p=a(6994),b=a(1772);let y={sectionTitle:"-esm-billing__bill-item-actions__sectionTitle___VJZLU",modalBody:"-esm-billing__bill-item-actions__modalBody___FImqs",billInfo:"-esm-billing__bill-item-actions__billInfo___grzHg",separator:"-esm-billing__bill-item-actions__separator___CKXsJ",label:"-esm-billing__bill-item-actions__label___FwJ2Z",controlField:"-esm-billing__bill-item-actions__controlField___vJUpf",loader:"-esm-billing__bill-item-actions__loader___UfgTz"},_=({bill:e,closeModal:t,item:a,onMutate:_})=>{let{t:h}=(0,r.useTranslation)(),{defaultCurrency:g}=(0,u.useConfig)(),{billableServices:v}=(0,p.ly)(),[T,f]=(0,i.useState)(0),E=(0,i.useMemo)(()=>c.z.object({quantity:c.z.coerce.number({required_error:h("quantityRequired","Quantity is required"),invalid_type_error:h("quantityMustBeNumber","Quantity must be a valid number")}).int(h("quantityMustBeInteger","Quantity must be a whole number")).min(1,h("quantityMustBeAtLeastOne","Quantity must be at least 1")).max(100,h("quantityCannotExceed100","Quantity cannot exceed 100")),price:c.z.coerce.number({required_error:h("priceIsRequired","Price is required"),invalid_type_error:h("priceMustBeNumber","Price must be a valid number")}).min(0,h("priceMustBeNonNegative","Price must be 0 or greater"))}),[h]),{control:S,handleSubmit:q,formState:{isSubmitting:N,errors:F},watch:I}=(0,s.mN)({defaultValues:{quantity:a.quantity,price:a.price},resolver:(0,o.u)(E)}),M=I("quantity"),C=I("price");(0,i.useEffect)(()=>{let e=("number"==typeof M?M:parseFloat(M)||0)*("number"==typeof C?C:parseFloat(C)||0);f(isNaN(e)?0:e)},[M,C]);let B=async i=>{let l={...a,quantity:i.quantity,price:i.price,billableService:(0,m.e)(v,a.billableService),item:a?.item},n=(e?.lineItems.filter(e=>e.uuid!==a?.uuid).map(e=>({...e,billableService:(0,m.e)(v,e.billableService)}))).concat(l),r={cashPoint:e.cashPointUuid,cashier:e.cashier.uuid,lineItems:n,patient:e.patientUuid,status:e.status,uuid:e.uuid};try{await (0,d.FR)(r),_?.(),(0,u.showSnackbar)({title:h("lineItemUpdated","Line item updated"),subtitle:h("lineItemUpdateSuccess","The bill line item has been updated successfully"),kind:"success"}),t()}catch(e){(0,u.showSnackbar)({title:h("lineItemUpdateFailed","Failed to update line item"),subtitle:e?.message||h("lineItemUpdateErrorDefault","Unable to update the bill line item. Please try again."),kind:"error"})}};return Object.keys(e)?.length===0?l().createElement(n.ModalHeader,{closeModal:t,title:h("billLineItemEmpty","This bill has no line items")}):l().createElement(l().Fragment,null,l().createElement(n.ModalHeader,{closeModal:t,title:h("editBillLineItem","Edit bill line item")}),l().createElement(n.Form,{onSubmit:q(B)},l().createElement(n.ModalBody,null,l().createElement(n.Stack,{gap:5},l().createElement("div",{className:y.modalBody},l().createElement("div",{className:y.billInfo},e?.patientName,l().createElement("span",{className:y.separator},"\xb7"),e?.cashPointName,l().createElement("span",{className:y.separator},"\xb7"),e?.receiptNumber)),l().createElement("section",null,l().createElement("p",{className:y.label},h("item","Item"),": ",a?.billableService?a?.billableService:a?.item),l().createElement("p",{className:y.label},h("currentPrice","Current price"),": ",(0,b.aL)(a?.price,g)),l().createElement("p",{className:y.label},h("serviceStatus","Service status"),": ",a?.status),l().createElement(s.xI,{name:"quantity",control:S,render:({field:{onChange:e,value:t}})=>l().createElement(n.NumberInput,{allowEmpty:!0,disableWheel:!0,className:y.controlField,hideSteppers:!0,id:"quantityInput",invalid:!!F.quantity,invalidText:F.quantity?.message,label:h("quantity","Quantity"),onChange:(t,a)=>{e(a.value)},value:t})}),l().createElement(s.xI,{name:"price",control:S,render:({field:{value:e}})=>l().createElement(n.TextInput,{className:y.controlField,helperText:h("unitPriceHelperText","This is the unit price for this item"),id:"priceInput",labelText:h("unitPrice","Unit price"),readOnly:!0,value:e})}),l().createElement("p",{className:y.label,"aria-live":"polite"},h("total","Total"),": ",(0,b.aL)(T,g))))),l().createElement(n.ModalFooter,null,l().createElement(n.Button,{kind:"secondary",onClick:t},(0,u.getCoreTranslation)("cancel")),l().createElement(n.Button,{type:"submit",disabled:N},N?l().createElement("div",{className:y.inline},l().createElement(n.InlineLoading,{className:y.loader,description:`${h("submitting","Submitting")}...`})):(0,u.getCoreTranslation)("save")))))}},6994(e,t,a){a.d(t,{MH:()=>c,OS:()=>d,WJ:()=>o,bb:()=>u,cW:()=>p,j2:()=>m,ly:()=>s,vv:()=>b});var i=a(6335),l=a.n(i),n=a(3137),r=a(7003);let s=()=>{let e=`${r.B}billableService?v=custom:(uuid,name,shortName,serviceStatus,concept:(uuid,display,name:(name)),serviceType:(display,uuid),servicePrices:(uuid,name,price,paymentMode:(uuid,name)))`,{data:t,isLoading:a,isValidating:i,error:l,mutate:s}=(0,n.useOpenmrsFetchAll)(e);return{billableServices:t??[],isLoading:a,isValidating:i,error:l,mutate:s}};function c(){let{serviceTypes:e}=(0,n.useConfig)(),t=e.billableService,a=`${n.restBaseUrl}/concept/${t}?v=custom:(setMembers:(uuid,display))`,{data:i,error:r,isLoading:s}=l()(a,n.openmrsFetch);return{serviceTypes:i?.data.setMembers?[...i.data.setMembers].sort((e,t)=>e.display.localeCompare(t.display)):[],error:r,isLoadingServiceTypes:s}}let o=()=>{let e=`${r.B}paymentMode`,{data:t,error:a,isLoading:i,mutate:s}=l()(e,n.openmrsFetch);return{paymentModes:t?.data.results?[...t.data.results].sort((e,t)=>e.name.localeCompare(t.name)):[],error:a,isLoadingPaymentModes:i,mutate:s}};function u(e){let t=`${n.restBaseUrl}/conceptsearch?q=${e}`,{data:a,error:i,isLoading:r}=l()(e?t:null,n.openmrsFetch);return{searchResults:a?.data?.results??[],error:i,isSearching:r}}let m=async e=>{let t=`${r.B}api/billable-service`;return await (0,n.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},d=async(e,t)=>{let a=`${r.B}billableService/${e}`;return await (0,n.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})},p=e=>{let t=`${n.restBaseUrl}/billing/paymentMode`;return(0,n.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},b=(e,t)=>{let a=`${n.restBaseUrl}/billing/paymentMode/${e}`;return(0,n.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})}},2373(e,t,a){a.d(t,{Zz:()=>l,aL:()=>n,o_:()=>r});var i=a(3137);function l(e){return Array.isArray(e)?e.reduce((e,t)=>"number"==typeof t.price&&"number"==typeof t.quantity&&!0!==t.voided?e+t.price*t.quantity:e,0):0}let n=(e,t)=>{let a=window.i18next?.language?.substring(0,2)??"",i=new Intl.NumberFormat(a,{style:"currency",currency:t,minimumFractionDigits:2}).format(Math.abs(e));return e<0&&(i=`(${i})`),i},r=(e,t)=>{switch(e){case"male":return(0,i.getCoreTranslation)("male");case"female":return(0,i.getCoreTranslation)("female");case"other":return(0,i.getCoreTranslation)("other");case"unknown":return(0,i.getCoreTranslation)("unknown");default:return e}}},1772(e,t,a){a.d(t,{aL:()=>i.aL,o_:()=>i.o_});var i=a(2373)},7661(e,t,a){a.d(t,{e:()=>i});let i=(e,t)=>{if(!e.length)return null;let a=e.find(e=>e.name===t);return a?.uuid??null}}}]);
1
+ "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["6969"],{8e3(e,t,a){a.r(t),a.d(t,{default:()=>_});var i=a(5275),l=a.n(i),n=a(1752),r=a(8395),s=a(9785),c=a(4476),o=a(3285),u=a(9124),m=a(7661),d=a(6199),p=a(6994),b=a(1772);let y={sectionTitle:"-esm-billing__bill-item-actions__sectionTitle___VJZLU",modalBody:"-esm-billing__bill-item-actions__modalBody___FImqs",billInfo:"-esm-billing__bill-item-actions__billInfo___grzHg",separator:"-esm-billing__bill-item-actions__separator___CKXsJ",label:"-esm-billing__bill-item-actions__label___FwJ2Z",controlField:"-esm-billing__bill-item-actions__controlField___vJUpf",loader:"-esm-billing__bill-item-actions__loader___UfgTz"},_=({bill:e,closeModal:t,item:a,onMutate:_})=>{let{t:h}=(0,r.useTranslation)(),{defaultCurrency:g}=(0,u.useConfig)(),{billableServices:v}=(0,p.ly)(),[T,f]=(0,i.useState)(0),E=(0,i.useMemo)(()=>c.z.object({quantity:c.z.coerce.number({required_error:h("quantityRequired","Quantity is required"),invalid_type_error:h("quantityMustBeNumber","Quantity must be a valid number")}).int(h("quantityMustBeInteger","Quantity must be a whole number")).min(1,h("quantityMustBeAtLeastOne","Quantity must be at least 1")).max(100,h("quantityCannotExceed100","Quantity cannot exceed 100")),price:c.z.coerce.number({required_error:h("priceIsRequired","Price is required"),invalid_type_error:h("priceMustBeNumber","Price must be a valid number")}).min(0,h("priceMustBeNonNegative","Price must be 0 or greater"))}),[h]),{control:S,handleSubmit:q,formState:{isSubmitting:N,errors:F},watch:I}=(0,s.mN)({defaultValues:{quantity:a.quantity,price:a.price},resolver:(0,o.u)(E)}),M=I("quantity"),C=I("price");(0,i.useEffect)(()=>{let e=("number"==typeof M?M:parseFloat(M)||0)*("number"==typeof C?C:parseFloat(C)||0);f(isNaN(e)?0:e)},[M,C]);let B=async i=>{let l={...a,quantity:i.quantity,price:i.price,billableService:(0,m.e)(v,a.billableService),item:a?.item},n=(e?.lineItems.filter(e=>e.uuid!==a?.uuid).map(e=>({...e,billableService:(0,m.e)(v,e.billableService)}))).concat(l),r={cashPoint:e.cashPointUuid,cashier:e.cashier.uuid,lineItems:n,patient:e.patientUuid,status:e.status,uuid:e.uuid};try{await (0,d.FR)(r),_?.(),(0,u.showSnackbar)({title:h("lineItemUpdated","Line item updated"),subtitle:h("lineItemUpdateSuccess","The bill line item has been updated successfully"),kind:"success"}),t()}catch(e){(0,u.showSnackbar)({title:h("lineItemUpdateFailed","Failed to update line item"),subtitle:e?.message||h("lineItemUpdateErrorDefault","Unable to update the bill line item. Please try again."),kind:"error"})}};return Object.keys(e)?.length===0?l().createElement(n.ModalHeader,{closeModal:t,title:h("billLineItemEmpty","This bill has no line items")}):l().createElement(l().Fragment,null,l().createElement(n.ModalHeader,{closeModal:t,title:h("editBillLineItem","Edit bill line item")}),l().createElement(n.Form,{onSubmit:q(B)},l().createElement(n.ModalBody,null,l().createElement(n.Stack,{gap:5},l().createElement("div",{className:y.modalBody},l().createElement("div",{className:y.billInfo},e?.patientName,l().createElement("span",{className:y.separator},"\xb7"),e?.cashPointName,l().createElement("span",{className:y.separator},"\xb7"),e?.receiptNumber)),l().createElement("section",null,l().createElement("p",{className:y.label},h("item","Item"),": ",a?.billableService?a?.billableService:a?.item),l().createElement("p",{className:y.label},h("currentPrice","Current price"),": ",(0,b.aL)(a?.price,g)),l().createElement("p",{className:y.label},h("serviceStatus","Service status"),": ",a?.status),l().createElement(s.xI,{name:"quantity",control:S,render:({field:{onChange:e,value:t}})=>l().createElement(n.NumberInput,{allowEmpty:!0,disableWheel:!0,className:y.controlField,hideSteppers:!0,id:"quantityInput",invalid:!!F.quantity,invalidText:F.quantity?.message,label:h("quantity","Quantity"),onChange:(t,a)=>{e(a.value)},value:t})}),l().createElement(s.xI,{name:"price",control:S,render:({field:{value:e}})=>l().createElement(n.TextInput,{className:y.controlField,helperText:h("unitPriceHelperText","This is the unit price for this item"),id:"priceInput",labelText:h("unitPrice","Unit price"),readOnly:!0,value:e})}),l().createElement("p",{className:y.label,"aria-live":"polite"},h("total","Total"),": ",(0,b.aL)(T,g))))),l().createElement(n.ModalFooter,null,l().createElement(n.Button,{kind:"secondary",onClick:t},(0,u.getCoreTranslation)("cancel")),l().createElement(n.Button,{type:"submit",disabled:N},N?l().createElement("div",{className:y.inline},l().createElement(n.InlineLoading,{className:y.loader,description:`${h("submitting","Submitting")}...`})):(0,u.getCoreTranslation)("save")))))}},6994(e,t,a){a.d(t,{MH:()=>c,OS:()=>d,WJ:()=>o,bb:()=>u,cW:()=>p,j2:()=>m,ly:()=>s,vv:()=>b});var i=a(6335),l=a.n(i),n=a(9124),r=a(7003);let s=()=>{let e=`${r.B}billableService?v=custom:(uuid,name,shortName,serviceStatus,concept:(uuid,display,name:(name)),serviceType:(display,uuid),servicePrices:(uuid,name,price,paymentMode:(uuid,name)))`,{data:t,isLoading:a,isValidating:i,error:l,mutate:s}=(0,n.useOpenmrsFetchAll)(e);return{billableServices:t??[],isLoading:a,isValidating:i,error:l,mutate:s}};function c(){let{serviceTypes:e}=(0,n.useConfig)(),t=e.billableService,a=`${n.restBaseUrl}/concept/${t}?v=custom:(setMembers:(uuid,display))`,{data:i,error:r,isLoading:s}=l()(a,n.openmrsFetch);return{serviceTypes:i?.data.setMembers?[...i.data.setMembers].sort((e,t)=>e.display.localeCompare(t.display)):[],error:r,isLoadingServiceTypes:s}}let o=()=>{let e=`${r.B}paymentMode`,{data:t,error:a,isLoading:i,mutate:s}=l()(e,n.openmrsFetch);return{paymentModes:t?.data.results?[...t.data.results].sort((e,t)=>e.name.localeCompare(t.name)):[],error:a,isLoadingPaymentModes:i,mutate:s}};function u(e){let t=`${n.restBaseUrl}/conceptsearch?q=${e}`,{data:a,error:i,isLoading:r}=l()(e?t:null,n.openmrsFetch);return{searchResults:a?.data?.results??[],error:i,isSearching:r}}let m=async e=>{let t=`${r.B}api/billable-service`;return await (0,n.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},d=async(e,t)=>{let a=`${r.B}billableService/${e}`;return await (0,n.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})},p=e=>{let t=`${n.restBaseUrl}/billing/paymentMode`;return(0,n.openmrsFetch)(t,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})},b=(e,t)=>{let a=`${n.restBaseUrl}/billing/paymentMode/${e}`;return(0,n.openmrsFetch)(a,{method:"POST",body:t,headers:{"Content-Type":"application/json"}})}},2373(e,t,a){a.d(t,{Zz:()=>l,aL:()=>n,o_:()=>r});var i=a(9124);function l(e){return Array.isArray(e)?e.reduce((e,t)=>"number"==typeof t.price&&"number"==typeof t.quantity&&!0!==t.voided?e+t.price*t.quantity:e,0):0}let n=(e,t)=>{let a=window.i18next?.language?.substring(0,2)??"",i=new Intl.NumberFormat(a,{style:"currency",currency:t,minimumFractionDigits:2}).format(Math.abs(e));return e<0&&(i=`(${i})`),i},r=(e,t)=>{switch(e){case"male":return(0,i.getCoreTranslation)("male");case"female":return(0,i.getCoreTranslation)("female");case"other":return(0,i.getCoreTranslation)("other");case"unknown":return(0,i.getCoreTranslation)("unknown");default:return e}}},1772(e,t,a){a.d(t,{aL:()=>i.aL,o_:()=>i.o_});var i=a(2373)},7661(e,t,a){a.d(t,{e:()=>i});let i=(e,t)=>{if(!e.length)return null;let a=e.find(e=>e.name===t);return a?.uuid??null}}}]);
package/dist/7019.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["7019"],{2982(e,t,l){l.r(t),l.d(t,{default:()=>c});var n=l(5275),a=l.n(n),r=l(8395),o=l(6335),s=l(1752),d=l(3137),i=l(7003);let c=({closeModal:e,paymentModeUuid:t,paymentModeName:l})=>{let{t:c}=(0,r.useTranslation)(),{mutate:m}=(0,o.useSWRConfig)(),[u,y]=(0,n.useState)(!1),p=async()=>{y(!0);let l=`${i.B}paymentMode`;try{await (0,d.openmrsFetch)(`${d.restBaseUrl}/billing/paymentMode/${t}`,{method:"DELETE"}),m(e=>"string"==typeof e&&e.startsWith(l),void 0,{revalidate:!0}),(0,d.showSnackbar)({title:c("success","Success"),subtitle:c("paymentModeDeleted","Payment mode was successfully deleted."),kind:"success"}),e()}catch(e){(0,d.showSnackbar)({title:(0,d.getCoreTranslation)("error"),subtitle:e?.message||c("errorDeletingPaymentMode","An error occurred while deleting the payment mode."),kind:"error",isLowContrast:!1})}finally{y(!1)}};return a().createElement(a().Fragment,null,a().createElement(s.ModalHeader,{closeModal:e,title:c("deletePaymentMode","Delete Payment Mode")}),a().createElement(s.ModalBody,null,a().createElement("p",null,c("confirmDeleteMessage","Are you sure you want to delete this payment mode? Proceed cautiously.")),l&&a().createElement("p",null,a().createElement("strong",null,c("paymentModeNameToDelete","Payment Mode Name: {{paymentModeName}}",{paymentModeName:l})))),a().createElement(s.ModalFooter,null,a().createElement(s.Button,{kind:"secondary",onClick:e},(0,d.getCoreTranslation)("cancel")),a().createElement(s.Button,{kind:"danger",onClick:p,disabled:u},u?c("deleting","Deleting")+"...":(0,d.getCoreTranslation)("delete"))))}}}]);
1
+ "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["7019"],{2982(e,t,l){l.r(t),l.d(t,{default:()=>c});var n=l(5275),a=l.n(n),r=l(8395),o=l(6335),s=l(1752),d=l(9124),i=l(7003);let c=({closeModal:e,paymentModeUuid:t,paymentModeName:l})=>{let{t:c}=(0,r.useTranslation)(),{mutate:m}=(0,o.useSWRConfig)(),[u,y]=(0,n.useState)(!1),p=async()=>{y(!0);let l=`${i.B}paymentMode`;try{await (0,d.openmrsFetch)(`${d.restBaseUrl}/billing/paymentMode/${t}`,{method:"DELETE"}),m(e=>"string"==typeof e&&e.startsWith(l),void 0,{revalidate:!0}),(0,d.showSnackbar)({title:c("success","Success"),subtitle:c("paymentModeDeleted","Payment mode was successfully deleted."),kind:"success"}),e()}catch(e){(0,d.showSnackbar)({title:(0,d.getCoreTranslation)("error"),subtitle:e?.message||c("errorDeletingPaymentMode","An error occurred while deleting the payment mode."),kind:"error",isLowContrast:!1})}finally{y(!1)}};return a().createElement(a().Fragment,null,a().createElement(s.ModalHeader,{closeModal:e,title:c("deletePaymentMode","Delete Payment Mode")}),a().createElement(s.ModalBody,null,a().createElement("p",null,c("confirmDeleteMessage","Are you sure you want to delete this payment mode? Proceed cautiously.")),l&&a().createElement("p",null,a().createElement("strong",null,c("paymentModeNameToDelete","Payment Mode Name: {{paymentModeName}}",{paymentModeName:l})))),a().createElement(s.ModalFooter,null,a().createElement(s.Button,{kind:"secondary",onClick:e},(0,d.getCoreTranslation)("cancel")),a().createElement(s.Button,{kind:"danger",onClick:p,disabled:u},u?c("deleting","Deleting")+"...":(0,d.getCoreTranslation)("delete"))))}}}]);
package/dist/7247.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["7247"],{4352(e,l,t){t.d(l,{A:()=>n});let n={spinner:"-esm-billing__delete-line-item-confirmation__spinner___4aqIs",modalBody:"-esm-billing__delete-line-item-confirmation__modalBody___yKwtP",sectionTitle:"-esm-billing__delete-line-item-confirmation__sectionTitle___u+XCL"}},8402(e,l,t){t.r(l),t.d(l,{default:()=>c});var n=t(5275),i=t.n(n),a=t(1752),r=t(8395),o=t(3137),s=t(6199),d=t(4352);let c=({closeModal:e,bill:l,onSuccess:t})=>{let{t:c}=(0,r.useTranslation)(),[m,u]=(0,n.useState)(!1),[b,_]=(0,n.useState)(""),g=async()=>{if(l?.uuid){u(!0);try{await (0,s.LM)(l.uuid,b.trim()),(0,o.showSnackbar)({title:c("billDeleted","Bill deleted"),subtitle:c("billDeleteSuccess","Bill deleted successfully"),kind:"success"}),t?.(),e()}catch(l){let e=l?.responseBody?.error?.message||l?.message||c("deleteBillFailedTryAgain","Unable to delete bill. Please try again.");(0,o.showSnackbar)({title:c("billDeleteFailed","Failed to delete bill"),subtitle:e,kind:"error"})}finally{u(!1)}}};return i().createElement(i().Fragment,null,i().createElement(a.ModalHeader,{closeModal:e,title:c("deleteBill","Delete bill")}),i().createElement(a.ModalBody,{className:d.A.modalBody},i().createElement(a.Stack,{gap:5},i().createElement("p",null,c("deleteBillConfirmation","Are you sure you want to delete bill {{receiptNumber}}? This action cannot be undone.",{receiptNumber:l?.receiptNumber})),i().createElement(a.TextArea,{enableCounter:!0,id:"deleteBillReason",labelText:c("deleteReason","Reason for deletion"),maxCount:255,onChange:e=>_(e.target.value),placeholder:c("deleteBillReasonPlaceholder","Enter the reason for deleting this bill"),required:!0,rows:3,value:b}))),i().createElement(a.ModalFooter,null,i().createElement(a.Button,{kind:"secondary",onClick:e,disabled:m},(0,o.getCoreTranslation)("cancel")),i().createElement(a.Button,{kind:"danger",onClick:g,disabled:m||!b.trim()},m?i().createElement(a.InlineLoading,{className:d.A.spinner,description:c("deleting","Deleting")+"..."}):i().createElement("span",null,(0,o.getCoreTranslation)("delete")))))}}}]);
1
+ "use strict";(globalThis.webpackChunk_openmrs_esm_billing_app=globalThis.webpackChunk_openmrs_esm_billing_app||[]).push([["7247"],{4352(e,l,t){t.d(l,{A:()=>n});let n={spinner:"-esm-billing__delete-line-item-confirmation__spinner___4aqIs",modalBody:"-esm-billing__delete-line-item-confirmation__modalBody___yKwtP",sectionTitle:"-esm-billing__delete-line-item-confirmation__sectionTitle___u+XCL"}},8402(e,l,t){t.r(l),t.d(l,{default:()=>c});var n=t(5275),i=t.n(n),a=t(1752),r=t(8395),o=t(9124),s=t(6199),d=t(4352);let c=({closeModal:e,bill:l,onSuccess:t})=>{let{t:c}=(0,r.useTranslation)(),[m,u]=(0,n.useState)(!1),[b,_]=(0,n.useState)(""),g=async()=>{if(l?.uuid){u(!0);try{await (0,s.LM)(l.uuid,b.trim()),(0,o.showSnackbar)({title:c("billDeleted","Bill deleted"),subtitle:c("billDeleteSuccess","Bill deleted successfully"),kind:"success"}),t?.(),e()}catch(l){let e=l?.responseBody?.error?.message||l?.message||c("deleteBillFailedTryAgain","Unable to delete bill. Please try again.");(0,o.showSnackbar)({title:c("billDeleteFailed","Failed to delete bill"),subtitle:e,kind:"error"})}finally{u(!1)}}};return i().createElement(i().Fragment,null,i().createElement(a.ModalHeader,{closeModal:e,title:c("deleteBill","Delete bill")}),i().createElement(a.ModalBody,{className:d.A.modalBody},i().createElement(a.Stack,{gap:5},i().createElement("p",null,c("deleteBillConfirmation","Are you sure you want to delete bill {{receiptNumber}}? This action cannot be undone.",{receiptNumber:l?.receiptNumber})),i().createElement(a.TextArea,{enableCounter:!0,id:"deleteBillReason",labelText:c("deleteReason","Reason for deletion"),maxCount:255,onChange:e=>_(e.target.value),placeholder:c("deleteBillReasonPlaceholder","Enter the reason for deleting this bill"),required:!0,rows:3,value:b}))),i().createElement(a.ModalFooter,null,i().createElement(a.Button,{kind:"secondary",onClick:e,disabled:m},(0,o.getCoreTranslation)("cancel")),i().createElement(a.Button,{kind:"danger",onClick:g,disabled:m||!b.trim()},m?i().createElement(a.InlineLoading,{className:d.A.spinner,description:c("deleting","Deleting")+"..."}):i().createElement("span",null,(0,o.getCoreTranslation)("delete")))))}}}]);