@go-avro/avro-js 1.6.6-rc7 → 1.6.6-rc9
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.
|
@@ -11,7 +11,7 @@ import { Proposal } from '../types/api/Proposal.js';
|
|
|
11
11
|
import { ProposalTerms } from '../types/api/ProposalTerms.js';
|
|
12
12
|
import type { EmailSucceededPayload, EmailFailedPayload, EmailType } from '../types/api/EmailNotification.js';
|
|
13
13
|
import type { BulkDeleteBillsResponse, BulkEmailBillsResponse } from './hooks/bills.js';
|
|
14
|
-
import type { BillWritePayload, BreakWritePayload, CatalogItemCreatePayload, CatalogItemUpdatePayload, CompanyCreatePayload, CompanyUpdatePayload, EventCreatePayload,
|
|
14
|
+
import type { BillWritePayload, BreakWritePayload, CatalogItemCreatePayload, CatalogItemUpdatePayload, CompanyCreatePayload, CompanyUpdatePayload, EventCreatePayload, IntuitSyncStatus, MemberAddPayload, MemberUpdatePayload, PayoutStatusFilter, ProposalReviewPayload, ProposalWritePayload, SessionCreatePayload, SessionUpdatePayload, SkillCreatePayload, SkillUpdatePayload, TeamWritePayload, UserCreatePayload, UserUpdatePayload } from './requests.js';
|
|
15
15
|
import { type QueryPersistOptions } from './persist.js';
|
|
16
16
|
export interface TrackEmailOptions {
|
|
17
17
|
emailType?: EmailType;
|
|
@@ -486,7 +486,11 @@ declare module './QueryClient.js' {
|
|
|
486
486
|
id: string | null;
|
|
487
487
|
job_id: string | null;
|
|
488
488
|
}>;
|
|
489
|
-
useImportBillsFromIntuit(): ReturnType<typeof useMutation<
|
|
489
|
+
useImportBillsFromIntuit(): ReturnType<typeof useMutation<{
|
|
490
|
+
msg: string;
|
|
491
|
+
}, StandardError, void>>;
|
|
492
|
+
/** The company's QuickBooks sync as its socket events report it. */
|
|
493
|
+
useIntuitSyncStatus(): IntuitSyncStatus;
|
|
490
494
|
useSyncBillToIntuit(): ReturnType<typeof useMutation<{
|
|
491
495
|
msg: string;
|
|
492
496
|
}, StandardError, {
|
|
@@ -396,12 +396,15 @@ export class AvroQueryClient {
|
|
|
396
396
|
patchTeamLocation(queryClient, data);
|
|
397
397
|
patchMemberLocation(queryClient, data);
|
|
398
398
|
});
|
|
399
|
-
// schedule_locked
|
|
399
|
+
// schedule_locked and intuit_sync_locked live in Redis locks, not rows.
|
|
400
400
|
for (const event of [
|
|
401
401
|
'schedule_started',
|
|
402
402
|
'schedule_complete',
|
|
403
403
|
'scheduling_error',
|
|
404
404
|
'schedule_adjustments',
|
|
405
|
+
'intuit_sync_started',
|
|
406
|
+
'intuit_sync_complete',
|
|
407
|
+
'intuit_sync_error',
|
|
405
408
|
]) {
|
|
406
409
|
on(event, () => {
|
|
407
410
|
queryClient.invalidateQueries({ queryKey: ['companies'] });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useInfiniteQuery, useQuery, useMutation } from '@tanstack/react-query';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
2
3
|
import { AvroQueryClient } from '../QueryClient.js';
|
|
3
4
|
import { seedDetails } from '../cache.js';
|
|
4
5
|
import { restoreNs, snapshotNs } from '../cache.js';
|
|
@@ -221,16 +222,40 @@ AvroQueryClient.prototype.useSyncBillToIntuit = function () {
|
|
|
221
222
|
AvroQueryClient.prototype.useImportBillsFromIntuit = function () {
|
|
222
223
|
const queryClient = this.getQueryClient();
|
|
223
224
|
return useMutation({
|
|
225
|
+
// Starts the sync (202); follow it with useIntuitSyncStatus.
|
|
224
226
|
mutationFn: async () => {
|
|
225
227
|
return this.post({
|
|
226
228
|
path: `/company/${this.companyId}/intuit/import`,
|
|
227
229
|
});
|
|
228
230
|
},
|
|
229
|
-
onSuccess: () => {
|
|
230
|
-
this.syncAfterMutation('bill');
|
|
231
|
-
},
|
|
232
231
|
});
|
|
233
232
|
};
|
|
233
|
+
/**
|
|
234
|
+
* The company's QuickBooks sync, followed over the socket: `running` (with the
|
|
235
|
+
* latest progress) from `intuit_sync_started` on, then `complete` with the
|
|
236
|
+
* counts or `error`. Every staff member sees a run, whoever started it; the
|
|
237
|
+
* bills it changes arrive through the changes stream.
|
|
238
|
+
*/
|
|
239
|
+
AvroQueryClient.prototype.useIntuitSyncStatus = function () {
|
|
240
|
+
const [status, setStatus] = useState({ state: 'idle' });
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
const started = () => setStatus({ state: 'running' });
|
|
243
|
+
const progress = (data) => setStatus({ state: 'running', progress: data });
|
|
244
|
+
const complete = (data) => setStatus({ state: 'complete', result: data });
|
|
245
|
+
const failed = (data) => setStatus({ state: 'error', message: data?.msg ?? 'QuickBooks sync failed' });
|
|
246
|
+
this.on('intuit_sync_started', started);
|
|
247
|
+
this.on('intuit_sync_progress', progress);
|
|
248
|
+
this.on('intuit_sync_complete', complete);
|
|
249
|
+
this.on('intuit_sync_error', failed);
|
|
250
|
+
return () => {
|
|
251
|
+
this.off('intuit_sync_started', started);
|
|
252
|
+
this.off('intuit_sync_progress', progress);
|
|
253
|
+
this.off('intuit_sync_complete', complete);
|
|
254
|
+
this.off('intuit_sync_error', failed);
|
|
255
|
+
};
|
|
256
|
+
}, [this]);
|
|
257
|
+
return status;
|
|
258
|
+
};
|
|
234
259
|
AvroQueryClient.prototype.generatePDFFromBackend = function ({ billId }) {
|
|
235
260
|
return this.get({
|
|
236
261
|
path: `/company/${this.companyId}/bill/${billId}/pdf`,
|
|
@@ -229,17 +229,41 @@ export interface BillWritePayload {
|
|
|
229
229
|
enabled_payment_methods?: PaymentType[];
|
|
230
230
|
pass_on_fees?: boolean;
|
|
231
231
|
}
|
|
232
|
-
/**
|
|
232
|
+
/** Counts a finished QuickBooks sync reports (the `intuit_sync_complete` payload). */
|
|
233
233
|
export interface IntuitImportResult {
|
|
234
234
|
msg: string;
|
|
235
235
|
imported: number;
|
|
236
236
|
skipped: number;
|
|
237
237
|
payments_imported: number;
|
|
238
238
|
payments_skipped: number;
|
|
239
|
+
/** Avro bills sent to QuickBooks as new invoices. */
|
|
239
240
|
pushed: number;
|
|
241
|
+
/** Avro payments sent to QuickBooks. */
|
|
240
242
|
payments_pushed: number;
|
|
243
|
+
/** Bills QuickBooks refused; they retry on the next sync. */
|
|
241
244
|
push_failed: number;
|
|
242
245
|
}
|
|
246
|
+
/** A sync's phases, in order: send to QuickBooks, import invoices, import payments. */
|
|
247
|
+
export type IntuitSyncPhase = 'push' | 'import' | 'payments';
|
|
248
|
+
/** An `intuit_sync_progress` payload: `done` of `total` items in `phase`. */
|
|
249
|
+
export interface IntuitSyncProgress {
|
|
250
|
+
phase: IntuitSyncPhase;
|
|
251
|
+
done: number;
|
|
252
|
+
total: number;
|
|
253
|
+
}
|
|
254
|
+
/** The company's QuickBooks sync as its socket events report it. */
|
|
255
|
+
export type IntuitSyncStatus = {
|
|
256
|
+
state: 'idle';
|
|
257
|
+
} | {
|
|
258
|
+
state: 'running';
|
|
259
|
+
progress?: IntuitSyncProgress;
|
|
260
|
+
} | {
|
|
261
|
+
state: 'complete';
|
|
262
|
+
result: IntuitImportResult;
|
|
263
|
+
} | {
|
|
264
|
+
state: 'error';
|
|
265
|
+
message: string;
|
|
266
|
+
};
|
|
243
267
|
/**
|
|
244
268
|
* A payment option on a catalog item write (backend `CreatePaymentOption`).
|
|
245
269
|
* Prices are integer cents.
|
|
@@ -44,6 +44,8 @@ export interface Company {
|
|
|
44
44
|
num_routes: number;
|
|
45
45
|
schedule_locked: boolean;
|
|
46
46
|
schedule_locked_since: number | null;
|
|
47
|
+
/** A QuickBooks sync is running; another can't start until it ends. */
|
|
48
|
+
intuit_sync_locked: boolean;
|
|
47
49
|
num_teams: number;
|
|
48
50
|
num_skills: number;
|
|
49
51
|
/** Legacy key, always empty. */
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AVRO_JS_VERSION = "1.6.6-
|
|
1
|
+
export declare const AVRO_JS_VERSION = "1.6.6-rc9";
|
package/dist/version.js
CHANGED