관리-도구
편집 파일: analytics-report-taxes.js
(window.__wcAdmin_webpackJsonp=window.__wcAdmin_webpackJsonp||[]).push([[22],{749:function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return L}));var a=r(5),n=r.n(a),o=r(17),i=r.n(o),c=r(15),s=r.n(c),u=r(18),l=r.n(u),d=r(19),m=r.n(d),p=r(9),f=r.n(p),y=r(0),b=r(1),g=r.n(b),h=r(3),v=r(790),_=r(768),O=r(766),j=r(769),R=r(11),x=r.n(R),w=r(2),C=r(77),q=r(32),D=r(298),k=r(765),S=r(771),E=r(762);function P(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,a=f()(e);if(t){var n=f()(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return m()(this,r)}}var T=function(e){l()(r,e);var t=P(r);function r(){var e;return i()(this,r),(e=t.call(this)).getHeadersContent=e.getHeadersContent.bind(x()(e)),e.getRowsContent=e.getRowsContent.bind(x()(e)),e.getSummary=e.getSummary.bind(x()(e)),e}return s()(r,[{key:"getHeadersContent",value:function(){return[{label:Object(h.__)("Tax Code",'kkart'),key:"tax_code",required:!0,isLeftAligned:!0,isSortable:!0},{label:Object(h.__)("Rate",'kkart'),key:"rate",isSortable:!0,isNumeric:!0},{label:Object(h.__)("Total Tax",'kkart'),key:"total_tax",isSortable:!0},{label:Object(h.__)("Order Tax",'kkart'),key:"order_tax",isSortable:!0},{label:Object(h.__)("Shipping Tax",'kkart'),key:"shipping_tax",isSortable:!0},{label:Object(h.__)("Orders",'kkart'),key:"orders_count",required:!0,defaultSort:!0,isSortable:!0,isNumeric:!0}]}},{key:"getRowsContent",value:function(e){var t=this,r=this.context,a=r.render,n=r.formatDecimal,o=r.getCurrencyConfig;return Object(w.map)(e,(function(e){var r=t.props.query,i=e.order_tax,c=e.orders_count,s=e.tax_rate,u=e.tax_rate_id,l=e.total_tax,d=e.shipping_tax,m=Object(k.a)(e),p=Object(q.getPersistedQuery)(r),f=Object(q.getNewPath)(p,"/analytics/orders",{filter:"advanced",tax_rate_includes:u});return[{display:Object(y.createElement)(C.Link,{href:f,type:"kkart-admin"},m),value:m},{display:s.toFixed(2)+"%",value:s},{display:a(l),value:n(l)},{display:a(i),value:n(i)},{display:a(d),value:n(d)},{display:Object(D.formatValue)(o(),"number",c),value:c}]}))}},{key:"getSummary",value:function(e){var t=e.tax_codes,r=void 0===t?0:t,a=e.total_tax,n=void 0===a?0:a,o=e.order_tax,i=void 0===o?0:o,c=e.shipping_tax,s=void 0===c?0:c,u=e.orders_count,l=void 0===u?0:u,d=this.context,m=d.formatAmount,p=(0,d.getCurrencyConfig)();return[{label:Object(h._n)("tax code","tax codes",r,'kkart'),value:Object(D.formatValue)(p,"number",r)},{label:Object(h.__)("total tax",'kkart'),value:m(n)},{label:Object(h.__)("order tax",'kkart'),value:m(i)},{label:Object(h.__)("shipping tax",'kkart'),value:m(s)},{label:Object(h._n)("order","orders",l,'kkart'),value:Object(D.formatValue)(p,"number",l)}]}},{key:"render",value:function(){var e=this.props,t=e.advancedFilters,r=e.filters,a=e.isRequesting,n=e.query;return Object(y.createElement)(S.a,{compareBy:"taxes",endpoint:"taxes",getHeadersContent:this.getHeadersContent,getRowsContent:this.getRowsContent,getSummary:this.getSummary,summaryFields:["tax_codes","total_tax","order_tax","shipping_tax","orders_count"],isRequesting:a,itemIdField:"tax_rate_id",query:n,searchBy:"taxes",tableQuery:{orderby:n.orderby||"tax_rate_id"},title:Object(h.__)("Taxes",'kkart'),columnPrefsKey:"taxes_report_columns",filters:r,advancedFilters:t})}}]),r}(y.Component);T.contextType=E.a;var F=T,A=r(770);function N(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function M(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,a=f()(e);if(t){var n=f()(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return m()(this,r)}}var L=function(e){l()(r,e);var t=M(r);function r(){return i()(this,r),t.apply(this,arguments)}return s()(r,[{key:"getChartMeta",value:function(){var e="compare-taxes"===this.props.query.filter?"item-comparison":"time-comparison";return{itemsLabel:Object(h.__)("%d taxes",'kkart'),mode:e}}},{key:"render",value:function(){var e=this.props,t=e.isRequesting,r=e.query,a=e.path,o=this.getChartMeta(),i=o.mode,c=o.itemsLabel,s=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?N(Object(r),!0).forEach((function(t){n()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):N(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},r);return"item-comparison"===i&&(s.segmentby="tax_rate_id"),Object(y.createElement)(y.Fragment,null,Object(y.createElement)(A.a,{query:r,path:a,filters:v.c,advancedFilters:v.a,report:"taxes"}),Object(y.createElement)(j.a,{charts:v.b,endpoint:"taxes",isRequesting:t,query:s,selectedChart:Object(_.a)(r.chart,v.b),filters:v.c,advancedFilters:v.a}),Object(y.createElement)(O.a,{charts:v.b,filters:v.c,advancedFilters:v.a,mode:i,endpoint:"taxes",query:s,path:a,isRequesting:t,itemsLabel:c,selectedChart:Object(_.a)(r.chart,v.b)}),Object(y.createElement)(F,{isRequesting:t,query:r,filters:v.c,advancedFilters:v.a}))}}]),r}(y.Component);L.propTypes={query:g.a.object.isRequired}},764:function(e,t,r){"use strict";r.d(t,"e",(function(){return d})),r.d(t,"a",(function(){return m})),r.d(t,"b",(function(){return p})),r.d(t,"c",(function(){return f})),r.d(t,"d",(function(){return y})),r.d(t,"f",(function(){return b})),r.d(t,"h",(function(){return g})),r.d(t,"g",(function(){return h}));var a=r(37),n=r(43),o=r.n(n),i=r(2),c=r(32),s=r(35),u=r(36),l=r(765);function d(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.identity;return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0,i="function"==typeof e?e(n):e,s=Object(c.getIdsFromQuery)(r);if(s.length<1)return Promise.resolve([]);var u={include:s.join(","),per_page:s.length};return o()({path:Object(a.addQueryArgs)(i,u)}).then((function(e){return e.map(t)}))}}var m=d(s.NAMESPACE+"/products/categories",(function(e){return{key:e.id,label:e.name}})),p=d(s.NAMESPACE+"/coupons",(function(e){return{key:e.id,label:e.code}})),f=d(s.NAMESPACE+"/customers",(function(e){return{key:e.id,label:e.name}})),y=d(s.NAMESPACE+"/products",(function(e){return{key:e.id,label:e.name}})),b=d(s.NAMESPACE+"/taxes",(function(e){return{key:e.id,label:Object(l.a)(e)}}));function g(e){var t=e.attributes,r=e.name,a=Object(u.g)("variationTitleAttributesSeparator"," - ");if(r.indexOf(a)>-1)return r;var n=t.map((function(e){return e.option})).join(", ");return n?r+a+n:r}var h=d((function(e){var t=e.products;return t?s.NAMESPACE+"/products/".concat(t,"/variations"):s.NAMESPACE+"/variations"}),(function(e){return{key:e.id,label:g(e)}}))},765:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var a=r(3);function n(e){return[e.country,e.state,e.name||Object(a.__)("TAX",'kkart'),e.priority].map((function(e){return e.toString().toUpperCase().trim()})).filter(Boolean).join("-")}},766:function(e,t,r){"use strict";var a=r(5),n=r.n(a),o=r(17),i=r.n(o),c=r(15),s=r.n(c),u=r(18),l=r.n(u),d=r(19),m=r.n(d),p=r(9),f=r.n(p),y=r(0),b=r(3),g=r(277),h=r(154),v=r(20),_=r(2),O=r(1),j=r.n(O),R=r(77),x=r(35),w=r(40),C=r(762),q=r(763),D=r(32);function k(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?k(Object(r),!0).forEach((function(t){n()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):k(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function E(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,a=f()(e);if(t){var n=f()(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return m()(this,r)}}var P=function(e){l()(r,e);var t=E(r);function r(){return i()(this,r),t.apply(this,arguments)}return s()(r,[{key:"shouldComponentUpdate",value:function(e){return e.isRequesting!==this.props.isRequesting||e.primaryData.isRequesting!==this.props.primaryData.isRequesting||e.secondaryData.isRequesting!==this.props.secondaryData.isRequesting||!Object(_.isEqual)(e.query,this.props.query)}},{key:"getItemChartData",value:function(){var e=this.props,t=e.primaryData,r=e.selectedChart;return t.data.intervals.map((function(e){var t={};return e.subtotals.segments.forEach((function(e){if(e.segment_label){var a=t[e.segment_label]?e.segment_label+" (#"+e.segment_id+")":e.segment_label;t[e.segment_id]={label:a,value:e.subtotals[r.key]||0}}})),S({date:Object(h.a)("Y-m-d\\TH:i:s",e.date_start)},t)}))}},{key:"getTimeChartData",value:function(){var e=this.props,t=e.query,r=e.primaryData,a=e.secondaryData,n=e.selectedChart,o=e.defaultDateRange,i=Object(w.getIntervalForQuery)(t),c=Object(w.getCurrentDates)(t,o),s=c.primary,u=c.secondary;return r.data.intervals.map((function(e,r){var o=Object(w.getPreviousDate)(e.date_start,s.after,u.after,t.compare,i),c=a.data.intervals[r];return{date:Object(h.a)("Y-m-d\\TH:i:s",e.date_start),primary:{label:"".concat(s.label," (").concat(s.range,")"),labelDate:e.date_start,value:e.subtotals[n.key]||0},secondary:{label:"".concat(u.label," (").concat(u.range,")"),labelDate:o.format("YYYY-MM-DD HH:mm:ss"),value:c&&c.subtotals[n.key]||0}}}))}},{key:"getTimeChartTotals",value:function(){var e=this.props,t=e.primaryData,r=e.secondaryData,a=e.selectedChart;return{primary:Object(_.get)(t,["data","totals",a.key],null),secondary:Object(_.get)(r,["data","totals",a.key],null)}}},{key:"renderChart",value:function(e,t,r,a){var n=this.props,o=n.emptySearchResults,i=n.filterParam,c=n.interactiveLegend,s=n.itemsLabel,u=n.legendPosition,l=n.path,d=n.query,m=n.selectedChart,p=n.showHeaderControls,f=n.primaryData,g=Object(w.getIntervalForQuery)(d),h=Object(w.getAllowedIntervalsForQuery)(d),v=Object(w.getDateFormatsForInterval)(g,f.data.intervals.length),_=o?Object(b.__)("No data for the current search",'kkart'):Object(b.__)("No data for the selected date range",'kkart'),O=this.context,j=O.formatAmount,C=O.getCurrencyConfig;return Object(y.createElement)(R.Chart,{allowedIntervals:h,data:r,dateParser:"%Y-%m-%dT%H:%M:%S",emptyMessage:_,filterParam:i,interactiveLegend:c,interval:g,isRequesting:t,itemsLabel:s,legendPosition:u,legendTotals:a,mode:e,path:l,query:d,screenReaderFormat:v.screenReaderFormat,showHeaderControls:p,title:m.label,tooltipLabelFormat:v.tooltipLabelFormat,tooltipTitle:"time-comparison"===e&&m.label||null,tooltipValueFormat:Object(x.getTooltipValueFormat)(m.type,j),chartType:Object(w.getChartTypeForQuery)(d),valueType:m.type,xFormat:v.xFormat,x2Format:v.x2Format,currency:C()})}},{key:"renderItemComparison",value:function(){var e=this.props,t=e.isRequesting,r=e.primaryData;if(r.isError)return Object(y.createElement)(q.a,{isError:!0});var a=t||r.isRequesting,n=this.getItemChartData();return this.renderChart("item-comparison",a,n)}},{key:"renderTimeComparison",value:function(){var e=this.props,t=e.isRequesting,r=e.primaryData,a=e.secondaryData;if(!r||r.isError||a.isError)return Object(y.createElement)(q.a,{isError:!0});var n=t||r.isRequesting||a.isRequesting,o=this.getTimeChartData(),i=this.getTimeChartTotals();return this.renderChart("time-comparison",n,o,i)}},{key:"render",value:function(){return"item-comparison"===this.props.mode?this.renderItemComparison():this.renderTimeComparison()}}]),r}(y.Component);P.contextType=C.a,P.propTypes={filters:j.a.array,isRequesting:j.a.bool,itemsLabel:j.a.string,limitProperties:j.a.array,mode:j.a.string,path:j.a.string.isRequired,primaryData:j.a.object,query:j.a.object.isRequired,secondaryData:j.a.object,selectedChart:j.a.shape({key:j.a.string.isRequired,label:j.a.string.isRequired,order:j.a.oneOf(["asc","desc"]),orderby:j.a.string,type:j.a.oneOf(["average","number","currency"]).isRequired}).isRequired},P.defaultProps={isRequesting:!1,primaryData:{data:{intervals:[]},isError:!1,isRequesting:!1},secondaryData:{data:{intervals:[]},isError:!1,isRequesting:!1}};t.a=Object(g.a)(Object(v.withSelect)((function(e,t){var r=t.charts,a=t.endpoint,n=t.filters,o=t.isRequesting,i=t.limitProperties,c=t.query,s=t.advancedFilters,u=i||[a],l=function e(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t||0===t.length)return null;var n=t.slice(0),o=n.pop();if(o.showFilters(r,a)){var i=Object(D.flattenFilters)(o.filters),c=r[o.param]||o.defaultValue||"all";return Object(_.find)(i,{value:c})}return e(n,r,a)}(n,c),d=Object(_.get)(l,["settings","param"]),m=t.mode||function(e,t){if(e&&t){var r=Object(_.get)(e,["settings","param"]);if(!r||Object.keys(t).includes(r))return Object(_.get)(e,["chartMode"])}return null}(l,c)||"time-comparison",p=e(x.SETTINGS_STORE_NAME).getSetting("kkart_admin","wcAdminSettings").kkart_default_date_range,f={mode:m,filterParam:d,defaultDateRange:p};if(o)return f;var y=u.some((function(e){return c[e]&&c[e].length}));if(c.search&&!y)return S(S({},f),{},{emptySearchResults:!0});var b=r&&r.map((function(e){return e.key})),g=Object(x.getReportChartData)({endpoint:a,dataType:"primary",query:c,select:e,limitBy:u,filters:n,advancedFilters:s,defaultDateRange:p,fields:b});if("item-comparison"===m)return S(S({},f),{},{primaryData:g});var h=Object(x.getReportChartData)({endpoint:a,dataType:"secondary",query:c,select:e,limitBy:u,filters:n,advancedFilters:s,defaultDateRange:p,fields:b});return S(S({},f),{},{primaryData:g,secondaryData:h})})))(P)},768:function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));var a=r(2);function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=Object(a.find)(t,{key:e});return r||t[0]}},769:function(e,t,r){"use strict";var a=r(17),n=r.n(a),o=r(15),i=r.n(o),c=r(18),s=r.n(c),u=r(19),l=r.n(u),d=r(9),m=r.n(d),p=r(0),f=r(3),y=r(277),b=r(20),g=r(1),h=r.n(g),v=r(32),_=r(77),O=r(298),j=r(35),R=r(40),x=r(64),w=r(763),C=r(762);function q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,a=m()(e);if(t){var n=m()(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return l()(this,r)}}var D=function(e){s()(r,e);var t=q(r);function r(){return n()(this,r),t.apply(this,arguments)}return i()(r,[{key:"formatVal",value:function(e,t){var r=this.context,a=r.formatAmount,n=r.getCurrencyConfig;return"currency"===t?a(e):Object(O.formatValue)(n(),t,e)}},{key:"getValues",value:function(e,t){var r=this.props,a=r.emptySearchResults,n=r.summaryData.totals,o=n.primary?n.primary[e]:0,i=n.secondary?n.secondary[e]:0,c=a?0:o,s=a?0:i;return{delta:Object(O.calculateDelta)(c,s),prevValue:this.formatVal(s,t),value:this.formatVal(c,t)}}},{key:"render",value:function(){var e=this,t=this.props,r=t.charts,a=t.query,n=t.selectedChart,o=t.summaryData,i=t.endpoint,c=t.report,s=t.defaultDateRange,u=o.isError,l=o.isRequesting;if(u)return Object(p.createElement)(w.a,{isError:!0});if(l)return Object(p.createElement)(_.SummaryListPlaceholder,{numberOfItems:r.length});var d=Object(R.getDateParamsFromQuery)(a,s).compare;return Object(p.createElement)(_.SummaryList,null,(function(t){var a=t.onToggle;return r.map((function(t){var r=t.key,o=t.order,s=t.orderby,u=t.label,l=t.type,m={chart:r};s&&(m.orderby=s),o&&(m.order=o);var y=Object(v.getNewPath)(m),b=n.key===r,g=e.getValues(r,l),h=g.delta,O=g.prevValue,j=g.value;return Object(p.createElement)(_.SummaryNumber,{key:r,delta:h,href:y,label:u,prevLabel:"previous_period"===d?Object(f.__)("Previous Period:",'kkart'):Object(f.__)("Previous Year:",'kkart'),prevValue:O,selected:b,value:j,onLinkClickCallback:function(){a&&a(),Object(x.recordEvent)("analytics_chart_tab_click",{report:c||i,key:r})}})}))}))}}]),r}(p.Component);D.propTypes={charts:h.a.array.isRequired,endpoint:h.a.string.isRequired,limitProperties:h.a.array,query:h.a.object.isRequired,selectedChart:h.a.shape({key:h.a.string.isRequired,label:h.a.string.isRequired,order:h.a.oneOf(["asc","desc"]),orderby:h.a.string,type:h.a.oneOf(["average","number","currency"]).isRequired}).isRequired,summaryData:h.a.object,report:h.a.string},D.defaultProps={summaryData:{totals:{primary:{},secondary:{}},isError:!1}},D.contextType=C.a,t.a=Object(y.a)(Object(b.withSelect)((function(e,t){var r=t.charts,a=t.endpoint,n=t.limitProperties,o=t.query,i=t.filters,c=t.advancedFilters,s=n||[a],u=s.some((function(e){return o[e]&&o[e].length}));if(o.search&&!u)return{emptySearchResults:!0};var l=r&&r.map((function(e){return e.key})),d=e(j.SETTINGS_STORE_NAME).getSetting("kkart_admin","wcAdminSettings").kkart_default_date_range;return{summaryData:Object(j.getSummaryNumbers)({endpoint:a,query:o,select:e,limitBy:s,filters:i,advancedFilters:c,defaultDateRange:d,fields:l}),defaultDateRange:d}})))(D)},790:function(e,t,r){"use strict";r.d(t,"b",(function(){return s})),r.d(t,"c",(function(){return u})),r.d(t,"a",(function(){return l}));var a=r(3),n=r(55),o=r(35),i=r(764),c=r(765),s=Object(n.applyFilters)("kkart_admin_taxes_report_charts",[{key:"total_tax",label:Object(a.__)("Total Tax",'kkart'),order:"desc",orderby:"total_tax",type:"currency"},{key:"order_tax",label:Object(a.__)("Order Tax",'kkart'),order:"desc",orderby:"order_tax",type:"currency"},{key:"shipping_tax",label:Object(a.__)("Shipping Tax",'kkart'),order:"desc",orderby:"shipping_tax",type:"currency"},{key:"orders_count",label:Object(a.__)("Orders",'kkart'),order:"desc",orderby:"orders_count",type:"number"}]),u=Object(n.applyFilters)("kkart_admin_taxes_report_filters",[{label:Object(a.__)("Show",'kkart'),staticParams:["chartType","paged","per_page"],param:"filter",showFilters:function(){return!0},filters:[{label:Object(a.__)("All Taxes",'kkart'),value:"all"},{label:Object(a.__)("Comparison",'kkart'),value:"compare-taxes",chartMode:"item-comparison",settings:{type:"taxes",param:"taxes",getLabels:Object(i.e)(o.NAMESPACE+"/taxes",(function(e){return{id:e.id,key:e.id,label:Object(c.a)(e)}})),labels:{helpText:Object(a.__)("Check at least two tax codes below to compare",'kkart'),placeholder:Object(a.__)("Search for tax codes to compare",'kkart'),title:Object(a.__)("Compare Tax Codes",'kkart'),update:Object(a.__)("Compare",'kkart')}}}]}]),l=Object(n.applyFilters)("kkart_admin_taxes_report_advanced_filters",{})}}]);