whoami7 - Manager
:
/
home
/
qbizpnmr
/
arif.umairtax.com
/
public
/
Upload File:
files >> //home/qbizpnmr/arif.umairtax.com/public/useProductColumns-CRexQ0gt.js
import{u as y,y as k,ap as O,cB as q,cC as A,j as a,bq as B,i as D,bj as M,p as h,be as V,cD as b,cE as z,cF as H,a as R,t as T,by as g,cz as S,cy as K,cx as U,w as G,C as J,ay as Q,cG as X,bF as Y,b2 as Z,cH as P,cI as E}from"./bundle.OlIVtvc7.js";import{I as v}from"./InvoiceViewer-Dp83-peG.js";function W(){var t,l;const[e]=y(),n=k(),{isOwner:i}=O();return!q()&&!A()&&i?a.jsxs("div",{className:"flex text-base space-x-1",children:[a.jsx(B,{className:"capitalize",to:((t=n==null?void 0:n.company_user)==null?void 0:t.ninja_portal_url)||D("/settings/account_management"),setBaseFont:!0,external:!!((l=n==null?void 0:n.company_user)!=null&&l.ninja_portal_url),children:e("click_here")}),a.jsxs("span",{children:[M("pro_plan_remove_logo",{link:""}),"."]})]}):null}function ue(e){const[n,i]=h.useState(!1),[t,l]=h.useState(e.resource),r=e.endpoint||"/api/v1/live_preview?entity=:entity",d=h.useRef(null),m=h.useRef(!1),u=h.useRef(!1),s=h.useRef(null),x=h.useRef(!1);return h.useEffect(()=>{const _=setTimeout(()=>{l(e.resource)},1e3);return()=>clearTimeout(_)},[e.resource]),h.useEffect(()=>{if(!e.observable)return;const _=V.debounce(()=>{m.current=!0,u.current&&i(!0)},1e3),f=()=>{_()};window.addEventListener("mousedown",f);const o=new IntersectionObserver(j=>{j.forEach(C=>{s.current&&(clearTimeout(s.current),s.current=null),C.isIntersecting?s.current=setTimeout(()=>{if(u.current=!0,!x.current){x.current=!0,i(!0);return}m.current&&(i(!0),m.current=!1)},1e3):(u.current=!1,i(!1))})},{threshold:.3,rootMargin:"0px"});return d.current&&o.observe(d.current),()=>{window.removeEventListener("mousedown",f),_.cancel(),o.disconnect(),s.current&&clearTimeout(s.current)}},[d.current,e.observable]),t!=null&&t[e.relationType]&&e.for==="create"?a.jsx("div",{ref:d,children:a.jsx(v,{link:b(r,{entity:e.entity}),resource:t,method:"POST",enabled:e.observable?n:!0})}):t!=null&&t.id&&(t!=null&&t[e.relationType])&&e.entity==="purchase_order"?a.jsxs("div",{className:"flex flex-col space-y-3",children:[a.jsx(v,{link:b("/api/v1/live_preview/purchase_order?entity=:entity&entity_id=:id",{entity:e.entity,id:t==null?void 0:t.id}),resource:t,method:"POST",enabled:e.observable?n:!0}),e.withRemoveLogoCTA&&a.jsx(W,{})]}):t!=null&&t.id&&(t!=null&&t[e.relationType])&&e.for==="invoice"?a.jsxs("div",{className:"flex flex-col space-y-3",children:[a.jsx("div",{ref:d,children:a.jsx(v,{link:b("/api/v1/live_preview?entity=:entity&entity_id=:id",{entity:e.entity,id:t==null?void 0:t.id}),method:"POST",resource:t,enabled:e.observable?n:!0})}),e.withRemoveLogoCTA&&a.jsx(W,{})]}):a.jsx(a.Fragment,{})}/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://opensource.org/licenses/AAL */function ee(e){const[n,i]=e.split("$");return{dollar:n,property:i}}function te(e){const n=e.resource,i=e.invoiceSum,t=z(),l=H({resource:e.resource,relationType:e.relationType});R();const r=T(),d=(u,s)=>{e.onChange(u,s)},m={total:"amount",outstanding:"balance"};return u=>{let s=0;const{property:x}=ee(u),_=m[x]||x;return u=="$net_subtotal"&&i?a.jsx(g,{leftSide:t(u,"$"),className:"py-5",noVerticalPadding:!0,noExternalPadding:!0,pushContentToRight:!0,withoutWrappingLeftSide:!0,children:a.jsx("span",{className:"text-sm font-medium font-mono",children:l(i.subTotal)})}):u=="$discount"&&i?i.totalDiscount!=0?a.jsx(g,{leftSide:t(u,"$"),className:"py-5",noVerticalPadding:!0,noExternalPadding:!0,pushContentToRight:!0,withoutWrappingLeftSide:!0,children:a.jsx("span",{className:"text-sm font-medium font-mono",children:l(i.totalDiscount)})}):"":u=="$subtotal"&&i?a.jsx(g,{leftSide:t(u,"$"),className:"py-5",noVerticalPadding:!0,noExternalPadding:!0,pushContentToRight:!0,withoutWrappingLeftSide:!0,children:a.jsx("span",{className:"text-sm font-medium font-mono",children:l(i.subTotal)})}):u=="$taxes"&&i?i.getTaxMap().count()>0?a.jsx(a.Fragment,{children:i.getTaxMap().map((f,o)=>a.jsx(g,{leftSide:f.name,className:"py-5",noVerticalPadding:!0,noExternalPadding:!0,pushContentToRight:!0,withoutWrappingLeftSide:!0,children:a.jsx("span",{className:"text-sm font-medium font-mono",children:l(f.total)})},o))}):null:u=="$total"&&i?a.jsx(g,{leftSide:t(u,"$"),className:"py-5",noVerticalPadding:!0,noExternalPadding:!0,pushContentToRight:!0,withoutWrappingLeftSide:!0,children:a.jsx("span",{className:"text-sm font-medium font-mono",children:l(i.total)})}):u=="$paid_to_date"&&i?a.jsx(g,{leftSide:t(u,"$"),className:"py-5",noVerticalPadding:!0,noExternalPadding:!0,pushContentToRight:!0,withoutWrappingLeftSide:!0,children:a.jsx("span",{className:"text-sm font-medium font-mono",children:l(i.invoice.paid_to_date)})}):u=="$balance_due"&&i?a.jsx(g,{leftSide:t(u,"$"),className:"py-5",noVerticalPadding:!0,noExternalPadding:!0,pushContentToRight:!0,withoutWrappingLeftSide:!0,children:a.jsx("span",{className:"text-sm font-medium font-mono",children:l(i.getBalanceDue())})}):u==="$custom_surcharge1"?a.jsx(S,{field:"surcharge1",defaultValue:(n==null?void 0:n.custom_surcharge1)||"",value:(r==null?void 0:r.custom_fields.surcharge1)||"",onValueChange:f=>d("custom_surcharge1",f)}):u==="$custom_surcharge2"?a.jsx(S,{field:"surcharge2",defaultValue:(n==null?void 0:n.custom_surcharge2)||"",value:(r==null?void 0:r.custom_fields.surcharge2)||"",onValueChange:f=>d("custom_surcharge2",f)}):u==="$custom_surcharge3"?a.jsx(S,{field:"surcharge3",defaultValue:(n==null?void 0:n.custom_surcharge3)||"",value:(r==null?void 0:r.custom_fields.surcharge3)||"",onValueChange:f=>d("custom_surcharge3",f)}):u==="$custom_surcharge4"?a.jsx(S,{field:"surcharge4",defaultValue:(n==null?void 0:n.custom_surcharge4)||"",value:(r==null?void 0:r.custom_fields.surcharge4)||"",onValueChange:f=>d("custom_surcharge4",f)}):(n&&(s=n[_]??0),a.jsx(g,{leftSide:t(_,"$"),className:"py-5",noVerticalPadding:!0,noExternalPadding:!0,pushContentToRight:!0,withoutWrappingLeftSide:!0,children:a.jsx("span",{className:"text-sm font-medium font-mono",children:l(s)})}))}}/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function ne(){const e=T(),[n,i]=h.useState([]);return h.useEffect(()=>{var l,r,d,m;if((e==null?void 0:e.settings.pdf_variables.total_columns.length)>0){const u=V.cloneDeep(e==null?void 0:e.settings.pdf_variables.total_columns);(e==null?void 0:e.enabled_tax_rates)>0&&u.push("$tax1"),(e==null?void 0:e.enabled_tax_rates)>1&&u.push("$tax2"),(e==null?void 0:e.enabled_tax_rates)>2&&u.push("$tax3"),u.forEach((x,_)=>{(x==="$line_taxes"||x==="$total_taxes")&&(u[_]="$taxes")});const s=u.filter((x,_,f)=>x!=="$taxes"||f.indexOf(x)===_);i(s);return}let t=["$subtotal"];t.push("$total"),(l=e==null?void 0:e.custom_fields)!=null&&l.surcharge1||(t=t.filter(u=>u!=="$custom_surcharge1")),(r=e==null?void 0:e.custom_fields)!=null&&r.surcharge2||(t=t.filter(u=>u!=="$custom_surcharge2")),(d=e==null?void 0:e.custom_fields)!=null&&d.surcharge3||(t=t.filter(u=>u!=="$custom_surcharge3")),(m=e==null?void 0:e.custom_fields)!=null&&m.surcharge4||(t=t.filter(u=>u!=="$custom_surcharge4")),t.push("$discount"),t.push("$paid_to_date"),t.push("$balance_due"),t.push("$taxes"),(e==null?void 0:e.enabled_tax_rates)>0&&t.push("$tax1"),(e==null?void 0:e.enabled_tax_rates)>1&&t.push("$tax2"),(e==null?void 0:e.enabled_tax_rates)>2&&t.push("$tax3"),i(t)},[e]),n}function N(e){const[n,i]=h.useState(""),t=T();return h.useEffect(()=>{const[l]=[t.custom_fields[e.field],""];i(l||"")},[]),a.jsx(g,{leftSide:n,className:e.elementClassName,style:e.elementStyle,noExternalPadding:e.elementNoExternalPadding,withoutWrappingLeftSide:e.elementWithoutWrappingLeftSide,children:e.type==="number"?a.jsx(K,{...e}):a.jsx(U,{...e})})}function ie(e){const n=e.resource,[i]=y(),t=h.useRef(null),l=R(),r=T(),d=ne(),m=G(),u=te({resource:n,onChange:e.onChange,invoiceSum:e.invoiceSum,relationType:e.relationType}),s=(o,j)=>e.onChange(o,j),x=()=>!!(r.enabled_tax_rates===0&&(n!=null&&n.tax_name1||n!=null&&n.tax_name2||n!=null&&n.tax_name3)||r.enabled_item_tax_rates===0&&(n!=null&&n.line_items.some(({tax_name1:o,tax_name2:j,tax_name3:C})=>o||j||C))),_=o=>o==="$tax1"||o==="$tax2"||o==="$tax3"||o==="$total_taxes"||o==="$line_taxes",f=o=>o==="$custom_surcharge1"||o==="$custom_surcharge2"||o==="$custom_surcharge3"||o==="$custom_surcharge4";return a.jsxs(J,{className:"col-span-12 xl:col-span-4 shadow-sm pb-6",withoutBodyPadding:!0,height:"full",style:{borderColor:l.$24,height:"100%"},innerRef:t,children:[x()&&a.jsxs("div",{className:"flex items-center space-x-3 px-6 pt-4",children:[a.jsx("div",{children:a.jsx(Q,{element:X,size:20,color:"orange"})}),a.jsx("div",{className:"text-sm font-medium",children:Y(i("hidden_taxes_warning"),":link",()=>a.jsx(B,{to:"/settings/tax_settings",children:i("settings")}))})]}),a.jsx("div",{className:"px-6",children:a.jsx("div",{className:Z("divide-y divide-dashed",{"divide-[#09090B1A]":!m.dark_mode,"divide-[#1f2e41]":m.dark_mode}),children:d.map((o,j)=>{var C,I,L,F;return a.jsxs(h.Fragment,{children:[_(o)&&a.jsxs(a.Fragment,{children:[!!(r&&r.enabled_tax_rates>0&&o==="$tax1")&&a.jsx(g,{leftSide:i("tax"),noExternalPadding:!0,children:a.jsx(P,{defaultValue:E(n,"tax_name1"),onChange:c=>{var $,p;s("tax_name1",($=c.resource)==null?void 0:$.name),s("tax_rate1",(p=c.resource)==null?void 0:p.rate)},onClearButtonClick:()=>{s("tax_name1",""),s("tax_rate1",0)},onTaxCreated:c=>{s("tax_name1",c.name),s("tax_rate1",c.rate)},resourceTaxName:n.tax_name1,resourceTaxRate:n.tax_rate1})}),!!(r&&r.enabled_tax_rates>1&&o==="$tax2")&&a.jsx(g,{leftSide:i("tax"),noExternalPadding:!0,children:a.jsx(P,{defaultValue:E(n,"tax_name2"),onChange:c=>{var $,p;s("tax_name2",($=c.resource)==null?void 0:$.name),s("tax_rate2",(p=c.resource)==null?void 0:p.rate)},onClearButtonClick:()=>{s("tax_name2",""),s("tax_rate2",0)},onTaxCreated:c=>{s("tax_name2",c.name),s("tax_rate2",c.rate)},resourceTaxName:n.tax_name2,resourceTaxRate:n.tax_rate2})}),!!(r&&r.enabled_tax_rates>2&&o==="$tax3")&&a.jsx(g,{leftSide:i("tax"),noExternalPadding:!0,children:a.jsx(P,{defaultValue:E(n,"tax_name3"),onChange:c=>{var $,p;s("tax_name3",($=c.resource)==null?void 0:$.name),s("tax_rate3",(p=c.resource)==null?void 0:p.rate)},onClearButtonClick:()=>{s("tax_name3",""),s("tax_rate3",0)},onTaxCreated:c=>{s("tax_name3",c.name),s("tax_rate3",c.rate)},resourceTaxName:n.tax_name3,resourceTaxRate:n.tax_rate3})})]}),f(o)&&a.jsxs(a.Fragment,{children:[!!(r&&((C=r==null?void 0:r.custom_fields)!=null&&C.surcharge1)&&o==="$custom_surcharge1")&&a.jsx(N,{field:"surcharge1",type:"number",defaultValue:n==null?void 0:n.custom_surcharge1,value:n==null?void 0:n.custom_surcharge1,onValueChange:c=>s("custom_surcharge1",parseFloat(c)),elementNoExternalPadding:!0,elementClassName:"py-5",elementWithoutWrappingLeftSide:!0}),!!(r&&((I=r==null?void 0:r.custom_fields)!=null&&I.surcharge2)&&o==="$custom_surcharge2")&&a.jsx(N,{field:"surcharge2",type:"number",defaultValue:n==null?void 0:n.custom_surcharge2,value:n==null?void 0:n.custom_surcharge2,onValueChange:c=>s("custom_surcharge2",parseFloat(c)),elementNoExternalPadding:!0,elementClassName:"py-5",elementWithoutWrappingLeftSide:!0}),!!(r&&((L=r==null?void 0:r.custom_fields)!=null&&L.surcharge3)&&o==="$custom_surcharge3")&&a.jsx(N,{field:"surcharge3",type:"number",defaultValue:n==null?void 0:n.custom_surcharge3,value:n==null?void 0:n.custom_surcharge3,onValueChange:c=>s("custom_surcharge3",parseFloat(c)),elementNoExternalPadding:!0,elementClassName:"py-5",elementWithoutWrappingLeftSide:!0}),!!(r&&((F=r==null?void 0:r.custom_fields)!=null&&F.surcharge4)&&o==="$custom_surcharge4")&&a.jsx(N,{field:"surcharge4",type:"number",defaultValue:n==null?void 0:n.custom_surcharge4,value:n==null?void 0:n.custom_surcharge4,onValueChange:c=>s("custom_surcharge4",parseFloat(c)),elementNoExternalPadding:!0,elementClassName:"py-5",elementWithoutWrappingLeftSide:!0})]}),!_(o)&&!f(o)&&a.jsx(a.Fragment,{children:u(o)})]},j)})})})]})}/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */const ae=(e,n,i)=>{const t=n.findIndex(r=>r===e);return t>-1?t:i.length},w=(e,n,i)=>{const t=i.slice(0,e),l=i.slice(e);return t.concat(n,l)};function le(){const e=T(),[n,i]=h.useState([]);return h.useEffect(()=>{let t=V.clone(e==null?void 0:e.settings.pdf_variables.product_columns)||[],l=V.clone(e==null?void 0:e.settings.pdf_variables.product_columns)||[];const r=l.length;t.includes("$product.item")||(t=["$product.item",...t],l=["$product.item",...l]),r||t.push("$product.description"),t.includes("$product.unit_cost")||(t.push("$product.unit_cost"),l.push("$product.unit_cost")),t.includes("$product.quantity")||(t.push("$product.quantity"),l.push("$product.quantity"));const d=[],m=(e==null?void 0:e.enabled_item_tax_rates)||0;m>0&&d.push("$product.tax_rate1"),m>1&&d.push("$product.tax_rate2"),m>2&&d.push("$product.tax_rate3");const u=ae("$product.tax",l,t);t=w(u,d,t),l=w(u,d,l),t=t.filter(s=>s!=="$product.tax"),l=l.filter(s=>s!=="$product.tax"),e.enable_product_discount||(t=t.filter(s=>s!=="$product.discount"),l=l.filter(s=>s!=="$product.discount")),e.enable_product_discount&&!t.includes("$product.discount")&&(t.push("$product.discount"),l.push("$product.discount")),["product1","product2","product3","product4"].forEach(s=>{e!=null&&e.custom_fields[s]&&!l.includes(`$product.${s}`)&&(t=w(t.length,[`$product.${s}`],t)),!(e!=null&&e.custom_fields[s])&&l.includes(`$product.${s}`)&&(t=t.filter(x=>x!==`$product.${s}`),l=l.filter(x=>x!==`$product.${s}`))}),e!=null&&e.enable_product_quantity||(t=t.filter(s=>s!=="$product.quantity")),t.includes("$product.tax_amount")&&(t=t.filter(s=>s!=="$product.tax_amount"),t.push("$product.tax_amount")),t.includes("$product.gross_line_total")&&(t=t.filter(s=>s!=="$product.gross_line_total"),t.push("$product.gross_line_total")),t.includes("$product.line_total")&&(t=t.filter(s=>s!=="$product.line_total"),t.push("$product.line_total")),i(t)},[e]),n}export{ie as I,ue as a,ae as g,w as i,le as u};
Copyright ©2021 || Defacer Indonesia