@railzai/railz-visualizations
Version:
Railz.ai Visualizations
7 lines • 10.3 kB
JavaScript
/*!
* Accounting Data as a Service™ is the solution that makes sense of your business customers' financial data.
* Built with Stencil
* Copyright (c) FIS.
*/
import{r as i,h as t}from"./p-a257e2b5.js";import{T as e}from"./p-dadb736f.js";import{i as o,p as s,R as l,e as n,g as a,C as r,a as d,b as h,v as c,c as v,h as u,d as p}from"./p-fb585e73.js";import{g as f}from"./p-81bde732.js";import{i as b}from"./p-a03ff4fe.js";import{i as g}from"./p-6c64b0b5.js";import"./p-ce5b13e7.js";import"./p-3d5262c3.js";import"./p-b93548b9.js";import"./p-7497d5a3.js";const m=["January","February","March","April","May","June","July","August","September","October","November","December"];const y=(i,t)=>{if(o(i)||o(t)||t===0){return null}return Math.round((i-t)/t*1e4)/100};const x=i=>{const t=new Date(i);const e=m[t.getMonth()];const o=`${e} ${t.getDate()}, ${t.getFullYear()}`;return o};const w=async({filter:i})=>{let t;try{const e=s(Object.assign({},i),["industryCode","region","connectionUuid"]);if(o(e===null||e===void 0?void 0:e.region))e===null||e===void 0?true:delete e.region;t=await l.getReportData({path:f[i.reportType],filter:e})}catch(i){n(e.RV_NOT_ABLE_TO_RETRIEVE_REPORT_DATA,i);t={error:i}}return t};const j='@font-face{font-family:Inter;src:url("../assets/fonts/Inter-italic-var.woff2");font-family:Inter;src:url("../assets/fonts/Inter-upright-var.woff2")}body,div[class^=railz-],div[class*=" railz-"]{font-family:Inter, Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"}.rv-container{display:flex;padding:16px;position:relative;border:1px solid #eee;border-radius:7px;flex-direction:column;justify-content:space-between;width:auto}.rv-container p{margin-block:0}.rv-container *{font-family:Inter, Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"}.rv-header-container{display:flex;flex-direction:row;justify-content:space-between}.rv-tax-benchmarking-container{width:100%;height:100%}.rv-title{display:flex;color:#015b7e;font-size:18px;font-weight:600;margin:0;padding:0;text-align:left;flex-grow:1;line-height:1.235;align-items:baseline}.rv-chart-percentage{visibility:inherit;-webkit-font-smoothing:antialiased;margin:0;line-height:1.5;display:flex;flex-direction:row;font-size:14px;font-weight:500;padding-left:8px}.rv-chart-percentage .rv-positive{color:#006037}.rv-chart-percentage .rv-negative{color:#b30000}.rv-score-last-updated{align-self:center;text-align:center;font-size:12px;color:#757575;font-weight:500;line-height:28px}.rv-tax-benchmarking-group{margin-top:24px}.rv-tax-benchmarking-business-info{display:flex;justify-content:space-between;font-size:12px;font-weight:600;color:#424242}.table-container{overflow-x:auto;width:100%}.benchmarking-table{border-collapse:collapse;width:100%;margin-top:24px}th,td{padding:16px;text-align:left}.table-header{font-size:12px;font-weight:600;color:#424242}.header-with-tooltip{display:flex}tr{border-bottom:1px solid #ddd}select{border:none;background-color:transparent;font-size:1rem;font-family:inherit;cursor:pointer}option{background-color:white;font-size:1rem;font-family:inherit}option:checked{font-weight:bold}';const k=(i,e)=>{var s,l,n,a;if(i<0){return t("div",{class:"rv-negative",style:(l=(s=e===null||e===void 0?void 0:e.chart)===null||s===void 0?void 0:s.pie)===null||l===void 0?void 0:l.negative},"▼ ",Math.abs(i),"%")}else{return t("div",{class:"rv-positive",style:(a=(n=e===null||e===void 0?void 0:e.chart)===null||n===void 0?void 0:n.pie)===null||a===void 0?void 0:a.positive},o(i)||isNaN(i)||Math.abs(i)===Infinity?"-":t("div",null,"▲ ",Math.abs(i),"%"))}};const O=class{constructor(t){i(this,t);this.loading="";this.updateTaxBenchmarkingParams=()=>{this.selectedLineItem=this._taxBenchmarkingData&&Object.keys(this._taxBenchmarkingData)[0];this.selectedCategory=this._taxBenchmarkingData&&Object.keys(this._taxBenchmarkingData[this.selectedLineItem])[0];this.lineItemOptions=Object.keys(this._taxBenchmarkingData);this.setCategoryOptions()};this.setCategoryOptions=()=>{this.categoryOptions=Object.keys(this._taxBenchmarkingData[this.selectedLineItem]);this.selectedCategory=this.categoryOptions[0];this.refreshTableData()};this.setSelectedLineItem=i=>{var t;this.selectedLineItem=(t=i===null||i===void 0?void 0:i.target)===null||t===void 0?void 0:t.value;this.setCategoryOptions()};this.setSelectedCategory=i=>{var t;this.selectedCategory=(t=i===null||i===void 0?void 0:i.target)===null||t===void 0?void 0:t.value;this.refreshTableData()};this.refreshTableData=()=>{if(this.selectedLineItem!==null&&this.selectedCategory!==null){const i=this._businessValuesData[this.selectedLineItem];const t=Object.entries(this._taxBenchmarkingData[this.selectedLineItem][this.selectedCategory]);const e=t.map((t=>({lineItemName:t[0],businessValue:i[t[0]],benchmarkValue:t[1],differencePercent:y(i[t[0]],t[1])})));this.tableData=e}};this.validateParams=async(i,t,o,s=true)=>{this._configuration=a(i);if(this._configuration){r.configuration=this._configuration;try{this._filter=d(t);this._options=h(o);if(c(this._filter)){if(v(this._filter.reportType)){if(s){await this.requestReportData()}}else{this.errorStatusCode=500;n(e.RV_ERROR_INVALID_REPORT_TYPE)}}else{this.errorStatusCode=204}}catch(i){this.errorStatusCode=500;n(i)}}else{this.errorStatusCode=0}};this.propsUpdated=async(i=true)=>{await this.validateParams(this.configuration,this.filter,this.options,i)};this.requestReportData=async()=>{this.errorStatusCode=undefined;this.loading=e.RV_LOADING_REPORT;try{const i=await w({filter:this._filter});if(!o(i===null||i===void 0?void 0:i.taxBenchmarkingData)&&!o(i===null||i===void 0?void 0:i.businessValues)){this._data=i;this._taxBenchmarkingData=i===null||i===void 0?void 0:i.taxBenchmarkingData;this._businessValuesData=i===null||i===void 0?void 0:i.businessValues;this.updateTaxBenchmarkingParams()}else{this.errorStatusCode=u(i)}}catch(i){n(e.RV_NOT_ABLE_TO_PARSE_REPORT_DATA,i)}finally{this.loading=""}}}async watchConfiguration(i,t){if(i&&t&&!b(t,i)){await this.validateParams(i,this.filter,this.options)}}async watchFilter(i,t){if(i&&t&&!b(t,i)){await this.validateParams(this.configuration,i,this.options)}}async watchOptions(i,t){if(i&&t&&!b(t,i)){await this.validateParams(this.configuration,this.filter,i)}}componentWillLoad(){this.propsUpdated&&this.propsUpdated()}render(){var i,o,s,l;const n=()=>{var i,e,o,s,l;return t("p",{class:"rv-title",style:(e=(i=this._options)===null||i===void 0?void 0:i.title)===null||e===void 0?void 0:e.style},((s=(o=this._options)===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.title)||p((l=this._filter)===null||l===void 0?void 0:l.reportType)||""," ")};const a=()=>{var i,o,s,l,n,a,r,d,h,c,v,u,p,f,b,m,y,w,j,O;if(g(this.loading)&&this.errorStatusCode===undefined&&g((i=this._data)===null||i===void 0?void 0:i.taxBenchmarkingData)&&g((o=this._data)===null||o===void 0?void 0:o.businessValues)){this.errorStatusCode=204}if(this.errorStatusCode!==undefined){return t("railz-error-image",Object.assign({statusCode:this.errorStatusCode||500},(s=this._options)===null||s===void 0?void 0:s.errorIndicator))}if(!g(this.loading)){return t("railz-loading",Object.assign({loadingText:this.loading},(l=this._options)===null||l===void 0?void 0:l.loadingIndicator))}return t("div",{class:"rv-tax-benchmarking-container"},t("div",{class:"rv-tax-benchmarking-group"},t("div",{class:"rv-tax-benchmarking-business-info"},t("div",null,"Current Business:"," ",t("span",{style:{color:"#111111"}},g(this.loading)&&((a=(n=this._data)===null||n===void 0?void 0:n.meta)===null||a===void 0?void 0:a.businessName))),t("div",null,"As of ",g(this.loading)&&x((d=(r=this._data)===null||r===void 0?void 0:r.meta)===null||d===void 0?void 0:d.endDate))),t("div",{class:"table-container"},t("table",{class:"benchmarking-table",id:"benchmarking-table"},t("thead",null,t("tr",null,t("th",null,t("div",{class:"table-header"},"Line Item ","-",t("select",{onChange:this.setSelectedLineItem},this.lineItemOptions.map((i=>t("option",{selected:this.selectedLineItem===i,value:i},i)))))),t("th",null,t("div",{class:"header-with-tooltip table-header"},"Business Value"," ",t("railz-tooltip",{tooltipStyle:Object.assign(Object.assign({position:"bottom-center"},(h=this._options)===null||h===void 0?void 0:h.tooltipIndicator),{style:Object.assign({marginLeft:"6px"},(v=(c=this._options)===null||c===void 0?void 0:c.tooltipIndicator)===null||v===void 0?void 0:v.style)}),tooltipText:((f=(p=(u=this._options)===null||u===void 0?void 0:u.content)===null||p===void 0?void 0:p.tooltip)===null||f===void 0?void 0:f.description)||e.RV_TOOLTIP_TAX_BENCHMARKING_BUSINESS_VALUE}))),t("th",null,t("div",{class:"header-with-tooltip table-header"},"Benchmark Value"," ",t("railz-tooltip",{tooltipStyle:Object.assign(Object.assign({position:"bottom-center"},(b=this._options)===null||b===void 0?void 0:b.tooltipIndicator),{style:Object.assign({marginLeft:"6px"},(y=(m=this._options)===null||m===void 0?void 0:m.tooltipIndicator)===null||y===void 0?void 0:y.style)}),tooltipText:((O=(j=(w=this._options)===null||w===void 0?void 0:w.content)===null||j===void 0?void 0:j.tooltip)===null||O===void 0?void 0:O.description)||e.RV_TOOLTIP_TAX_BENCHMARKING_BENCHMARK_VALUE}))),t("th",null,t("div",{class:"table-header"},t("select",{onChange:this.setSelectedCategory},this.categoryOptions.map((i=>t("option",{selected:this.selectedCategory===i,value:i},i)))))))),t("tbody",null,this.tableData.map((i=>t("tr",null,t("td",null,i.lineItemName),t("td",null,i.businessValue||"-"),t("td",null,i.benchmarkValue),t("td",null,t("div",{class:"rv-chart-percentage"},k(i.differencePercent,{})))))))))))};return t("div",{class:"rv-container",style:(o=(i=this._options)===null||i===void 0?void 0:i.container)===null||o===void 0?void 0:o.style},t("div",{class:"rv-header-container"},((l=(s=this._options)===null||s===void 0?void 0:s.title)===null||l===void 0?void 0:l.visible)===false?"":t(n,null)),a())}static get watchers(){return{configuration:["watchConfiguration"],filter:["watchFilter"],options:["watchOptions"]}}};O.style=j;export{O as railz_tax_benchmarking};
//# sourceMappingURL=p-f59316d5.entry.js.map