UNPKG

@accounter/server

Version:
152 lines (151 loc) • 5.8 kB
import type { Injector } from 'graphql-modules'; import type { LedgerProto, StrictLedgerProto } from '../../../shared/types/index.js'; import type { DeelWorker, Invoice, PaymentBreakdownRecord, PaymentReceipts } from '../../app-providers/deel/schemas.js'; import type { IGetDocumentsByChargeIdResult } from '../../documents/types.js'; import type { IInsertDeelInvoiceRecordsParams } from '../types.js'; export declare function isDeelDocument(document: IGetDocumentsByChargeIdResult): boolean; export declare function getDeelEmployeeId(injector: Injector, document: IGetDocumentsByChargeIdResult, ledgerEntry: StrictLedgerProto, ledgerEntries: LedgerProto[], updateLedgerBalance: (entry: LedgerProto) => void): Promise<void>; type Prefixer<Type> = { [Property in keyof Type as `breakdown_${string & Property}`]: Type[Property]; }; export type PrefixedBreakdown = Prefixer<PaymentBreakdownRecord & { receipt_id: string; }>; export type DeelInvoiceMatch = Invoice & PrefixedBreakdown; export declare const createDeelInvoiceMatchFromUnmatchedInvoice: (invoice: Invoice) => DeelInvoiceMatch; export declare function uploadDeelInvoice(chargeId: string, match: DeelInvoiceMatch, injector: Injector, ownerId: string): Promise<string>; export declare function convertMatchToDeelInvoiceRecord(match: DeelInvoiceMatch, documentId: string): IInsertDeelInvoiceRecordsParams; export declare function getDeelChargeDescription(injector: Injector, workers?: DeelWorker[]): Promise<string>; export declare function fetchAndFilterInvoices(injector: Injector): Promise<{ id: string; amount: string; contract_id: string | null; created_at: string; currency: string; deel_fee: "0.00"; due_date: string; is_overdue: boolean; issued_at: string; label: string; paid_at: string; status: "pending" | "paid" | "processing" | "canceled" | "skipped" | "failed" | "refunded" | "processed"; total: string; vat_id: ""; vat_percentage: ""; vat_total: "0.00"; recipient_legal_entity_id: "1dee10b1-105b-4dc7-bcdb-5ed5c52ba868"; }[]>; export declare function fetchReceipts(injector: Injector): Promise<{ id: string; created_at: string; label: string; paid_at: string | null; payment_currency: string; total: string; status: "paid"; invoices: { id: string; }[]; timezone: string | null; deel_reference: string | null; payment_method?: Record<string, never> | undefined; workers?: { id: string; picUrl: string | null; contract_id?: string | null | undefined; name?: string | undefined; public_id?: string | undefined; }[] | undefined; }[]>; export declare function fetchPaymentBreakdowns(injector: Injector, receipts: PaymentReceipts[]): Promise<({ adjustment: "0.00"; approve_date: string; approvers: string; bonus: "0.00"; commissions: "0.00"; contract_country: string; contract_start_date: string; contract_type: string; contractor_email: string; contractor_employee_name: string; contractor_unique_identifier: string; currency: string; date: string; deductions: "0.00"; expenses: string; frequency: "" | "custom" | "hourly" | "daily" | "monthly"; general_ledger_account: ""; group_id: string; invoice_id: string; others: string; overtime: "0.00"; payment_currency: string; payment_date: string; pro_rata: string; processing_fee: string; work: string; total: string; total_payment_currency: string; } & { receipt_id: string; })[]>; type ContractInfo = { contract_country: string; contract_start_date: string; contract_type: string; contractor_email: string; contractor_employee_name: string; contractor_unique_identifier: string; }; export declare function getContractsFromPaymentBreakdowns(matches: DeelInvoiceMatch[]): Map<string, ContractInfo>; export declare function validateContracts(contractsInfo: Map<string, ContractInfo>, injector: Injector): Promise<void>; export declare function getChargeMatchesForPayments(injector: Injector, receipts: PaymentReceipts[]): Promise<{ receiptChargeMap: Map<string, string>; invoiceChargeMap: Map<string, string>; newReceipts: { id: string; created_at: string; label: string; paid_at: string | null; payment_currency: string; total: string; status: "paid"; invoices: { id: string; }[]; timezone: string | null; deel_reference: string | null; payment_method?: Record<string, never> | undefined; workers?: { id: string; picUrl: string | null; contract_id?: string | null | undefined; name?: string | undefined; public_id?: string | undefined; }[] | undefined; }[]; }>; export declare function matchInvoicesWithPayments(injector: Injector, invoices: Invoice[], receipts: PaymentReceipts[]): Promise<{ matches: DeelInvoiceMatch[]; unmatched: { id: string; amount: string; contract_id: string | null; created_at: string; currency: string; deel_fee: "0.00"; due_date: string; is_overdue: boolean; issued_at: string; label: string; paid_at: string; status: "pending" | "paid" | "processing" | "canceled" | "skipped" | "failed" | "refunded" | "processed"; total: string; vat_id: ""; vat_percentage: ""; vat_total: "0.00"; recipient_legal_entity_id: "1dee10b1-105b-4dc7-bcdb-5ed5c52ba868"; }[]; }>; export declare function insertDeelInvoiceRecord(injector: Injector, match: DeelInvoiceMatch, chargeId: string): Promise<void>; export {};