PageSourceSearch

https://app.costcrunch.ai/_next/static/chunks/6615-b88e5c5f2ebacf17.js

js costcrunch.ai collected 2026-10-05 15:32:23 UTC 15,829 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6615],{83870:function(t,e,n){n.d(e,{Lo:function(){return u},RV:function(){return d}});var i=n(3547),r=n(89982),o=n(94844),a=n(77076),c=n(10217);let s=t=>{if(!t)return null;try{let e=new URL(t);return e.pathname=e.pathname.split("/").map(t=>encodeURIComponent(decodeURIComponent(t))).join("/"),e.toString()}catch(e){return t}},l=t=>"needs-mapping-".concat(t),d=t=>{r.Am.dismiss(l(t))},u=t=>{let{invoiceId:e,displayName:n,thumbnailUrl:d,onMap:u,variant:p="mapping"}=t,g=s(d),m={mapping:{title:"Needs mapping to export",body:"needs a vendor/customer mapping before it can export.",button:"Map & export"},metadata:{title:"Needs details to export",body:"is missing a vendor and/or shipping address before it can export.",button:"Add details"},mismatch:{title:"Confirm total to export",body:"has line items that don't sum to its total — confirm to export.",button:"Review & export"}}[p];r.Am.custom(t=>(0,i.jsxs)("div",{className:"w-[356px] rounded-lg border bg-background p-4 text-foreground shadow-lg flex items-start gap-3",children:[(0,i.jsx)(o.Z,{className:"h-4 w-4 flex-shrink-0 mt-0.5 text-muted-foreground"}),(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)("div",{className:"text-sm font-medium",children:m.title}),(0,i.jsxs)("div",{className:"text-sm text-muted-foreground mt-0.5",children:[(0,i.jsxs)(c.zs,{openDelay:150,children:[(0,i.jsx)(c.Yi,{asChild:!0,children:(0,i.jsx)("button",{type:"button",className:"font-medium text-foreground underline decoration-dotted underline-offset-2",children:n})}),(0,i.jsx)(c.bZ,{className:"w-56 p-1",children:g?(0,i.jsx)("img",{src:g,alt:n,className:"w-full h-auto rounded border max-h-64 object-contain"}):(0,i.jsx)("div",{className:"text-xs text-muted-foreground p-3 text-center",children:"No preview available"})})]})," ",m.body]}),(0,i.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,i.jsx)(a.z,{size:"sm",className:"h-7 px-3 text-xs",onClick:()=>u(),children:m.button}),(0,i.jsx)(a.z,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs text-muted-foreground",onClick:()=>r.Am.dismiss(t),children:"Dismiss"})]})]})]}),{id:l(e),duration:1/0})}},96615:function(t,e,n){n.d(e,{Bp:function(){return D},DS:function(){return S},Ex:function(){return k},IH:function(){return f},N4:function(){return g},OU:function(){return y},Qj:function(){return N},S0:function(){return C},Sb:function(){return j},TW:function(){return E},W9:function(){return _},aL:function(){return R},aT:function(){return V},b0:function(){return m},ej:function(){return O},fh:function(){return v},hx:function(){return p},jP:function(){return s},k8:function(){return h},mD:function(){return u},p6:function(){return d},sd:function(){return I},tB:function(){return T},uf:function(){return l}});var i=n(89982),r=n(53340),o=n(99619),a=n(83870),c=n(92265);let s=async(t,e,n,i)=>{try{return(await fetch("".concat("https://api-prod.costcrunch.ai","/documents/").concat(t,"/document-type"),{method:"PUT",headers:{"user-id":n,"org-id":i,"Content-Type":"application/json"},body:JSON.stringify({document_type:e})})).ok}catch(t){return console.error("Error updating document type:",t),!1}},l=t=>null==t||isNaN(t)?"0.00":t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),d=t=>{if(!t)return"No date";let[e,n,i]=t.split("-").map(Number);return new Date(e,n-1,i).toLocaleDateString()};function u(t){if(!t)return null;let e=t.split(".");return e.length<2?null:e[e.length-1].toLowerCase()}function p(t){return(null==t?void 0:t.exports.some(t=>"success"===t.status))||!1}function g(t){return(null==t?void 0:t.exports.some(t=>"failure"===t.status))||!1}let m={override:"Override for this export only",invoice:"Overridden for this invoice",vendor:"From vendor default",integration:"From integration default",fallback:"Matched in QuickBooks",none:"No expense account configured"},f={override:"This Export Only",invoice:"Invoice Override",vendor:"Vendor Default",integration:"Integration Default",fallback:"QuickBooks Match",none:"Not Configured"},_=async(t,e)=>
1{try{let n=await fetch("".concat("https://api-prod.costcrunch.ai","/accounting"),{headers:{"user-id":t,"org-id":e,"Content-Type":"application/json"}});if(!n.ok)throw Error("Failed to fetch accounting integrations");return(await n.json()).integrations||[]}catch(t){return console.error("Error fetching accounting integrations:",t),[]}},h=async function(t,e,n,r,o){let a=!(arguments.length>5)||void 0===arguments[5]||arguments[5];try{let i=await fetch("".concat("https://api-prod.costcrunch.ai","/accounting/export/preview"),{method:"POST",headers:{"user-id":r,"org-id":o,"Content-Type":"application/json"},body:JSON.stringify({invoice_id:t,connection_id:e,provider:n,check_existing_bill:a})});if(!i.ok){let t=await i.json().catch(()=>null);throw Error((null==t?void 0:t.detail)||"Failed to preview export mappings")}return await i.json()}catch(t){return console.error("Error previewing export mappings:",t),i.Am.error("Failed to preview export mappings",{description:t instanceof Error?t.message:"Unknown error"}),null}},x=new Map,v=(t,e,n,i,r)=>{let o="".concat(t,":").concat(e,":").concat(n),a=x.get(o);if(a)return a;let c=h(t,e,n,i,r,!1);return x.set(o,c),c.then(t=>{null==t?x.delete(o):setTimeout(()=>x.delete(o),6e4)}),c},y=t=>{for(let e of Array.from(x.keys()))e.startsWith("".concat(t,":"))&&x.delete(e)},w=new Set,b=new Map,E=(t,e)=>{e?b.set(t,e):b.delete(t)},N=async function(t,e,n,a,c){let s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],l=arguments.length>6&&void 0!==arguments[6]&&arguments[6],d=arguments.length>7?arguments[7]:void 0,u=arguments.length>8&&void 0!==arguments[8]?arguments[8]:"invoice",p=arguments.length>9?arguments[9]:void 0,g="credit_bill"===u?"/documents/credits/".concat(t):"/documents/invoices/".concat(t),m="credit_bill"===u?"Credit":"Invoice",f="".concat(t,"|").concat(e,"|").concat(n);if(w.has(f))return!1;w.add(f);let _=(0,r.j)({type:"loading",title:"Exporting to ".concat(n,"..."),onClick:()=>{window.location.href="".concat(g,"?export=open")}});try{let f={invoice_id:t,connection_id:e,provider:n,confirmed:s,force_reexport:l},h=null!=p?p:b.get(t);b.delete(t),h&&(f.existing_bill_action=h.action,f.existing_bill_id=h.billId),d&&(f.expense_account_override_id=d);let x=await fetch("".concat("https://api-prod.costcrunch.ai","/accounting/export"),{method:"POST",headers:{"user-id":a,"org-id":c,"Content-Type":"application/json"},body:JSON.stringify(f)});if(409===x.status)return i.Am.dismiss(_),(0,r.j)({type:"info",title:"".concat(m," is already being exported"),description:"Another export of this document is still running.",onClick:()=>{window.location.href="".concat(g,"?export=open")}}),!1;if(!x.ok){let t=await x.json().catch(()=>null);throw Error((null==t?void 0:t.detail)||"Failed to export invoice")}let v=await x.json();if(i.Am.dismiss(_),v.number_conflict){let i=v.number_conflict;return(0,o.Lh)(i,r=>{N(t,e,n,a,c,s,l,d,u,{action:r,billId:i.existing_bill_id})}),!1}return v.warnings&&v.warnings.length>
10&&v.warnings.forEach(t=>{i.Am.warning("Connection Issue Detected",{description:t,duration:8e3})}),v.already_exported?(0,r.j)({type:"info",title:"".concat(m," already in ").concat(n),description:"Linked to the existing bill, nothing new created. External ID: ".concat(v.external_bill_id),onClick:()=>{window.location.href="".concat(g,"?export=open")}}):v.was_updated&&(null==h?void 0:h.action)==="update"?(0,r.j)({type:"success",title:"".concat(m," updated the existing bill in ").concat(n),description:"External ID: ".concat(v.external_bill_id),onClick:()=>{window.location.href="".concat(g,"?export=open")}}):v.was_updated?(0,r.j)({type:"success",title:"".concat(m," updated in ").concat(n),description:"External ID: ".concat(v.external_bill_id),onClick:()=>{window.location.href="".concat(g,"?export=open")}}):(0,r.j)({type:"success",title:"".concat(m," exported to ").concat(n),description:"External ID: ".concat(v.external_bill_id),onClick:()=>{window.location.href="".concat(g,"?export=open")}}),!0}catch(t){return console.error("Error exporting invoice:",t),i.Am.dismiss(_),(0,r.j)({type:"error",title:"Failed to export to ".concat(n),description:t instanceof Error?t.message:"Unknown error",onClick:()=>{window.location.href="".concat(g,"?export=open")}}),!1}finally{w.delete(f)}},k=t=>{let{invoiceId:e,connectionId:n,provider:i,userId:r,orgId:o,documentType:c="invoice",expenseAccountOverrideId:s,onSettled:l}=t;N(e,n,i,r,o,!0,!1,s,c).then(t=>{t&&(0,a.RV)(e),null==l||l(e,t)}).catch(()=>null==l?void 0:l(e,!1))},j=async(t,e,n,i,r)=>{let o="QuickBooks Desktop"===e?"conductor":"quickbooks",a=async t=>{try{let e=await fetch("".concat("https://api-prod.costcrunch.ai","/accounting/entity-mappings"),{method:"POST",headers:{"user-id":i,"org-id":r,"Content-Type":"application/json"},body:JSON.stringify(t)});e.ok||console.warn("[saveExportMappings] mapping save failed, continuing:",await e.text())}catch(t){console.warn("[saveExportMappings] mapping save error, continuing:",t)}},c=t=>{if(!t)return null;if(t.startsWith("SUGGESTED::")||t.startsWith("EXISTING::")){let e=t.split("::");return{action:"map_existing",id:e[1]||null,name:e[2]||null}}return t.startsWith("CREATE_NEW::")?{action:"create_new",id:null,name:t.substring(12)}:null};for(let e of n.vendors||[]){let n=c(e.editedName);(null==n?void 0:n.action)==="map_existing"&&n.id&&await a({integration_id:t,local_entity_type:"supplier",external_entity_type:"vendor",external_entity_id:n.id,external_data:{supplier_name:e.supplier_name,vendor_name:n.name,integration_type:o}})}for(let e of n.customers||[]){let n=c(e.editedName);(null==n?void 0:n.action)==="map_existing"&&n.id&&await a({integration_id:t,local_entity_type:"project",external_entity_type:"customer",external_entity_id:n.id,external_data:{address_key:e.address_key,customer_name:n.name,integration_type:o}})}},I=async(t,e,n)=>{try{let i=await fetch("".concat("https://api-prod.costcrunch.ai","/accounting/invoices/").concat(t,"/export-status"),{headers:{"user-id":e,"org-id":n,"Content-Type":"application/json"}});if(!i.ok)throw Error("Failed to fetch export status");return await i.json()}catch(t){return console.error("Error fetching export status:",t),null}},C=t=>(0,c.fT)(t),T=t=>(0,c.gO)(t),A=(t,e)=>{var n;let i=t.length;return{id:"processing-aggregate-".concat(e),file_name:"".concat(i," Document").concat(i>1?"s":""," Processing..."),processing_status:"processing_aggregate",document_type:e,invoice_number:null,invoice_date:null,total_amount:null,vendor_id:null,vendor_name:null,street_address:null,status:null,processed_at:null,public_url:null,thumbnail_url:null,error_message:null,user_id:(null===(n=t[0])||void 0===n?void 0:n.user_id)||null,approved:null,_processing_count:i,_is_aggregate:!0,_isExpanded:!1,_isExpandedChild:!1,_parentAggregateId:void 0}},D=function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.filter(t=>C(t.processing_status)),r=t.filter(t=>T(t.processing_status)),o=t.filter(t=>!C(t.processing_status)&&!T(t.processing_status)),a=[...i,...r],c=[...o];if(a.length>0){let t="processing-aggregate-".concat(e),i=n[t]||!1,r=A(a,e);r._isExpanded=i,c.unshift(r),i&&a.forEach((e,n)=>{c.splice(1+n,0,{...e,_isExpandedChild:!0,_parentAggregateId:t})})}return c},S=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.filter(t=>C(t.processing_status)),i=t.filter(t=>T(t.processing_status)),r=t.filter(t=>!C(t.processing_status)&&!T(t.processing_status)),o=[...n,...i],a=0;return o.length>0&&(a=e["processing-aggregate-invoice"]?o.length+1:1),r.length+a};async function O(t,e,n){let i=await fetch("".concat("https://api-prod.c
1ostcrunch.ai","/accounting/invoices/").concat(t,"/verify-export"),{method:"POST",headers:{"user-id":e,"org-id":n,"Content-Type":"application/json"}});if(!i.ok)throw Error((await i.json().catch(()=>({}))).detail||"Verification failed (".concat(i.status,")"));return i.json()}function R(t){let e=[];return t.invoice_number&&""!==t.invoice_number.trim()||e.push({field:"invoice_number",label:"Invoice Number",type:"missing",currentValue:t.invoice_number}),t.vendor_name&&""!==t.vendor_name.trim()||e.push({field:"vendor_name",label:"Vendor",type:"missing",currentValue:t.vendor_name}),t.street_address&&""!==t.street_address.trim()||e.push({field:"street_address",label:"Shipping Address",type:"missing",currentValue:t.street_address}),(null===t.total_amount||void 0===t.total_amount||0===t.total_amount)&&e.push({field:"total_amount",label:"Total Amount",type:0===t.total_amount?"zero":"missing",currentValue:t.total_amount}),{isValid:0===e.length,issues:e}}function V(t){return t.map(t=>({invoice:t,validation:R(t)})).filter(t=>!t.validation.isValid)}},10217:function(t,e,n){n.d(e,{Yi:function(){return s},bZ:function(){return l},zs:function(){return c}});var i=n(3547),r=n(55767),o=n(4855),a=n(65556);let c=o.fC,s=o.xz,l=r.forwardRef((t,e)=>{let{className:n,align:r="center",sideOffset:c=4,...s}=t;return(0,i.jsx)(o.VY,{ref:e,align:r,sideOffset:c,className:(0,a.cn)("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-hover-card-content-transform-origin]",n),...s})});l.displayName=o.VY.displayName},92265:function(t,e,n){var i,r,o,a;n.d(e,{VI:function(){return m},Wm:function(){return i},YK:function(){return s},ed:function(){return f},fT:function(){return u},gO:function(){return p},uG:function(){return l},zH:function(){return g}}),(o=i||(i={})).INGESTED="ingested",o.QUEUED="queued",o.VALIDATING_INVOICE="validating_invoice",o.EXTRACTING_WITH_OCR="extracting_with_ocr",o.EXTRACTING_METADATA="extracting_metadata",o.ENRICHING_LINE_ITEMS="enriching_line_items",o.SAVING_METADATA="saving_metadata",o.PARSING_COMPLETED="parsing_completed",o.COMPLETED="completed",o.FAILED="failed",o.FAILED_NO_RETRY="failed_no_retry",o.SKIPPED="skipped",o.REPROCESSING="reprocessing";let c={ingested:5,queued:20,validating_invoice:40,extracting_with_ocr:50,extracting_metadata:60,enriching_line_items:70,saving_metadata:80,parsing_completed:90,completed:100,reprocessing:5,failed:0,failed_no_retry:0,skipped:100},s=["ingested","queued","validating_invoice","extracting_with_ocr","extracting_metadata","enriching_line_items","saving_metadata","parsing_completed","reprocessing"],l=["failed","failed_no_retry"],d={data_extraction:"extracting_metadata",extracting_table_data:"extracting_metadata",metadata_extracted:"extracting_metadata",saving_line_items:"saving_metadata",final_metadata_saved:"saving_metadata",document_preparation:"validating_invoice",processing:"extracting_metadata"};function u(t){return s.includes(t)}function p(t){return l.includes(t)}function g(t){return"skipped"===t}function m(t){var e;return null!==(e=c[t])&&void 0!==e?e:5}function f(t){switch(function(t){var e;let n=null!==(e=d[t])&&void 0!==e?e:t;return"failed"===n||"failed_no_retry"===n?"failed":"completed"===n||"skipped"===n?"completed":"ingested"===n||"queued"===n||"reprocessing"===n?"queued":"validating_invoice"===n||"extracting_with_ocr"===n?"extracting":"extracting_metadata"===n||"enriching_line_items"===n?"validating":"saving_metadata"===n||"parsing_completed"===n?"enriching":"queued"}(t)){case"queued":case"failed":default:return 0;case"extracting":return 25;case"validating":return 50;case"enriching":return 75;case"completed":return 100}}(a=r||(r={})).QUEUED="queued",a.EXTRACTING="extracting",a.VALIDATING="validating",a.ENRICHING="enriching",a.COMPLETED="completed",a.FAILED="failed"}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.