woocommerce/packages/woocommerce-admin/dist/chunks/analytics-report-revenue.js

1 line
7.0 KiB
JavaScript
Raw Normal View History

2021-12-10 12:03:04 +00:00
(window.__wcAdmin_webpackJsonp=window.__wcAdmin_webpackJsonp||[]).push([[13],{481:function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return F}));var a=r(0),s=r(1),o=r.n(s),n=r(528),c=r(510),l=r(508),i=r(511),d=r(2),m=r(59),u=r(7),b=r(14),p=r(4),_=r(21),y=r(120),v=r(13),O=r(11),j=r(19),g=r(32),f=r(506),w=r(501);const h=[],R=["orders_count","gross_sales","total_sales","refunds","coupons","taxes","shipping","net_revenue"];class S extends a.Component{constructor(){super(),this.getHeadersContent=this.getHeadersContent.bind(this),this.getRowsContent=this.getRowsContent.bind(this),this.getSummary=this.getSummary.bind(this)}getHeadersContent(){return[{label:Object(d.__)("Date",'woocommerce'),key:"date",required:!0,defaultSort:!0,isLeftAligned:!0,isSortable:!0},{label:Object(d.__)("Orders",'woocommerce'),key:"orders_count",required:!1,isSortable:!0,isNumeric:!0},{label:Object(d.__)("Gross sales",'woocommerce'),key:"gross_sales",required:!1,isSortable:!0,isNumeric:!0},{label:Object(d.__)("Returns",'woocommerce'),key:"refunds",required:!1,isSortable:!0,isNumeric:!0},{label:Object(d.__)("Coupons",'woocommerce'),key:"coupons",required:!1,isSortable:!0,isNumeric:!0},{label:Object(d.__)("Net sales",'woocommerce'),key:"net_revenue",required:!1,isSortable:!0,isNumeric:!0},{label:Object(d.__)("Taxes",'woocommerce'),key:"taxes",required:!1,isSortable:!0,isNumeric:!0},{label:Object(d.__)("Shipping",'woocommerce'),key:"shipping",required:!1,isSortable:!0,isNumeric:!0},{label:Object(d.__)("Total sales",'woocommerce'),key:"total_sales",required:!1,isSortable:!0,isNumeric:!0}]}getRowsContent(e=[]){const t=Object(v.f)("dateFormat",j.defaultTableDateFormat),{formatAmount:r,render:s,formatDecimal:o,getCurrencyConfig:n}=this.context;return e.map(e=>{const{coupons:c,gross_sales:l,total_sales:i,net_revenue:d,orders_count:u,refunds:b,shipping:p,taxes:v}=e.subtotals,O=Object(a.createElement)(_.Link,{href:"edit.php?post_type=shop_order&m="+Object(m.format)("Ymd",e.date_start),type:"wp-admin"},Object(y.formatValue)(n(),"number",u));return[{display:Object(a.createElement)(_.Date,{date:e.date_start,visibleFormat:t}),value:e.date_start},{display:O,value:Number(u)},{display:s(l),value:o(l)},{display:r(b),value:o(b)},{display:r(c),value:o(c)},{display:s(d),value:o(d)},{display:s(v),value:o(v)},{display:s(p),value:o(p)},{display:s(i),value:o(i)}]})}getSummary(e,t=0){const{orders_count:r=0,gross_sales:a=0,total_sales:s=0,refunds:o=0,coupons:n=0,taxes:c=0,shipping:l=0,net_revenue:i=0}=e,{formatAmount:m,getCurrencyConfig:u}=this.context,b=u();return[{label:Object(d._n)("day","days",t,'woocommerce'),value:Object(y.formatValue)(b,"number",t)},{label:Object(d._n)("order","orders",r,'woocommerce'),value:Object(y.formatValue)(b,"number",r)},{label:Object(d.__)("Gross sales",'woocommerce'),value:m(a)},{label:Object(d.__)("Returns",'woocommerce'),value:m(o)},{label:Object(d.__)("Coupons",'woocommerce'),value:m(n)},{label:Object(d.__)("Net sales",'woocommerce'),value:m(i)},{label:Object(d.__)("Taxes",'woocommerce'),value:m(c)},{label:Object(d.__)("Shipping",'woocommerce'),value:m(l)},{label:Object(d.__)("Total sales",'woocommerce'),value:m(s)}]}render(){const{advancedFilters:e,filters:t,tableData:r,query:s}=this.props;return Object(a.createElement)(f.a,{endpoint:"revenue",getHeadersContent:this.getHeadersContent,getRowsContent:this.getRowsContent,getSummary:this.getSummary,summaryFields:R,query:s,tableData:r,title:Object(d.__)("Revenue",'woocommerce'),columnPrefsKey:"revenue_report_columns",filters:t,advancedFilters:e})}}S.contextType=w.a;const T=Object(p.memoize)((e,t,r,a)=>({tableData:{items:{data:Object(p.get)(a,["data","intervals"],h),totalResults:Object(p.get)(a,["totalResults"],0)},isError:e,isRequesting:t,query:r}}),(e,t,r,a)=>[e,t,Object(g.stringify)(r),Object(p.get)(a,["totalResults"],0),Object(p.get)(a,["data","intervals"],h).length].join(":")),q=Object(p.memoize)((e,t,r,a,s)=>({interval:"day",orderby:t,order:e,page:r,per_page:a,after:Object(j.appendTimestamp)(s.primary.after,"start"),before:Object(j.appendTimestamp)(s.primary.before,"end")}),(e,t