1"use strict";(self.webpackChunkorderry=self.webpackChunkorderry||[]).push([[13398],{13398:function(ot,J,e){e.r(J),e.d(J,{default:function(){return nt}});var s=e(74848),f=e(96540),Y=e(15360),le=e(99374),X=e.n(le),de=e(75522),p=e(73531),T=e(82454),y=e(70881),w=e(13555),x=e(60016),ce=e(97717),ie=e(9814),F=e(66080),$=e(19619),ue=e(95892),N=e(95944),k=e(49785),V=e(62770),q=e(71468),K=e(48997),he=e(66940),Ee=e(70284),_=e(5601),Q=e(891),Se=e(91733),Re=e(88416),me=e(63539),U=e(56289),Ae=e(23356),Oe=e(34201),Pe=e(51653),ve=e(7238),De=e(80309),b=e(367),ge=e(20559),ee=e(63227),Ce=e(17212),Te=e(68445),r=e(37738),Ie=e(66244),v=e(48676),Z=e(21210),fe=e(75832),pe=e(5955),ye=e(55998),xe=e(2078),Ne=e(27723),Ue=e(79224),z=e(49466),Le=e(58552),Me=e(90748),He=e(38251),Be=e(78759);const c={DATE:"date",STATUSES:"statuses",SUPPLIER_ID:"supplierId",WAREHOUSE_IDS:"warehouseIds",EXPECTED_DELIVERY_DATE:"expectedDeliveryDate",EMPLOYEES_IDS:"employeesIds"};var W=e(94618),je=e(52386);const te=t=>{const{ranges:o}=(0,je.O)();return{preparePayload:(l,d)=>{const n=t(),{ID:i}=e(98147);if(d)return{branchId:i,badgeId:d,...l&&{q:l}};const R=n[c.DATE],h=n[c.EXPECTED_DELIVERY_DATE],[u,D]=(0,W.Zw)(R,o),[g,I]=(0,W.Zw)(h,o),m=(0,W.j1)(n[c.STATUSES]),A=(0,W.j1)(n[c.WAREHOUSE_IDS]),C=(0,W.j1)(n[c.EMPLOYEES_IDS]),O=n[c.SUPPLIER_ID].value;return{...R!==r.$u.ANY&&{startDateCreate:u,endDateCreate:D}
1,...h!==r.$u.ANY&&{startDateExpected:g,endDateExpected:I},...m&&{statuses:m.length?m:[-1]},...A&&{warehouseIds:A.length?A:0},...C&&{employeesIds:C.length?C:0},...O>0&&{supplierId:O},...l&&{q:l},branchId:i}}}},$e=(t,o,l)=>{const{ExportManager:d}=e(70171),{preparePayload:n}=te(t);return{filename:d.purchaseOrders.filename,url:d.purchaseOrders.url,payload:n(o,l),method:"GET"}};var We="szLPC";function Ye(){const{t}=(0,V.Bd)(),o=(0,$.wA)(),{ROLE:l}=e(49332),{name:d,fetchTableData:n}=(0,Oe.$A)(),i=(0,q.d4)(a=>(0,He.Wx)(a,d)),{[v.A.PERMISSION_PURCHASE_ORDERS_CREATE]:R}=(0,z.S)(),h=(0,q.d4)(Me.M),[u,D]=(0,f.useState)(()=>{var a,E;return(E=(a=(0,Be.storageGet)(T.bk))==null?void 0:a[T.sc.PURCHASE_ORDER])!=null?E:null}),g=a=>{D(a)},I=(0,xe.k)({instances:[Ie.Hc.PURCHASE_ORDERS],roleId:l,disableSelectNode:!1}),m=(0,Ne.A)({onlyCurrentBranch:!0,withNoWarehouseOption:!0}),A=(0,ye.n)(),{defaultStorageValues:C}=(0,Le.w)({persistName:d,configs:a=>({[c.DATE]:a({defaultValue:r.$u.ANY}),[c.EXPECTED_DELIVERY_DATE]:a({defaultValue:r.$u.ANY}),[c.STATUSES]:a({defaultValue:"all",restore:(0,Z.h)(I)}),[c.WAREHOUSE_IDS]:a({defaultValue:"all",restore:(0,Z.h)(m)}),[c.SUPPLIER_ID]:a({defaultValue:{value:-1}}),[c.EMPLOYEES_IDS]:a({defaultValue:"all",restore:(0,Z.h)(A)})})}),O=(0,k.mN)({defaultValues:C}),{preparePayload:L}=te(O.getValues),M=(0,pe.P)("q"),{searchQuery:H}=(0,Ue.o)({initialState:M,onSearchQueryChange:a=>{n(L(a,u))}}),B=$e(O.getValues,H,u),j=(0,fe.D)(()=>{const a=L(H,u);return n({...i,...a})}),P=()=>{const a=()=>{o((0,F.fh)({badgeType:T.sc.PURCHASE_ORDER,shouldUpdateBadges:!0}))};o((0,N.to)(y.PurchaseOrderModalName,{tableName:x.BL.PURCHASE_ORDERS,onSave:a,onDelete:a}))};return(0,he.C)(()=>{j()},[h,u]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Ee.A,{type:T.sc.PURCHASE_ORDER,url:T._X.PURCHASE_ORDER,onSelectBadge:g}),(0,s.jsx)(k.Op,{...O,children:(0,s.jsxs)(b.A,{bottomOffset:16,children:[R&&(0,s.jsx)(b.A,{alignSelf:"end",children:(0,s.jsx)(b.A,{divider:"right",children:(0,s.jsx)(Ae.A,{onClick:P,color:"green",icon:ge.A,iconFill:"white_100",iconSize:10,iconPosition:"left_8",dataCid:"purchase-order-table-btn-add",innerClassName:We,children:t("Purchase order")})})}),(0,s.jsxs)(De.A,{onSubmit:j,children:[(0,s.jsx)(U.A,{name:c.DATE,children:(0,s.jsx)(_.A,{title:t("Created"),only:[r.$u.ANY,r.$u.TODAY,r.$u.CURRENT_WEEK,r.$u.CURRENT_MONTH,r.$u.CURRENT_YEAR,r.$u.YESTERDAY,r.$u.LAST_WEEK,r.$u.LAST_MONTH,r.$u.LAST_YEAR],withCustom:!0})}),(0,s.jsx)(U.A,{name:c.EMPLOYEES_IDS,children:(0,s.jsx)(Q.A,{title:t("Employee"),image:(0,s.jsx)(K._,{image:Ce.A}),data:A,contentWidth:320,ItemComponent:Re.A})}),(0,s.jsx)(U.A,{name:c.STATUSES,children:(0,s.jsx)(Q.A,{title:t("Status"),image:(0,s.jsx)(K._,{image:ee.A}),data:I,ItemComponent:me.A,isVirtualized:!0})}),(0,s.jsx)(U.A,{name:c.SUPPLIER_ID,children:(0,s.jsx)(Se.A,{})}),(0,s.jsx)(U.A,{name:c.WAREHOUSE_IDS,children:(0,s.jsx)(Q.A,{title:t("Warehouse"),image:(0,s.jsx)(K._,{image:Te.A}),data:m})}),(0,s.jsx)(U.A,{name:c.EXPECTED_DELIVERY_DATE,children:(0,s.jsx)(_.A,{title:t("Expected delivery date"),only:[r.$u.ANY,r.$u.TODAY,r.$u.FULL_CURRENT_WEEK,r.$u.FULL_CURRENT_MONTH,r.$u.CURRENT_YEAR,r.$u.TOMORROW,r.$u.NEXT_WEEK,r.$u.NEXT_MONTH,r.$u.YESTERDAY,r.$u.LAST_WEEK,r.$u.LAST_MONTH],dividerAfter:[r.$u.NEXT_MONTH,r.$u.LAST_MONTH,r.$u.CURRENT_YEAR],withCustom:!0})})]}),(0,s.jsxs)(b.A,{gap:8,alignSelf:"end",children:[(0,s.jsx)(ve.A,{exportOptions:B}),(0,s.jsx)(Pe.A,{})]})]})})]})}var Fe=(0,f.memo)(Ye),G=e(60799),ae=e(3618),se=e(88586),Ve=e(51880),be=e(59362),re=e(16682),ze=e(96159),Ge=e(86436),Xe=e(43561),Ke=e(73631),Qe=e(56995),Ze=e(94948),ne=e(14261),oe=e(75268);function Je(t){const{purchaseOrder:o,relativeValue:l,tableName:d,id:n}=t,{t:i}=(0,V.Bd)(),{ID:R}=e(98147),{GROUPS:h,STATUSES_HASH:u}=e(91530),{ROLE:D}=e(49332),g=(0,$.wA)(),{[v.A.PERMISSION_PURCHASE_ORDERS_EDIT]:I}=(0,z.S)(),[m,{isLoading:A}]=(0,p.yi)(),[C,{isLoading:O}]=(0,p.hI)(),L=(0,f.useMemo)(()=>(0,ne.getStatusesByInstance)(Ze.lr.PURCHASE_ORDERS),[]),M=u[o.status],H=()=>{g((0,F.fh)({badgeType:T.sc.PURCHASE_ORDER,shouldUpdateBadges:!0}))},B=async P=>{try{const a=await m({params:{id:n},data:{status:P}}).unwrap();
1H(),d&&a.id&&(0,oe.p)({dispatch:g,id:a.id,tableName:d}),G.Ay.success(i("Status has been successfully changed"))}catch{}},j=async P=>{if((0,ne.isPostedPurchaseOrderStatus)(u[P]))try{const a=await C({params:{id:n}}).unwrap();if(!a.supplierId){G.Ay.error(i("Specify supplier for this purchase order."));return}g((0,N.to)(y.PostingModalName,{extraData:{purchase_order_id:n},data:(0,Qe.II)({...a,products:a.products.map(E=>({...E,id:(0,Xe.Ak)()}))}),onSave:()=>B(P)}))}catch{}else await B(P)};return(0,s.jsx)(Ke.A,{instanceId:M.id,statusId:o.status,branchId:R,groups:h,statuses:L,userRole:D,relativeValue:l,tableName:d,changeStatusId:j,disabled:!I,isLoading:A||O},M.id)}var we=(0,f.memo)(Je),ke=e(21683);function qe(t,o){const{tableName:l,isMobile:d,setShowedPopover:n,prevShowedPopover:i,relativeValue:R}=o,{id:h}=t;return(0,s.jsx)(ke.A,{tableName:l,isMobile:d,setShowedPopover:n,prevShowedPopover:i,relativeValue:R,children:(0,s.jsx)(we,{purchaseOrder:t,relativeValue:R,tableName:l,id:h})},h)}var _e=e(88510),et=e(76752),tt=e(84408);const at=()=>{const{t}=(0,V.Bd)(),{CURRENCY_SYMBOL:o}=e(91530),{[v.A.PERMISSION_COMMON_INCOME_PRICE]:l}=(0,z.S)();return[{field:"invoiceNumber",title:t("Invoice",{context:"Purchase order"}),cell:(0,se.x)("invoiceNumber"),width:100,minWidth:50,checked:!1,sortable:!0},{field:"invoiceDate",title:t("Invoice date"),cell:(0,re.F)("invoiceDate",{withTime:!1}),width:100,minWidth:50,checked:!1,sortable:!0},{field:"purchaseIdLabel",title:t("Purchase order"),cell:Ge.p,width:100,minWidth:50,system:!0,sortable:!0,align:"right"},{field:"documentDatetime",title:t("Created"),cell:(0,ae.h)((0,be.p)({tpl:"createdById",dateTpl:"documentDatetime"})),width:130,minWidth:50,checked:!0,sortable:!0},{field:"status",title:t("Status"),cell:qe,width:300,minWidth:50,checked:!0,sortable:!0},{field:"supplierId",title:t("Supplier"),cell:(0,ae.h)((0,Ve.C)()),width:200,minWidth:50,checked:!0,sortable:!0},{field:"warehouseTitle",title:t("Warehouse"),cell:(0,se.x)("warehouseTitle"),width:200,minWidth:50,checked:!0,sortable:!0},{field:"expectedDeliveryDate",title:t("Expected delivery date"),cell:(0,re.F)("expectedDeliveryDate",{withTime:!1}),width:130,checked:!0,sortable:!0},...l?[{field:"totalSumWithTaxes",title:`${t("Amount")}, ${o}`,cell:(0,ze.E)({tpl:"totalSumWithTaxes"}),width:130,checked:!0,sortable:!0,align:"right"}]:[]]},st=()=>{const{t}=(0,V.Bd)(),o=(0,$.wA)(),l=(0,Y.W6)(),d=(0,Y.zy)(),n=(0,f.useRef)(null),{[v.A.PERMISSION_PURCHASE_ORDERS_CREATE]:i,[v.A.PERMISSION_PURCHASE_ORDERS_VIEW]:R,[v.A.PERMISSION_PURCHASE_ORDERS_DELETE]:h,[v.A.PERMISSION_PURCHASE_ORDERS_EDIT]:u,[v.A.PERMISSION_WAREHOUSE_EXPORT]:D,[v.A.PERMISSION_COMMON_INCOME_PRICE]:g}=(0,z.S)(),[I]=(0,p.mv)(),[m]=(0,p.v$)(),[A]=(0,p.aE)(),C=at(),O=a=>{if(!R){G.Ay.error(t("Access denied"));return}l.push(`${w.vc.WAREHOUSE.PURCHASE_ORDERS.ORDERS}/${a.id}${d.search}`)},L=async a=>{o((0,N.to)(y.ConfirmDeleteModalName,{title:t("Delete the selected elements?"),headerSize:"medium",onConfirm:async E=>{try{await I({params:{ids:a}}).unwrap(),(0,oe.p)({dispatch:o,tableName:x.BL.PURCHASE_ORDERS}),G.Ay.success(t("Successfully deleted"))}catch{}E()}}))},M=async a=>{try{const E=await m({params:{...n.current,ids:a}}).unwrap(),S=window.open("about:blank");S&&(S.document.open(),S.document.write(E),S.document.close())}catch{}},H=async a=>{try{const E=await A({params:{...n.current,ids:a}}).unwrap(),S=window.open("about:blank");S&&(S.document.open(),S.document.write(E),S.document.close())}catch{}},B=a=>{const{fileExport:E,ExportManager:S}=e(70171);E({url:S.purchaseOrders.url,filename:S.purchaseOrders.filename,method:"GET"},{...n.current,ids:a})},j=a=>{o((0,N.to)(y.ChangePurchaseOrderStatusModalName,{tableName:x.BL.PURCHASE_ORDERS,data:{ids:a}}))},P=()=>{o((0,F.fh)({badgeType:T.sc.PURCHASE_ORDER,shouldUpdateBadges:!0}))};return{name:x.BL.PURCHASE_ORDERS,requestUrl:"/purchase-orders/",requestMethod:"GET",alignKey:"supplierId",fields:C,offset:0,perPage:50,initialPage:0,isColumnDraggable:!0,isColumnResizable:!0,minHeaderMargin:!0,withCheckboxField:!0,withoutHeader:!0,withColumnDp:!1,isBigTable:!0,noPreFetch:!0,countLabel:t("v2 Total"),checkedLabel:t
1("v2 Selected"),checkedActionLabel:t("Actions"),transformData:()=>a=>{const{totalCost:E,...S}=a;return{...S,...g&&{total_cost:E}}},onDblClickRow:{cb:()=>O,fullData:!0},requestPreHook:a=>(n.current=a,a),whenEmptyTable:{image:et.A,imageSize:"large",label:t("Nothing here yet"),secondaryLabel:t("Create purchase orders to restock products and manage supplier deliveries."),actionLabel:t("Create purchase order"),actionCb:()=>{o((0,N.to)(y.PurchaseOrderModalName,{tableName:x.BL.PURCHASE_ORDERS,onSave:P,onDelete:P}))},isShow:()=>i},whenEmptyTableWithFilters:{image:tt.A,imageSize:"large",label:t("Nothing found"),secondaryLabel:t("Try adjusting your filters or search.")},actionsBtnOptions:[{icon:{image:ee.A},label:t("Change status"),enabled:u,cb:j},{icon:{image:_e.A},label:t("Export"),enabled:D,cb:B}],printBtnOptions:[{label:t("Print order",{context:"Purchase order"}),enabled:!0,cb:H},{label:t("Print purchase order list",{context:"Purchase order"}),enabled:!0,cb:M}],deleteBtnOptions:{label:t("Delete"),enabled:h,cb:L}}};function rt(){const t=st(),o=(0,Y.zy)(),l=(0,Y.W6)(),d=(0,$.wA)(),[n]=(0,p.hI)(),i=(0,ie.z)(o.pathname,w.vc.WAREHOUSE.PURCHASE_ORDERS.ORDERS_DIALOG),R=(0,$.d4)(u=>!!(0,ue.Up)(u).find(({modalProps:D})=>D.id===X()(i))),h=()=>{d((0,F.fh)({badgeType:T.sc.PURCHASE_ORDER,shouldUpdateBadges:!0}))};return(0,f.useEffect)(()=>{i&&!R&&d((0,N.to)(y.PurchaseOrderModalName,{id:X()(i),tableName:x.BL.PURCHASE_ORDERS,onSave:h,onDelete:h,preloader:()=>n({params:{id:X()(i)}}),onClose:l.goBack,onFailPreload:l.goBack,condition:({error:u})=>!u}))},[i]),(0,s.jsx)(de.Q,{children:(0,s.jsx)(ce.A,{...t,children:(0,s.jsx)(Fe,{})})})}var nt=(0,f.memo)(rt)}}]); 2 3//# sourceMappingURL=13398.e43646486e722725dec1.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.