umwd-components 0.1.640 → 0.1.642
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/src/components/e-commerce/invoice/InvoicePDF.js +1 -1
- package/dist/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/src/data/services/common/confirmation-service.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/data/services/common/confirmation-service.d.ts +2 -1
- package/dist/types/types/e-commerce/invoice/types.d.ts +13 -0
- package/package.json +1 -1
- package/src/components/e-commerce/invoice/InvoicePDF.tsx +260 -220
- package/src/components/e-commerce/iro/TextualManageIROForm.tsx +324 -3
- package/src/data/services/common/confirmation-service.ts +9 -2
- package/src/types/e-commerce/invoice/types.ts +17 -0
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import{StyleSheet as l,PDFDownloadLink as n,PDFViewer as o,Document as r,Page as
|
|
7
|
+
import{__read as e,__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import{StyleSheet as l,PDFDownloadLink as n,PDFViewer as o,Document as r,Page as c,View as i,Text as a}from"@react-pdf/renderer";import m,{useState as d,Fragment as u}from"react";import s from"@mui/material/IconButton";import E from"@mui/material/Dialog";import y from"@mui/material/DialogContent";import v from"@mui/material/DialogActions";import p from"@mui/material/Button";import S from"@mui/icons-material/PictureAsPdf";var f=l.create({page:{flexDirection:"column",backgroundColor:"#E4E4E4"},header:{padding:10,flexDirection:"row",alignItems:"center"},logo:{width:24,height:24,marginRight:10},section:{margin:10,padding:10,fontSize:12},row:{flexDirection:"row"},rowSection:{flex:1},productRowSection:{flex:1,width:1/6},h1:{fontSize:28},h2:{fontSize:24,fontStyle:"bold"},h3:{fontSize:16,fontStyle:"bold"}});function _(e){var l,n,o,d,s,E,y,v=e.props.invoice;console.log("invoice from invoicePDF",v);var p=v.seller_business_credentials,S=v.seller_company_address,_=v.buyer_company_address,w=v.buyer_business_credentials,b=v.type;return v.invoice_number,console.log("type",b),"credit"===b?m.createElement(r,{title:"credit_".concat(null==v?void 0:v.invoice_number)},m.createElement(c,{size:"A4",style:f.page},m.createElement(i,{style:f.header},m.createElement(a,{style:f.h1},null==p?void 0:p.company_name)),m.createElement(a,null,"Credit note"))):"proforma"===b?m.createElement(r,{title:"proforma_".concat(null==v?void 0:v.invoice_number)},m.createElement(c,{size:"A4",style:f.page},m.createElement(i,{style:f.header},m.createElement(a,{style:f.h1},null==p?void 0:p.company_name)),m.createElement(a,null,"Proforma invoice"))):m.createElement(r,{title:"invoice_".concat(null==v?void 0:v.invoice_number)},m.createElement(c,{size:"A4",style:f.page},m.createElement(i,{style:f.header},m.createElement(a,{style:f.h1},null==p?void 0:p.company_name)),m.createElement(i,{style:f.section},m.createElement(a,{style:f.h2},"INVOICE")),m.createElement(i,{style:f.section},m.createElement(i,{style:f.row},m.createElement(i,{style:f.rowSection},m.createElement(a,{style:f.h3},"BILLING DETAILS"),m.createElement(a,null,null==w?void 0:w.company_name),m.createElement(a,null,null==v?void 0:v.buyer_first_name," ",null==v?void 0:v.buyer_last_name),m.createElement(a,null,null==_?void 0:_.street," ",null==_?void 0:_.street_number," ",null==_?void 0:_.street_number_addition),m.createElement(a,null,null==_?void 0:_.postal_code," ",null==_?void 0:_.city)),m.createElement(i,{style:f.rowSection},m.createElement(a,{style:f.h3},"FROM"),m.createElement(a,null,null==p?void 0:p.company_name),m.createElement(a,null,null==S?void 0:S.street," ",null==S?void 0:S.street_number," ",null==S?void 0:S.street_number_addition),m.createElement(a,null,null==S?void 0:S.postal_code," ",null==S?void 0:S.city),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"CoC Number"),m.createElement(a,null,null==p?void 0:p.coc_number),m.createElement(a,{style:{fontStyle:"bold",marginTop:10}},"VAT Number"),m.createElement(a,null,null==p?void 0:p.vat_number)))),m.createElement(i,{style:f.section},m.createElement(i,{style:f.row},m.createElement(i,{style:f.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice number: "),m.createElement(a,null,null==v?void 0:v.invoice_number)),(null==v?void 0:v.customer_reference)&&m.createElement(i,{style:f.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Your reference: "),m.createElement(a,null,null==v?void 0:v.customer_reference)),m.createElement(i,{style:f.rowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Invoice date"),m.createElement(a,null,null==v?void 0:v.invoice_date)))),m.createElement(i,{style:f.section},m.createElement(a,{style:f.h3},"SUMMARY"),m.createElement(i,{style:f.row},(null===(l=null==v?void 0:v.admin_items)||void 0===l?void 0:l.length)>0&&m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Line Item Number")),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Title")),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Amount")),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT rate")),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"VAT")),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px",fontStyle:"bold"}},"Incl. VAT"))),null===(n=null==v?void 0:v.items)||void 0===n?void 0:n.map((function(e,t){var l,n,o;return m.createElement(u,{key:t},m.createElement(i,{style:f.row},m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"product_title"in e&&e.product_title,"item_description"in e&&e.item_description)),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.vat_rate," %")," "),m.createElement(i,{style:f.productRowSection},e.price_excl_vat&&e.price_incl_vat&&m.createElement(a,{style:{fontSize:"10px"}},"€"," ",null===(l=e.price_incl_vat-e.price_excl_vat)||void 0===l?void 0:l.toFixed(2))),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(n=e.price_excl_vat)||void 0===n?void 0:n.toFixed(2))),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=e.price_incl_vat)||void 0===o?void 0:o.toFixed(2)))))})),null===(o=null==v?void 0:v.admin_items)||void 0===o?void 0:o.map((function(e,t){var l,n,o,r,c,d,s;return m.createElement(u,{key:t},m.createElement(i,{style:f.row},m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.line_item_number)),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.description)),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},e.quantity)),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},null===(l=null==e?void 0:e.price)||void 0===l?void 0:l.vat_rate," %")),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(o=null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.vat)||void 0===o?void 0:o.toFixed(2))),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(c=null===(r=null==e?void 0:e.price)||void 0===r?void 0:r.price)||void 0===c?void 0:c.toFixed(2))),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontSize:"10px"}},"€ ",null===(s=null===(d=null==e?void 0:e.price)||void 0===d?void 0:d.price_incl_vat)||void 0===s?void 0:s.toFixed(2)))))}))),m.createElement(i,{style:f.section},m.createElement(a,{style:f.h3},"TOTALS"),m.createElement(i,{style:f.row},m.createElement(i,{style:f.productRowSection}),m.createElement(i,{style:f.productRowSection}),m.createElement(i,{style:f.productRowSection}),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"VAT")),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Excl. VAT")),m.createElement(i,{style:f.productRowSection},m.createElement(a,{style:{fontStyle:"bold"}},"Incl. VAT"))),m.createElement(i,{style:f.row},m.createElement(i,{style:f.productRowSection}),m.createElement(i,{style:f.productRowSection}),m.createElement(i,{style:f.productRowSection}),m.createElement(i,{style:f.productRowSection},m.createElement(a,null,"€ ",null===(d=null==v?void 0:v.VAT_total)||void 0===d?void 0:d.toFixed(2))),m.createElement(i,{style:f.productRowSection},m.createElement(a,null,"€ ",null===(s=null==v?void 0:v.total_excl_vat)||void 0===s?void 0:s.toFixed(2))),m.createElement(i,{style:f.productRowSection},m.createElement(a,null,"€ ",null===(E=null==v?void 0:v.total_incl_vat)||void 0===E?void 0:E.toFixed(2))))),m.createElement(i,{style:f.section},m.createElement(a,{style:t(t({},f.h3),{border:"2px solid black",padding:10})},"Total Due: € ",null===(y=null==v?void 0:v.total_incl_vat)||void 0===y?void 0:y.toFixed(2)))))}function w(e){var t=e.invoice;return m.createElement(n,{document:m.createElement(_,{props:{invoice:t}}),fileName:"invoice_".concat(null==t?void 0:t.invoice_number)},m.createElement(s,null,m.createElement(S,null)))}function b(t){var l=t.invoice,n=e(d(!1),2),r=n[0],c=n[1];return m.createElement(m.Fragment,null,m.createElement(s,{onClick:function(){return c(!0)}},m.createElement(S,null)),m.createElement(E,{open:r,fullWidth:!0,maxWidth:"lg"},m.createElement(y,null,m.createElement(o,{style:{width:"100%",minHeight:"70vh"}},m.createElement(_,{props:{invoice:l}}))),m.createElement(v,null,m.createElement(p,{variant:"contained",onClick:function(){return c(!1)}},"Close"))))}export{w as InvoiceDownloadLink,b as InvoicePDFViewer};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__read as e,__spreadArray as t,__assign as r}from"../../../../node_modules/tslib/tslib.es6.js";import n,{useState as a,useEffect as i}from"react";import{useFormState as o}from"react-dom";import{updateIroAction as l}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import m from"./TextualIROItemUpdater.js";import c from"./IroItemDisplay.js";import s from"../../logistics/note/NotesDisplay.js";import u from"../../logistics/note/NoteTakingComponent.js";import{StrapiErrors as d}from"../../StrapiErrors.js";import{SubmitButton as p}from"../../SubmitButton.js";import E from"@mui/material/Alert";import f from"@mui/material/Dialog";import v from"@mui/material/DialogActions";import g from"@mui/material/DialogContent";import y from"@mui/material/DialogTitle";import h from"@mui/material/Typography";import b from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import _ from"@mui/material/Stack";import I from"@mui/material/Divider";import{confirmationService as k}from"../../../data/services/common/confirmation-service.js";import{cancellationService as q}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as D,Checkbox as R,List as j,ListItem as A,TextField as S}from"@mui/material";import N from"@mui/icons-material/Numbers";import T from"@mui/icons-material/AssignmentReturn";import B from"@mui/icons-material/CalendarToday";import P from"@mui/icons-material/Business";import W from"@mui/icons-material/Description";import M from"@mui/icons-material/Update";import{IroStatusIndicator as U}from"./IroStatusIndicator.js";var O={zodErrors:null,strapiErrors:null,data:null,message:null};function Y(e){var t=e.open,r=e.handleClose,a=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return n.createElement(f,{open:t},n.createElement(y,null,"Confirm Return"),n.createElement(g,null,n.createElement(_,{spacing:2},n.createElement(h,null,"Are you sure you want to confirm this return?"),n.createElement(j,null,"requested"===i&&n.createElement(A,null,"When confirming this return order a rma number will be generated"),n.createElement(A,null,"requested"===i?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done")),n.createElement(h,null,"Current status: ",i))),n.createElement(v,null,n.createElement(b,{variant:"contained",onClick:function(e){k("iros",[a]),o&&o(),r()}},"Yes"),n.createElement(b,{variant:"contained",onClick:r},"No")))}function z(t){var r=t.open,i=t.handleClose,o=t.orderID,l=t.revalidateCallback,m=e(a(""),2),c=m[0],s=m[1],u=e(a(""),2),d=u[0],p=u[1];return n.createElement("form",null,n.createElement(f,{open:r},n.createElement(y,null,"Cancel Return"),n.createElement(g,null,n.createElement(_,{spacing:2},n.createElement(h,null,"Are you sure you want to cancel this return?"),n.createElement(j,null,n.createElement(A,null,"By cancelling this return order you will update it's status from requested to cancelled"),n.createElement(A,null,"Please provide a reason for the cancellation"),n.createElement(A,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),n.createElement(S,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:c,onChange:function(e){return s(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),n.createElement(v,null,n.createElement(b,{variant:"contained",onClick:function(e){c.length<5?p("Please provide a reason for the cancellation"):(q("iros",o,c),l&&l(),i())}},"Yes"),n.createElement(b,{variant:"contained",onClick:i},"No"))))}function G(f){var v,g,y,k,q=f.data,j=f.sx,A=f.revalidateCallback;f.handleClose;var S=f.role,G=e(o(l,O),2),J=G[0],L=G[1],Q=e(a(q.iro_items.data?q.iro_items.data:[]),2),F=Q[0],H=Q[1],K=e(a(!1),2),V=K[0],X=K[1],Z=e(a(!1),2),$=Z[0],ee=Z[1],te=e(a(["received","registered","released","reports"]),2),re=te[0],ne=te[1],ae=function(r,n,a){var i=t([],e(F),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,H(i)},ie=function(n,a){var i,o,l,m=t([],e(F),!1),c=m.findIndex((function(e){return e.id===a})),s=(null===(o=null===(i=m[c])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],u=t(t([],e(s),!1),[n],!1);null==(null===(l=m[c])||void 0===l?void 0:l.reports)&&(m[c]=r(r({},m[c]),{reports:{data:[]}})),m[c].reports.data=u,H(m)},oe=function(r,n){var a,i,o=t([],e(F),!1),l=o.findIndex((function(e){return e.id===r})),m=(null===(i=null===(a=o[l])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],c=m.filter((function(e){return"id"in e})),s=m.filter((function(e){return!("id"in e)}));s.splice(n,1);var u=t(t([],e(c),!1),e(s),!1);o[l].reports.data=u,H(o)};return i((function(){"Iro Updated"===(null==J?void 0:J.message)&&A&&A()}),[J]),i((function(){var e;(null===(e=q.iro_items)||void 0===e?void 0:e.data)&&H(q.iro_items.data?q.iro_items.data:[])}),[q]),n.createElement(C,{sx:t([],e(Array.isArray(j)?j:[j]),!1)},n.createElement(x,{container:!0,spacing:2},n.createElement(x,{item:!0,xs:12},n.createElement(_,{spacing:2},n.createElement(_,{direction:"row",spacing:2,justifyContent:"space-between"},n.createElement(_,{spacing:2},n.createElement(h,{variant:"h3",component:"h1"},"Management Inbound Return"),n.createElement(h,{variant:"body1"},"Manage arrival, registration and release of returns")),n.createElement(u,{content:"",related:[{id:q.id,__type:"api::e-commerce.iro"}],revalidateCallback:A})),n.createElement(I,null))),n.createElement(x,{item:!0,xs:12},n.createElement(h,{variant:"h5",sx:{py:1}},"Details")),n.createElement(x,{item:!0,xs:6},n.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(_,{spacing:2},n.createElement(_,{direction:"row",spacing:2,alignItems:"center"},n.createElement(N,{color:"primary"}),n.createElement(h,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),n.createElement(h,{variant:"body1",fontWeight:"medium"},q.return_number)),n.createElement(_,{direction:"row",spacing:2,alignItems:"center"},n.createElement(T,{color:"primary"}),n.createElement(h,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),n.createElement(h,{variant:"body1",fontWeight:"medium"},q.rma_number)),n.createElement(_,{direction:"row",spacing:2,alignItems:"center"},n.createElement(W,{color:"primary"}),n.createElement(h,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),n.createElement(h,{variant:"body1",fontWeight:"medium"},q.customer_reference)),n.createElement(_,{direction:"row",spacing:2,alignItems:"center"},n.createElement(B,{color:"primary"}),n.createElement(h,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),n.createElement(h,{variant:"body1",fontWeight:"medium"},q.return_date)),n.createElement(_,{direction:"row",spacing:2,alignItems:"center"},n.createElement(P,{color:"primary"}),n.createElement(h,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),n.createElement(h,{variant:"body1",fontWeight:"medium"},null===(g=null===(v=q.customer)||void 0===v?void 0:v.business_credentials)||void 0===g?void 0:g.company_name)),n.createElement(_,{direction:"row",spacing:2,alignItems:"center"},n.createElement(M,{color:"primary"}),n.createElement(h,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),n.createElement(U,{status:q.status}))))),("requested"===q.status||"finalising_process"===q.status)&&"enduser"===S&&n.createElement(x,{item:!0,xs:6},n.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(_,{spacing:2},n.createElement(b,{variant:"contained",color:"primary",onClick:function(){return X(!0)}},"Confirm order"),"requested"===q.status&&n.createElement(E,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"),"finalising_process"===q.status&&n.createElement(E,{severity:"warning"},"Please finalise this return order. Make sure the customer recieves a return payment if eligible and than confirm this step. Status: finalising_process - done"),"finalising_process"===q.status&&n.createElement(b,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),n.createElement(b,{variant:"contained",color:"error",onClick:function(){return ee(!0)}},"Cancel order"),n.createElement(Y,{open:V,handleClose:function(){return X(!1)},orderID:q.id,currentStatus:q.status,revalidateCallback:A}),n.createElement(z,{open:$,handleClose:function(){return ee(!1)},orderID:q.id,revalidateCallback:A})))),n.createElement(x,{item:!0,xs:12},n.createElement(_,{spacing:2},n.createElement(h,{variant:"h5"},"Documents"),n.createElement(w,{sx:{p:2}},n.createElement(_,{spacing:1})))),(null===(k=null===(y=null==q?void 0:q.notes)||void 0===y?void 0:y.data)||void 0===k?void 0:k.length)>0&&n.createElement(x,{item:!0,xs:12},n.createElement(_,{spacing:2},n.createElement(h,{variant:"h5"},"Notes"),n.createElement(s,{notes:q.notes.data}),n.createElement(I,null))),n.createElement(x,{item:!0,xs:12},n.createElement(_,{spacing:1},n.createElement(h,{variant:"h5"},"Items"),n.createElement(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1},n.createElement(h,{variant:"body1"},"Show:"),["received","registered","released","reports"].map((function(r){return n.createElement(D,{key:r,control:n.createElement(R,{checked:re.includes(r),onChange:function(n){n.target.checked?ne(t(t([],e(re),!1),[r],!1)):ne(re.filter((function(e){return e!==r})))}}),label:r.charAt(0).toUpperCase()+r.slice(1)})}))),"requested"===q.status&&n.createElement(E,{severity:"warning"},"Before confirmation you cannot update the items"),n.createElement(I,null),n.createElement("form",{action:L},n.createElement("input",{name:"id",type:"hidden",value:q.id}),F&&F.map((function(e,t){var r,a;return n.createElement(w,{sx:{p:2,mb:2},key:t},"requested"===q.status||"cancelled"===q.status||"done"===q.status?n.createElement(c,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):n.createElement(m,{item:e,index:t,handleUpdateQuantity:ae,handleAddReport:ie,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:oe,revalidateCallback:A,showing:re}))})),n.createElement(w,{sx:{p:2}},n.createElement(_,{direction:"row",spacing:2,justifyContent:"end"},n.createElement(p,{text:"Update items",loadingText:"Loading..."}),n.createElement(d,{error:null==J?void 0:J.strapiErrors}),(null==J?void 0:J.message)&&n.createElement(E,{severity:"error"},null==J?void 0:J.message))),n.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,r;return{id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:(null===(r=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===r?void 0:r.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(F))}))))))}export{G as default};
|
|
6
|
+
import{__read as e,__spreadArray as t,__assign as n,__awaiter as r,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as l,useEffect as o}from"react";import{useFormState as c}from"react-dom";import{updateIroAction as m}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import u from"./TextualIROItemUpdater.js";import s from"./IroItemDisplay.js";import d from"../../logistics/note/NotesDisplay.js";import v from"../../logistics/note/NoteTakingComponent.js";import{StrapiErrors as p}from"../../StrapiErrors.js";import{SubmitButton as f}from"../../SubmitButton.js";import E from"@mui/material/Alert";import g from"@mui/material/Dialog";import _ from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import y from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import x from"@mui/material/Button";import C from"@mui/material/Grid";import w from"@mui/material/Box";import q from"@mui/material/Paper";import I from"@mui/material/Stack";import k from"@mui/material/Divider";import{confirmationService as A}from"../../../data/services/common/confirmation-service.js";import{cancellationService as D}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as j,Checkbox as R,DialogContentText as T,CircularProgress as W,TextField as S,List as P,ListItem as F}from"@mui/material";import O from"@mui/icons-material/Numbers";import N from"@mui/icons-material/AssignmentReturn";import B from"@mui/icons-material/CalendarToday";import M from"@mui/icons-material/Business";import U from"@mui/icons-material/Description";import z from"@mui/icons-material/Update";import{IroStatusIndicator as V}from"./IroStatusIndicator.js";import{queryAllProducts as Y}from"../../../data/loaders/e-commerce/queryAllProducts.js";import Q from"../../../../node_modules/qs/lib/index.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null};function J(c){var m,u,s=this,d=c.open,v=c.handleClose,p=c.overwrites,f=c.setOverwrites,E=c.iro,C=e(l(!1),2),w=C[0],q=C[1];return o((function(){var e,t;d&&(null===(t=null===(e=null==E?void 0:E.iro_items)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)>0&&r(s,void 0,void 0,(function(){var e,t,n,r,i,l;return a(this,(function(a){switch(a.label){case 0:return q(!0),e=Q.stringify({filters:{product_number:{$in:E.iro_items.data.map((function(e){var t,n;return(null===(n=null===(t=e.product)||void 0===t?void 0:t.product_number)||void 0===n?void 0:n.replace(/^r-/,""))||""}))}},populate:{price:!0}},{encodeValuesOnly:!0}),[4,Y(e)];case 1:return t=a.sent(),n=t.data.map((function(e){return{id:e.id,product_number:e.product_number,price:e.price}})),console.log("correspondingProducts",n),q(!1),r=0,i=0,l=E.iro_items.data.map((function(e,t){var a=e.product,l=n.find((function(e){var t;return e.product_number===(null===(t=null==a?void 0:a.product_number)||void 0===t?void 0:t.replace(/^r-/,""))||""})),o=0,c=0,m=0;if(l&&l.price){o=l.price.price||0,c=l.price.price_incl_vat||0,m=l.price.vat_rate||0;var u=o*e.returned_quantity,s=c*e.returned_quantity;r+=u,i+=s}return{vat_rate:m,price_excl_vat:o,price_incl_vat:c,quantity:e.returned_quantity}})),f({customer_internal_reference:E.customer_reference||"",total_excl_vat:parseFloat(r.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:l}),[2]}}))}))}),[d,E]),i.createElement(g,{open:d,fullWidth:!0,maxWidth:"lg"},i.createElement(y,null,"Check or overwrite value for the return payment"),i.createElement(h,null,i.createElement(I,{spacing:2,alignItems:"left",sx:{px:0}},i.createElement(T,null,"This is very important because these values will be used for automated invoice generation"),i.createElement(T,{variant:"h5"},"Overwrites"),w?i.createElement(W,null):i.createElement(I,{spacing:2},i.createElement(S,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:p.customer_internal_reference,onChange:function(e){return f(n(n({},p),{customer_internal_reference:e.target.value}))}}),i.createElement(S,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_excl_vat,onChange:function(e){return f(n(n({},p),{total_excl_vat:parseFloat(e.target.value)}))}}),i.createElement(S,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_incl_vat,onChange:function(e){return f(n(n({},p),{total_incl_vat:parseFloat(e.target.value)}))}})),(null===(u=null===(m=null==E?void 0:E.iro_items)||void 0===m?void 0:m.data)||void 0===u?void 0:u.length)>0&&i.createElement(i.Fragment,null,i.createElement(T,{variant:"h5"},"Items"),E.iro_items.data.map((function(r,a){var l,o,c,m,u,s,d,v,E,g,_,h,y,x;return i.createElement(I,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},key:r.id},i.createElement(b,{sx:{minWidth:100}},r.line_item_number),i.createElement(b,{sx:{minWidth:150}},null===(l=r.product)||void 0===l?void 0:l.product_number),i.createElement(b,{sx:{minWidth:200}},null===(o=r.product)||void 0===o?void 0:o.title),i.createElement(S,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:null!==(u=null===(m=null===(c=null==p?void 0:p.lines)||void 0===c?void 0:c[a])||void 0===m?void 0:m.vat_rate)&&void 0!==u?u:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{vat_rate:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(S,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:null!==(v=null===(d=null===(s=null==p?void 0:p.lines)||void 0===s?void 0:s[a])||void 0===d?void 0:d.price_excl_vat)&&void 0!==v?v:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_excl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(S,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:null!==(_=null===(g=null===(E=null==p?void 0:p.lines)||void 0===E?void 0:E[a])||void 0===g?void 0:g.price_incl_vat)&&void 0!==_?_:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_incl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(S,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:null!==(x=null===(y=null===(h=null==p?void 0:p.lines)||void 0===h?void 0:h[a])||void 0===y?void 0:y.quantity)&&void 0!==x?x:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{quantity:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}))}))))),i.createElement(_,null,i.createElement(x,{variant:"contained",onClick:function(e){A("iros",[E.id],p),v()}},"Confirm"),i.createElement(x,{variant:"contained",onClick:v},"Cancel")))}function L(e){var t=e.open,n=e.handleClose,r=e.orderID,a=e.currentStatus,l=e.revalidateCallback,o=e.openOverwritesDialog;return i.createElement(g,{open:t},i.createElement(y,null,"Confirm Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(b,null,"Are you sure you want to confirm this return?"),i.createElement(P,null,"requested"===a&&i.createElement(F,null,"When confirming this return order a rma number will be generated"),i.createElement(F,null,"requested"===a?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"),"finalising_process"===a&&i.createElement(F,null,"Confirming this order will automatically create an invoice")),i.createElement(b,null,"Current status: ",a))),i.createElement(_,null,i.createElement(x,{variant:"contained",onClick:function(e){"finalising_process"===a?(o&&o(),n()):"requested"===a&&(A("iros",[r]),l&&l(),n())}},"Yes"),i.createElement(x,{variant:"contained",onClick:n},"No")))}function $(t){var n=t.open,r=t.handleClose,a=t.orderID,o=t.revalidateCallback,c=e(l(""),2),m=c[0],u=c[1],s=e(l(""),2),d=s[0],v=s[1];return i.createElement("form",null,i.createElement(g,{open:n},i.createElement(y,null,"Cancel Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(b,null,"Are you sure you want to cancel this return?"),i.createElement(P,null,i.createElement(F,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(F,null,"Please provide a reason for the cancellation"),i.createElement(F,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(S,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return u(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),i.createElement(_,null,i.createElement(x,{variant:"contained",onClick:function(e){m.length<5?v("Please provide a reason for the cancellation"):(D("iros",a,m),o&&o(),r())}},"Yes"),i.createElement(x,{variant:"contained",onClick:r},"No"))))}function H(r){var a,g,_,h,y=r.data,A=r.sx,D=r.revalidateCallback;r.handleClose;var T=r.role,W=e(c(m,G),2),S=W[0],P=W[1],F=e(l(y.iro_items.data?y.iro_items.data:[]),2),Y=F[0],Q=F[1],H=e(l(!1),2),K=H[0],X=H[1],Z=e(l(!1),2),ee=Z[0],te=Z[1],ne=e(l(!1),2),re=ne[0],ae=ne[1],ie=e(l({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),2),le=ie[0],oe=ie[1],ce=e(l(["received","registered","released","reports"]),2),me=ce[0],ue=ce[1],se=function(n,r,a){var i=t([],e(Y),!1),l=i.findIndex((function(e){return e.id===r}));i[l][a]=n,Q(i)},de=function(r,a){var i,l,o,c=t([],e(Y),!1),m=c.findIndex((function(e){return e.id===a})),u=(null===(l=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===l?void 0:l.data)||[],s=t(t([],e(u),!1),[r],!1);null==(null===(o=c[m])||void 0===o?void 0:o.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=s,Q(c)},ve=function(n,r){var a,i,l=t([],e(Y),!1),o=l.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=l[o])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),u=c.filter((function(e){return!("id"in e)}));u.splice(r,1);var s=t(t([],e(m),!1),e(u),!1);l[o].reports.data=s,Q(l)};return o((function(){"Iro Updated"===(null==S?void 0:S.message)&&D&&D()}),[S]),o((function(){var e;console.log("data",y),(null===(e=y.iro_items)||void 0===e?void 0:e.data)&&Q(y.iro_items.data?y.iro_items.data:[])}),[y]),i.createElement(w,{sx:t([],e(Array.isArray(A)?A:[A]),!1)},i.createElement(C,{container:!0,spacing:2},i.createElement(C,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h3",component:"h1"},"Management Inbound Return"),i.createElement(b,{variant:"body1"},"Manage arrival, registration and release of returns")),i.createElement(v,{content:"",related:[{id:y.id,__type:"api::e-commerce.iro"}],revalidateCallback:D})),i.createElement(k,null))),i.createElement(C,{item:!0,xs:12},i.createElement(b,{variant:"h5",sx:{py:1}},"Details")),i.createElement(C,{item:!0,xs:6},i.createElement(q,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(O,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),i.createElement(b,{variant:"body1",fontWeight:"medium"},y.return_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(N,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),i.createElement(b,{variant:"body1",fontWeight:"medium"},y.rma_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),i.createElement(b,{variant:"body1",fontWeight:"medium"},y.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),i.createElement(b,{variant:"body1",fontWeight:"medium"},y.return_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(b,{variant:"body1",fontWeight:"medium"},null===(g=null===(a=y.customer)||void 0===a?void 0:a.business_credentials)||void 0===g?void 0:g.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(z,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),i.createElement(V,{status:y.status}))))),("requested"===y.status||"finalising_process"===y.status)&&"enduser"===T&&i.createElement(C,{item:!0,xs:6},i.createElement(q,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(x,{variant:"contained",color:"primary",onClick:function(){return X(!0)}},"Confirm order"),"requested"===y.status&&i.createElement(E,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"),"finalising_process"===y.status&&i.createElement(E,{severity:"warning"},"Please finalise this return order. Make sure the customer recieves a return payment if eligible and than confirm this step. Status: finalising_process - done"),"finalising_process"===y.status&&i.createElement(x,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),i.createElement(x,{variant:"contained",color:"error",onClick:function(){return te(!0)}},"Cancel order"),i.createElement(L,{open:K,handleClose:function(){return X(!1)},orderID:y.id,currentStatus:y.status,revalidateCallback:D,openOverwritesDialog:function(){return ae(!0)}}),i.createElement(J,{open:re,handleClose:function(){return ae(!1)},overwrites:le,setOverwrites:oe,iro:y}),i.createElement($,{open:ee,handleClose:function(){return te(!1)},orderID:y.id,revalidateCallback:D})))),i.createElement(C,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h5"},"Documents"),i.createElement(q,{sx:{p:2}},i.createElement(I,{spacing:1})))),(null===(h=null===(_=null==y?void 0:y.notes)||void 0===_?void 0:_.data)||void 0===h?void 0:h.length)>0&&i.createElement(C,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h5"},"Notes"),i.createElement(d,{notes:y.notes.data}),i.createElement(k,null))),i.createElement(C,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(b,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:q,p:1},i.createElement(b,{variant:"body1"},"Show:"),["received","registered","released","reports"].map((function(n){return i.createElement(j,{key:n,control:i.createElement(R,{checked:me.includes(n),onChange:function(r){r.target.checked?ue(t(t([],e(me),!1),[n],!1)):ue(me.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"requested"===y.status&&i.createElement(E,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(k,null),i.createElement("form",{action:P},i.createElement("input",{name:"id",type:"hidden",value:y.id}),Y&&Y.map((function(e,t){var n,r;return i.createElement(q,{sx:{p:2,mb:2},key:t},"requested"===y.status||"cancelled"===y.status||"done"===y.status?i.createElement(s,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):i.createElement(u,{item:e,index:t,handleUpdateQuantity:se,handleAddReport:de,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image,handleRemoveReportAtIndex:ve,revalidateCallback:D,showing:me}))})),i.createElement(q,{sx:{p:2}},i.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},i.createElement(f,{text:"Update items",loadingText:"Loading..."}),i.createElement(p,{error:null==S?void 0:S.strapiErrors}),(null==S?void 0:S.message)&&i.createElement(E,{severity:"error"},null==S?void 0:S.message))),i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(Y))}))))))}export{H as default};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as
|
|
7
|
+
import{__awaiter as e,__generator as o,__spreadArray as t,__read as r}from"../../../../node_modules/tslib/tslib.es6.js";import{getAuthToken as n}from"../get-token.js";import{getStrapiURL as s}from"../../../lib/utils.js";function i(i,a){return e(this,arguments,void 0,(function(e,i,a){var c,l,u,d,f,h;return void 0===a&&(a={}),o(this,(function(o){switch(o.label){case 0:return[4,n()];case 1:if(c=o.sent(),l=s(),u=new URL("api/".concat(e,"/confirm"),l),!c)throw new Error("No auth token found");d=JSON.stringify({data:{selectedIds:t([],r(i),!1),overwrites:a}}),console.log("payload",d),console.log("url",u),o.label=2;case 2:return o.trys.push([2,5,,6]),[4,fetch(u,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(c)},body:d})];case 3:return f=o.sent(),console.log(f),[4,f.json()];case 4:return[2,o.sent()];case 5:throw h=o.sent(),console.log("error",h),h;case 6:return[2]}}))}))}export{i as confirmationService};
|