1"use strict";(self.webpackChunkpuratos_react=self.webpackChunkpuratos_react||[]).push([[6988],{8474(e,t,n){n.r(t),n.d(t,{default:()=>U});var l=n(96540),o=n(19115),s=n(39501),i=n(9496),a=n(46797),r=n(54950),c=n(93390),d=n(99918),u=n(6010),m=n(17477),p=n(26436),h=n(5556),v=n.n(h),g=n(72359),b=n(54585);const f=(e,t)=>{const n="".concat((0,b.FB)(),"/bin/os/GetBillingDocumentBinary?DocumentTypeKey=").concat(e,"&DocumentNumber=").concat(t);return(0,g.p)().get(n,{responseType:"blob"}).then(e=>{const n=e.data,l="document-".concat(t,".pdf"),o=document.createElement("a");o.href=window.URL.createObjectURL(n),o.download=l,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(o.href)}).catch(e=>{console.error("Error downloading PDF:",e)})};var y=n(74848);const T=e=>{let{text:t,documentTypeKey:n,documentNumber:l}=e;return(0,y.jsxs)("div",{onClick:()=>f(n,l),onKeyDown:e=>"Enter"===e.key&&f(n,l),role:"button",tabIndex:0,className:"btn btn-download",children:[(0,y.jsx)("span",{className:"svg-download"}),t&&(0,y.jsx)("span",{className:"btn-download__text",children:t})]})};T.propTypes={documentTypeKey:v().string,documentNumber:v().string,text:v().string};const D=T,x=e=>{if(e)switch(e.toLowerCase()){case"paid":return"p-text-color-green";case"open":case"overdue":return"p-text-color-red";default:return""}return""},C=e=>{let{data:t,i18n:n,hidden:l,onlinePaymentEnabled:o,checkboxChange:s,selected:i,openModal:a}=e;const h=t&&t.status&&"overdue"===t.status.toLowerCase(),v="invoice"===t.documentType.toLowerCase(),g=(0,m.a)("1350px");return l?null:(0,y.jsxs)(c.XI.Row,{myPuratos:!0,children:[o?(0,y.jsx)(c.XI.Cell,{size:d.Dq._50,align:"flex-start",valign:"center",className:g?"order-7 footer-item":"",children:(0,y.jsx)(u.S,{id:t.documentNumber,selected:i,onChange:()=>s(t.documentNumber,t.documentTypeKey),centered:!0,label:g?(0,r.T)(n,"Select"):"",disabled:!t.onlinePayable||!v},t.documentNumber)}):!g&&o?(0,y.jsx)(c.XI.Cell,{size:d.Dq._50}):null,(0,y.jsx)(d.IQ,{size:d.Dq._equal,align:"left",valign:"center",className:g?"order-0":"",label:(0,r.T)(n,"Type"),value:(0,r.T)(n,t.documentType),isMobile:g}),(0,y.jsx)(d.IQ,{size:d.Dq._equal,align:"left",valign:"center",className:g?"order-1":"",label:(0,r.T)(n,"Date"),value:t.documentDate,isMobile:g}),(0,y.jsx)(d.IQ,{size:d.Dq._equal,align:"left",valign:"center",className:g?"order-2":"",label:(0,r.T)(n,"Billing document"),value:t.documentNumber,isMobile:g}),(0,y.jsx)(d.IQ,{size:d.Dq._equal,align:"left",valign:"center",className:g?"order-3":"",label:(0,r.T)(n,"Accounting document"),value:t.accountingDocumentNumber,isMobile:g}),(0,y.jsx)(d.IQ,{size:d.Dq._equal,align:"left",valign:"center",isMobile:g,className:g?"order-5":"",color:g&&h?"p-text-color-red":"",label:(0,r.T)(n,"Amount"),heavy:!g,bold:g&&h,value:"".concat(t.amount.TotalAmount," ").concat(h&&g?" (!)":"")}),(0,y.jsx)(d.IQ,{size:d.Dq._equal,align:"left",valign:"center",isMobile:g,className:g?"order-4":"",color:!g&&h?"p-text-color-red":"",label:(0,r.T)(n,"Due date"),heavy:!g&&!h,bold:!g&&h,value:v?t.dueDate+(h&&!g?" (!)":""):"-"}),(0,y.jsx)(d.AG,{size:d.Dq._equal,align:"left",valign:"center",isMobile:g,className:g?"order-6":"",color:x(t.status),label:(0,r.T)(n,"Status"),useLink:t.hasPaymentInfo,value:(0,r.T)(n,t.hasPaymentInfo?"Payment information":t.status),onClick:e=>{a(p.p,{type:(0,r.T)(n,"Invoice"),invoiceNumber:e})},onClickParam:t.documentNumber}),(0,y.jsx)(c.XI.Cell,{size:d.Dq._equal,align:"left",valign:"center",className:g?"order-8 footer-item":"",children:t.hasPDF?(0,y.jsx)(D,{documentTypeKey:t.documentTypeKey,documentNumber:t.documentNumber,text:g?(0,r.T)(n,"Download"):""}):"-"})]})};C.propTypes={},C.defaultProps={};const N=C;var I=n(68797),S=n(50536),A=n(54170),j=n(88481),q=n(99507),w=n(30673);const _=e=>{let{i18n:t,onlinePaymentEnabled:n,selectAll:l,isAllSelected:o,selectAllCheck:s}=e;return(0,y.jsxs)(c.XI.Header,{children:[n?(0,y.jsx)(c.XI.Cell,{valign:"flex-start",align:"left",size:d.Dq._50,children:(0,y.jsx)(u.S,{id:"selectAll",disabled:0===s,selected:o,onChange:l,centered:!0},"selectAll")}):null,(0,y.jsx)(c.XI.Cell,{valign:"flex-start",align:"left",size:d.Dq._equal,children:(0,r.T)(t,"Type")}),(0,y.jsx)(c.XI.Cell,{valign:"flex-start",align:"left",size:d.Dq._equal,children:(0,r.T)(t,"Date")}),(0,y.jsx)(c.XI.Cell,{valign:"flex-start",align:"left",size:d.Dq._equal,children:(0,r.T)(t,"Billing document")}),(0,y.jsx)(c.XI.Cell,{valign:"flex-start",align:"left",size:d.Dq._equal,children:(0,r.T)(t,"Accounting document")}),(0,y.jsx)(c.XI.Cell,{valign:"flex-start",align:"left",size:d.Dq._equal,children:(0,r.T)(t,"Amount")}),(0,y.jsx)(c.XI.Cell,{valign:"flex-start",align:"left",size:d.Dq._equal,children:(0,r.T)(t,"Due date")}),(0,y.jsx)(c.XI.Cell,{valign:"flex-start",align:"left",size:d.Dq._equal,children:(0,r.T)(t,"Status")}),(0,y.jsxs)(c.XI.Cell,{valign:"flex-start",align:"left",size:d.Dq._equal,children:[(0,r.T)(t,"Download")," "]})]})};var L=n(85305),P=n(45037),E=n(67849),F=n(82960),M=n(21978),k=n(32809),z=n(79393),X=n(16739),R=n(26270);function B(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var l=n.call(e,t||"default");if("object"!=typeof l)return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class K extends l.Component{constructor(){super(...arguments),B(this,"state",{isAllSelected:!1,invoices:null,loading:!0,searchTerm:"",sorting:"BillingDate DESC",selectedFilter:"ALL",totalAmount:0}),B(this,"handleSearchChange",e=>{void 0!==e&&this.setState({searchTerm:e})}),B(this,"handleSortChange",e=>{void 0!==e&&this.setState({sorting:e})}),B(this,"handleFilterChange",e=>{void 0!==e&&(this.setState({selectedFilter:e,isAllSelected:!1,totalAmount:0}),this.props.setSelectedInvoices([]))})}setScrollListener(){window.onscroll=e=>{const t=$(".p-filtered-list.top-section"),n=$(".p-filtered-list.mobile-section"),l=$("nav[aria-label='Page navigation']");var o,s;t&&n&&l&&(document.documentElement.scrollTop>(null===(o=t.offset())||void 0===o?void 0:o.top)?n.slideDown():n.slideUp(),document.documentElement.scrollTop+window.innerHeight>(null===(s=l.offset())||void 0===s?void 0:s.top)?n.removeClass("sticky"):n.addClass("sticky"))}}componentDidMount(){const{mapping:e}=this.props;this.props.resetFilters(K.FILTER_CONTEXT),this.props.fetchInvoicesModel(e),(0,g.p)().get("".concat((0,b.FB)(),"/bin/os/GetBillingDocuments")).then(e=>{this.setState({invoices:e.data,loading:!1})}).catch(e=>{console.error("Error fetching invoices:",e),this.setState({loading:!1})}),this.props.setLoading(!1);const t=(0,L.qg)(this.props.parameters,{decode:!1});
1t&&t.id&&this.props.openModal(p.p,{type:this.props.translate("Invoice"),invoiceNumber:t.id}),this.setScrollListener(),(0,M.c)("invoices")}componentDidUpdate(e){const{filter:t,mapping:n}=this.props;e.mapping!==n&&this.props.fetchInvoicesModel(n),e.filter&&(e.filter.filter!==t.filter&&this.handleFilterChange(t.filter),e.filter.searchTerm!==t.searchTerm&&this.handleSearchChange(t.searchTerm),e.filter.sorting!==t.sorting&&this.handleSortChange(t.sorting))}render(){var e,t;const{invoices:n,loading:l,searchTerm:o,selectedFilter:a,sorting:r}=this.state,{invoicesModel:c,i18n:d,setActive:u,homepage:m,resetFilters:p}=this.props,{selectedInvoices:h}=this.props.invoicesState,v=m&&m.enablePayInvoicesOnline,g=(0,R.z)(),b=(null===g||void 0===g||null===(e=g.dateTimeFormat)||void 0===e?void 0:e.date)||"MM-DD-yyyy",f=(e,t)=>{if(!e||!t)return null;const n=e.split(/[-/.]/);let l,o,s;return t.split(/[-/.]/).forEach((e,t)=>{switch(e){case"dd":case"DD":l=parseInt(n[t],10);break;case"MM":case"mm":o=parseInt(n[t],10)-1;break;case"yyyy":case"YYYY":s=parseInt(n[t],10)}}),new Date(s,o,l)},T=()=>{const{isAllSelected:e}=this.state,t=P.filter(e=>e.onlinePayable)||[],l=e?[]:t.map(e=>({documentNumber:e.documentNumber,DocumentTypeKey:e.documentTypeKey})),o=l.reduce((e,t)=>{var l;const o=null===n||void 0===n||null===(l=n.Documents)||void 0===l?void 0:l.find(e=>e.documentNumber===t.documentNumber);return o?e+o.amount.TotalAmountDouble:e},0).toFixed(2);this.setState({totalAmount:o,isAllSelected:!e}),this.props.setSelectedInvoices(l)},D=(e,t)=>{var l;const o=[...this.props.invoicesState.selectedInvoices],s=null===n||void 0===n||null===(l=n.Documents)||void 0===l?void 0:l.find(t=>t.documentNumber===e);if(null!==s&&void 0!==s&&s.onlinePayable){const l=o.findIndex(t=>t.documentNumber===e);-1!==l?o.splice(l,1):o.push({documentNumber:e,DocumentTypeKey:t});const s=o.reduce((e,t)=>{var l;const o=null===n||void 0===n||null===(l=n.Documents)||void 0===l?void 0:l.find(e=>e.documentNumber===t.documentNumber);return o?e+o.amount.TotalAmountDouble:e},0).toFixed(2);this.setState({totalAmount:s}),this.props.setSelectedInvoices(o)}},[x,C]=r.split(" "),j=x||"BillingDate",q=(C||"DESC").toUpperCase(),L={BillingDate:(e,t)=>f(e.documentDate,b)-f(t.documentDate,b),DueDate:(e,t)=>f(e.dueDate,b)-f(t.dueDate,b),DocumentNumber:(e,t)=>t.documentNumber.localeCompare(e.documentNumber),NetValue:(e,t)=>t.amount.TotalAmountDouble-e.amount.TotalAmountDouble,AccountingDocumentNumber:(e,t)=>t.accountingDocumentNumber-e.accountingDocumentNumber,InvoiceStatus:(e,t)=>e.status.localeCompare(t.status),Type:(e,t)=>e.documentType.localeCompare(t.documentType)},P=(null===n||void 0===n||null===(t=n.Documents)||void 0===t?void 0:t.filter(e=>{const t=e.documentNumber.toLowerCase().includes(o.toLowerCase()),n="ALL"===a||e.documentType.toLowerCase()===a.toLowerCase();return t&&n}))||[];P.sort((e,t)=>{const n=L[j];if(!n)return 0;const l=n(e,t);return"ASC"===q?l:-l});const E=P.filter(e=>e.onlinePayable).length;return(0,y.jsx)(w.A,{title:c.title,description:c.text,children:(0,y.jsxs)(s.A,{aemResource:c,className:"myPuratos-table",total:P.length,totalAmount:this.state.totalAmount,i18n:d,context:K.FILTER_CONTEXT,loading:l,skeletonType:k.N.INVOICES,payButtonDisabled:0===h.length,payInvoices:()=>{this.props.payInvoices({documentNumbers:h,successUrl:c.successPath})},onlinePaymentEnabled:v,selectAll:T,isAllSelected:this.state.isAllSelected,listHeader:(0,y.jsx)(_,{selectAllCheck:E,i18n:d,onlinePaymentEnabled:v,selectAll:T,isAllSelected:this.state.isAllSelected}),children:[(0,y.jsxs)(I.W,{children:[(0,y.jsxs)(I.W.FilterSection,{children:[(0,y.jsx)(S.A,{label:"Sort",id:"sorting",type:"sorting",options:i.Rr,filter:this.props.filter,onChange:this.handleSortChange}),(0,y.jsx)(S.A,{label:"Filter",id:"filter",type:"filter",hideInitOption:!0,options:i.wc,filter:this.props.filter,onChange:this.handleFilterChange})]}),(0,y.jsx)(I.W.SearchSection,{children:(0,y.jsx)(A.A,{placeholder:"Search",id:"searchTerm",onChange:this.handleSearchChange,reset:()=>{this.setState({searchTerm:"",selectedFilter:"ALL",sorting:"BillingDate DESC"}),p(K.FILTER_CONTEXT)}})})]}),P.map((e,t)=>
1(0,y.jsx)(N,{data:e,i18n:d,setActive:u,onlinePaymentEnabled:v,openModal:this.props.openModal,checkboxChange:D,selected:h.some(t=>t.documentNumber===e.documentNumber)},t))]})})}}B(K,"FILTER_CONTEXT","invoices");const O={fetchInvoicesModel:a.y,setLoading:a.r1,setSelectedInvoices:a.qt,payInvoices:a.xy,resetFilters:q.dr,openModal:P.qf},U=(0,F.Zz)((0,o.connect)(e=>({invoicesModel:e.myPuratos_invoices.aemResource,invoicesState:e.myPuratos_invoices,i18n:e.myPuratos_i18n.i18n,homepage:(0,b.W_)(e,(0,b.kJ)()),filter:(0,j.vD)(e,K.FILTER_CONTEXT),mapping:e.myPuratos_dashboard.mapping,parameters:e.router.location.search,paymentLoading:(0,z.KT)(e,X.aH.paymentLoading)}),O),E.lI)(K)}}]); 2//# sourceMappingURL=myPuratos-invoices.bb39b582.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.