1"use strict";(self.webpackChunksalesrouteadmin=self.webpackChunksalesrouteadmin||[]).push([[9944,451],{16755:(e,t,a)=>{a.d(t,{A:()=>r});a(65043),a(29856);var n=a(74117),s=a(70579);const r=e=>{let{text:t="Add",onClick:a,color:r,border:o,backgroundColor:i,variant:l="default",isSubmitting:c=!1,disabled:u=!1,className:d="",style:p,...m}=e;const{t:h}=(0,n.Bd)(),y={...p};i&&(y.backgroundColor=i,y.background=i),r&&(y.color=r),o&&(y.border=o);const v=c||u;return(0,s.jsx)("div",{onClick:v?void 0:a,className:`add-button common-text ftw-4 ${"compact"===l?"compact":""} ${v?"disabled":""} ${d}`,style:y,...m,children:h(t)})}},42155:(e,t,a)=>{a.d(t,{A:()=>r});a(65043);var n=a(74117),s=a(70579);const r=e=>{var t;let{buttonText:a,onClick:r,bgColor:o,textColor:i,borderColor:l}=e;const c={},u={},{t:d}=(0,n.Bd)();return o&&(c.backgroundColor=o),i&&(u.color=i),l&&(c.border=`1px solid ${l}`),(0,s.jsxs)("button",{type:"button",onClick:r,className:"button-with-image",style:c,children:[(0,s.jsxs)("svg",{className:"plus-icon",viewBox:"0 0 15 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("circle",{cx:"7.5",cy:"8.21436",r:"7.5",fill:"#DFA226"}),(0,s.jsx)("path",{d:"M10.1284 8.64655H7.96415V10.8644H6.82843V8.64655H4.66415V7.61798H6.82843V5.40012H7.96415V7.61798H10.1284V8.64655Z",fill:"white"})]}),(0,s.jsx)("span",{className:"button-text ftw-4 common-text",style:u,children:null===(t=d(a))||void 0===t?void 0:t.split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join(" ")})]})}},51291:(e,t,a)=>{a.d(t,{A:()=>s});a(65043);var n=a(70579);const s=e=>{let{onClick:t,...a}=e;return(0,n.jsx)("div",{className:"close-button",onClick:t,...a,children:(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 41 38",fill:"none",children:[(0,n.jsx)("rect",{width:"41",height:"38",rx:"8",fill:"#B1DDFF"}),(0,n.jsx)("path",{d:"M29 13.6114L27.3886 12L21 18.3886L14.6114 12L13 13.6114L19.3886 20L13 26.3886L14.6114 28L21 21.6114L27.3886 28L29 26.3886L22.6114 20L29 13.6114Z",fill:"#454545"})]})})}},31164:(e,t,a)=>{a.d(t,{A:()=>s});a(65043);var n=a(70579);const s=e=>{let{onClick:t,style:a,...s}=e;return(0,n.jsxs)("svg",{onClick:t,style:a,className:"close-red",...s,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:[(0,n.jsx)("path",{d:"M18 6L6 18",stroke:"#FF0000","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),(0,n.jsx)("path",{d:"M6 6L18 18",stroke:"#FF0000","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]})}},96148:(e,t,a)=>{a.d(t,{A:()=>d});var n=a(65043),s=a(58653),r=(a(25015),a(74117)),o=a(88847),i=a(21871),l=a(70579);const c=(e,t,a)=>{const n=t||"-";let s="";switch(e){case"YYYY MM DD":s=`yyyy${n}MM${n}dd`;break;case"MM DD YYYY":s=`MM${n}dd${n}yyyy`;break;default:s=`dd${n}MM${n}yyyy`}return a&&(s+=" HH:mm"),s},u=e=>{if(!e||e instanceof Date)return e instanceof Date?e:null;const t=new Date(e);if(!isNaN(t.getTime()))return t;const a=e.replace(/\//g,"-").trim().split(/[-\s]/);if(a.length>=3){const[e,t,n]=a;if(4===e.length){const a=new Date(parseInt(e),parseInt(t)-1,parseInt(n));if(!isNaN(a.getTime()))return a}if(4===n.length){const a=new Date(parseInt(n),parseInt(t)-1,parseInt(e));if(!isNaN(a.getTime())&&parseInt(t)<=12&&parseInt(e)<=31)return a;const s=new Date(parseInt(n),parseInt(e)-1,parseInt(t));if(!isNaN(s.getTime())&&parseInt(e)<=12&&parseInt(t)<=31)return s}}return null},d=e=>{let{label:t,defaultValue:a=null,onChange:d,name:p,disablePastDates:m,disableFutureDates:h,startDate:y,important:v=!1,readOnly:f=!1,error:g,showTimeSelect:j=!1,timeFormat:w="HH:mm",timeIntervals:_=15,className:b="",border:x=" ",portalId:C}=e;const[$,N]=(0,n.useState)(null),[A,k]=(0,n.useState)(!1),q=(0,n.useRef)(null),{t:S}=(0,r.Bd)(),V=(0,o.A)((e=>e.dateFormat)),F=(0,o.A)((e=>e.dateSeparator)),D=(0,i.A)((e=>e.lockedIntervals)),L=(0,i.A)((e=>e.isLoaded)),P=(0,i.A)((e=>e.fetchLockedFinancialYears));(0,n.useEffect)((()=>{L||P()}),[L,P]),(0,n.useEffect)((()=>{if(a){if(a instanceof Date)N(a);else if("string"===typeof a){const e=u(a);N(e)}}else N(null)}),[a]);const E=e=>{if(!e)return null;if(j)return e.toISOString();const t=e=>String(e).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`},I=null!==$&&void 0!==$||A,M=j?c(V,F,!1)+" h:mm aa":c(V,F,!1);return(0,l.jsx)("div",{className:`${b} datetime-picker-container`,children:(0,l.jsxs)("div",{className:"datetime-picker-wrapper",children:[(0,l.jsx)(s.Ay,{ref:q,selected:$,onChange:e=>{if(N(e),d){const t={target:{name:p,value:e?E(e):null}};d(t)}},onKeyDown:e=>{e.ctrlKey||e.metaKey||["Backspace","Delete","Tab","Enter","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.ke
1y)||/^[a-zA-Z]$/.test(e.key)&&e.preventDefault()},onChangeRaw:e=>{e&&e.target&&"string"===typeof e.target.value&&/[a-zA-Z]/.test(e.target.value)&&(e.target.value=e.target.value.replace(/[a-zA-Z]/g,""))},onFocus:()=>k(!0),onBlur:()=>k(!1),className:`datetime-picker-input ${g?"input-error":""} ${x}`,name:p,readOnly:f,minDate:(()=>{if(y){return u(y)||new Date(y)}if(m)return new Date})(),maxDate:(()=>{if(h)return new Date})(),excludeDateIntervals:D,showTimeSelect:j,timeFormat:j?"h:mm aa":w,timeIntervals:_,dateFormat:M,placeholderText:"",autoComplete:"off",showMonthDropdown:!0,showYearDropdown:!0,dropdownMode:"select",portalId:C}),(0,l.jsxs)("label",{className:"datetime-picker-label "+(I?"has-value":""),children:[S(t),v&&(0,l.jsx)("span",{className:"required-asterisk",children:"*"})]}),(0,l.jsx)("div",{className:"datetime-calendar-icon",onClick:()=>{q.current&&q.current.setFocus()},"data-tooltip-id":"global-tooltip","data-tooltip-content":S("Select Date"),children:(0,l.jsxs)("svg",{className:"datetime-calendar-svg",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[(0,l.jsx)("path",{opacity:"0.5",d:"M20 8H0V17C0 17.7956 0.316071 18.5587 0.87868 19.1213C1.44129 19.6839 2.20435 20 3 20H17C17.7956 20 18.5587 19.6839 19.1213 19.1213C19.6839 18.5587 20 17.7956 20 17V8ZM5 6C4.73478 6 4.48043 5.89464 4.29289 5.70711C4.10536 5.51957 4 5.26522 4 5V1C4 0.734784 4.10536 0.48043 4.29289 0.292893C4.48043 0.105357 4.73478 0 5 0C5.26522 0 5.51957 0.105357 5.70711 0.292893C5.89464 0.48043 6 0.734784 6 1V5C6 5.26522 5.89464 5.51957 5.70711 5.70711C5.51957 5.89464 5.26522 6 5 6ZM15 6C14.7348 6 14.4804 5.89464 14.2929 5.70711C14.1054 5.51957 14 5.26522 14 5V1C14 0.734784 14.1054 0.48043 14.2929 0.292893C14.4804 0.105357 14.7348 0 15 0C15.2652 0 15.5196 0.105357 15.7071 0.292893C15.8946 0.48043 16 0.734784 16 1V5C16 5.26522 15.8946 5.51957 15.7071 5.70711C15.5196 5.89464 15.2652 6 15 6Z",fill:"#6D6D6D"}),(0,l.jsx)("path",{d:"M17 2H16V5C16 5.26522 15.8946 5.51957 15.7071 5.70711C15.5196 5.89464 15.2652 6 15 6C14.7348 6 14.4804 5.89464 14.2929 5.70711C14.1054 5.51957 14 5.26522 14 5V2H6V5C6 5.26522 5.89464 5.51957 5.70711 5.70711C5.51957 5.89464 5.26522 6 5 6C4.73478 6 4.48043 5.89464 4.29289 5.70711C4.10536 5.51957 4 5.26522 4 5V2H3C2.20435 2 1.44129 2.31607 0.87868 2.87868C0.316071 3.44129 0 4.20435 0 5V8H20V5C20 4.20435 19.6839 3.44129 19.1213 2.87868C18.5587 2.31607 17.7956 2 17 2Z",fill:"#454545"})]})})]})})}},44632:(e,t,a)=>{a.d(t,{A:()=>i});var n=a(65043),s=(a(87839),a(88847)),r=a(7714),o=a(70579);const i=e=>{var t;let{options:a=[],onChange:i,onSelectChange:l,className:c="",defaultValue:u="",defaultOption:d="",selectDefaultValue:p="",readOnly:m=!1,border:h="",error:y=null,maxLength:v=null}=e;const[f,g]=(0,n.useState)(u),[j,w]=(0,n.useState)(!1),[_,b]=(0,n.useState)(p||d),[x,C]=(0,n.useState)(!1),$=(0,n.useRef)(null),N=(0,n.useRef)(null),A=(0,n.useRef)(null),k=null!==(t=(0,s.A)((e=>e.decimalPlaces)))&&void 0!==t?t:2;(0,n.useEffect)((()=>{const e=e=>{$.current&&!$.current.contains(e.target)&&C(!1)};return x?document.addEventListener("mousedown",e):document.removeEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[x]);const q=e=>{const t=(e=>a.find((t=>t.value===e))||a[0])(e);return t?t.label:e},S=e=>{b(e.value),C(!1);const t="percentage"===e.value||"%"===e.value||"%"===e.label;if(t&&""!==f){const e=parseFloat(f);!isNaN(e)&&e>100&&(g("100"),i&&i({target:{value:"100"}}))}else if(!t&&""!==f){const e=parseFloat(f);!isNaN(e)&&e>1e15&&(g("999999999999999.99"),i&&i({target:{value:"999999999999999.99"}}))}if(l){const t={target:{value:e.value}};l(t)}N.current&&"function"===typeof N.current.focus&&setTimeout((()=>N.current.focus()),0)},{highlightedIndex:V,handleTriggerKeyDown:F,handleItemMouseEnter:D}=(0,r.u)({isOpen:x,setIsOpen:C,options:a,onSelect:S,triggerRef:N,listRef:A,selectedValue:_,valueKey:"value"});(0,n.useEffect)((()=>{j||g(u)}),[u,j]),(0,n.useEffect)((()=>{b(p||d)}),[d,p]);return(0,o.jsxs)("div",{ref:$,className:`input-dropdown-container ${x?"is-open":""} ${y?"has-error":""} ${c}`,title:y||"",children:[(0,o.jsx)("input",{value:f,readOnly:m,onChange:e=>{let t=e.target.value;const a=null!==v&&void 0!==v?v:12+k;if(null!==v&&void 0!==v&&t.length>v)return;if(""===t)return g(""),void(i&&i(e));if(new RegExp(`^\\d*(\\.\\d{0,${k}})?$`).test(t)){const n="percentage"===_||"%"===_||"%"===q(_);if(n&&""!==t){const e=parseFloat(t);!isNaN(e)&&e>100&&(t="100")}else if(!n&&""!==t){const e=parseFloat(t);!isNaN(e)&&e>99999999999.9999&&(t="99999999999.9999")}if(t.length>a)return;if(g(t),i){const a={...e,target:{...e.target,value:t}};i(a)}}},onFocus:()=>w(!0),onBlur:()=>w(!1),className:`input-field common-text ${y?"input-error":""} ${h}`,maxLength:null!==v&&void 0!==v?v:void 0}),(0,o.jsxs)("div",{className:"select-wrapper",children:[(0,o.jsxs)("button",{ref:N,type:"button",onClick:()=>!m&&C(!x),onKeyDown:F,className:`select-button common-text ${y?"input-error":""} ${h}`,style:{cursor:m?"default":"pointer"},children:[q(_)," ",(0,o.jsx)("span",{className:"select-arrow"})]}),x&&!m&&(0,o.jsx)("div",{className:"dropdown-container",ref:A,children:a.map(((e,t)=>{const a=t===V;return(0,o.jsx)("div",{onClick:()=>S(e),onMouseEnter:()=>D(t),className:`dropdown-option common-text ${_===e.value?"selected":""} ${a?"highlighted":""}`,children:e.label},e.value)}))})]})]})}},37988:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(65043),s=(a(98455),a(74117)),r=a(88847),o=a(70579);const i=(0,n.forwardRef)(((e,t)=>
1{let{label:a,defaultValue:i="",onChange:l,onKeyPress:c,onFocus:u,onBlur:d,type:p="text",style:m,error:h,readOnly:y=!1,disabled:v=!1,className:f="",border:g="",maxQuantity:j,isPrice:w=!1,isNumber:_=!1,isPositiveNumber:b=!1,isDecimal:x=!1,isCoordinate:C=!1,important:$=!1,maxLength:N=null,maxIntDigits:A=null,autoFocus:k=!1,autoComplete:q="off"}=e;const[S,V]=(0,n.useState)(null!==i&&void 0!==i?i:""),{t:F}=(0,s.Bd)(),D=(0,r.A)((e=>e.decimalPlaces));(0,n.useEffect)((()=>{V(null!==i&&void 0!==i?i:"")}),[i]);const L=Array.isArray(h)?h:h?[h]:[];return(0,o.jsxs)("div",{className:`input-box-container posrel ${f} ${v?"disabled":""}`,children:[(0,o.jsx)("input",{ref:t,className:`input-box common-text ftw-4\n ${"date"===p?"input-box-with-icon":""}\n ${L.length>0?"input-error":""}\n ${g}`,style:m,type:p,value:!y||""!==S&&null!==S&&void 0!==S?null!==S&&void 0!==S?S:"":"-",onChange:e=>{if(v)return;let t=e.target.value;if(null!==N&&void 0!==N&&Number(N)>0&&t.length>Number(N)&&(t=t.slice(0,Number(N))),null!==A&&void 0!==A&&(w||x||C||_||b||"number"===p)){if(t.split(".")[0].replace(/^-/,"").length>A)return}if(""===t)return V(t),void(l&&l(e));if(C){if(!/^-?\d*(\.\d*)?$/.test(t))return}if(w||x){if(!new RegExp(`^\\d*(\\.\\d{0,${D}})?$`).test(t))return}if(_){if(!/^\d+$/.test(t))return}if(b){if(!/^\d+$/.test(t))return}if(void 0!==j){if(!/^\d+(\.\d{0,4})?$/.test(t))return;const e=parseFloat(t);if(0===parseFloat(j)){if("0"!==t)return}else if(e>parseFloat(j))return}V(t),l&&l(e)},onKeyPress:c,onFocus:u,onBlur:d,placeholder:" ",readOnly:y,disabled:v,maxLength:N,autoFocus:k,autoComplete:q}),(0,o.jsxs)("label",{className:"input-label common-text ftw-4 "+(void 0!==S&&null!==S&&""!==S||y&&(""===S||null===S||void 0===S)?"has-value":""),children:[F(a),$&&(0,o.jsx)("span",{className:"required-asterisk",children:"*"})]})]})}));i.displayName="InputBox";const l=i},54992:(e,t,a)=>{a.d(t,{A:()=>o});var n=a(65043),s=a(74117),r=(a(98455),a(70579));const o=e=>{let{label:t,defaultValue:a="",value:o,onChange:i,validators:l=[],name:c,isRequired:u=!1,error:d,className:p="",border:m="",readOnly:h=!1,maxChar:y=null,size:v="large",height:f="",important:g=!1,useAddLabel:j=!1}=e;const{t:w}=(0,s.Bd)(),[_,b]=(0,n.useState)(void 0!==o?o:a),[x,C]=(0,n.useState)([]),[$,N]=(0,n.useState)(!1),A=(0,n.useRef)(null),k=Array.isArray(l)?l:l?[l]:[],q=u?[..."function"===typeof k?[k]:k,e=>null!==e&&void 0!==e&&""!==e||"This field is required"]:k;(0,n.useEffect)((()=>{b(void 0!==o?o:a)}),[a,o]);const S=()=>{N(!0),setTimeout((()=>{A.current&&A.current.focus()}),0)},V=d?[d]:x,F=void 0!==o?o:_,D=Boolean(null!==F&&void 0!==F&&""!==String(F).trim()&&"-"!==String(F).trim());if(j&&h&&!D)return null;const L=!j||u||g||$||D||V.length>0,P="small"===v?"small-notes-box-container":"large-notes-box-container",E=t||"Notes",I=E.toLowerCase().startsWith("add ")?E:`Add ${E}`;if(!L)return(0,r.jsx)("div",{className:`notes-box-container ${P} ${p}`,children:(0,r.jsxs)("div",{className:"add-notes-trigger",onClick:S,children:[(0,r.jsx)("span",{className:"add-notes-text-label common-text ",children:w(I)}),(0,r.jsxs)("svg",{className:"plus-icon",viewBox:"0 0 15 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("circle",{cx:"7.5",cy:"8.21436",r:"7.5",fill:"#DFA226"}),(0,r.jsx)("path",{d:"M10.1284 8.64655H7.96415V10.8644H6.82843V8.64655H4.66415V7.61798H6.82843V5.40012H7.96415V7.61798H10.1284V8.64655Z",fill:"white"})]}),g&&(0,r.jsx)("span",{className:"required-asterisk",children:"*"})]})});const M=null!==F&&void 0!==F?F:"";return(0,r.jsxs)("div",{className:`notes-box-container ${P} ${p}`,children:[(0,r.jsx)("textarea",{ref:A,className:`notes-textarea ftw-4 ${V.length>0?"input-error":""} ${m} ${f}`,value:M,onChange:e=>{let t=e.target.value;y&&(t=t.slice(0,y));const a=(e=>{const t=q.map((t=>{if("function"===typeof t){const a=t(e);return!0===a?null:a}return null})).filter((e=>"string"===typeof e));return t})(t);if(b(t),C(a),i){const a={...e,target:{...e.target,value:t}};i(a)}},placeholder:"",name:c,readOnly:h}),(0,r.jsxs)("label",{className:"notes-label "+(M?"has-value":""),children:[w(t),g&&(0,r.jsx)("span",{className:"required-asterisk",children:"*"})]})]})}},37355:(e,t,a)=>{a.d(t,{A:()=>u});var n=a(65043),s=a(73216),r=a(35475);a(60178),a(9458);const o={Sales:"/sales",Inventory:"/inventory/products",Purchase:"/purchase/rfq",Accounts:"/accounts/invoices",Vehicle:"/vehicle/drivers",Expenses:"/Expenses",Dashboard:"/dashboard",Customers:"/sales/customers",Pricelists:"/sales/pricelist","Sales Order":"/sales",Quotation:"/sales/quotation","Delivery Orders":"/sales/delivery-orders","Return Receipt":"/sales/return-receipt","Sales Return":"/sales/return",Contacts:"/sales/contacts",Product:"/inventory/variants",Products:"/inventory/variants",Variants:"/inventory/variants","Product Category":"/inventory/product-categories","Product Categories":"/inventory/product-categories",Categories:"/inventory/product-categories",Category:"/inventory/product-categories","Product Attributes":"/inventory/product-attributes",Attributes:"/inventory/product-attributes",Attribute:"/inventory/product-attributes",UOM:"/inventory/uoms",UOMs:"/inventory/uoms",Categories:"/inventory/uoms/categories","Physical Warehouse":"/inventory/warehouses/physical","Physical Warehouses":"/inventory/warehouses/physical",Physical:"/inventory/warehouses/physical","Mobile Warehouse":"/inventory/warehouses/mobile","Mobile Warehouses":"/inventory/warehouses/mobile",Mobile:"/inventory/warehouses/mobile",Warehouses:"/inventory/warehouses/physical",RFQ:"/purchase/rfq","Purchase Return":"/purchase/return",Vendors:"/purchase/vendors","Goods Receipt":"/purchase/goods-receipt","Goods Return":"/purchase/goods-return","Batch tracking":"/purchase/batch-tracking","Batch Tracking":"/purchase/batch-tracking",Maintenance:"/vehicle/maintenance",Penalties:"/vehicle/penalties",Drivers:"/vehicle/drivers",Type:"/vehicle/type",Invoices:"/accounts/invoices","Credit Note":"/accounts/credit-notes","Chart of Account":"/accounts/configuration/chart-of-account",Currency:"/accounts/configuration/currency",Journals:"/accounts/configuration/journals",Taxes:"/accounts/configuration/taxes","Customer Payment":"/accounts/customer-payments","Journal Entries":"/accounts/journal-entries",Refunds:"/accounts/refunds","Vendor Bills":"/accounts/vendor-bills","Vendor Payments":"/accounts/vendor-payments","My Profile":"/my-profile","My Organization":"/my-organization","User Accounts":"/user-accounts","User Roles":"/user-roles",Roles:"/user-roles",Role:"/user-roles",Users:"/user-accounts",Create:"",Add:"",Edit:"",Details:"",View:"",List:""},i=e=>{if(0===e.length)return"/dashboard";if(1===e.length){const t=o[e[0]];return t||`/${e[0].toLowerCase().replace(/\s+/g,"-")}`}const t=e[0],a=e[e.length-1],n=o[a];if(n&&""!==n)return n;const s=o[t];if(!s)return`/${e.join("/").toLowerCase().replace(/\s+/g,"-")}`;if(2===e.length){const t=e[1],a=[`${s}/${t.toLowerCase().replace(/\s+/g,"-")}`,`${s}/${t.toLowerCase()}`,s];for(const e of a)if(Object.values(o).includes(e))return e;return a[0]}let r=s;for(let i=1;i<e.length;i++){const t=e[i];""!==o[t]&&(r+=`/${t.toLowerCase().replace(/\s+/g,"-")}`)}return r};var l=a(74117),c=a(70579);const u=e=>{let{breadcrumbs:t=[],pageName:a="",nestedpageName:o=""}=e;const u=(0,s.zy)(),{t:d}=(0,l.Bd)(),p=t.length>0?t:function(){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const a=[],n=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split(/[\/\>]/).map((e=>e.trim())).filter((e=>e)),s=e&&["Create","Edit","Details","View","List"].includes(e),r=e&&!s;let o=[];
1return n.forEach(((e,l)=>{if(e){o.push(e);const c=i(o),u=l===n.length-1;let d=!1;d=r?!u&&c!==t:!!s&&u&&c!==t,a.push({label:e,path:d?c:void 0})}})),e&&a.push({label:e,path:void 0}),a}(a,o,u.pathname);return(0,c.jsx)("div",{className:"page-name-left",children:(0,c.jsxs)("div",{className:"svg-logo svg-logo-home",children:[(0,c.jsx)("svg",{className:"home-icon",width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,c.jsx)("path",{d:"M8.3264 0.114948C8.23176 0.0404553 8.1152 0 7.9952 0C7.8752 0 7.75864 0.0404553 7.664 0.114948L0 6.14853L0.662933 6.99501L1.6 6.2573V12.9231C1.60056 13.2085 1.71313 13.4821 1.91304 13.6839C2.11296 13.8858 2.38394 13.9994 2.66667 14H13.3333C13.6161 13.9994 13.887 13.8858 14.087 13.6839C14.2869 13.4821 14.3994 13.2085 14.4 12.9231V6.26215L15.3371 6.99986L16 6.15338L8.3264 0.114948ZM9.06667 12.9231H6.93333V8.61528H9.06667V12.9231ZM10.1333 12.9231V8.61528C10.1333 8.32965 10.021 8.05573 9.82091 7.85376C9.62088 7.65179 9.34956 7.53833 9.06667 7.53833H6.93333C6.65044 7.53833 6.37913 7.65179 6.17909 7.85376C5.97905 8.05573 5.86667 8.32965 5.86667 8.61528V12.9231H2.66667V5.41783L8 1.22312L13.3333 5.42321V12.9231H10.1333Z",fill:"#606060"})}),(0,c.jsx)(r.N_,{to:"/dashboard",className:"lt-gray normal-text no-underline",children:d("Home")}),p.map(((e,t)=>{const a=t===p.length-1,s=a?"blue":"lt-gray";return(0,c.jsxs)(n.Fragment,{children:[(0,c.jsx)("span",{className:"lt-gray normal-text",children:" > "}),e.path&&!a?(0,c.jsx)(r.N_,{to:e.path,className:`normal-text no-underline ${s}`,children:d(e.label)}):(0,c.jsx)("span",{className:`normal-text no-underline ${s}`,children:d(e.label)})]},t)}))]})})}},15940:(e,t,a)=>{a.d(t,{A:()=>r});var n=a(65043);const s=["onClick","onConfirmClick","onCancelClick","onSubmit","onChange","onSave","onArchiveSelected","onDelete","onActionClick","onPrimaryClick","onSecondaryClick","onAddProducts","onDuplicate","onPrint","onEmail","onExport"],r=e=>{let{children:t,loadingProps:a=s,timeoutMs:r=1e4}=e;const[o,i]=(0,n.useState)(!1);let l;try{l=n.Children.only(t)}catch(d){return console.error("WithLoading requires exactly one child element."),t}const c={};a.forEach((e=>{l.props[e]&&(c[e]=(e=>{if(e)return async function(){if(o)return;const t=e(...arguments);if(t instanceof Promise){let e;i(!0);const n=new Promise((t=>{e=setTimeout((()=>{t({isTimeout:!0})}),r)}));try{await Promise.race([t,n])}catch(a){}finally{clearTimeout(e),i(!1)}}}})(l.props[e]))}));const u=o?{opacity:.5,cursor:"not-allowed"}:{};return n.cloneElement(l,{...c,disabled:l.props.disabled||o,style:{...l.props.style,...u}})}},84243:(e,t,a)=>{a.d(t,{A:()=>r});a(65043),a(9458),a(63426);var n=a(74117),s=a(70579);const r=e=>{let{isOpen:t,onSave:a,onClose:r}=e;const{t:o}=(0,n.Bd)();return t?(0,s.jsx)("div",{className:"popup-overlay",children:(0,s.jsxs)("div",{className:"discard-popup popup archive-popup popup2",children:[(0,s.jsxs)("div",{className:"discard-heading",children:[(0,s.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"33",height:"33",viewBox:"0 0 33 33",fill:"none",children:[(0,s.jsx)("path",{d:"M16.5 1.375C9.50945 1.375 1.48633 3.09375 1.48633 16.5C1.48633 29.9062 9.50945 31.625 16.5 31.625C23.4905 31.625 31.5136 29.9062 31.5136 16.5C31.5136 3.09375 23.4905 1.375 16.5 1.375ZM15.125 9.38163C15.125 8.62125 15.7396 8.00663 16.5 8.00663C17.2603 8.00663 17.875 8.62125 17.875 9.38163V17.1724C17.875 17.9328 17.2603 18.5474 16.5 18.5474C15.7396 18.5474 15.125 17.9328 15.125 17.1724V9.38163ZM16.5 24.7968C15.3642 24.7968 14.443 23.8755 14.443 22.7397C14.443 21.604 15.3642 20.6828 16.5 20.6828C17.6357 20.6828 18.557 21.604 18.557 22.7397C18.557 23.8755 17.6357 24.7968 16.5 24.7968Z",fill:"url(#paint0_linear_16479_5952)"}),(0,s.jsx)("defs",{children:(0,s.jsxs)("linearGradient",{id:"paint0_linear_16479_5952",x1:"16.5",y1:"1.375",x2:"16.5",y2:"31.625",gradientUnits:"userSpaceOnUse",children:[(0,s.jsx)("stop",{"stop-color":"#FFAB00"}),(0,s.jsx)("stop",{offset:"1","stop-color":"#D48E00"})]})})]}),(0,s.jsx)("h6",{className:"confirm-archive common-text ftw-4",children:o("Wait a second!")})]}),(0,s.jsx)("div",{className:"discard-content",children:(0,s.jsx)("p",{className:"card-title lt-gray discard-popup-content",children:o("You have unsaved changes. If you leave now, your changes will be lost.")})}),(0,s.jsxs)("div",{className:"discard-popup-buttons",children:[(0,s.jsx)("button",{className:"stay-button",onClick:r,children:o("Stay on page")}),(0,s.jsx)("button",{className:"discard-button",onClick:a,children:o("Leave & Discard Changes")}
1)]})]})}):null}},89494:(e,t,a)=>{a.d(t,{e:()=>r});var n=a(65043),s=a(73216);const r=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const[t,a]=(0,n.useState)(!1),[r,o]=(0,n.useState)(null),[i,l]=(0,n.useState)(!1),c=(0,s.Zp)(),u=(0,s.zy)(),d=(0,n.useRef)(u.pathname);(0,n.useEffect)((()=>{i&&(d.current=u.pathname)}),[u.pathname,i]),(0,n.useEffect)((()=>{const t=t=>{if(i)return;let n=t.target;for(;n&&n!==document;){if("A"===n.tagName&&n.href){const s=new URL(n.href),r=s.pathname;if(r!==d.current&&s.origin===window.location.origin)return void(e&&(t.preventDefault(),t.stopPropagation(),a(!0),o(r)))}n=n.parentElement}};return document.addEventListener("click",t,!0),()=>document.removeEventListener("click",t,!0)}),[e,i]),(0,n.useEffect)((()=>{window.history.pushState(window.history.state,"",window.location.href);const t=()=>{e&&!i&&(window.history.pushState(window.history.state,"",window.location.href),a(!0),o("back"))};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)}),[e,i]);return{showExitPopup:t,handleStay:(0,n.useCallback)((()=>{a(!1),o(null)}),[]),handleLeave:(0,n.useCallback)((()=>{a(!1),l(!0),setTimeout((()=>{"back"===r?window.history.back():r&&c(r),o(null),setTimeout((()=>l(!1)),100)}),50)}),[r,c]),navigateWithWarning:(0,n.useCallback)((e=>{a(!0),o(e)}),[]),allowNavigation:(0,n.useCallback)((e=>{l(!0),setTimeout((()=>{c(e),setTimeout((()=>l(!1)),100)}),0)}),[c])}}},81397:(e,t,a)=>{a.r(t),a.d(t,{default:()=>A});a(36784);var n=a(65043),s=a(37355),r=a(37988),o=a(42155),i=a(16755),l=a(14013),c=a(48240),u=a(31164),d=a(51291),p=a(73216),m=a(43651),h=a(14789),y=a(26755),v=a(96148),f=a(89494),g=a(84243),j=a(74117),w=a(44632),_=a(15940),b=a(11744),x=a(35087),C=a(54992),$=a(71087),N=a(70579);const A=()=>
1{const[e,t]=(0,b.v)(),[a,A]=(0,n.useState)(!0),{t:k}=(0,j.Bd)(),[q,S]=(0,n.useState)([]),[V,F]=(0,n.useState)({date:(0,$.EA)(),based_on:"uom",status:"draft",description:""}),[D,L]=(0,n.useState)({}),[P,E]=(0,n.useState)([]),[I,M]=(0,n.useState)(!1),[H,O]=(0,n.useState)([]),[T,B]=(0,n.useState)({}),[R,Z]=(0,n.useState)({}),W=(0,x.A)((e=>e.isBatchTrackingEnabled)),[U,Y]=(0,n.useState)(!1),{showExitPopup:Q,handleStay:z,handleLeave:K}=(0,f.e)(U),G=(0,p.Zp)(),J=[{value:"damage",label:"Damage / Defective",type:"minus"},{value:"expired",label:"Expired / Obsolete",type:"minus"},{value:"lost",label:"Lost / Shrinkage",type:"minus"},{value:"consumption",label:"Internal Consumption",type:"minus"},{value:"return_vendor",label:"Return to Vendor",type:"minus"},{value:"surplus",label:"Surplus (Stock Count Difference)",type:"plus"},{value:"customer_return",label:"Customer Return",type:"plus"},{value:"correction",label:"Data Entry Correction",type:"plus"}],X=["correction"],ee=e=>{const t=J.find((t=>t.value===e));return t?X.includes(e)?[{label:"+",value:"plus"},{label:"-",value:"minus"}]:[{label:"minus"===t.type?"-":"+",value:t.type}]:[{label:"+",value:"plus"}]},te=(0,n.useCallback)((async()=>{try{const e=await(0,c.lS)();E(e)}catch(e){console.error("Failed to fetch products:",e)}}),[]),ae=(0,n.useCallback)((async()=>{try{var e;const t=await(0,c.lU)(),a=((null===t||void 0===t||null===(e=t.data)||void 0===e?void 0:e.data)||[]).map((e=>{var t;return{value:e.id,label:e.name||`${e.warehouse_type} ${(null===(t=e.vehicle)||void 0===t?void 0:t.license_plate)||""}`,warehouse_type:e.warehouse_type,locations:e.locations||[],raw:e}}));O(a)}catch(t){console.error("Failed to fetch warehouses:",t)}}),[]);(0,n.useEffect)((()=>{(async()=>{t(!0);try{await Promise.all([te(),ae()])}catch(e){console.error("Failed to load inventory adjustment options:",e)}finally{t(!1),A(!1)}})()}),[te,ae]);const ne=(e,t,a,n)=>{const s=parseFloat(e)||0,r=parseFloat(t)||0;let o;if(X.includes(a))o="minus"===n;else{const e=J.find((e=>e.value===a));o="minus"===(null===e||void 0===e?void 0:e.type)}return o?Math.max(0,s-r):s+r},se=async(e,t,a)=>{Y(!0);const n=[...q];if(n[a][e]=t,D[`${e}_${a}`]&&L((t=>{const n={...t};return delete n[`${e}_${a}`],n})),"warehouse"===e){D[`warehouse_${a}`]&&L((e=>{const{[`warehouse_${a}`]:t,...n}=e;return n}));const e=H.find((e=>e.value===t));if(e&&e.locations){const t=e.locations.map((e=>({value:e.id,label:e.name,is_primary:e.is_primary,raw:e})));B((e=>({...e,[a]:t}))),n[a].location="",n[a].product="",n[a].batch_id="",n[a].previous_quantity="",n[a].adjustment_quantity="",n[a].current_quantity="",L((e=>{const t={...e};return delete t[`location_${a}`],delete t[`product_${a}`],delete t[`batch_${a}`],delete t[`adjustment_quantity_${a}`],t}))}}if("location"===e&&(D[`location_${a}`]&&L((e=>{const{[`location_${a}`]:t,...n}=e;return n})),n[a].product="",n[a].batch_id="",n[a].previous_quantity="",n[a].adjustment_quantity="",n[a].current_quantity="",L((e=>{const t={...e};return delete t[`product_${a}`],delete t[`batch_${a}`],delete t[`adjustment_quantity_${a}`],t}))),"product"===e){D[`product_${a}`]&&L((e=>{const{[`product_${a}`]:t,...n}=e;return n}));const e=n[a].warehouse,s=n[a].location;if(e&&s&&t)try{const r=await(0,c.P7)(t,e),o=((null===r||void 0===r?void 0:r.data)||[]).find((e=>e.location===s||e.location_id===s));let i=parseFloat((null===o||void 0===o?void 0:o.available_quantity)||0),l=null;if(W){const e=(null===o||void 0===o?void 0:o.batches)||[];if(e.length>0){const t=e.reduce(((e,t)=>e.id>t.id?e:t),e[0]);l=t.id,i=parseFloat(t.quantity||0)}n[a].batch_id=l}n[a].previous_quantity=i,Z((e=>({...e,[a]:{available_qty:i,location_data:o}}))),n[a].adjustment_quantity&&n[a].adjustment_type&&(n[a].current_quantity=ne(i,n[a].adjustment_quantity,n[a].adjustment_type,n[a].adjustment_direction))}catch(r){console.error("Failed to fetch location quantities:",r)}}if("batch_id"===e){var s;const e=null===(s=R[a])||void 0===s?void 0:s.location_data,r=((null===e||void 0===e?void 0:e.batches)||[]).find((e=>e.id===parseInt(t,10)))||null,o=r?parseFloat(r.quantity||0):0;n[a].batch_id=t?parseInt(t,10):null,n[a].previous_quantity=o,Z((e=>({...e,[a]:{...e[a],available_qty:o}})));const i=n[a].adjustment_quantity,l=n[a].adjustment_type;if(i&&l&&(n[a].current_quantity=ne(o,i,l,n[a].adjustment_direction)),i&&l){const e=J.find((e=>e.value===l)),t=X.includes(l)?"minus"===n[a].adjustment_direction:"minus"===(null===e||void 0===e?void 0:e.type),s=parseFloat(i)||0;L(t&&s>o?e=>({...e,[`adjustment_quantity_${a}`]:`Cannot reduce more than available batch stock (${o})`}):e=>{const t={...e};return delete t[`adjustment_quantity_${a}`],t})}}if("adjustment_type"===e){const e=J.find((e=>e.value===t));n[a].adjustment_direction=X.includes(t)?"plus":(null===e||void 0===e?void 0:e.type)||"plus",D[`adjustment_type_${a}`]&&L((e=>{const{[`adjustment_type_${a}`]:t,...n}=e;return n}));const s=n[a].previous_quantity,r=n[a].adjustment_quantity;""!==s&&r&&t&&(n[a].current_quantity=ne(s,r,t,n[a].adjustment_direction))}if("adjustment_direction"===e){const e=n[a].previous_quantity,s=n[a].adjustment_quantity,r=n[a].adjustment_type;if(""!==e&&s&&r&&(n[a].current_quantity=ne(e,s,r,t)),s&&r){const n=J.find((e=>e.value===r)),o=X.includes(r)?"minus"===t:"minus"===(null===n||void 0===n?void 0:n.type),i=parseFloat(e)||0,l=parseFloat(s)||0;o&&l>i?L((e=>({...e,[`adjustment_quantity_${a}`]:`Cannot reduce more than available stock (${i})`}))):l>0&&L((e=>{const t={...e};return delete t[`adjustment_quantity_${a}`],t}))}}if("adjustment_quantity"===e){const e=n[a].previous_quantity,s=n[a].adjustment_type;
1if(D[`adjustment_quantity_${a}`]&&L((e=>{const{[`adjustment_quantity_${a}`]:t,...n}=e;return n})),""!==e&&s&&(n[a].current_quantity=ne(e,t,s,n[a].adjustment_direction)),t&&parseFloat(t)<=0)L((e=>({...e,[`adjustment_quantity_${a}`]:"Adjustment quantity must be greater than 0"})));else if(t&&s){const r=J.find((e=>e.value===s)),o=X.includes(s)?"minus"===n[a].adjustment_direction:"minus"===(null===r||void 0===r?void 0:r.type),i=parseFloat(e)||0,l=parseFloat(t)||0;o&&l>i&&L((e=>({...e,[`adjustment_quantity_${a}`]:`Cannot reduce more than available stock (${i})`})))}}S(n)},re=e=>{const t=q.filter(((t,a)=>a!==e&&t.product)).map((e=>e.product));return P.filter((e=>!t.includes(e.value)))};return a?null:(0,N.jsxs)("div",{className:"whole-container",children:[(0,N.jsx)(g.A,{isOpen:Q,onClose:z,onSave:K}),(0,N.jsx)("div",{className:"path-header",children:(0,N.jsx)("div",{className:"path-name",children:(0,N.jsx)(s.A,{breadcrumbs:[{label:"Stock"},{label:"Adjustments",path:"/inventory/stock/inventory-adjustments"},{label:"Create"}]})})}),(0,N.jsxs)("div",{className:"page-actions-bar",children:[(0,N.jsx)("div",{className:"name-utility",children:(0,N.jsx)("span",{className:"title-heading",children:k("Create Inventory Adjustment")})}),(0,N.jsxs)("div",{className:"page-name-rightside-icons",children:[(0,N.jsx)(_.A,{children:(0,N.jsx)(i.A,{isSubmitting:I,onClick:async()=>{if(I)return;M(!0),L({});const e=(()=>{const e={};if(V.date||(e.date=k("Please select adjustment date and time.")),!q||0===q.length)return e.form_error=k("Please add at least one product to adjust."),e;for(let t=0;t<q.length;t++){const a=q[t];if(a.warehouse||(e[`warehouse_${t}`]=k("Please select a warehouse.")),a.location||(e[`location_${t}`]=k("Please select a location.")),a.product||(e[`product_${t}`]=k("Please select a product.")),a.adjustment_type){const n=J.find((e=>e.value===a.adjustment_type)),s=X.includes(a.adjustment_type)?"minus"===a.adjustment_direction:"minus"===(null===n||void 0===n?void 0:n.type);W&&s&&!a.batch_id&&(e[`batch_${t}`]=k("Please select a batch."))}else e[`adjustment_type_${t}`]=k("Please select adjustment type.");if(a.adjustment_quantity&&""!==a.adjustment_quantity.toString().trim()){const n=parseFloat(a.adjustment_quantity),s=parseFloat(a.previous_quantity)||0;if(n<=0)e[`adjustment_quantity_${t}`]=k("Adjustment quantity must be greater than 0.");else if(a.adjustment_type){const r=J.find((e=>e.value===a.adjustment_type));(X.includes(a.adjustment_type)?"minus"===a.adjustment_direction:"minus"===(null===r||void 0===r?void 0:r.type))&&n>s&&(e[`adjustment_quantity_${t}`]=k("Cannot reduce {{qty}} units when only {{prevQty}} available.",{qty:n,prevQty:s}))}}else e[`adjustment_quantity_${t}`]=k("Please enter adjustment quantity.")}return e})();if(Object.keys(e).length>0)return L(e),void M(!1);for(let t=0;t<q.length;t++){const e=q[t],a=parseFloat(e.adjustment_quantity),n=parseFloat(e.previous_quantity)||0;if(e.adjustment_type){const s=J.find((t=>t.value===e.adjustment_type));if((X.includes(e.adjustment_type)?"minus"===e.adjustment_direction:"minus"===(null===s||void 0===s?void 0:s.type))&&a>n)return L({[`adjustment_quantity_${t}`]:k("Cannot reduce {{qty}} units when only {{prevQty}} available.",{qty:a,prevQty:n})}),void M(!1)}}const a={adjustment:{date:V.date,based_on:V.based_on,status:V.status,number_of_products:q.length,description:V.description||""},products:q.map((e=>({warehouse:e.warehouse,warehouse_location:e.location,product:e.product,adjustment_type:e.adjustment_type,adjustment_direction:e.adjustment_direction,previous_quantity:parseFloat(e.previous_quantity)||0,adjustment_quantity:parseFloat(e.adjustment_quantity)||0,current_quantity:parseFloat(e.current_quantity)||0,reason:e.reason||"",batch:W&&e.batch_id||null})))};t(!0);try{var n,s;const e=await(0,m.ei)(a),t=null===(n=e.data)||void 0===n?void 0:n.adjustment_uuid;1===(null===e||void 0===e||null===(s=e.data)||void 0===s?void 0:s.response_code)&&((0,h.C)(k("Inventory adjustment created successfully!")),G(`/inventory/stock/inventory-adjustments/details/${t}`))}catch(r){console.error(r)}finally{t(!1),M(!1)}},"data-tooltip-id":"global-tooltip","data-tooltip-content":k("Create Inventory Adjustment")})}),(0,N.jsx)(d.A,{onClick:()=>{G("/inventory/stock/inventory-adjustments")},"data-tooltip-id":"global-tooltip","data-tooltip-content":k("Close")})]})]}),(0,N.jsx)("div",{style:{marginTop:"1rem"},children:(0,N.jsx)(y.A,{errors:D,width:"48%",marginBottom:"0rem"})}),(0,N.jsxs)("div",{className:"adjustment-main-container",children:[(0,N.jsx)("div",{className:"adjustment-section",children:(0,N.jsxs)("div",{className:"adjustment-fields-card",children:[(0,N.jsx)(v.A,{label:"Adjustment Date & Time",defaultValue:V.date,onChange:e=>F((t=>({...t,date:e.target.value}))),error:D.date,important:!0,showTimeSelect:!0}),(0,N.jsx)("div",{style:{marginTop:"1rem"},children:(0,N.jsx)(C.A,{label:"Description",defaultValue:V.description,onChange:e=>F((t=>({...t,description:e.target.value}))),className:"w-100",useAddLabel:!0})})]})}),(0,N.jsxs)("div",{children:[(0,N.jsxs)("table",{className:"common-table no-hover-table",style:{width:"100%",tableLayout:"fixed"},children:[(0,N.jsx)("thead",{className:"common-table-head",children:(0,N.jsxs)("tr",{className:"common-table-thead-tr",children:[(0,N.jsx)("th",{className:"tbl-start-pad "+(W?"w-12":"w-15"),children:k("Warehouse")}),(0,N.jsx)("th",{className:W?"w-10":"w-12",children:k("Location")}),(0,N.jsx)("th",{className:"w-15",children:k("Product")}),W&&(0,N.jsx)("th",{className:"w-12",children:k("Batch")}),(0,N.jsx)("th",{className:"w-15",children:k("Adjustment Type")}),(0,N.jsx)("th",{className:W?"w-8":"w-10",children:k("On Hand Qty")}),(0,N.jsx)("th",{className:"w-8",children:k("Adjustment Qty")}),(0,N.jsx)("th",{className:"w-8",children:k("Current Qty")}),(0,N.jsx)("th",{className:W?"w-10":"w-12",children:k("Notes")}),(0,N.jsx)("th",{className:"w-2"})]})}),(0,N.jsx)("tbody",{className:"compact-table-tbody common-table-tbody",children:q.map(((e,t)=>{var a,n,s;const o=((null===(a=R[t])||void 0===a||null===(n=a.location_data)||void 0===n?void 0:n.batches)||[]).map((e=>({value:e.id,label:`${e.batch_name} (On Hand: ${e.quantity})`})));return(0,N.jsxs)("tr",{style:{verticalAlign:"top"},children:[(0,N.jsx)("td",{children:(0,N.jsx)(l.A,{options:H,defaultValue:e.warehouse,onChange:e=>se("warehouse",e.target.value,t),error:D[`warehouse_${t}`]})}),(0,N.jsx)("td",{children:(0,N.jsx)(l.A,{options:T[t]||[],defaultValue:e.location,onChange:e=>se("location",e.target.value,t),disabled:!e.warehouse,error:D[`location_${t}`]})}),(0,N.jsx)("td",{children:(0,N.jsx)(l.A,{className:"w-100",options:re(t),defaultValue:e.product,onChange:e=>se("product",e.target.value,t),disabled:!e.location,error:D[`product_${t}`]})}),W&&(0,N.jsx)("td",{children:(0,N.jsx)(l.A,{className:"w-100",options:o,defaultValue:e.batch_id,onChange:e=>se("batch_id",e.target.value,t),disabled:!e.product||0===o.length,placeholder:0===o.length?"No batches":"Select batch",error:D[`batch_${t}`]})}),(0,N.jsx)("td",{children:(0,N.jsx)(l.A,{className:"w-100",options:J,defaultValue:e.adjustment_type,onCh
1ange:e=>se("adjustment_type",e.target.value,t),error:D[`adjustment_type_${t}`]})}),(0,N.jsx)("td",{children:(0,N.jsx)(r.A,{className:"w-100",defaultValue:e.previous_quantity,readOnly:!0,disabled:!0,placeholder:e.product?"":"Select product",border:""!==e.previous_quantity&&void 0!==e.previous_quantity&&null!==e.previous_quantity?parseFloat(e.previous_quantity)>0?"green-border":"red-border":"",style:{color:""!==e.previous_quantity&&void 0!==e.previous_quantity&&null!==e.previous_quantity?parseFloat(e.previous_quantity)>0?"#15803d":"#dc2626":void 0,fontWeight:"500"}})}),(0,N.jsx)("td",{children:(0,N.jsx)(w.A,{className:"w-100",defaultValue:e.adjustment_quantity,options:ee(e.adjustment_type),defaultOption:e.adjustment_direction||("minus"===(null===(s=J.find((t=>t.value===e.adjustment_type)))||void 0===s?void 0:s.type)?"minus":"plus"),onChange:e=>se("adjustment_quantity",e.target.value,t),onSelectChange:e=>se("adjustment_direction",e.target.value,t),readOnly:!e.adjustment_type,error:D[`adjustment_quantity_${t}`]})}),(0,N.jsx)("td",{children:(0,N.jsx)(r.A,{className:"w-100",defaultValue:e.current_quantity,readOnly:!0,border:""!==e.current_quantity&&void 0!==e.current_quantity&&null!==e.current_quantity?parseFloat(e.current_quantity)>0?"green-border":"red-border":"",style:{color:""!==e.current_quantity&&void 0!==e.current_quantity&&null!==e.current_quantity?parseFloat(e.current_quantity)>0?"#15803d":"#dc2626":void 0,fontWeight:"500"},placeholder:e.adjustment_quantity?"":"Auto-calculated"})}),(0,N.jsx)("td",{children:(0,N.jsx)(C.A,{label:"Notes",rows:2,defaultValue:e.reason,onChange:e=>se("reason",e.target.value,t)})}),(0,N.jsx)("td",{style:{paddingTop:"0.5rem"},children:(0,N.jsx)(u.A,{onClick:()=>(e=>{S((t=>t.filter(((t,a)=>a!==e)))),B((t=>{const a={...t};delete a[e];const n={};return Object.keys(a).forEach((t=>{const s=parseInt(t);s>e?n[s-1]=a[t]:s<e&&(n[s]=a[t])})),n})),Z((t=>{const a={...t};delete a[e];const n={};return Object.keys(a).forEach((t=>{const s=parseInt(t);s>e?n[s-1]=a[t]:s<e&&(n[s]=a[t])})),n})),L((t=>{const a={};return Object.keys(t).forEach((n=>{if(n.includes("_")){const s=n.split("_"),r=parseInt(s[s.length-1]);if(isNaN(r))a[n]=t[n];else if(r<e)a[n]=t[n];else if(r>e){const e=n.replace(`_${r}`,"_"+(r-1));a[e]=t[n]}}else a[n]=t[n]})),a}))})(t),"data-tooltip-id":"global-tooltip","data-tooltip-content":k("Remove Line")})})]},t)}))})]}),(0,N.jsx)("div",{className:"add-new-row",style:{paddingLeft:"0.3rem",paddingTop:"0.5rem"},children:(0,N.jsx)(_.A,{children:(0,N.jsx)(o.A,{imageSrc:"/assets/plus-yellow.png",buttonText:"Add New Row",onClick:()=>{Y(!0),L({});const e=(()=>{const e={};for(let t=0;t<q.length;t++){const a=q[t];if(!a.warehouse){e[`warehouse_${t}`]=k("Please select a warehouse.");break}if(!a.location){e[`location_${t}`]=k("Please select a location.");break}if(!a.product){e[`product_${t}`]=k("Please select a product.");break}if(!a.adjustment_type){e[`adjustment_type_${t}`]=k("Please select adjustment type.");break}const n=J.find((e=>e.value===a.adjustment_type)),s=X.includes(a.adjustment_type)?"minus"===a.adjustment_direction:"minus"===(null===n||void 0===n?void 0:n.type);if(W&&s&&!a.batch_id){e[`batch_${t}`]=k("Please select a batch.");break}if(!a.adjustment_quantity||""===a.adjustment_quantity.toString().trim()){e[`adjustment_quantity_${t}`]=k("Please enter adjustment quantity.");break}}return e})();Object.keys(e).length>0?L(e):S((e=>[...e,{warehouse:"",location:"",product:"",batch_id:"",adjustment_type:"",adjustment_direction:"",previous_quantity:"",adjustment_quantity:"",current_quantity:"",reason:""}]))}})})})]})]})]})}},43651:(e,t,a)=>{a.d(t,{$Z:()=>y,$q:()=>h,Dk:()=>g,Dn:()=>v,G6:()=>C,GW:()=>N,Ie:()=>$,PB:()=>u,Tb:()=>p,VI:()=>i,XS:()=>_,_c:()=>d,b5:()=>x,bs:()=>m,ei:()=>j,f0:()=>c,qV:()=>b,qu:()=>f,u5:()=>l,v$:()=>w,v6:()=>A,yH:()=>o});var n=a(64002),s=a(94505);const r=e=>{var t;const a=null===e||void 0===e||null===(t=e.response)||void 0===t?void 0:t.data;if(!a)return(null===e||void 0===e?void 0:e.message)||"Something went wrong";if(Array.isArray(a.details)&&a.details.length>0){const e=a.details.map((e=>"string"===typeof e?e:null!==e&&void 0!==e&&e.product?`${e.product} doesn't have enough stock`:null!==e&&void 0!==e&&e.message?e.message:null!==e&&void 0!==e&&e.error?e.error:null)).filter(
1Boolean);if(e.length>0)return e.join(", ")}return"string"===typeof a.error&&a.error.trim()?a.error:"string"===typeof a.message&&a.message.trim()?a.message:"string"===typeof a.detail&&a.detail.trim()?a.detail:"Something went wrong"};async function o(e){try{return(await s.Ay.get(`/stock/transfer/${e}`)).data}catch(t){throw t}}async function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return(await s.Ay.get("/stock/transfer/",{params:e})).data}catch(t){throw t}}async function l(e){try{return await s.Ay.post("stock/transfer/create/",e)}catch(t){(0,n.showAlert)(r(t))}}async function c(e){try{return await s.Ay.post(`stock/transfer/transit/?transfer_id=${e}`)}catch(t){throw(0,n.showAlert)(r(t)),t}}async function u(e){try{return await s.Ay.post(`stock/transfer/complete/?transfer_id=${e}`)}catch(t){throw(0,n.showAlert)(r(t)),t}}async function d(e){try{return await s.Ay.post(`stock/transfer/${e}/cancel/`)}catch(t){throw(0,n.showAlert)(r(t)),t}}async function p(e){try{return await s.Ay.delete(`stock/transfer/delete/?id=${Array.isArray(e)?e.join(","):e}`)}catch(t){throw t}}async function m(e,t){try{let a;return a=t?await s.Ay.post("stock/transfer/archive/",{id_list:t}):await s.Ay.get(`stock/transfer/archive/?id=${e}`),a}catch(a){throw a}}async function h(e,t){try{return await s.Ay.post(`stock/transfer/update/?id=${e}`,t)}catch(a){(0,n.showAlert)(r(a))}}async function y(e){return(await s.Ay.post(`stock/transfer/duplicate/?id=${e}`)).data}async function v(e){return(await s.Ay.post(`stock/inventory-adjustment/duplicate/?id=${e}`)).data}async function f(e){try{return(await s.Ay.get(`/stock/inventory-adjustment/${e}`)).data}catch(t){throw t}}async function g(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return(await s.Ay.get("/stock/inventory-adjustment/",{params:e})).data}catch(t){throw t}}async function j(e){try{return await s.Ay.post("stock/inventory-adjustment/create/",e)}catch(t){(0,n.showAlert)(r(t))}}async function w(e){try{return await s.Ay.post(`stock/inventory-adjustment/complete/?adjustment_id=${e}`)}catch(t){throw(0,n.showAlert)(r(t)),t}}async function _(e,t){try{return await s.Ay.post(`stock/inventory-adjustment/update/?id=${e}`,t)}catch(a){(0,n.showAlert)(r(a))}}async function b(e){try{return await s.Ay.post(`stock/inventory-adjustment/cancel/?adjustment_id=${e}`)}catch(t){throw(0,n.showAlert)(r(t)),t}}async function x(e){try{return await s.Ay.delete(`stock/inventory-adjustment/delete/?id=${Array.isArray(e)?e.join(","):e}`)}catch(t){throw t}}async function C(e,t){try{let a;return a=t?await s.Ay.post("stock/inventory-adjustment/archive/",{id_list:t}):await s.Ay.get(`stock/inventory-adjustment/archive/?id=${e}`),a}catch(a){throw a}}async function $(e){try{return(await s.Ay.get(`/stock/batch-tracking/${e}/`)).data}catch(t){throw t}}async function N(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return(await s.Ay.get("/stock/batch-tracking/",{params:e})).data}catch(t){throw t}}async function A(e,t){try{var a;const n=await s.Ay.get(`/stock/scan-layer/?barcode=${encodeURIComponent(e)}&warehouse_id=${t}`);return(null===(a=n.data)||void 0===a?void 0:a.data)||n.data}catch(n){throw n}}},29856:()=>{},87839:()=>{},98455:()=>{},60178:()=>{},63426:()=>{},36784:()=>{}}]); 2//# sourceMappingURL=9944.0554471d.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.