@airporting/tech-app 0.0.106 → 0.0.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mf/@mf-types/compiled-types/api/tech/usageChargeQuery.d.ts +2 -0
- package/dist/mf/@mf-types/compiled-types/apps/usage/ChargeStack.d.ts +5 -0
- package/dist/mf/@mf-types/compiled-types/apps/usage/ConcurrencyChart.d.ts +4 -0
- package/dist/mf/@mf-types/compiled-types/apps/usage/TopTables.d.ts +9 -0
- package/dist/mf/@mf-types/compiled-types/apps/usage/TractionChart.d.ts +4 -0
- package/dist/mf/@mf-types/compiled-types/apps/usage/UsageKpiRow.d.ts +4 -0
- package/dist/mf/@mf-types/compiled-types/apps/usage/formatBucket.d.ts +5 -0
- package/dist/mf/@mf-types/compiled-types/apps/usage/palette.d.ts +9 -0
- package/dist/mf/@mf-types/compiled-types/apps/usage/usage.types.d.ts +61 -0
- package/dist/mf/@mf-types/compiled-types/apps/usage.app.d.ts +1 -0
- package/dist/mf/@mf-types/compiled-types/tabs/usage.d.ts +2 -0
- package/dist/mf/@mf-types/usage.d.ts +2 -0
- package/dist/mf/@mf-types.d.ts +2 -2
- package/dist/mf/@mf-types.zip +0 -0
- package/dist/mf/__federation_expose_etat_saisie.js +1 -1
- package/dist/mf/__federation_expose_usage.js +1 -0
- package/dist/mf/index.css +385 -73
- package/dist/mf/index.js +3 -3
- package/dist/mf/mf-manifest.json +59 -17
- package/dist/mf/mf-stats.json +79 -25
- package/dist/mf/tech_app.js +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UsageTopCompany, UsageTopJob } from '@/src/apps/usage/usage.types.ts';
|
|
2
|
+
export declare function TopCompaniesTable(props: {
|
|
3
|
+
rows: UsageTopCompany[];
|
|
4
|
+
totalHours: number;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function TopJobsTable(props: {
|
|
7
|
+
rows: UsageTopJob[];
|
|
8
|
+
totalHours: number;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { UsageView } from '@/src/apps/usage/usage.types.ts';
|
|
2
|
+
export declare function formatMinuteTick(iso: string): string;
|
|
3
|
+
export declare function formatBucketTick(t: string, view: UsageView): string;
|
|
4
|
+
export declare function formatBucketLong(t: string, view: UsageView): string;
|
|
5
|
+
export declare function formatWindow(from: string, to: string, view: UsageView): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const USAGE_COLORS: {
|
|
2
|
+
productive: string;
|
|
3
|
+
errored: string;
|
|
4
|
+
noop: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const AXIS_INK = "#898781";
|
|
7
|
+
export declare function formatHours(hours: number): string;
|
|
8
|
+
export declare function formatCount(value: number): string;
|
|
9
|
+
export declare function formatCompactCount(value: number): string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type UsageView = 'day' | 'week' | 'month' | 'year';
|
|
2
|
+
export type UsageKpis = {
|
|
3
|
+
tasks: number;
|
|
4
|
+
companies: number;
|
|
5
|
+
distinctJobs: number;
|
|
6
|
+
computeHours: number;
|
|
7
|
+
productiveHours: number;
|
|
8
|
+
erroredHours: number;
|
|
9
|
+
erroredTasks: number;
|
|
10
|
+
noopHours: number;
|
|
11
|
+
noopTasks: number;
|
|
12
|
+
rowsSynced: number;
|
|
13
|
+
worksheetTasks: number;
|
|
14
|
+
maxConcurrent: number | null;
|
|
15
|
+
};
|
|
16
|
+
export type UsageBucket = {
|
|
17
|
+
t: string;
|
|
18
|
+
tasks: number;
|
|
19
|
+
computeHours: number;
|
|
20
|
+
productiveHours: number;
|
|
21
|
+
erroredHours: number;
|
|
22
|
+
erroredTasks: number;
|
|
23
|
+
noopHours: number;
|
|
24
|
+
worksheetTasks: number;
|
|
25
|
+
rowsSynced: number;
|
|
26
|
+
companies: number | null;
|
|
27
|
+
distinctJobs: number | null;
|
|
28
|
+
waitMaxMinutes: number | null;
|
|
29
|
+
};
|
|
30
|
+
export type UsageConcurrencyPoint = {
|
|
31
|
+
t: string;
|
|
32
|
+
concurrent: number;
|
|
33
|
+
started: number;
|
|
34
|
+
errored: number;
|
|
35
|
+
};
|
|
36
|
+
export type UsageTopCompany = {
|
|
37
|
+
companyId: number;
|
|
38
|
+
slug: string | null;
|
|
39
|
+
displayName: string | null;
|
|
40
|
+
tasks: number;
|
|
41
|
+
computeHours: number;
|
|
42
|
+
erroredHours: number;
|
|
43
|
+
};
|
|
44
|
+
export type UsageTopJob = {
|
|
45
|
+
jobName: string;
|
|
46
|
+
tasks: number;
|
|
47
|
+
companies: number;
|
|
48
|
+
computeHours: number;
|
|
49
|
+
erroredHours: number;
|
|
50
|
+
};
|
|
51
|
+
export type UsageChargeResponse = {
|
|
52
|
+
view: UsageView;
|
|
53
|
+
granularity: 'day' | 'month';
|
|
54
|
+
from: string;
|
|
55
|
+
to: string;
|
|
56
|
+
kpis: UsageKpis;
|
|
57
|
+
buckets: UsageBucket[];
|
|
58
|
+
concurrency: UsageConcurrencyPoint[];
|
|
59
|
+
topCompanies: UsageTopCompany[];
|
|
60
|
+
topJobs: UsageTopJob[];
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function UsageApp(): import("react/jsx-runtime").JSX.Element;
|
package/dist/mf/@mf-types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
export type RemoteKeys = 'REMOTE_ALIAS_IDENTIFIER/amex' | 'REMOTE_ALIAS_IDENTIFIER/bnpp' | 'REMOTE_ALIAS_IDENTIFIER/credmut' | 'REMOTE_ALIAS_IDENTIFIER/dashboard' | 'REMOTE_ALIAS_IDENTIFIER/etat-saisie' | 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' | 'REMOTE_ALIAS_IDENTIFIER/github' | 'REMOTE_ALIAS_IDENTIFIER/mcp-access' | 'REMOTE_ALIAS_IDENTIFIER/payfit' | 'REMOTE_ALIAS_IDENTIFIER/sales' | 'REMOTE_ALIAS_IDENTIFIER/scrapers' | 'REMOTE_ALIAS_IDENTIFIER/spendesk' | 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' | 'REMOTE_ALIAS_IDENTIFIER/synchro' | 'REMOTE_ALIAS_IDENTIFIER/wise';
|
|
3
|
-
type PackageType<T> = T extends 'REMOTE_ALIAS_IDENTIFIER/wise' ? typeof import('REMOTE_ALIAS_IDENTIFIER/wise') :T extends 'REMOTE_ALIAS_IDENTIFIER/synchro' ? typeof import('REMOTE_ALIAS_IDENTIFIER/synchro') :T extends 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spreadsheet') :T extends 'REMOTE_ALIAS_IDENTIFIER/spendesk' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spendesk') :T extends 'REMOTE_ALIAS_IDENTIFIER/scrapers' ? typeof import('REMOTE_ALIAS_IDENTIFIER/scrapers') :T extends 'REMOTE_ALIAS_IDENTIFIER/sales' ? typeof import('REMOTE_ALIAS_IDENTIFIER/sales') :T extends 'REMOTE_ALIAS_IDENTIFIER/payfit' ? typeof import('REMOTE_ALIAS_IDENTIFIER/payfit') :T extends 'REMOTE_ALIAS_IDENTIFIER/mcp-access' ? typeof import('REMOTE_ALIAS_IDENTIFIER/mcp-access') :T extends 'REMOTE_ALIAS_IDENTIFIER/github' ? typeof import('REMOTE_ALIAS_IDENTIFIER/github') :T extends 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' ? typeof import('REMOTE_ALIAS_IDENTIFIER/finance-jobs') :T extends 'REMOTE_ALIAS_IDENTIFIER/etat-saisie' ? typeof import('REMOTE_ALIAS_IDENTIFIER/etat-saisie') :T extends 'REMOTE_ALIAS_IDENTIFIER/dashboard' ? typeof import('REMOTE_ALIAS_IDENTIFIER/dashboard') :T extends 'REMOTE_ALIAS_IDENTIFIER/credmut' ? typeof import('REMOTE_ALIAS_IDENTIFIER/credmut') :T extends 'REMOTE_ALIAS_IDENTIFIER/bnpp' ? typeof import('REMOTE_ALIAS_IDENTIFIER/bnpp') :T extends 'REMOTE_ALIAS_IDENTIFIER/amex' ? typeof import('REMOTE_ALIAS_IDENTIFIER/amex') :any;
|
|
2
|
+
export type RemoteKeys = 'REMOTE_ALIAS_IDENTIFIER/amex' | 'REMOTE_ALIAS_IDENTIFIER/bnpp' | 'REMOTE_ALIAS_IDENTIFIER/credmut' | 'REMOTE_ALIAS_IDENTIFIER/dashboard' | 'REMOTE_ALIAS_IDENTIFIER/etat-saisie' | 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' | 'REMOTE_ALIAS_IDENTIFIER/github' | 'REMOTE_ALIAS_IDENTIFIER/mcp-access' | 'REMOTE_ALIAS_IDENTIFIER/payfit' | 'REMOTE_ALIAS_IDENTIFIER/sales' | 'REMOTE_ALIAS_IDENTIFIER/scrapers' | 'REMOTE_ALIAS_IDENTIFIER/spendesk' | 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' | 'REMOTE_ALIAS_IDENTIFIER/synchro' | 'REMOTE_ALIAS_IDENTIFIER/usage' | 'REMOTE_ALIAS_IDENTIFIER/wise';
|
|
3
|
+
type PackageType<T> = T extends 'REMOTE_ALIAS_IDENTIFIER/wise' ? typeof import('REMOTE_ALIAS_IDENTIFIER/wise') :T extends 'REMOTE_ALIAS_IDENTIFIER/usage' ? typeof import('REMOTE_ALIAS_IDENTIFIER/usage') :T extends 'REMOTE_ALIAS_IDENTIFIER/synchro' ? typeof import('REMOTE_ALIAS_IDENTIFIER/synchro') :T extends 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spreadsheet') :T extends 'REMOTE_ALIAS_IDENTIFIER/spendesk' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spendesk') :T extends 'REMOTE_ALIAS_IDENTIFIER/scrapers' ? typeof import('REMOTE_ALIAS_IDENTIFIER/scrapers') :T extends 'REMOTE_ALIAS_IDENTIFIER/sales' ? typeof import('REMOTE_ALIAS_IDENTIFIER/sales') :T extends 'REMOTE_ALIAS_IDENTIFIER/payfit' ? typeof import('REMOTE_ALIAS_IDENTIFIER/payfit') :T extends 'REMOTE_ALIAS_IDENTIFIER/mcp-access' ? typeof import('REMOTE_ALIAS_IDENTIFIER/mcp-access') :T extends 'REMOTE_ALIAS_IDENTIFIER/github' ? typeof import('REMOTE_ALIAS_IDENTIFIER/github') :T extends 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' ? typeof import('REMOTE_ALIAS_IDENTIFIER/finance-jobs') :T extends 'REMOTE_ALIAS_IDENTIFIER/etat-saisie' ? typeof import('REMOTE_ALIAS_IDENTIFIER/etat-saisie') :T extends 'REMOTE_ALIAS_IDENTIFIER/dashboard' ? typeof import('REMOTE_ALIAS_IDENTIFIER/dashboard') :T extends 'REMOTE_ALIAS_IDENTIFIER/credmut' ? typeof import('REMOTE_ALIAS_IDENTIFIER/credmut') :T extends 'REMOTE_ALIAS_IDENTIFIER/bnpp' ? typeof import('REMOTE_ALIAS_IDENTIFIER/bnpp') :T extends 'REMOTE_ALIAS_IDENTIFIER/amex' ? typeof import('REMOTE_ALIAS_IDENTIFIER/amex') :any;
|
package/dist/mf/@mf-types.zip
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["7915"],{3437:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{D:()=>CompanyLogo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);const BASE_URL="https://s3.dualstack.eu-west-3.amazonaws.com/media.airporting/companies";function CompanyLogo({slug,updatedAt,size=20,...rest}){const base=`${BASE_URL}/${slug}.png`;const url=updatedAt?`${base}?v=${new Date(updatedAt).getTime()}`:base;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Image,{src:url,fallbackSrc:`${BASE_URL}/undefined.png`,alt:slug??"",w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1},...rest})}},1354:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{m:()=>PageHeader});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(9632);var react__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3106);function formatRelative(now,then){const seconds=Math.max(0,Math.floor((now-then)/1e3));if(seconds<5)return"\xe0 l’instant";if(seconds<60)return`il y a ${seconds}s`;const minutes=Math.floor(seconds/60);if(minutes<60)return`il y a ${minutes} min`;const hours=Math.floor(minutes/60);return`il y a ${hours} h`}function PageHeader({title,leading,badge,updatedAt,isFetching,isError,onRefresh,actions}){const[now,setNow]=(0,react__WEBPACK_IMPORTED_MODULE_3__.useState)(()=>Date.now());(0,react__WEBPACK_IMPORTED_MODULE_3__.useEffect)(()=>{if(!updatedAt)return;const id=window.setInterval(()=>setNow(Date.now()),1e3);return()=>window.clearInterval(id)},[updatedAt]);const relative=updatedAt?formatRelative(now,updatedAt):null;const color=isError?"orange":isFetching?"teal":"dimmed";return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{justify:"space-between",align:"center",mih:48,mb:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[leading,/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Title,{order:2,children:title}),badge]}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[relative&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Text,{size:"xs",c:color,fw:isFetching?600:400,"data-testid":"page-header-freshness",children:isError?"\xe9chec maj":isFetching?"maj…":relative}),onRefresh&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Tooltip,{label:"Rafra\xeechir",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.ActionIcon,{variant:"default",size:"md",onClick:onRefresh,loading:isFetching,"aria-label":"Refresh",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__.IconRefresh,{size:16})})}),actions]})]})}},9781:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{h:()=>QuickBooksIcon});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);function QuickBooksIcon(props){const size=props.size??20;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("svg",{width:size,height:size,viewBox:"0 0 24 24",role:"img","aria-label":"QuickBooks",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("title",{children:"QuickBooks"}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("circle",{cx:"12",cy:"12",r:"12",fill:"#2CA01C"}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("text",{x:"12",y:"16.5",textAnchor:"middle",fontSize:"12",fontWeight:"700",fill:"#ffffff",fontFamily:"Arial, Helvetica, sans-serif",children:"qb"})]})}},243:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{j:()=>logoDevUrl});const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}},5494:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>EtatSaisie});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(3863);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useEtatSaisieLatest(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","etat-saisie","latest"],queryFn:async()=>(await api.etatSaisie.getLatestV1()).data,refetchOnWindowFocus:true})}function useEtatSaisieRecompute(){const api=(0,useApi.h)();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async()=>(await api.etatSaisie.recomputeV1()).data,onSuccess:()=>qc.invalidateQueries({queryKey:["tech","etat-saisie","latest"]})})}function useSetReconciliationMute(){const api=(0,useApi.h)();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async variables=>(await api.etatSaisie.setReconciliationMuteV1({company_id:variables.company_id,account_id:variables.account_id,muted:variables.muted})).data,onSuccess:()=>{qc.invalidateQueries({queryKey:["tech","etat-saisie","dossiers"]});qc.invalidateQueries({queryKey:["tech","etat-saisie","latest"]})}})}var tabler_icons_react_mjs_=__webpack_require__(9632);function DetailTable(props){const{columns,rows,onRowClick}=props;const[sortKey,setSortKey]=(0,index_js_.useState)(null);const[asc,setAsc]=(0,index_js_.useState)(false);const sorted=[...rows].sort((a,b)=>{if(!sortKey)return 0;const av=a[sortKey];const bv=b[sortKey];if("number"==typeof av&&"number"==typeof bv)return asc?av-bv:bv-av;return asc?String(av).localeCompare(String(bv)):String(bv).localeCompare(String(av))});const toggle=k=>{if(sortKey===k)setAsc(v=>!v);else{setSortKey(k);setAsc(false)}};const fmt=(v,numeric)=>{if(numeric&&"number"==typeof v)return v.toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2});if("boolean"==typeof v)return v?"✓":"";if(null==v)return"—";if("object"==typeof v)return"—";return String(v)};return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{striped:true,highlightOnHover:true,withTableBorder:true,stickyHeader:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{children:columns.map(c=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{onClick:()=>toggle(c.key),style:{cursor:"pointer"},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:4,wrap:"nowrap",component:"span",display:"inline-flex",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:c.label}),c.hint?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:c.hint,multiline:true,w:260,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)("span",{style:{display:"inline-flex",alignItems:"center"},onClick:e=>e.stopPropagation(),children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconInfoCircle,{size:13})})}):null,/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:sortKey===c.key?asc?" ▲":" ▼":""})]})},c.key))})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:0===sorted.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{colSpan:columns.length,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",ta:"center",children:"Aucune ligne"})})}):sorted.map((row,i)=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{onClick:onRowClick?()=>onRowClick(row):void 0,style:onRowClick?{cursor:"pointer"}:void 0,children:columns.map(c=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{style:c.numeric?{textAlign:"right",fontVariantNumeric:"tabular-nums"}:void 0,children:c.render?c.render(row):fmt(row[c.key],c.numeric)},c.key))},i))})]})}function useDossiers(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","etat-saisie","dossiers"],queryFn:async()=>(await api.etatSaisie.getDossiersV1()).data,refetchOnWindowFocus:true})}function useSetManaged(){const api=(0,useApi.h)();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async variables=>(await api.etatSaisie.setManagedV1({id:variables.id},{managed:variables.managed})).data,onSuccess:()=>{qc.invalidateQueries({queryKey:["tech","etat-saisie","dossiers"]});qc.invalidateQueries({queryKey:["tech","etat-saisie","latest"]})}})}function useSetResponsable(){const api=(0,useApi.h)();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async variables=>(await api.etatSaisie.setResponsableV1({id:variables.id},{notion_user_id:variables.notionUserId})).data,onSuccess:()=>{qc.invalidateQueries({queryKey:["tech","etat-saisie","dossiers"]})}})}var logoDev=__webpack_require__(243);var QuickBooksIcon=__webpack_require__(9781);const PROVIDER_DOMAIN={pennylane:"pennylane.com",zohobooks:"zoho.com",xero:"xero.com",odoo:"odoo.com"};function ProviderIcon(props){const{provider}=props;if(!provider)return null;if("quickbooks"===provider)return/*#__PURE__*/(0,jsx_runtime.jsx)(QuickBooksIcon.h,{size:20});const domain=PROVIDER_DOMAIN[provider];if(!domain)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"sm",variant:"light",color:"gray",title:provider,children:provider.slice(0,2).toUpperCase()});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Image,{src:(0,logoDev.j)(domain),alt:provider,title:provider,w:20,h:20,fit:"contain",radius:"sm",style:{aspectRatio:1}})}function DossiersTab(){const isMobile=(0,esm_index_mjs_.useMediaQuery)("(max-width: 48em)",false);const dossiers=useDossiers();const setManaged=useSetManaged();const setResponsable=useSetResponsable();const[filter,setFilter]=(0,index_js_.useState)("");const options=dossiers.data?.responsable_options??[];const optionData=options.map(u=>({value:String(u.id),label:u.name}));const rows=(0,index_js_.useMemo)(()=>{const all=dossiers.data?.dossiers??[];const needle=filter.trim().toLowerCase();const filtered=needle?all.filter(dossier=>dossier.display_name.toLowerCase().includes(needle)||dossier.slug.toLowerCase().includes(needle)):all;return[...filtered].sort((a,b)=>a.display_name.localeCompare(b.display_name))},[dossiers.data,filter]);if(dossiers.isError)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",mt:"md",children:"Erreur de chargement des dossiers."});return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{mb:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{placeholder:"Filtrer par nom ou slug",value:filter,onChange:event=>setFilter(event.currentTarget.value),w:isMobile?"100%":320})}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Stack,{gap:"sm",children:0===rows.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",ta:"center",py:"xl",children:"Aucun dossier"}):rows.map(dossier=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,p:"sm",radius:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:dossier.provider}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:dossier.display_name}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:dossier.slug})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{checked:dossier.managed,onChange:event=>setManaged.mutate({id:dossier.airporting_id,managed:event.currentTarget.checked})})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{placeholder:"Responsable",data:optionData,value:dossier.responsable?String(dossier.responsable.id):null,onChange:v=>setResponsable.mutate({id:dossier.airporting_id,notionUserId:v?Number(v):null}),searchable:true,clearable:true,leftSection:dossier.responsable?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:dossier.responsable.avatar_url,size:20,radius:"xl"}):void 0})]})},`${dossier.airporting_id}:${dossier.provider}`))}):/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{striped:true,highlightOnHover:true,withTableBorder:true,stickyHeader:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Source"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Dossier"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"G\xe9r\xe9"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Responsable"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:0===rows.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{colSpan:4,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",ta:"center",children:"Aucun dossier"})})}):rows.map(dossier=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:dossier.provider})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:dossier.display_name}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{checked:dossier.managed,onChange:event=>setManaged.mutate({id:dossier.airporting_id,managed:event.currentTarget.checked})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{placeholder:"—",data:optionData,value:dossier.responsable?String(dossier.responsable.id):null,onChange:v=>setResponsable.mutate({id:dossier.airporting_id,notionUserId:v?Number(v):null}),searchable:true,clearable:true,w:220,leftSection:dossier.responsable?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:dossier.responsable.avatar_url,size:20,radius:"xl"}):void 0})})]},`${dossier.airporting_id}:${dossier.provider}`))})]})]})}function ManagedBadge(props){const{managed}=props;if(!managed)return null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Image,{src:(0,logoDev.j)("airporting.com"),alt:"G\xe9r\xe9 par Airporting",title:"G\xe9r\xe9 par Airporting",w:18,h:18,fit:"contain",radius:"sm",style:{aspectRatio:1}})}const BANK_DOMAINS=[["bnp paribas","bnpparibas.com"],["societe generale","societegenerale.fr"],["qonto","qonto.com"],["revolut","revolut.com"],["stripe","stripe.com"],["wise","wise.com"],["transferwise","wise.com"],["ibanfirst","ibanfirst.com"],["credit agricole","credit-agricole.fr"],["credit mutuel","creditmutuel.fr"],["banque populaire","banquepopulaire.fr"],["caisse d","caisse-epargne.fr"],["american express","americanexpress.com"],["amex","americanexpress.com"],["paypal","paypal.com"],["hsbc","hsbc.com"],["pennylane","pennylane.com"],["mercury","mercury.com"],["lcl","lcl.fr"],["boursorama","boursorama.com"],["bpce","bpce.fr"]];function normalize(value){return value.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu,"")}function BankLogo(props){const{label,size=20}=props;const normalized=label?normalize(label):"";const match=BANK_DOMAINS.find(([needle])=>normalized.includes(needle));if(!match)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,children:"\uD83C\uDFE6"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Image,{src:(0,logoDev.j)(match[1]),alt:label??"",title:label??"",w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}var CompanyLogo=__webpack_require__(3437);var PageHeader=__webpack_require__(1354);function drillCategoryLabel(category){if("471"===category)return"D\xe9tail 471";if("58"===category)return"D\xe9tail 58";if("supplier"===category)return"Fournisseurs d\xe9biteurs 401";if("customer"===category)return"Clients cr\xe9diteurs 411";return null}const STALE_THRESHOLD_DAYS=30;function staleBadge(isoDate){if(!isoDate)return null;const days=Math.floor((Date.now()-new Date(isoDate).getTime())/864e5);if(days<STALE_THRESHOLD_DAYS)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Badge,{ml:6,size:"xs",color:"red",variant:"light",children:["+",days,"j"]})}function syncBadge(isoDate){if(!isoDate)return null;const days=Math.floor((Date.now()-new Date(isoDate).getTime())/864e5);let color="green";if(days>10)color="red";else if(days>4)color="orange";return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Badge,{ml:6,size:"xs",color:color,variant:"light",children:[days,"j"]})}function isStaleRefresh(refreshedAt,computedAt){if(!refreshedAt)return false;const refreshedDay=refreshedAt.slice(0,10);const referenceDay=(computedAt??new Date().toISOString()).slice(0,10);return refreshedDay<referenceDay}function refreshKoBadge(refreshedAt,computedAt){if(!isStaleRefresh(refreshedAt,computedAt))return null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:`Chiffres du ${formatDate(refreshedAt?.slice(0,10))} \u{2014} refresh KO ce run`,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{ml:6,size:"xs",color:"yellow",variant:"light",children:"refresh KO"})})}function withDossierFilter(rows,dossier){if(!dossier)return rows;return rows.filter(r=>r.dossier===dossier)}function withManagedFilter(rows,managedOnly){if(!managedOnly)return rows;return rows.filter(r=>true===r.managed)}function withCategoryFilter(rows,category){if("all"===category)return rows;return rows.filter(r=>r.category===category)}function etatBadge(row){if("error"===row.status)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"red",variant:"light",children:"Erreur"});if("too_large"===row.status)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"orange",variant:"light",children:"Trop volumineux"});if("anomalie"===row.category)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"orange",variant:"light",children:"Anomalie"});if("stale"===row.reason)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"yellow",variant:"light",children:"P\xe9rim\xe9"});if("empty"===row.reason)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"gray",variant:"light",children:"Vide"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"green",variant:"light",children:"Propre"})}function formatCurrency(value){if(null==value)return"—";return value.toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:0,maximumFractionDigits:2})}function formatNumber(value){if(null==value)return"—";return value.toLocaleString("fr-FR")}function formatDate(value){if(!value)return"—";return value.split("-").reverse().join("/")}function formatKeur(value){if(null==value)return"—";const keur=(value/1e3).toLocaleString("fr-FR",{minimumFractionDigits:0,maximumFractionDigits:1});return`${keur} k\u{20AC}`}function ClickableMetricValue(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,td:"underline",style:{cursor:"pointer"},onClick:e=>{e.stopPropagation();props.onClick()},children:props.value})}function clickableCardStyle(clickable){return clickable?{cursor:"pointer"}:void 0}function MobileMetricGrid({metrics}){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:2,spacing:"xs",children:metrics.map(metric=>/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:metric.label}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:700,c:metric.color,lineClamp:2,children:metric.value})]},metric.label))})}function MobileAccountingList(props){const{rows,emptyLabel="Aucune ligne",getKey,renderHeader,getMetrics,onRowClick}=props;if(0===rows.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",ta:"center",py:"xl",children:emptyLabel});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Stack,{gap:"sm",children:rows.map((row,index)=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,p:"sm",radius:"md",onClick:onRowClick?()=>onRowClick(row):void 0,style:clickableCardStyle(!!onRowClick),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[renderHeader(row),/*#__PURE__*/(0,jsx_runtime.jsx)(MobileMetricGrid,{metrics:getMetrics(row)})]})},getKey(row,index)))})}function MobileDossierLineList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:row=>props.onDrill(row),getKey:row=>`${row.source}:${row.dossier}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsx)(CompanyLogo.D,{slug:row.slug,updatedAt:row.logo_updated_at,size:24}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:row.dossier}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.responsable?.name??"Sans responsable"})]})]})]}),etatBadge(row)]}),getMetrics:row=>[{label:"471",value:/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(row.solde_attente_eur),onClick:()=>props.onDrill(row,"471")})},{label:"58",value:/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(row.solde_virements_eur),onClick:()=>props.onDrill(row,"58")})},{label:"401",value:/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(row.total_fournisseurs_eur),onClick:()=>props.onDrill(row,"supplier")})},{label:"411",value:/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(row.total_clients_eur),onClick:()=>props.onDrill(row,"customer")})},{label:"Derni\xe8re \xe9criture",value:/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[formatDate(row.last_entry_date),staleBadge(row.last_entry_date),refreshKoBadge(row.refreshed_at,props.computedAt)]})},{label:"Rappro",value:"pennylane"!==row.source?"—":row.last_reconciliation_date?formatDate(row.last_reconciliation_date):props.dossiersWithActiveReco.has(row.dossier)?"jamais":"—",color:"pennylane"===row.source&&null==row.last_reconciliation_date&&props.dossiersWithActiveReco.has(row.dossier)?"red":void 0},{label:"Dernier import GLA",value:"pennylane"!==row.source||null==row.gla_last_sync_date?"—":/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[formatDate(row.gla_last_sync_date.slice(0,10)),syncBadge(row.gla_last_sync_date)]})}]})}function MobileSuspenseList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:(row,index)=>`${row.dossier}:${row.date}:${row.numero_piece??index}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:row.dossier}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:2,children:row.libelle_ecriture??row.libelle_compte??"Sans libell\xe9"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Solde net",value:formatCurrency(row.solde_net)},{label:"Date",value:formatDate(row.date)},{label:"Compte",value:row.numero_compte??"—"},{label:"Pi\xe8ce",value:row.numero_piece??"—"}]})}function MobileSupplierList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:(row,index)=>`${row.dossier}:${row.fournisseur}:${index}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:row.fournisseur}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.dossier})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Solde d\xe9biteur",value:formatCurrency(row.solde_debiteur_eur)},{label:"\xc9critures",value:formatNumber(row.nb_ecritures)},{label:"Devise",value:row.devise||"—"}]})}function MobileCustomerList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:(row,index)=>`${row.dossier}:${row.client}:${index}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:row.client}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.dossier})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Solde cr\xe9diteur",value:formatCurrency(row.solde_crediteur_eur)},{label:"\xc9critures",value:formatNumber(row.nb_ecritures)},{label:"Devise",value:row.devise||"—"}]})}function MobileReconciliationList({rows,onToggleMute}){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:rows,getKey:(row,index)=>`${row.dossier}:${row.bank_label??index}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"center",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(BankLogo,{label:row.bank_label,size:24}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,c:row.muted?"dimmed":void 0,children:row.bank_label??"Banque"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{size:"sm",checked:!row.muted,label:row.muted?"non suivi":"suivi",onLabel:"suivi",onChange:e=>onToggleMute({company_id:row.airporting_company_id,account_id:row.account_id,muted:!e.currentTarget.checked})})]}),getMetrics:row=>[{label:"Dernier rappro",value:row.muted?"non suivi":row.last_reconciled_period_end?formatDate(row.last_reconciled_period_end):"jamais",color:row.muted?"dimmed":row.last_reconciled_period_end?void 0:"red"}]})}function MobileTopSuspenseList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:row=>`471:${row.rank}:${row.dossier}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:["#",row.rank," ",row.dossier]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.top_libelle??"Sans libell\xe9"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Solde 471",value:formatCurrency(row.solde_eur)},{label:"\xc9critures",value:formatNumber(row.nb_ecritures)},{label:"Top montant",value:formatCurrency(row.top_montant)}]})}function MobileTopSupplierList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:row=>`401:${row.rank}:${row.dossier}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:["#",row.rank," ",row.dossier]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.top_nom??"Sans fournisseur"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Total d\xe9biteur",value:formatCurrency(row.total_eur)},{label:"Fournisseurs",value:formatNumber(row.nb_fournisseurs)},{label:"Top montant",value:formatCurrency(row.top_montant)}]})}function MobileTopCustomerList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:row=>`411:${row.rank}:${row.dossier}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:["#",row.rank," ",row.dossier]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.top_nom??"Sans client"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Total cr\xe9diteur",value:formatCurrency(row.total_eur)},{label:"Clients",value:formatNumber(row.nb_clients)},{label:"Top montant",value:formatCurrency(row.top_montant)}]})}function EtatSaisieApp(){const isMobile=(0,esm_index_mjs_.useMediaQuery)("(max-width: 48em)",false);const latest=useEtatSaisieLatest();const recompute=useEtatSaisieRecompute();const setReconciliationMute=useSetReconciliationMute();const[tab,setTab]=(0,index_js_.useState)("resume");const[selectedDossier,setSelectedDossier]=(0,index_js_.useState)(null);const[managedOnly,setManagedOnly]=(0,index_js_.useState)(true);const[statusFilter,setStatusFilter]=(0,index_js_.useState)("all");const[drillDossier,setDrillDossier]=(0,index_js_.useState)(null);const[drillCategory,setDrillCategory]=(0,index_js_.useState)(null);const d=latest.data;const allDossiers=(0,index_js_.useMemo)(()=>{if(!d?.available)return[];const set=new Set;for(const r of d.suspense_rows??[])set.add(r.dossier);for(const r of d.supplier_rows??[])set.add(r.dossier);for(const r of d.customer_rows??[])set.add(r.dossier);for(const r of d.dossier_lines??[])set.add(r.dossier);for(const r of d.reconciliation_rows??[])set.add(r.dossier);for(const r of d.summary?.top_5_suspense??[])set.add(r.dossier);for(const r of d.summary?.top_5_supplier_debtors??[])set.add(r.dossier);for(const r of d.summary?.top_5_customer_creditors??[])set.add(r.dossier);return[...set].sort()},[d]);const dossiersWithActiveReco=(0,index_js_.useMemo)(()=>{const set=new Set;for(const r of d?.reconciliation_rows??[])if(!r.muted)set.add(r.dossier);return set},[d]);const openDrill=(row,category=null)=>{setDrillDossier(row.dossier);setDrillCategory(category)};const closeDrill=()=>{setDrillDossier(null);setDrillCategory(null)};const drillData=(0,index_js_.useMemo)(()=>{if(!drillDossier||!d?.available)return null;const reconciliation=(d.reconciliation_rows??[]).filter(r=>r.dossier===drillDossier).sort((a,b)=>{const av=a.last_reconciled_period_end??"0000-00-00";const bv=b.last_reconciled_period_end??"0000-00-00";return av.localeCompare(bv)});return{reconciliation,suspense:(d.suspense_rows??[]).filter(r=>r.dossier===drillDossier),internalTransfers:(d.internal_transfer_rows??[]).filter(r=>r.dossier===drillDossier),supplier:(d.supplier_rows??[]).filter(r=>r.dossier===drillDossier),customer:(d.customer_rows??[]).filter(r=>r.dossier===drillDossier)}},[drillDossier,d]);const summaryRows=(0,index_js_.useMemo)(()=>withCategoryFilter(withManagedFilter(withDossierFilter(d?.dossier_lines??[],selectedDossier),managedOnly),statusFilter),[d,selectedDossier,managedOnly,statusFilter]);const topSuspenseRows=(0,index_js_.useMemo)(()=>withDossierFilter(d?.summary?.top_5_suspense??[],selectedDossier),[d,selectedDossier]);const topSupplierRows=(0,index_js_.useMemo)(()=>withDossierFilter(d?.summary?.top_5_supplier_debtors??[],selectedDossier),[d,selectedDossier]);const topCustomerRows=(0,index_js_.useMemo)(()=>withDossierFilter(d?.summary?.top_5_customer_creditors??[],selectedDossier),[d,selectedDossier]);const suspenseRows=(0,index_js_.useMemo)(()=>withManagedFilter(withDossierFilter(d?.suspense_rows??[],selectedDossier),managedOnly),[d,selectedDossier,managedOnly]);const internalTransferRows=(0,index_js_.useMemo)(()=>withManagedFilter(withDossierFilter(d?.internal_transfer_rows??[],selectedDossier),managedOnly),[d,selectedDossier,managedOnly]);const supplierRows=(0,index_js_.useMemo)(()=>withManagedFilter(withDossierFilter(d?.supplier_rows??[],selectedDossier),managedOnly),[d,selectedDossier,managedOnly]);const customerRows=(0,index_js_.useMemo)(()=>withManagedFilter(withDossierFilter(d?.customer_rows??[],selectedDossier),managedOnly),[d,selectedDossier,managedOnly]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{fluid:true,my:isMobile?0:"md",px:isMobile?12:void 0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(PageHeader.m,{title:"Accounting",updatedAt:d?.computed_at?new Date(d.computed_at).getTime():latest.dataUpdatedAt,isFetching:latest.isFetching,isError:latest.isError,onRefresh:()=>latest.refetch(),actions:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:recompute.isPending,onClick:()=>recompute.mutate(),variant:"light",size:isMobile?"xs":"sm",children:"Recalculer"})}),d&&!d.available?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Aucun snapshot disponible — lancez \xab Recalculer \xbb ou attendez le run nocturne."}):/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{mb:"md",align:"end",gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Focus dossier",placeholder:"Tous les dossiers",data:allDossiers.map(dos=>({value:dos,label:dos})),value:selectedDossier,onChange:setSelectedDossier,searchable:true,clearable:true,w:isMobile?"100%":320}),selectedDossier&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",onClick:()=>setSelectedDossier(null),w:isMobile?"100%":void 0,children:"R\xe9initialiser"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:managedOnly?"managed":"all",onChange:v=>setManagedOnly("managed"===v),data:[{label:"G\xe9r\xe9s",value:"managed"},{label:"Tous",value:"all"}],w:isMobile?"100%":void 0})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Tabs,{value:tab,onChange:setTab,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Tabs.List,{style:isMobile?{flexWrap:"nowrap",overflowX:"auto",overflowY:"hidden"}:void 0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Tab,{value:"resume",children:"R\xe9sum\xe9"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Tab,{value:"dossiers",children:"Dossiers"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Tabs.Panel,{value:"resume",pt:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:isMobile?2:4,mb:"md",spacing:"sm",children:[{key:"all",label:"Scann\xe9s",value:d?.summary?.companies_scanned??0,color:void 0},{key:"propre",label:"Propres",value:d?.summary?.companies_clean??0,color:"green"},{key:"anomalie",label:"En anomalie",value:d?.summary?.companies_with_anomalies??0,color:"orange"},{key:"erreur",label:"En erreur",value:d?.summary?.companies_in_error??0,color:"red"}].map(tile=>{const active=statusFilter===tile.key;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{withBorder:active,style:{cursor:"pointer",borderColor:active?"var(--mantine-color-blue-5)":void 0},onClick:()=>setStatusFilter(tile.key),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:tile.label}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"xl",c:tile.color,children:tile.value})]},tile.key)})}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileDossierLineList,{rows:summaryRows,onDrill:openDrill,computedAt:d?.computed_at,dossiersWithActiveReco:dossiersWithActiveReco}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:buildUnifiedCols(d?.computed_at,openDrill,dossiersWithActiveReco),rows:summaryRows,onRowClick:openDrill})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"top5",pt:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:"Top 5 comptes d'attente (471)"}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileTopSuspenseList,{rows:topSuspenseRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:TOP_SUSPENSE_COLS,rows:topSuspenseRows,onRowClick:openDrill})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:"Top 5 fournisseurs d\xe9biteurs (401)"}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileTopSupplierList,{rows:topSupplierRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:TOP_SUPPLIER_COLS,rows:topSupplierRows,onRowClick:openDrill})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:"Top 5 clients cr\xe9diteurs (411)"}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileTopCustomerList,{rows:topCustomerRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:TOP_CUSTOMER_COLS,rows:topCustomerRows,onRowClick:openDrill})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s471",pt:"md",children:isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSuspenseList,{rows:suspenseRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:SUSPENSE_COLS,rows:suspenseRows,onRowClick:openDrill})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s58",pt:"md",children:isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSuspenseList,{rows:internalTransferRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:SUSPENSE_COLS,rows:internalTransferRows,onRowClick:openDrill})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s401",pt:"md",children:isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSupplierList,{rows:supplierRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:SUPPLIER_COLS,rows:supplierRows,onRowClick:openDrill})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s411",pt:"md",children:isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileCustomerList,{rows:customerRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:CUSTOMER_COLS,rows:customerRows,onRowClick:openDrill})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"dossiers",pt:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(DossiersTab,{})})]})]}),latest.isError?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",mt:"md",children:"Erreur de chargement."}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Drawer,{opened:!!drillDossier,onClose:closeDrill,position:isMobile?"bottom":"right",size:isMobile?"calc(100dvh - 88px)":"xl",title:drillDossier?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",wrap:isMobile?"wrap":"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:isMobile?5:4,children:drillCategoryLabel(drillCategory)?`${drillCategoryLabel(drillCategory)} \u{2014} ${drillDossier}`:`Dossier ${drillDossier}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"light",onClick:()=>{setSelectedDossier(drillDossier);closeDrill()},children:"Focus sur ce dossier"})]}):null,styles:isMobile?{body:{padding:12,paddingBottom:24}}:void 0,children:drillData&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[null===drillCategory&&/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:5,mb:6,children:["Rappros bancaires (",drillData.reconciliation.length,")"]}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileReconciliationList,{rows:drillData.reconciliation,onToggleMute:setReconciliationMute.mutate}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:buildDrillRecoCols(setReconciliationMute.mutate),rows:drillData.reconciliation})]}),(null===drillCategory||"471"===drillCategory)&&/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:5,mb:6,children:["Comptes d'attente 471 (",drillData.suspense.length,")"]}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSuspenseList,{rows:drillData.suspense}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:DRILL_SUSPENSE_COLS,rows:drillData.suspense})]}),(null===drillCategory||"58"===drillCategory)&&/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:5,mb:6,children:["Virements internes 58 (",drillData.internalTransfers.length,")"]}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSuspenseList,{rows:drillData.internalTransfers}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:DRILL_SUSPENSE_COLS,rows:drillData.internalTransfers})]}),(null===drillCategory||"supplier"===drillCategory)&&/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:5,mb:6,children:["Fournisseurs d\xe9biteurs 401 (",drillData.supplier.length,")"]}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSupplierList,{rows:drillData.supplier}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:DRILL_SUPPLIER_COLS,rows:drillData.supplier})]}),(null===drillCategory||"customer"===drillCategory)&&/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:5,mb:6,children:["Clients cr\xe9diteurs 411 (",drillData.customer.length,")"]}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileCustomerList,{rows:drillData.customer}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:DRILL_CUSTOMER_COLS,rows:drillData.customer})]})]})})]})}const TOP_SUSPENSE_COLS=[{key:"rank",label:"#",numeric:true},{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"G\xe9r\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"solde_eur",label:"Solde 471 (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr.",numeric:true},{key:"top_libelle",label:"Top \xe9criture"},{key:"top_montant",label:"Montant",numeric:true}];const TOP_SUPPLIER_COLS=[{key:"rank",label:"#",numeric:true},{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"total_eur",label:"Total d\xe9biteur (€)",numeric:true},{key:"nb_fournisseurs",label:"Nb fourn.",numeric:true},{key:"top_nom",label:"Top fournisseur"},{key:"top_montant",label:"Montant",numeric:true}];const TOP_CUSTOMER_COLS=[{key:"rank",label:"#",numeric:true},{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"total_eur",label:"Total cr\xe9diteur (€)",numeric:true},{key:"nb_clients",label:"Nb clients",numeric:true},{key:"top_nom",label:"Top client"},{key:"top_montant",label:"Montant",numeric:true}];function buildUnifiedCols(computedAt,openDrill,dossiersWithActiveReco){return[{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"status",label:"\xc9tat",render:r=>etatBadge(r)},{key:"dossier",label:"Dossier",render:r=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(CompanyLogo.D,{slug:r.slug,updatedAt:r.logo_updated_at,size:20}),/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:r.dossier})]})},{key:"responsable",label:"Responsable",render:r=>r.responsable?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:r.responsable.avatar_url,size:20,radius:"xl"}),/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:r.responsable.name})]}):/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:"—"})},{key:"fiscal_year_end",label:"Cl\xf4ture",render:r=>r.fiscal_year_end?/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:r.fiscal_year_end.split("-").reverse().join("/")}):/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:"—"})},{key:"solde_attente_eur",label:"Solde 471",numeric:true,render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(r.solde_attente_eur),onClick:()=>openDrill(r,"471")})},{key:"solde_virements_eur",label:"Solde 58",numeric:true,render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(r.solde_virements_eur),onClick:()=>openDrill(r,"58")})},{key:"total_fournisseurs_eur",label:"Fourn. d\xe9biteurs",numeric:true,render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(r.total_fournisseurs_eur),onClick:()=>openDrill(r,"supplier")})},{key:"total_clients_eur",label:"Clients cr\xe9diteurs",numeric:true,render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(r.total_clients_eur),onClick:()=>openDrill(r,"customer")})},{key:"last_entry_date",label:"Derni\xe8re \xe9criture",render:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)("span",{children:[row.last_entry_date??"—",staleBadge(row.last_entry_date),refreshKoBadge(row.refreshed_at,computedAt)]})},{key:"last_reconciliation_date",label:"Rappro le + en retard",render:r=>{if("pennylane"!==r.source)return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:"—"});if(null==r.last_reconciliation_date){if(!dossiersWithActiveReco.has(r.dossier))return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"dimmed",children:"—"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"red",fw:700,td:"underline",style:{cursor:"pointer"},children:"jamais"})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,td:"underline",style:{cursor:"pointer"},children:r.last_reconciliation_date.split("-").reverse().join("/")})}},{key:"gla_last_sync_date",label:"Dernier import GLA",hint:'Derni\xe8re ex\xe9cution de l\'import GLA (recopie des \xe9critures Pennylane dans notre base) — \xe0 distinguer de "Derni\xe8re \xe9criture" = date de la derni\xe8re \xe9criture comptable.',render:r=>{if("pennylane"!==r.source||null==r.gla_last_sync_date)return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:"—"});return/*#__PURE__*/(0,jsx_runtime.jsxs)("span",{children:[r.gla_last_sync_date.slice(0,10).split("-").reverse().join("/"),syncBadge(r.gla_last_sync_date)]})}},{key:"pending_supplier_invoices",label:"Fact. fourn. \xe0 traiter",numeric:true,render:r=>{if("pennylane"!==r.source||null==r.pending_supplier_invoices)return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:"—"});return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:r.pending_supplier_invoices})}}]}const SUSPENSE_COLS=[{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"date",label:"Date"},{key:"numero_compte",label:"N\xb0 Compte"},{key:"libelle_compte",label:"Libell\xe9 compte"},{key:"libelle_ecriture",label:"Libell\xe9 \xe9criture"},{key:"journal",label:"Journal"},{key:"numero_piece",label:"N\xb0 Pi\xe8ce"},{key:"debit",label:"D\xe9bit",numeric:true},{key:"credit",label:"Cr\xe9dit",numeric:true},{key:"solde_net",label:"Solde net",numeric:true},{key:"lettre",label:"Lettr\xe9"},{key:"devise",label:"Devise"}];const SUPPLIER_COLS=[{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"fournisseur",label:"Fournisseur"},{key:"solde_debiteur_eur",label:"Solde d\xe9biteur (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr. non lettr\xe9es",numeric:true},{key:"devise",label:"Devise"}];const CUSTOMER_COLS=[{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"client",label:"Client"},{key:"solde_crediteur_eur",label:"Solde cr\xe9diteur (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr. non lettr\xe9es",numeric:true},{key:"devise",label:"Devise"}];function buildDrillRecoCols(onToggleMute){return[{key:"bank_label",label:"Banque",render:r=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(BankLogo,{label:r.bank_label,size:20}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:r.muted?"dimmed":void 0,children:r.bank_label??"—"})]})},{key:"last_reconciled_period_end",label:"Dernier rappro",render:r=>{if(r.muted)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"dimmed",children:"non suivi"});if(null==r.last_reconciled_period_end)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"red",fw:700,children:"jamais"});return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:r.last_reconciled_period_end.split("-").reverse().join("/")})}},{key:"muted",label:"Suivi",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{size:"sm",checked:!r.muted,label:r.muted?"non suivi":"suivi",onLabel:"suivi",onChange:e=>onToggleMute({company_id:r.airporting_company_id,account_id:r.account_id,muted:!e.currentTarget.checked})})}]}const DRILL_SUSPENSE_COLS=[{key:"date",label:"Date"},{key:"numero_compte",label:"N\xb0 Compte"},{key:"libelle_ecriture",label:"Libell\xe9"},{key:"debit",label:"D\xe9bit",numeric:true},{key:"credit",label:"Cr\xe9dit",numeric:true},{key:"solde_net",label:"Solde net",numeric:true},{key:"lettre",label:"Lettr\xe9"}];const DRILL_SUPPLIER_COLS=[{key:"fournisseur",label:"Fournisseur"},{key:"solde_debiteur_eur",label:"Solde d\xe9biteur (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr.",numeric:true},{key:"devise",label:"Devise"}];const DRILL_CUSTOMER_COLS=[{key:"client",label:"Client"},{key:"solde_crediteur_eur",label:"Solde cr\xe9diteur (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr.",numeric:true},{key:"devise",label:"Devise"}];function EtatSaisie(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(EtatSaisieApp,{})})})}}}]);
|
|
1
|
+
"use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["7915"],{3437:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{D:()=>CompanyLogo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);const BASE_URL="https://s3.dualstack.eu-west-3.amazonaws.com/media.airporting/companies";function CompanyLogo({slug,updatedAt,size=20,...rest}){const base=`${BASE_URL}/${slug}.png`;const url=updatedAt?`${base}?v=${new Date(updatedAt).getTime()}`:base;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Image,{src:url,fallbackSrc:`${BASE_URL}/undefined.png`,alt:slug??"",w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1},...rest})}},1354:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{m:()=>PageHeader});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(9632);var react__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3106);function formatRelative(now,then){const seconds=Math.max(0,Math.floor((now-then)/1e3));if(seconds<5)return"\xe0 l’instant";if(seconds<60)return`il y a ${seconds}s`;const minutes=Math.floor(seconds/60);if(minutes<60)return`il y a ${minutes} min`;const hours=Math.floor(minutes/60);return`il y a ${hours} h`}function PageHeader({title,leading,badge,updatedAt,isFetching,isError,onRefresh,actions}){const[now,setNow]=(0,react__WEBPACK_IMPORTED_MODULE_3__.useState)(()=>Date.now());(0,react__WEBPACK_IMPORTED_MODULE_3__.useEffect)(()=>{if(!updatedAt)return;const id=window.setInterval(()=>setNow(Date.now()),1e3);return()=>window.clearInterval(id)},[updatedAt]);const relative=updatedAt?formatRelative(now,updatedAt):null;const color=isError?"orange":isFetching?"teal":"dimmed";return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{justify:"space-between",align:"center",mih:48,mb:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[leading,/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Title,{order:2,children:title}),badge]}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[relative&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Text,{size:"xs",c:color,fw:isFetching?600:400,"data-testid":"page-header-freshness",children:isError?"\xe9chec maj":isFetching?"maj…":relative}),onRefresh&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Tooltip,{label:"Rafra\xeechir",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.ActionIcon,{variant:"default",size:"md",onClick:onRefresh,loading:isFetching,"aria-label":"Refresh",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__.IconRefresh,{size:16})})}),actions]})]})}},9781:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{h:()=>QuickBooksIcon});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);function QuickBooksIcon(props){const size=props.size??20;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("svg",{width:size,height:size,viewBox:"0 0 24 24",role:"img","aria-label":"QuickBooks",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("title",{children:"QuickBooks"}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("circle",{cx:"12",cy:"12",r:"12",fill:"#2CA01C"}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("text",{x:"12",y:"16.5",textAnchor:"middle",fontSize:"12",fontWeight:"700",fill:"#ffffff",fontFamily:"Arial, Helvetica, sans-serif",children:"qb"})]})}},243:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{j:()=>logoDevUrl});const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}},5494:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>EtatSaisie});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(3863);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useEtatSaisieLatest(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","etat-saisie","latest"],queryFn:async()=>(await api.etatSaisie.getLatestV1()).data,refetchOnWindowFocus:true})}function useEtatSaisieRecompute(){const api=(0,useApi.h)();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async()=>(await api.etatSaisie.recomputeV1()).data,onSuccess:()=>qc.invalidateQueries({queryKey:["tech","etat-saisie","latest"]})})}function useSetReconciliationMute(){const api=(0,useApi.h)();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async variables=>(await api.etatSaisie.setReconciliationMuteV1({company_id:variables.company_id,account_id:variables.account_id,muted:variables.muted})).data,onSuccess:()=>{qc.invalidateQueries({queryKey:["tech","etat-saisie","dossiers"]});qc.invalidateQueries({queryKey:["tech","etat-saisie","latest"]})}})}var tabler_icons_react_mjs_=__webpack_require__(9632);function DetailTable(props){const{columns,rows,onRowClick}=props;const[sortKey,setSortKey]=(0,index_js_.useState)(null);const[asc,setAsc]=(0,index_js_.useState)(false);const sorted=[...rows].sort((a,b)=>{if(!sortKey)return 0;const av=a[sortKey];const bv=b[sortKey];if("number"==typeof av&&"number"==typeof bv)return asc?av-bv:bv-av;return asc?String(av).localeCompare(String(bv)):String(bv).localeCompare(String(av))});const toggle=k=>{if(sortKey===k)setAsc(v=>!v);else{setSortKey(k);setAsc(false)}};const fmt=(v,numeric)=>{if(numeric&&"number"==typeof v)return v.toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2});if("boolean"==typeof v)return v?"✓":"";if(null==v)return"—";if("object"==typeof v)return"—";return String(v)};return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{striped:true,highlightOnHover:true,withTableBorder:true,stickyHeader:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{children:columns.map(c=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{onClick:()=>toggle(c.key),style:{cursor:"pointer"},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:4,wrap:"nowrap",component:"span",display:"inline-flex",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:c.label}),c.hint?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:c.hint,multiline:true,w:260,withArrow:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)("span",{style:{display:"inline-flex",alignItems:"center"},onClick:e=>e.stopPropagation(),children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconInfoCircle,{size:13})})}):null,/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:sortKey===c.key?asc?" ▲":" ▼":""})]})},c.key))})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:0===sorted.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{colSpan:columns.length,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",ta:"center",children:"Aucune ligne"})})}):sorted.map((row,i)=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{onClick:onRowClick?()=>onRowClick(row):void 0,style:onRowClick?{cursor:"pointer"}:void 0,children:columns.map(c=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{style:c.numeric?{textAlign:"right",fontVariantNumeric:"tabular-nums"}:void 0,children:c.render?c.render(row):fmt(row[c.key],c.numeric)},c.key))},i))})]})}function useDossiers(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","etat-saisie","dossiers"],queryFn:async()=>(await api.etatSaisie.getDossiersV1()).data,refetchOnWindowFocus:true})}function useSetManaged(){const api=(0,useApi.h)();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async variables=>(await api.etatSaisie.setManagedV1({id:variables.id},{managed:variables.managed})).data,onSuccess:()=>{qc.invalidateQueries({queryKey:["tech","etat-saisie","dossiers"]});qc.invalidateQueries({queryKey:["tech","etat-saisie","latest"]})}})}function useSetResponsable(){const api=(0,useApi.h)();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async variables=>(await api.etatSaisie.setResponsableV1({id:variables.id},{notion_user_id:variables.notionUserId})).data,onSuccess:()=>{qc.invalidateQueries({queryKey:["tech","etat-saisie","dossiers"]})}})}var logoDev=__webpack_require__(243);var QuickBooksIcon=__webpack_require__(9781);const PROVIDER_DOMAIN={pennylane:"pennylane.com",zohobooks:"zoho.com",xero:"xero.com",odoo:"odoo.com"};function ProviderIcon(props){const{provider}=props;if(!provider)return null;if("quickbooks"===provider)return/*#__PURE__*/(0,jsx_runtime.jsx)(QuickBooksIcon.h,{size:20});const domain=PROVIDER_DOMAIN[provider];if(!domain)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"sm",variant:"light",color:"gray",title:provider,children:provider.slice(0,2).toUpperCase()});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Image,{src:(0,logoDev.j)(domain),alt:provider,title:provider,w:20,h:20,fit:"contain",radius:"sm",style:{aspectRatio:1}})}function DossiersTab(){const isMobile=(0,esm_index_mjs_.useMediaQuery)("(max-width: 48em)",false);const dossiers=useDossiers();const setManaged=useSetManaged();const setResponsable=useSetResponsable();const[filter,setFilter]=(0,index_js_.useState)("");const options=dossiers.data?.responsable_options??[];const optionData=options.map(u=>({value:String(u.id),label:u.name}));const rows=(0,index_js_.useMemo)(()=>{const all=dossiers.data?.dossiers??[];const needle=filter.trim().toLowerCase();const filtered=needle?all.filter(dossier=>dossier.display_name.toLowerCase().includes(needle)||dossier.slug.toLowerCase().includes(needle)):all;return[...filtered].sort((a,b)=>a.display_name.localeCompare(b.display_name))},[dossiers.data,filter]);if(dossiers.isError)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",mt:"md",children:"Erreur de chargement des dossiers."});return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{mb:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{placeholder:"Filtrer par nom ou slug",value:filter,onChange:event=>setFilter(event.currentTarget.value),w:isMobile?"100%":320})}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Stack,{gap:"sm",children:0===rows.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",ta:"center",py:"xl",children:"Aucun dossier"}):rows.map(dossier=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,p:"sm",radius:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:dossier.provider}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:dossier.display_name}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:dossier.slug})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{checked:dossier.managed,onChange:event=>setManaged.mutate({id:dossier.airporting_id,managed:event.currentTarget.checked})})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{placeholder:"Responsable",data:optionData,value:dossier.responsable?String(dossier.responsable.id):null,onChange:v=>setResponsable.mutate({id:dossier.airporting_id,notionUserId:v?Number(v):null}),searchable:true,clearable:true,leftSection:dossier.responsable?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:dossier.responsable.avatar_url,size:20,radius:"xl"}):void 0})]})},`${dossier.airporting_id}:${dossier.provider}`))}):/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{striped:true,highlightOnHover:true,withTableBorder:true,stickyHeader:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Source"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Dossier"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"G\xe9r\xe9"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Responsable"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:0===rows.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{colSpan:4,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",ta:"center",children:"Aucun dossier"})})}):rows.map(dossier=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:dossier.provider})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:dossier.display_name}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{checked:dossier.managed,onChange:event=>setManaged.mutate({id:dossier.airporting_id,managed:event.currentTarget.checked})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{placeholder:"—",data:optionData,value:dossier.responsable?String(dossier.responsable.id):null,onChange:v=>setResponsable.mutate({id:dossier.airporting_id,notionUserId:v?Number(v):null}),searchable:true,clearable:true,w:220,leftSection:dossier.responsable?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:dossier.responsable.avatar_url,size:20,radius:"xl"}):void 0})})]},`${dossier.airporting_id}:${dossier.provider}`))})]})]})}function ManagedBadge(props){const{managed}=props;if(!managed)return null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Image,{src:(0,logoDev.j)("airporting.com"),alt:"G\xe9r\xe9 par Airporting",title:"G\xe9r\xe9 par Airporting",w:18,h:18,fit:"contain",radius:"sm",style:{aspectRatio:1}})}const BANK_DOMAINS=[["bnp paribas","bnpparibas.com"],["societe generale","societegenerale.fr"],["qonto","qonto.com"],["revolut","revolut.com"],["stripe","stripe.com"],["wise","wise.com"],["transferwise","wise.com"],["ibanfirst","ibanfirst.com"],["credit agricole","credit-agricole.fr"],["credit mutuel","creditmutuel.fr"],["banque populaire","banquepopulaire.fr"],["caisse d","caisse-epargne.fr"],["american express","americanexpress.com"],["amex","americanexpress.com"],["paypal","paypal.com"],["hsbc","hsbc.com"],["pennylane","pennylane.com"],["mercury","mercury.com"],["lcl","lcl.fr"],["boursorama","boursorama.com"],["bpce","bpce.fr"]];function normalize(value){return value.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu,"")}function BankLogo(props){const{label,size=20}=props;const normalized=label?normalize(label):"";const match=BANK_DOMAINS.find(([needle])=>normalized.includes(needle));if(!match)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,children:"\uD83C\uDFE6"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Image,{src:(0,logoDev.j)(match[1]),alt:label??"",title:label??"",w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}var CompanyLogo=__webpack_require__(3437);var PageHeader=__webpack_require__(1354);function drillCategoryLabel(category){if("471"===category)return"D\xe9tail 471";if("58"===category)return"D\xe9tail 58";if("supplier"===category)return"Fournisseurs d\xe9biteurs 401";if("customer"===category)return"Clients cr\xe9diteurs 411";return null}const STALE_THRESHOLD_DAYS=30;function staleBadge(isoDate){if(!isoDate)return null;const days=Math.floor((Date.now()-new Date(isoDate).getTime())/864e5);if(days<STALE_THRESHOLD_DAYS)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Badge,{ml:6,size:"xs",color:"red",variant:"light",children:["+",days,"j"]})}function syncBadge(isoDate){if(!isoDate)return null;const days=Math.floor((Date.now()-new Date(isoDate).getTime())/864e5);let color="green";if(days>10)color="red";else if(days>4)color="orange";return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Badge,{ml:6,size:"xs",color:color,variant:"light",children:[days,"j"]})}function isStaleRefresh(refreshedAt,computedAt){if(!refreshedAt)return false;const refreshedDay=refreshedAt.slice(0,10);const referenceDay=(computedAt??new Date().toISOString()).slice(0,10);return refreshedDay<referenceDay}function refreshKoBadge(refreshedAt,computedAt){if(!isStaleRefresh(refreshedAt,computedAt))return null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:`Chiffres du ${formatDate(refreshedAt?.slice(0,10))} \u{2014} refresh KO ce run`,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{ml:6,size:"xs",color:"yellow",variant:"light",children:"refresh KO"})})}function withDossierFilter(rows,dossier){if(!dossier)return rows;return rows.filter(r=>r.dossier===dossier)}function withManagedFilter(rows,managedOnly){if(!managedOnly)return rows;return rows.filter(r=>true===r.managed)}function withCategoryFilter(rows,category){if("all"===category)return rows;return rows.filter(r=>r.category===category)}function etatBadge(row){if("error"===row.status)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"red",variant:"light",children:"Erreur"});if("too_large"===row.status)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"orange",variant:"light",children:"Trop volumineux"});if("anomalie"===row.category)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"orange",variant:"light",children:"Anomalie"});if("stale"===row.reason)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"yellow",variant:"light",children:"P\xe9rim\xe9"});if("empty"===row.reason)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"gray",variant:"light",children:"Vide"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"green",variant:"light",children:"Propre"})}function formatCurrency(value){if(null==value)return"—";return value.toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:0,maximumFractionDigits:2})}function formatNumber(value){if(null==value)return"—";return value.toLocaleString("fr-FR")}function formatDate(value){if(!value)return"—";return value.split("-").reverse().join("/")}function formatKeur(value){if(null==value)return"—";const keur=(value/1e3).toLocaleString("fr-FR",{minimumFractionDigits:0,maximumFractionDigits:1});return`${keur} k\u{20AC}`}function ClickableMetricValue(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,td:"underline",style:{cursor:"pointer"},onClick:e=>{e.stopPropagation();props.onClick()},children:props.value})}function clickableCardStyle(clickable){return clickable?{cursor:"pointer"}:void 0}function MobileMetricGrid({metrics}){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:2,spacing:"xs",children:metrics.map(metric=>/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:metric.label}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:700,c:metric.color,lineClamp:2,children:metric.value})]},metric.label))})}function MobileAccountingList(props){const{rows,emptyLabel="Aucune ligne",getKey,renderHeader,getMetrics,onRowClick}=props;if(0===rows.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",ta:"center",py:"xl",children:emptyLabel});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Stack,{gap:"sm",children:rows.map((row,index)=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,p:"sm",radius:"md",onClick:onRowClick?()=>onRowClick(row):void 0,style:clickableCardStyle(!!onRowClick),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[renderHeader(row),/*#__PURE__*/(0,jsx_runtime.jsx)(MobileMetricGrid,{metrics:getMetrics(row)})]})},getKey(row,index)))})}function MobileDossierLineList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:row=>props.onDrill(row),getKey:row=>`${row.source}:${row.dossier}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsx)(CompanyLogo.D,{slug:row.slug,updatedAt:row.logo_updated_at,size:24}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:row.dossier}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.responsable?.name??"Sans responsable"})]})]})]}),etatBadge(row)]}),getMetrics:row=>[{label:"471",value:/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(row.solde_attente_eur),onClick:()=>props.onDrill(row,"471")})},{label:"58",value:/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(row.solde_virements_eur),onClick:()=>props.onDrill(row,"58")})},{label:"401",value:/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(row.total_fournisseurs_eur),onClick:()=>props.onDrill(row,"supplier")})},{label:"411",value:/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(row.total_clients_eur),onClick:()=>props.onDrill(row,"customer")})},{label:"Derni\xe8re \xe9criture",value:/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[formatDate(row.last_entry_date),staleBadge(row.last_entry_date),refreshKoBadge(row.refreshed_at,props.computedAt)]})},{label:"Rappro",value:"pennylane"!==row.source?"—":row.last_reconciliation_date?formatDate(row.last_reconciliation_date):props.dossiersWithActiveReco.has(row.dossier)?"jamais":"—",color:"pennylane"===row.source&&null==row.last_reconciliation_date&&props.dossiersWithActiveReco.has(row.dossier)?"red":void 0},{label:"Dernier import GLA",value:null==row.gla_last_sync_date?"—":/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[formatDate(row.gla_last_sync_date.slice(0,10)),syncBadge(row.gla_last_sync_date)]})}]})}function MobileSuspenseList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:(row,index)=>`${row.dossier}:${row.date}:${row.numero_piece??index}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:row.dossier}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:2,children:row.libelle_ecriture??row.libelle_compte??"Sans libell\xe9"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Solde net",value:formatCurrency(row.solde_net)},{label:"Date",value:formatDate(row.date)},{label:"Compte",value:row.numero_compte??"—"},{label:"Pi\xe8ce",value:row.numero_piece??"—"}]})}function MobileSupplierList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:(row,index)=>`${row.dossier}:${row.fournisseur}:${index}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:row.fournisseur}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.dossier})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Solde d\xe9biteur",value:formatCurrency(row.solde_debiteur_eur)},{label:"\xc9critures",value:formatNumber(row.nb_ecritures)},{label:"Devise",value:row.devise||"—"}]})}function MobileCustomerList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:(row,index)=>`${row.dossier}:${row.client}:${index}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:row.client}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.dossier})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Solde cr\xe9diteur",value:formatCurrency(row.solde_crediteur_eur)},{label:"\xc9critures",value:formatNumber(row.nb_ecritures)},{label:"Devise",value:row.devise||"—"}]})}function MobileReconciliationList({rows,onToggleMute}){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:rows,getKey:(row,index)=>`${row.dossier}:${row.bank_label??index}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"center",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(BankLogo,{label:row.bank_label,size:24}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,c:row.muted?"dimmed":void 0,children:row.bank_label??"Banque"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{size:"sm",checked:!row.muted,label:row.muted?"non suivi":"suivi",onLabel:"suivi",onChange:e=>onToggleMute({company_id:row.airporting_company_id,account_id:row.account_id,muted:!e.currentTarget.checked})})]}),getMetrics:row=>[{label:"Dernier rappro",value:row.muted?"non suivi":row.last_reconciled_period_end?formatDate(row.last_reconciled_period_end):"jamais",color:row.muted?"dimmed":row.last_reconciled_period_end?void 0:"red"}]})}function MobileTopSuspenseList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:row=>`471:${row.rank}:${row.dossier}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:["#",row.rank," ",row.dossier]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.top_libelle??"Sans libell\xe9"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Solde 471",value:formatCurrency(row.solde_eur)},{label:"\xc9critures",value:formatNumber(row.nb_ecritures)},{label:"Top montant",value:formatCurrency(row.top_montant)}]})}function MobileTopSupplierList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:row=>`401:${row.rank}:${row.dossier}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:["#",row.rank," ",row.dossier]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.top_nom??"Sans fournisseur"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Total d\xe9biteur",value:formatCurrency(row.total_eur)},{label:"Fournisseurs",value:formatNumber(row.nb_fournisseurs)},{label:"Top montant",value:formatCurrency(row.top_montant)}]})}function MobileTopCustomerList(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(MobileAccountingList,{rows:props.rows,onRowClick:props.onRowClick,getKey:row=>`411:${row.rank}:${row.dossier}`,renderHeader:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",gap:"sm",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",miw:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:row.source}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:700,size:"sm",lineClamp:1,children:["#",row.rank," ",row.dossier]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",lineClamp:1,children:row.top_nom??"Sans client"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:row.managed})]}),getMetrics:row=>[{label:"Total cr\xe9diteur",value:formatCurrency(row.total_eur)},{label:"Clients",value:formatNumber(row.nb_clients)},{label:"Top montant",value:formatCurrency(row.top_montant)}]})}function EtatSaisieApp(){const isMobile=(0,esm_index_mjs_.useMediaQuery)("(max-width: 48em)",false);const latest=useEtatSaisieLatest();const recompute=useEtatSaisieRecompute();const setReconciliationMute=useSetReconciliationMute();const[tab,setTab]=(0,index_js_.useState)("resume");const[selectedDossier,setSelectedDossier]=(0,index_js_.useState)(null);const[managedOnly,setManagedOnly]=(0,index_js_.useState)(true);const[statusFilter,setStatusFilter]=(0,index_js_.useState)("all");const[drillDossier,setDrillDossier]=(0,index_js_.useState)(null);const[drillCategory,setDrillCategory]=(0,index_js_.useState)(null);const d=latest.data;const allDossiers=(0,index_js_.useMemo)(()=>{if(!d?.available)return[];const set=new Set;for(const r of d.suspense_rows??[])set.add(r.dossier);for(const r of d.supplier_rows??[])set.add(r.dossier);for(const r of d.customer_rows??[])set.add(r.dossier);for(const r of d.dossier_lines??[])set.add(r.dossier);for(const r of d.reconciliation_rows??[])set.add(r.dossier);for(const r of d.summary?.top_5_suspense??[])set.add(r.dossier);for(const r of d.summary?.top_5_supplier_debtors??[])set.add(r.dossier);for(const r of d.summary?.top_5_customer_creditors??[])set.add(r.dossier);return[...set].sort()},[d]);const dossiersWithActiveReco=(0,index_js_.useMemo)(()=>{const set=new Set;for(const r of d?.reconciliation_rows??[])if(!r.muted)set.add(r.dossier);return set},[d]);const openDrill=(row,category=null)=>{setDrillDossier(row.dossier);setDrillCategory(category)};const closeDrill=()=>{setDrillDossier(null);setDrillCategory(null)};const drillData=(0,index_js_.useMemo)(()=>{if(!drillDossier||!d?.available)return null;const reconciliation=(d.reconciliation_rows??[]).filter(r=>r.dossier===drillDossier).sort((a,b)=>{const av=a.last_reconciled_period_end??"0000-00-00";const bv=b.last_reconciled_period_end??"0000-00-00";return av.localeCompare(bv)});return{reconciliation,suspense:(d.suspense_rows??[]).filter(r=>r.dossier===drillDossier),internalTransfers:(d.internal_transfer_rows??[]).filter(r=>r.dossier===drillDossier),supplier:(d.supplier_rows??[]).filter(r=>r.dossier===drillDossier),customer:(d.customer_rows??[]).filter(r=>r.dossier===drillDossier)}},[drillDossier,d]);const summaryRows=(0,index_js_.useMemo)(()=>withCategoryFilter(withManagedFilter(withDossierFilter(d?.dossier_lines??[],selectedDossier),managedOnly),statusFilter),[d,selectedDossier,managedOnly,statusFilter]);const topSuspenseRows=(0,index_js_.useMemo)(()=>withDossierFilter(d?.summary?.top_5_suspense??[],selectedDossier),[d,selectedDossier]);const topSupplierRows=(0,index_js_.useMemo)(()=>withDossierFilter(d?.summary?.top_5_supplier_debtors??[],selectedDossier),[d,selectedDossier]);const topCustomerRows=(0,index_js_.useMemo)(()=>withDossierFilter(d?.summary?.top_5_customer_creditors??[],selectedDossier),[d,selectedDossier]);const suspenseRows=(0,index_js_.useMemo)(()=>withManagedFilter(withDossierFilter(d?.suspense_rows??[],selectedDossier),managedOnly),[d,selectedDossier,managedOnly]);const internalTransferRows=(0,index_js_.useMemo)(()=>withManagedFilter(withDossierFilter(d?.internal_transfer_rows??[],selectedDossier),managedOnly),[d,selectedDossier,managedOnly]);const supplierRows=(0,index_js_.useMemo)(()=>withManagedFilter(withDossierFilter(d?.supplier_rows??[],selectedDossier),managedOnly),[d,selectedDossier,managedOnly]);const customerRows=(0,index_js_.useMemo)(()=>withManagedFilter(withDossierFilter(d?.customer_rows??[],selectedDossier),managedOnly),[d,selectedDossier,managedOnly]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{fluid:true,my:isMobile?0:"md",px:isMobile?12:void 0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(PageHeader.m,{title:"Accounting",updatedAt:d?.computed_at?new Date(d.computed_at).getTime():latest.dataUpdatedAt,isFetching:latest.isFetching,isError:latest.isError,onRefresh:()=>latest.refetch(),actions:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:recompute.isPending,onClick:()=>recompute.mutate(),variant:"light",size:isMobile?"xs":"sm",children:"Recalculer"})}),d&&!d.available?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Aucun snapshot disponible — lancez \xab Recalculer \xbb ou attendez le run nocturne."}):/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{mb:"md",align:"end",gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Focus dossier",placeholder:"Tous les dossiers",data:allDossiers.map(dos=>({value:dos,label:dos})),value:selectedDossier,onChange:setSelectedDossier,searchable:true,clearable:true,w:isMobile?"100%":320}),selectedDossier&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",onClick:()=>setSelectedDossier(null),w:isMobile?"100%":void 0,children:"R\xe9initialiser"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:managedOnly?"managed":"all",onChange:v=>setManagedOnly("managed"===v),data:[{label:"G\xe9r\xe9s",value:"managed"},{label:"Tous",value:"all"}],w:isMobile?"100%":void 0})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Tabs,{value:tab,onChange:setTab,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Tabs.List,{style:isMobile?{flexWrap:"nowrap",overflowX:"auto",overflowY:"hidden"}:void 0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Tab,{value:"resume",children:"R\xe9sum\xe9"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Tab,{value:"dossiers",children:"Dossiers"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Tabs.Panel,{value:"resume",pt:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:isMobile?2:4,mb:"md",spacing:"sm",children:[{key:"all",label:"Scann\xe9s",value:d?.summary?.companies_scanned??0,color:void 0},{key:"propre",label:"Propres",value:d?.summary?.companies_clean??0,color:"green"},{key:"anomalie",label:"En anomalie",value:d?.summary?.companies_with_anomalies??0,color:"orange"},{key:"erreur",label:"En erreur",value:d?.summary?.companies_in_error??0,color:"red"}].map(tile=>{const active=statusFilter===tile.key;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{withBorder:active,style:{cursor:"pointer",borderColor:active?"var(--mantine-color-blue-5)":void 0},onClick:()=>setStatusFilter(tile.key),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:tile.label}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"xl",c:tile.color,children:tile.value})]},tile.key)})}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileDossierLineList,{rows:summaryRows,onDrill:openDrill,computedAt:d?.computed_at,dossiersWithActiveReco:dossiersWithActiveReco}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:buildUnifiedCols(d?.computed_at,openDrill,dossiersWithActiveReco),rows:summaryRows,onRowClick:openDrill})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"top5",pt:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:"Top 5 comptes d'attente (471)"}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileTopSuspenseList,{rows:topSuspenseRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:TOP_SUSPENSE_COLS,rows:topSuspenseRows,onRowClick:openDrill})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:"Top 5 fournisseurs d\xe9biteurs (401)"}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileTopSupplierList,{rows:topSupplierRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:TOP_SUPPLIER_COLS,rows:topSupplierRows,onRowClick:openDrill})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:"Top 5 clients cr\xe9diteurs (411)"}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileTopCustomerList,{rows:topCustomerRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:TOP_CUSTOMER_COLS,rows:topCustomerRows,onRowClick:openDrill})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s471",pt:"md",children:isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSuspenseList,{rows:suspenseRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:SUSPENSE_COLS,rows:suspenseRows,onRowClick:openDrill})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s58",pt:"md",children:isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSuspenseList,{rows:internalTransferRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:SUSPENSE_COLS,rows:internalTransferRows,onRowClick:openDrill})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s401",pt:"md",children:isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSupplierList,{rows:supplierRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:SUPPLIER_COLS,rows:supplierRows,onRowClick:openDrill})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s411",pt:"md",children:isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileCustomerList,{rows:customerRows,onRowClick:openDrill}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:CUSTOMER_COLS,rows:customerRows,onRowClick:openDrill})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"dossiers",pt:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(DossiersTab,{})})]})]}),latest.isError?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",mt:"md",children:"Erreur de chargement."}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Drawer,{opened:!!drillDossier,onClose:closeDrill,position:isMobile?"bottom":"right",size:isMobile?"calc(100dvh - 88px)":"xl",title:drillDossier?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",wrap:isMobile?"wrap":"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:isMobile?5:4,children:drillCategoryLabel(drillCategory)?`${drillCategoryLabel(drillCategory)} \u{2014} ${drillDossier}`:`Dossier ${drillDossier}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"light",onClick:()=>{setSelectedDossier(drillDossier);closeDrill()},children:"Focus sur ce dossier"})]}):null,styles:isMobile?{body:{padding:12,paddingBottom:24}}:void 0,children:drillData&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[null===drillCategory&&/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:5,mb:6,children:["Rappros bancaires (",drillData.reconciliation.length,")"]}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileReconciliationList,{rows:drillData.reconciliation,onToggleMute:setReconciliationMute.mutate}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:buildDrillRecoCols(setReconciliationMute.mutate),rows:drillData.reconciliation})]}),(null===drillCategory||"471"===drillCategory)&&/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:5,mb:6,children:["Comptes d'attente 471 (",drillData.suspense.length,")"]}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSuspenseList,{rows:drillData.suspense}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:DRILL_SUSPENSE_COLS,rows:drillData.suspense})]}),(null===drillCategory||"58"===drillCategory)&&/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:5,mb:6,children:["Virements internes 58 (",drillData.internalTransfers.length,")"]}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSuspenseList,{rows:drillData.internalTransfers}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:DRILL_SUSPENSE_COLS,rows:drillData.internalTransfers})]}),(null===drillCategory||"supplier"===drillCategory)&&/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:5,mb:6,children:["Fournisseurs d\xe9biteurs 401 (",drillData.supplier.length,")"]}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileSupplierList,{rows:drillData.supplier}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:DRILL_SUPPLIER_COLS,rows:drillData.supplier})]}),(null===drillCategory||"customer"===drillCategory)&&/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:5,mb:6,children:["Clients cr\xe9diteurs 411 (",drillData.customer.length,")"]}),isMobile?/*#__PURE__*/(0,jsx_runtime.jsx)(MobileCustomerList,{rows:drillData.customer}):/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:DRILL_CUSTOMER_COLS,rows:drillData.customer})]})]})})]})}const TOP_SUSPENSE_COLS=[{key:"rank",label:"#",numeric:true},{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"G\xe9r\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"solde_eur",label:"Solde 471 (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr.",numeric:true},{key:"top_libelle",label:"Top \xe9criture"},{key:"top_montant",label:"Montant",numeric:true}];const TOP_SUPPLIER_COLS=[{key:"rank",label:"#",numeric:true},{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"total_eur",label:"Total d\xe9biteur (€)",numeric:true},{key:"nb_fournisseurs",label:"Nb fourn.",numeric:true},{key:"top_nom",label:"Top fournisseur"},{key:"top_montant",label:"Montant",numeric:true}];const TOP_CUSTOMER_COLS=[{key:"rank",label:"#",numeric:true},{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"total_eur",label:"Total cr\xe9diteur (€)",numeric:true},{key:"nb_clients",label:"Nb clients",numeric:true},{key:"top_nom",label:"Top client"},{key:"top_montant",label:"Montant",numeric:true}];function buildUnifiedCols(computedAt,openDrill,dossiersWithActiveReco){return[{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"status",label:"\xc9tat",render:r=>etatBadge(r)},{key:"dossier",label:"Dossier",render:r=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(CompanyLogo.D,{slug:r.slug,updatedAt:r.logo_updated_at,size:20}),/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:r.dossier})]})},{key:"responsable",label:"Responsable",render:r=>r.responsable?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Avatar,{src:r.responsable.avatar_url,size:20,radius:"xl"}),/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:r.responsable.name})]}):/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:"—"})},{key:"fiscal_year_end",label:"Cl\xf4ture",render:r=>r.fiscal_year_end?/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:r.fiscal_year_end.split("-").reverse().join("/")}):/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:"—"})},{key:"solde_attente_eur",label:"Solde 471",numeric:true,render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(r.solde_attente_eur),onClick:()=>openDrill(r,"471")})},{key:"solde_virements_eur",label:"Solde 58",numeric:true,render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(r.solde_virements_eur),onClick:()=>openDrill(r,"58")})},{key:"total_fournisseurs_eur",label:"Fourn. d\xe9biteurs",numeric:true,render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(r.total_fournisseurs_eur),onClick:()=>openDrill(r,"supplier")})},{key:"total_clients_eur",label:"Clients cr\xe9diteurs",numeric:true,render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ClickableMetricValue,{value:formatKeur(r.total_clients_eur),onClick:()=>openDrill(r,"customer")})},{key:"last_entry_date",label:"Derni\xe8re \xe9criture",render:row=>/*#__PURE__*/(0,jsx_runtime.jsxs)("span",{children:[row.last_entry_date??"—",staleBadge(row.last_entry_date),refreshKoBadge(row.refreshed_at,computedAt)]})},{key:"last_reconciliation_date",label:"Rappro le + en retard",render:r=>{if("pennylane"!==r.source)return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:"—"});if(null==r.last_reconciliation_date){if(!dossiersWithActiveReco.has(r.dossier))return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"dimmed",children:"—"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"red",fw:700,td:"underline",style:{cursor:"pointer"},children:"jamais"})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,td:"underline",style:{cursor:"pointer"},children:r.last_reconciliation_date.split("-").reverse().join("/")})}},{key:"gla_last_sync_date",label:"Dernier import GLA",hint:"Derni\xe8re ex\xe9cution de l'import GLA (recopie des \xe9critures de l'outil comptable dans notre base) — \xe0 distinguer de \"Derni\xe8re \xe9criture\" = date de la derni\xe8re \xe9criture comptable.",render:r=>{if(null==r.gla_last_sync_date)return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:"—"});return/*#__PURE__*/(0,jsx_runtime.jsxs)("span",{children:[r.gla_last_sync_date.slice(0,10).split("-").reverse().join("/"),syncBadge(r.gla_last_sync_date)]})}},{key:"pending_supplier_invoices",label:"Fact. fourn. \xe0 traiter",numeric:true,render:r=>{if("pennylane"!==r.source||null==r.pending_supplier_invoices)return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:"—"});return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:r.pending_supplier_invoices})}}]}const SUSPENSE_COLS=[{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"date",label:"Date"},{key:"numero_compte",label:"N\xb0 Compte"},{key:"libelle_compte",label:"Libell\xe9 compte"},{key:"libelle_ecriture",label:"Libell\xe9 \xe9criture"},{key:"journal",label:"Journal"},{key:"numero_piece",label:"N\xb0 Pi\xe8ce"},{key:"debit",label:"D\xe9bit",numeric:true},{key:"credit",label:"Cr\xe9dit",numeric:true},{key:"solde_net",label:"Solde net",numeric:true},{key:"lettre",label:"Lettr\xe9"},{key:"devise",label:"Devise"}];const SUPPLIER_COLS=[{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"fournisseur",label:"Fournisseur"},{key:"solde_debiteur_eur",label:"Solde d\xe9biteur (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr. non lettr\xe9es",numeric:true},{key:"devise",label:"Devise"}];const CUSTOMER_COLS=[{key:"source",label:"Source",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ProviderIcon,{provider:r.source})},{key:"managed",label:"Manag\xe9",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(ManagedBadge,{managed:r.managed})},{key:"dossier",label:"Dossier"},{key:"client",label:"Client"},{key:"solde_crediteur_eur",label:"Solde cr\xe9diteur (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr. non lettr\xe9es",numeric:true},{key:"devise",label:"Devise"}];function buildDrillRecoCols(onToggleMute){return[{key:"bank_label",label:"Banque",render:r=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(BankLogo,{label:r.bank_label,size:20}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:r.muted?"dimmed":void 0,children:r.bank_label??"—"})]})},{key:"last_reconciled_period_end",label:"Dernier rappro",render:r=>{if(r.muted)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"dimmed",children:"non suivi"});if(null==r.last_reconciled_period_end)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"red",fw:700,children:"jamais"});return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:r.last_reconciled_period_end.split("-").reverse().join("/")})}},{key:"muted",label:"Suivi",render:r=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{size:"sm",checked:!r.muted,label:r.muted?"non suivi":"suivi",onLabel:"suivi",onChange:e=>onToggleMute({company_id:r.airporting_company_id,account_id:r.account_id,muted:!e.currentTarget.checked})})}]}const DRILL_SUSPENSE_COLS=[{key:"date",label:"Date"},{key:"numero_compte",label:"N\xb0 Compte"},{key:"libelle_ecriture",label:"Libell\xe9"},{key:"debit",label:"D\xe9bit",numeric:true},{key:"credit",label:"Cr\xe9dit",numeric:true},{key:"solde_net",label:"Solde net",numeric:true},{key:"lettre",label:"Lettr\xe9"}];const DRILL_SUPPLIER_COLS=[{key:"fournisseur",label:"Fournisseur"},{key:"solde_debiteur_eur",label:"Solde d\xe9biteur (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr.",numeric:true},{key:"devise",label:"Devise"}];const DRILL_CUSTOMER_COLS=[{key:"client",label:"Client"},{key:"solde_crediteur_eur",label:"Solde cr\xe9diteur (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr.",numeric:true},{key:"devise",label:"Devise"}];function EtatSaisie(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(EtatSaisieApp,{})})})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["4927"],{1354:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{m:()=>PageHeader});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(9632);var react__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3106);function formatRelative(now,then){const seconds=Math.max(0,Math.floor((now-then)/1e3));if(seconds<5)return"\xe0 l’instant";if(seconds<60)return`il y a ${seconds}s`;const minutes=Math.floor(seconds/60);if(minutes<60)return`il y a ${minutes} min`;const hours=Math.floor(minutes/60);return`il y a ${hours} h`}function PageHeader({title,leading,badge,updatedAt,isFetching,isError,onRefresh,actions}){const[now,setNow]=(0,react__WEBPACK_IMPORTED_MODULE_3__.useState)(()=>Date.now());(0,react__WEBPACK_IMPORTED_MODULE_3__.useEffect)(()=>{if(!updatedAt)return;const id=window.setInterval(()=>setNow(Date.now()),1e3);return()=>window.clearInterval(id)},[updatedAt]);const relative=updatedAt?formatRelative(now,updatedAt):null;const color=isError?"orange":isFetching?"teal":"dimmed";return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{justify:"space-between",align:"center",mih:48,mb:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[leading,/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Title,{order:2,children:title}),badge]}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[relative&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Text,{size:"xs",c:color,fw:isFetching?600:400,"data-testid":"page-header-freshness",children:isError?"\xe9chec maj":isFetching?"maj…":relative}),onRefresh&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Tooltip,{label:"Rafra\xeechir",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.ActionIcon,{variant:"default",size:"md",onClick:onRefresh,loading:isFetching,"aria-label":"Refresh",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__.IconRefresh,{size:16})})}),actions]})]})}},3694:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Usage});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useUsageCharge(view,at){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","usage","charge",view,at??null],queryFn:async()=>{const response=await api.http.request({path:"/v1/usage/charge",method:"GET",query:{view,...at?{at}:{}},format:"json"});return response.data},refetchInterval:"day"===view?6e4:false,refetchOnWindowFocus:true})}var PageHeader=__webpack_require__(1354);const USAGE_COLORS={productive:"#3987e5",errored:"#d03b3b",noop:"#fab219"};const AXIS_INK="#898781";function formatHours(hours){if(hours>=100)return`${Math.round(hours)} h`;return`${hours.toFixed(1).replace(".",",")} h`}function formatCount(value){return new Intl.NumberFormat("fr-FR").format(value)}function formatCompactCount(value){return new Intl.NumberFormat("fr-FR",{notation:"compact",maximumFractionDigits:1}).format(value)}function wastePercent(kpis){if(kpis.computeHours<=0)return 0;return Math.round((kpis.erroredHours+kpis.noopHours)/kpis.computeHours*100)}function UsageKpiRow(props){const{kpis}=props;const tiles=[{key:"compute",label:"Compute",value:formatHours(kpis.computeHours),hint:`${formatCount(kpis.tasks)} t\xe2ches, dont ${formatCount(kpis.worksheetTasks)} worksheets`},{key:"companies",label:"Entreprises actives",value:formatCount(kpis.companies),hint:`${formatCount(kpis.distinctJobs)} connecteurs distincts`},{key:"waste",label:"Compute non productif",value:`${formatHours(kpis.erroredHours+kpis.noopHours)} \xb7 ${wastePercent(kpis)} %`,hint:`${formatHours(kpis.erroredHours)} en erreur (${formatCount(kpis.erroredTasks)} t\xe2ches), ${formatHours(kpis.noopHours)} sans r\xe9sultat`,accent:USAGE_COLORS.errored},{key:"concurrency",label:"Concurrence max",value:null===kpis.maxConcurrent?"—":`${formatCount(kpis.maxConcurrent)} t\xe2ches`,hint:null===kpis.maxConcurrent?"Non calcul\xe9 sur 12 mois : trop co\xfbteux \xe0 recouvrir":"Pic de t\xe2ches simultan\xe9es, dur\xe9e born\xe9e \xe0 110 min"},{key:"rows",label:"Lignes synchronis\xe9es",value:formatCompactCount(kpis.rowsSynced),hint:"Somme des compteurs renvoy\xe9s par les jobs — proxy de tendance"}];return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:{base:1,sm:3,lg:5},spacing:"md",children:tiles.map(tile=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,align:"center",mb:6,children:[tile.accent?/*#__PURE__*/(0,jsx_runtime.jsx)("span",{"aria-hidden":true,style:{width:8,height:8,borderRadius:2,background:tile.accent,display:"inline-block"}}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",tt:"uppercase",fw:700,children:tile.label})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:tile.hint,withArrow:true,multiline:true,w:260,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fz:26,fw:600,lh:1.1,children:tile.value})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",mt:6,lineClamp:2,children:tile.hint})]},tile.key))})}var esm_index_mjs_=__webpack_require__(7183);const PARIS_TZ="Europe/Paris";const minuteFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,hour:"2-digit",minute:"2-digit"});const weekDayFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,weekday:"short",day:"numeric"});const monthFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,month:"short",year:"2-digit"});const fullDayFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:PARIS_TZ,weekday:"long",day:"numeric",month:"long"});function bucketDate(t){if(7===t.length)return new Date(`${t}-15T12:00:00Z`);return new Date(`${t}T12:00:00Z`)}function formatMinuteTick(iso){return minuteFormatter.format(new Date(iso))}function formatBucketTick(t,view){if("year"===view)return monthFormatter.format(bucketDate(t));if("month"===view)return String(bucketDate(t).getUTCDate());return weekDayFormatter.format(bucketDate(t))}function formatBucketLong(t,view){if("year"===view)return monthFormatter.format(bucketDate(t));return fullDayFormatter.format(bucketDate(t))}function formatWindow(from,to,view){if("day"===view)return fullDayFormatter.format(new Date(from));if("year"===view){const start=monthFormatter.format(new Date(from));const end=monthFormatter.format(new Date(new Date(to).getTime()-1));return`${start} \u{2192} ${end}`}const start=fullDayFormatter.format(new Date(from));const end=fullDayFormatter.format(new Date(new Date(to).getTime()-1));return`${start} \u{2192} ${end}`}function ConcurrencyTooltip({payload}){const point=payload?.[0]?.payload;if(!point)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatMinuteTick(point.t)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[point.concurrent," t\xe2che",point.concurrent>1?"s":""," en cours"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:[point.started," d\xe9marrage",point.started>1?"s":""]}),point.errored>0?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:USAGE_COLORS.errored,children:[point.errored," en erreur"]}):null]})}function ConcurrencyChart(props){const{data}=props;if(0===data.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucune t\xe2che sur la journ\xe9e."});return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.AreaChart,{h:260,data:data,dataKey:"t",withDots:false,strokeWidth:2,curveType:"linear",gridAxis:"y",tickLine:"none",series:[{name:"concurrent",label:"T\xe2ches en cours",color:USAGE_COLORS.productive}],xAxisProps:{tickFormatter:formatMinuteTick,minTickGap:48,stroke:AXIS_INK},yAxisProps:{allowDecimals:false,stroke:AXIS_INK,width:32},tooltipProps:{content:ConcurrencyTooltip},tooltipAnimationDuration:0})}const SURFACE="var(--mantine-color-body)";const SERIES=[{name:"productiveHours",label:"Productif",color:USAGE_COLORS.productive},{name:"noopHours",label:"Sans r\xe9sultat",color:USAGE_COLORS.noop},{name:"erroredHours",label:"En erreur",color:USAGE_COLORS.errored}];const TOP_SERIES=SERIES[SERIES.length-1].name;function makeTooltip(view){return function({payload}){const bucket=payload?.[0]?.payload;if(!bucket)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatBucketLong(bucket.t,view)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[formatHours(bucket.computeHours)," de compute"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:USAGE_COLORS.errored,children:["dont ",formatHours(bucket.erroredHours)," en erreur (",formatCount(bucket.erroredTasks)," t\xe2ches)"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:["dont ",formatHours(bucket.noopHours)," sans r\xe9sultat"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",mt:4,children:[formatCount(bucket.tasks)," t\xe2ches \xb7 ",formatCount(bucket.worksheetTasks)," ","worksheets"]}),bucket.waitMaxMinutes?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:["attente max ",Math.round(bucket.waitMaxMinutes)," min"]}):null]})}}function ChargeStack(props){const{buckets,view}=props;if(0===buckets.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Aucune t\xe2che sur la p\xe9riode."});return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:300,data:buckets,dataKey:"t",type:"stacked",withLegend:true,legendProps:{verticalAlign:"top",height:32},gridAxis:"y",tickLine:"none",unit:" h",series:SERIES,barProps:item=>({stroke:SURFACE,strokeWidth:1.5,strokeOpacity:1,radius:item.name===TOP_SERIES?[4,4,0,0]:0}),xAxisProps:{tickFormatter:t=>formatBucketTick(t,view),stroke:AXIS_INK,minTickGap:4},yAxisProps:{stroke:AXIS_INK,width:44},tooltipProps:{content:makeTooltip(view)},tooltipAnimationDuration:0})}const TRACTION_SERIES=[{name:"companies",label:"Entreprises actives",color:"#3987e5"},{name:"distinctJobs",label:"Connecteurs distincts",color:"#d95926"}];function TractionTooltip({payload}){const bucket=payload?.[0]?.payload;if(!bucket)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{px:"md",py:"sm",withBorder:true,shadow:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,mb:4,children:formatBucketLong(bucket.t,"year")}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[bucket.companies??0," entreprises actives"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:[bucket.distinctJobs??0," connecteurs distincts"]})]})}function TractionChart(props){const{buckets}=props;if(0===buckets.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",size:"sm",children:"Pas d'historique sur la p\xe9riode."});return/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.LineChart,{h:240,data:buckets,dataKey:"t",withLegend:true,legendProps:{verticalAlign:"top",height:32},strokeWidth:2,dotProps:{r:4},activeDotProps:{r:6},gridAxis:"y",tickLine:"none",series:TRACTION_SERIES,xAxisProps:{tickFormatter:t=>formatBucketTick(t,"year"),stroke:AXIS_INK},yAxisProps:{allowDecimals:false,stroke:AXIS_INK,width:40},tooltipProps:{content:TractionTooltip},tooltipAnimationDuration:0})}function ShareBar(props){const{hours,erroredHours,max}=props;if(max<=0)return null;const total=hours/max*100;const errored=Math.min(erroredHours,hours)/max*100;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Progress.Root,{size:"md",w:140,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Progress.Section,{value:Math.max(total-errored,0),color:USAGE_COLORS.productive}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Progress.Section,{value:errored,color:USAGE_COLORS.errored})]})}function TopCompaniesTable(props){const{rows,totalHours}=props;const max=rows.length>0?rows[0].computeHours:0;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,striped:false,verticalSpacing:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:32,children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:150,children:"Part"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:90,ta:"right",children:"Compute"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:70,ta:"right",children:"% total"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:100,ta:"right",children:"T\xe2ches"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map((row,index)=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{c:"dimmed",children:index+1}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Td,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:500,children:row.displayName??row.slug??`#${row.companyId}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:row.slug??`company ${row.companyId}`})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{withArrow:true,label:`${formatHours(row.erroredHours)} en erreur sur ${formatHours(row.computeHours)}`,children:/*#__PURE__*/(0,jsx_runtime.jsx)("div",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ShareBar,{hours:row.computeHours,erroredHours:row.erroredHours,max:max})})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",style:{fontVariantNumeric:"tabular-nums"},children:formatHours(row.computeHours)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:totalHours>0?`${Math.round(row.computeHours/totalHours*100)} %`:"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:formatCount(row.tasks)})]},row.companyId))})]})}function TopJobsTable(props){const{rows,totalHours}=props;const max=rows.length>0?rows[0].computeHours:0;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,verticalSpacing:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:32,children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Connecteur"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:150,children:"Part"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:90,ta:"right",children:"Compute"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:70,ta:"right",children:"% total"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{w:110,ta:"right",children:"h / entreprise"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map((row,index)=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{c:"dimmed",children:index+1}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Td,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:500,children:row.jobName}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",children:[formatCount(row.companies)," entreprise",row.companies>1?"s":""," \xb7 ",formatCount(row.tasks)," t\xe2ches"]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{withArrow:true,label:`${formatHours(row.erroredHours)} en erreur sur ${formatHours(row.computeHours)}`,children:/*#__PURE__*/(0,jsx_runtime.jsx)("div",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ShareBar,{hours:row.computeHours,erroredHours:row.erroredHours,max:max})})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",style:{fontVariantNumeric:"tabular-nums"},children:formatHours(row.computeHours)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:totalHours>0?`${Math.round(row.computeHours/totalHours*100)} %`:"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{ta:"right",c:"dimmed",style:{fontVariantNumeric:"tabular-nums"},children:row.companies>0?formatHours(row.computeHours/row.companies):"—"})]},row.jobName))})]})}const VIEW_OPTIONS=[{value:"day",label:"Jour"},{value:"week",label:"Semaine"},{value:"month",label:"Mois"},{value:"year",label:"12 mois"}];const CHART_TITLES={day:"T\xe2ches simultan\xe9es, minute par minute",week:"Compute par jour (lundi → dimanche)",month:"Compute par jour du mois",year:"Compute par mois"};function SectionTitle(props){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"baseline",mb:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",fw:600,children:props.children}),props.hint?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:props.hint}):null]})}function UsageApp(){const[view,setView]=(0,index_js_.useState)("day");const charge=useUsageCharge(view);const data=charge.data;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(PageHeader.m,{title:"Usage & charge",updatedAt:charge.dataUpdatedAt,isFetching:charge.isFetching,isError:charge.isError,onRefresh:()=>charge.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:view,onChange:value=>setView(value),data:VIEW_OPTIONS}),data?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:[formatWindow(data.from,data.to,data.view)," \xb7 heure de Paris"]}):null]}),charge.isError?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{color:"red",title:"Impossible de charger la charge",children:String(charge.error)}):null,data?/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(UsageKpiRow,{kpis:data.kpis}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"day"===view?"dur\xe9e born\xe9e \xe0 110 min — au-del\xe0, une t\xe2che est perdue, pas en cours":"heures de compute, d\xe9compos\xe9es par issue",children:CHART_TITLES[view]}),"day"===view?/*#__PURE__*/(0,jsx_runtime.jsx)(ConcurrencyChart,{data:data.concurrency}):/*#__PURE__*/(0,jsx_runtime.jsx)(ChargeStack,{buckets:data.buckets,view:data.view})]}),"year"===view?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"deux d\xe9nombrements, un seul axe",children:"Traction — entreprises actives et connecteurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(TractionChart,{buckets:data.buckets})]}):null,"day"===view&&data.buckets.length>0?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"d\xe9composition du compute de la journ\xe9e",children:"Compute de la journ\xe9e"}),/*#__PURE__*/(0,jsx_runtime.jsx)(ChargeStack,{buckets:data.buckets,view:data.view})]}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Grid,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:12,lg:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",h:"100%",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"classement, pas de moyenne",children:"Top consommateurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(TopCompaniesTable,{rows:data.topCompanies,totalHours:data.kpis.computeHours})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:12,lg:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"md",h:"100%",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SectionTitle,{hint:"brique de tarification du free",children:"Co\xfbt par connecteur"}),/*#__PURE__*/(0,jsx_runtime.jsx)(TopJobsTable,{rows:data.topJobs,totalHours:data.kpis.computeHours})]})})]})]}):/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:96}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:300})]})]})})}function Usage(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(UsageApp,{})})})}}}]);
|