PageSourceSearch

https://alpaga.ai/_next/static/chunks/2216-8253a1e7fa680616.js

js alpaga.ai collected 2026-10-05 13:43:19 UTC 13,568 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2216],{5025:function(e,n,t){t.d(n,{CB:function(){return u},tw:function(){return c},xF:function(){return i}});var r=t(34092);function o(e){return"string"===typeof e?parseFloat(e)||0:e||0}function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const n={};return e.forEach((e=>{if(!e.project_id||"paid"!==e.status)return;const t=o(e.subtotal)||o(e.amount);n[e.project_id]=(n[e.project_id]||0)+t})),n}function c(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const t=a(n);return e.filter(r.O0).reduce(((e,n)=>{const r=o(n.budget),a=t[n.id]||0;return e+Math.max(r-a,0)}),0)}function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.filter(r.zv).reduce(((e,n)=>e+o(n.budget)),0)}function u(){return new Date((new Date).getFullYear()-1,0,1)}},49784:function(e,n,t){t.d(n,{T:function(){return a},Z:function(){return o}});var r=t(31067);function o(e){let{realized:n,balances:t,from:o,to:c,coverage:i,granularity:u="month"}=e;const l=(0,r.uy)(o),s=(0,r.uy)(c);if(!l||!s||o>c)return[];const d=[];for(let r=new Date(l.getFullYear(),l.getMonth(),1,12);r<=s;r.setMonth(r.getMonth()+1)){const e="".concat(r.getFullYear(),"-").concat(String(r.getMonth()+1).padStart(2,"0")),a="".concat(e,"-").concat(new Date(r.getFullYear(),r.getMonth()+1,0).getDate()),u=[o,"".concat(e,"-01")].sort().at(-1),l=[c,a].sort()[0],s=!!i&&u>=i.from&&l<=i.to,f=n.filter((e=>e.date>=u&&e.date<=l)),m=f.reduce(((e,n)=>e+Math.max(n.amountMinor,0)),0),g=f.reduce(((e,n)=>e+Math.max(-n.amountMinor,0)),0),h=t.find((e=>e.date===l));d.push({month:e,label:r.toLocaleDateString("fr-CA",{month:"short"}),fullLabel:r.toLocaleDateString("fr-CA",{month:"long",year:"numeric"}),income:s?m/100:null,expenses:s?g/100:null,net:s?(m-g)/100:null,balance:h?h.balanceMinor/100:null,partial:u!=="".concat(e,"-01")||l!==a,through:l})}return a(d,u)}function a(e,n){if(!["quarter","year"].includes(n))return e;const t=new Map;return e.forEach((e=>{const[r,o]=e.month.split("-").map(Number),a=Math.ceil(o/3),c="year"===n?String(r):"".concat(r,"-Q").concat(a);t.has(c)||t.set(c,{year:r,quarter:a,rows:[]}),t.get(c).rows.push(e)})),[...t.entries()].map((e=>{let[t,r]=e;const o=r.rows[0],a=r.rows.at(-1),c="year"===n?1:3*(r.quarter-1)+1,i="year"===n?12:3*r.quarter,u="".concat(r.year,"-").concat(String(c).padStart(2,"0")),l="".concat(r.year,"-").concat(String(i).padStart(2,"0")),s=e=>r.rows.some((n=>null===n[e]))?null:r.rows.reduce(((n,t)=>n+t[e]),0),d="year"===n?String(r.year):"T".concat(r.quarter," ").concat(r.year);return{month:t,label:d,fullLabel:d,income:s("income"),expenses:s("expenses"),net:s("net"),balance:a.balance,through:a.through,...void 0!==a.balanceEstimated?{balanceEstimated:a.balanceEstimated}:{},partial:o.month!==u||a.month!==l||r.rows.some((e=>e.partial))}}))}},95477:function(e,n,t){t.d(n,{_:function(){return u}});var r=t(31067),o=t(49784);function a(e){if(null===e||void 0===e||"boolean"===typeof e||""===String(e).trim())return null;const n=Number(e);return Number.isSafeInteger(n)?n:null}const c=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(0,r.LJ)(new Date(e.getFullYear(),e.getMonth()+n,1,12))},i=e=>{var n;return(null===(n=(0,r.uy)(e))||void 0===n?void 0:n.toLocaleDateString("fr-CA",{day:"numeric",month:"short",year:"numeric"}))||"\u2014"};function u(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"last6",t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Date;var u;if(!(null===e||void 0===e||null===(u=e.accounts)||void 0===u?void 0:u.length))return null;const l=e.accounts[0];if("CAD"!==l.currency)throw new Error("La vue de tr\xe9sorerie attend un compte en CAD.");const s=(0,r.LJ)(t),d=e.imports.filter((e=>e.account_id===l.id&&(0,r.uy)(e.observed_from)&&(0,r.uy)(e.observed_to))),f=d.map((e=>e.observed_from)).sort()[0],m=d.map((e=>e.observed_to)).sort().at(-1),g=m&&m<s?m:s,h=["last6","last12"].includes(n)?c(t,"last6"===n?-5:-11):f||c(t);let p=0,b=0,v=0;const _=e.transactions.filter((e=>e.account_id===l.id)).flatMap((e=>{const n=a(e.amount_minor),t=(0,r.LJ)(e.transaction_date);return null!==n&&t&&e.currency===l.currency&&["booked","unconfirmed","pending"].includes(e.status)?"pending"===e.status?(b+=1,[]):t>s?(v+=1,[]):[{...e,date:t,amountMinor:n}]:(p+=1,[])})),y=e.balances.filter((e=>e.account_id===l.id&&e.currency===l.currency&&(0,r.uy)(e.reference_date)&&e.reference_date<=s&&null!==a(e.balance_minor))).sort(((e,n)=>n.reference_date.localeCompare(e.reference_date)||n.observed_at.localeCompare(e.observed_at))),M=y[0]||null,w=_.filter((e=>e.date>=h&&e.date<=g)),x=w.reduce(((e,n)=>e+Math.max(n.amountMinor,0)),0),L=w.reduce(((e,n)=>e+Math.max(-n.amountMinor,0)),0);if(![x,L,x-L].every(Number.isSafeInteger))throw new RangeError("Montant agr\xe9g\xe9 hors limite.");const S=(e,n)=>d.some((t=>t.coverage_confirmed&&t.observed_from<=e&&t.observed_to>=n)),k=w.length>0||h<=g&&S(h,g),D=(0,o.Z)({realized:_,balances:y.map((e=>({date:e.reference_date,balanceMinor:Number(e.balance_minor)}))),from:h,to:g,coverage:{from:h,to:g}}).map((e=>{const n="".concat(e.month,"-01")<h?h:"".concat(e.month,"-01");return _.some((t=>t.date>=n&&t.date<=e.through))||S(n,e.through)?e:{...e,income:null,expenses:null,net:null}})).map((e=>{if(null!==e.balance)return{...e,balanceEstimated:!1};if(!M||p||!f||e.through<f||e.through>m||M.reference_date<f||M.reference_date>m)return e;const n=e.through>M.reference_date,t=n?M.reference_date:e.through,r=n?e.through:M.reference_date,o=_.filter((e=>e.date>t&&e.date<=r)).reduce(((e,n)=>e+n.amountMinor),0),a=Number(M.balance_minor)+(n?o:-o);if(!Number.isSafeInteger(o)||!Number.isSafeInteger(a))throw new RangeError("Solde reconstitu\xe9 hors limite.");return{...e,balance:a/100,balanceEstimated:!0}})),C=(0,r.uy)(g),E=c(C,-6),N=(0,r.LJ)(new Date(C.getFullYear(),C.getMonth(),0,12)),F=(0,o.Z)({realized:_,balances:[],from:E,to:N,coverage:{from:E,to:N}}),A=F.every((e=>_.some((n=>n.date.startsWith(e.month)))||S("".concat(e.month,"-01"),e.through))),j=!!f&&f<=E&&m>=N&&A&&!p,q=j?Math.round(F.reduce(((e,n)=>e+Math.round(100*n.income)),0)/6):null,Y=j?Math.round(F.reduce(((e,n)=>e+Math.round(100*n.expenses)),0)/6):null,I=j?Y-q:null,J=S(E,N),R=(null===M||void 0===M?void 0:M.reference_date)===s&&"available"===M.balance_type&&!0===M.pending_excluded,z=J&&R&&I>0?Math.max(0,Number(M.balance_minor))/I:null;return{account:l,rows:(0,o.T)(D,n),from:h,to:g,observedFrom:f,observedTo:m,count:w.length,incomeMinor:k?x:null,expensesMinor:k?
1L:null,netMinor:k?x-L:null,balanceMinor:M?Number(M.balance_minor):null,balanceDate:(null===M||void 0===M?void 0:M.reference_date)||null,balanceDateLabel:i(null===M||void 0===M?void 0:M.reference_date),balanceCurrent:R,periodLabel:"".concat(i(h)," \u2013 ").concat(i(g)),invalid:p,pending:b,future:v,coverageConfirmed:J,averageIncomeMinor:q,averageExpensesMinor:Y,burnMinor:I,runwayMonths:z,averageLabel:"".concat(i(E)," \u2013 ").concat(i(N)," \xb7 6 mois termin\xe9s")}}},54770:function(e,n,t){t.d(n,{c:function(){return c}});var r=t(95477),o=t(31067),a=t(23950);function c(e){let{banking:n,invoices:t=[]}=e,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date;const i=String(c.getFullYear()),u=(0,r._)(n,"month",c);if(u){const e=e=>{const n=u.rows.filter((n=>n.month.startsWith("".concat(e,"-"))&&null!==n.income));return n.length?n.reduce(((e,n)=>e+Math.round(100*n.income)),0)/100:null};return{totalRevenue:null===u.incomeMinor?null:u.incomeMinor/100,ytdRevenue:e(i),prevYearRevenue:e(String(Number(i)-1)),source:"bank",sourceLabel:"RBC \xb7 entr\xe9es import\xe9es jusqu\u2019au ".concat((0,o.uy)(u.to).toLocaleDateString("fr-CA",{day:"numeric",month:"short",year:"numeric"}))}}const l=(0,o.LJ)(c),s=t.flatMap((e=>{const n=(0,o.LJ)(e.paid_date),t=(0,a.j)(e.amount);return"paid"===e.status&&n&&n<=l&&null!==t?[{date:n,amount:t}]:[]})),d=e=>e.reduce(((e,n)=>e+n.amount),0)/100;return{totalRevenue:d(s),ytdRevenue:d(s.filter((e=>e.date.startsWith(i)))),prevYearRevenue:d(s.filter((e=>e.date.startsWith(String(Number(i)-1))))),source:"invoices",sourceLabel:"Factures pay\xe9es \xb7 TTC \xb7 aucun compte bancaire accessible"}}},63348:function(e,n,t){t.d(n,{C:function(){return c},W:function(){return a}});var r=t(34092);async function o(e){const n=[];let t=null;for(let r=0;r<100;r+=1){const{data:r,error:o,count:a}=await e().range(n.length,n.length+250-1);if(o)throw new Error("Impossible de lire les donn\xe9es financi\xe8res.");if(!Array.isArray(r)||!Number.isInteger(a)||a<0)throw new Error("Historique financier incomplet.");if(null!==t&&a!==t)throw new Error("Les donn\xe9es ont chang\xe9 pendant la lecture. Actualisez la vue.");if(t=a,n.push(...r),n.length===t)return n;if(!r.length||n.length>t)throw new Error("Historique financier incomplet.")}throw new Error("Historique trop volumineux pour cette vue. Aucun total partiel affich\xe9.")}async function a(e){const[n,t,a]=await Promise.all([o((()=>e.from("invoices").select("id, amount, subtotal, tax_amount, paid_date, status, project_id, created_at",{count:"exact"}).order("id",{ascending:!0}))),o((()=>e.from("projects").select("id, budget, kind, status, deleted_at",{count:"exact"}).is("deleted_at",null).eq("kind","client").in("status",r._5).gt("budget",0).order("id",{ascending:!0}))),c(e)]);return{invoices:n,projects:t,banking:a,loadedAt:(new Date).toISOString()}}async function c(e){const n=await o((()=>e.from("finance_bank_accounts").select("id, display_name, institution, currency",{count:"exact"}).order("id",{ascending:!0})));if(!n.length)return{accounts:n,transactions:[],imports:[],balances:[]};const t=n.map((e=>e.id)),[r,a,c]=await Promise.all([o((()=>e.from("finance_bank_transactions").select("id, account_id, currency, transaction_date, amount_minor, description, status",{count:"exact"}).in("account_id",t).order("id",{ascending:!0}))),o((()=>e.from("finance_bank_imports").select("id, account_id, observed_from, observed_to, coverage_confirmed, row_count, created_at",{count:"exact"}).in("account_id",t).order("id",{ascending:!0}))),o((()=>e.from("finance_bank_balances").select("id, account_id, currency, balance_minor, reference_date, balance_type, pending_excluded, observed_at",{count:"exact"}).in("account_id",t).order("id",{ascending:!0})))]);return{accounts:n,transactions:r,imports:a,balances:c}}},23950:function(e,n,t){t.d(n,{I:function(){return i},j:function(){return c}});var r=t(31067),o=t(49784),a=t(5025);function c(e){if(null===e||void 0===e||"string"===typeof e&&""===e.trim()||"boolean"===typeof e)return null;const n=Number(e),t=Math.round(100*n);return Number.isFinite(n)&&Number.isSafeInteger(t)?t:null}function i(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Date;const i=(0,r.LJ)(t);let u=0,l=0;const s=e.invoices.filter((e=>"paid"===e.status)).flatMap((e=>{const n=(0,r.LJ)(e.paid_date),t=c(e.amount);return n&&null!==t?n>i?(l+=1,[]):[{...e,date:n,amountMinor:t}]:(u+=1,[])})),d=Math.min(t.getFullYear(),...s.map((e=>Number(e.date.slice(0,4))))),f=["last6","last12"].includes(n)?(0,r.LJ)(new Date(t.getFullYear(),t.getMonth()-("last6"===n?5:11),1,12)):"".concat(d,"-01-01"),m=s.filter((e=>e.date>=f)),g=new Map;m.forEach((e=>{const n=e.date.slice(0,7);g.set(n,(g.get(n)||0)+e.amountMinor)}));const h=(0,o.Z)({realized:[],balances:[],from:f,to:i,coverage:{from:f,to:i}}).map((e=>({...e,income:(g.get(e.month)||0)/100,expenses:null,net:null,balance:null}))),p=(0,a.CB)(),b=e.invoices.filter((e=>{const n=(0,r.uy)(e.created_at);return n&&n>=p&&n<=t})),v=m.reduce(((e,n)=>e+n.amountMinor),0),_=m.map((e=>c(e.subtotal))),y=_.some((e=>null===e))?null:_.reduce(((e,n)=>e+n),0);return{rows:(0,o.T)(h,n),from:f,to:i,count:m.length,invalid:u,future:l,totalMinor:v,subtotalMinor:y,taxMinor:null===y?null:v-y,backlogMinor:Math.round(100*(0,a.tw)(e.projects,b)),expensesMinor:null,balanceMinor:null,netMinor:null,periodLabel:"".concat((0,r.uy)(f).toLocaleDateString("fr-CA",{month:"short",year:"numeric"})," \u2013 ").concat((0,r.uy)(i).toLocaleDateString("fr-CA",{day:"numeric",month:"short",year:"numeric"}))}}},34092:function(e,n,t){t.d(n,{$u:function(){return f},Lh:function(){return a},O0:function(){return s},WD:function(){return c},_5:function(){return o},tS:function(){return l},zv:function(){return d}});const r=["completed","archived"],o=["planning","in_progress","review"],a=["proposal","negotiation","review"],c=["client","
1internal","product"];function i(e){return r.includes(null===e||void 0===e?void 0:e.status)}function u(e){return"proposal"===(null===e||void 0===e?void 0:e.kind)&&!e.deleted_at&&!i(e)}function l(e){return!(null===e||void 0===e?void 0:e.deleted_at)&&c.includes(null===e||void 0===e?void 0:e.kind)&&o.includes(null===e||void 0===e?void 0:e.status)}function s(e){return"client"===(null===e||void 0===e?void 0:e.kind)&&l(e)}function d(e){return u(e)&&a.includes(e.status)}function f(e){const n=e.filter((e=>"proposal"===e.kind));return{active:n.filter(u),closed:n.filter((e=>e.deleted_at||i(e))),all:n}}},33431:function(e,n,t){t.d(n,{Q:function(){return o},a:function(){return a}});var r=t(34092);function o(e){return e.from("projects").select("id, budget, kind, status, deleted_at").is("deleted_at",null).eq("kind","proposal").in("status",r.Lh).gt("budget",0)}function a(e){return e.from("projects").select("id, name, kind, status, deleted_at, priority, deadline, budget, created_at, clients(company_name), client_documents(count)").eq("kind","proposal").order("deadline",{ascending:!0,nullsFirst:!1})}}}]);

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.