@accounter/server 0.0.9-alpha-20251211104252-b3c952744561fadd467a200a9cce8f310391f41a → 0.0.9-alpha-20251211105553-850821f760a4152f9e24e7fca4d23874a887bbe3
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/CHANGELOG.md +5 -5
- package/GMAIL_LISTENER.md +7 -7
- package/dist/green-invoice-graphql/src/mesh-artifacts/index.js +2 -2
- package/dist/green-invoice-graphql/src/mesh-artifacts/index.js.map +1 -1
- package/dist/server/src/modules/accountant-approval/index.js +1 -1
- package/dist/server/src/modules/accountant-approval/index.js.map +1 -1
- package/dist/server/src/modules/admin-context/index.js +1 -1
- package/dist/server/src/modules/admin-context/index.js.map +1 -1
- package/dist/server/src/modules/bank-deposits/index.js +1 -1
- package/dist/server/src/modules/bank-deposits/index.js.map +1 -1
- package/dist/server/src/modules/bank-deposits/providers/bank-deposit-transactions.provider.d.ts +4 -4
- package/dist/server/src/modules/business-trips/index.js +3 -3
- package/dist/server/src/modules/business-trips/index.js.map +1 -1
- package/dist/server/src/modules/charges/index.js +4 -4
- package/dist/server/src/modules/charges/index.js.map +1 -1
- package/dist/server/src/modules/charges-matcher/index.js +1 -1
- package/dist/server/src/modules/charges-matcher/index.js.map +1 -1
- package/dist/server/src/modules/charts/index.js +1 -1
- package/dist/server/src/modules/charts/index.js.map +1 -1
- package/dist/server/src/modules/common/index.js +4 -4
- package/dist/server/src/modules/common/index.js.map +1 -1
- package/dist/server/src/modules/common/resolvers/timeless-date.d.ts +1 -1
- package/dist/server/src/modules/contracts/index.js +1 -1
- package/dist/server/src/modules/contracts/index.js.map +1 -1
- package/dist/server/src/modules/corn-jobs/index.js +1 -1
- package/dist/server/src/modules/corn-jobs/index.js.map +1 -1
- package/dist/server/src/modules/corporate-taxes/index.js +1 -1
- package/dist/server/src/modules/corporate-taxes/index.js.map +1 -1
- package/dist/server/src/modules/corporate-taxes/providers/corporate-taxes.provider.d.ts +1 -1
- package/dist/server/src/modules/countries/index.js +1 -1
- package/dist/server/src/modules/countries/index.js.map +1 -1
- package/dist/server/src/modules/deel/index.js +1 -1
- package/dist/server/src/modules/deel/index.js.map +1 -1
- package/dist/server/src/modules/depreciation/index.js +1 -1
- package/dist/server/src/modules/depreciation/index.js.map +1 -1
- package/dist/server/src/modules/dividends/index.js +1 -1
- package/dist/server/src/modules/dividends/index.js.map +1 -1
- package/dist/server/src/modules/documents/index.js +3 -3
- package/dist/server/src/modules/documents/index.js.map +1 -1
- package/dist/server/src/modules/exchange-rates/index.js +1 -1
- package/dist/server/src/modules/exchange-rates/index.js.map +1 -1
- package/dist/server/src/modules/financial-accounts/index.js +2 -2
- package/dist/server/src/modules/financial-accounts/index.js.map +1 -1
- package/dist/server/src/modules/financial-entities/index.js +6 -6
- package/dist/server/src/modules/financial-entities/index.js.map +1 -1
- package/dist/server/src/modules/green-invoice/index.js +1 -1
- package/dist/server/src/modules/green-invoice/index.js.map +1 -1
- package/dist/server/src/modules/ledger/index.js +1 -1
- package/dist/server/src/modules/ledger/index.js.map +1 -1
- package/dist/server/src/modules/misc-expenses/index.js +1 -1
- package/dist/server/src/modules/misc-expenses/index.js.map +1 -1
- package/dist/server/src/modules/reports/helpers/pcn.helper.d.ts +1 -1
- package/dist/server/src/modules/reports/index.js +12 -12
- package/dist/server/src/modules/reports/index.js.map +1 -1
- package/dist/server/src/modules/salaries/index.js +3 -3
- package/dist/server/src/modules/salaries/index.js.map +1 -1
- package/dist/server/src/modules/sort-codes/index.js +1 -1
- package/dist/server/src/modules/sort-codes/index.js.map +1 -1
- package/dist/server/src/modules/tags/index.js +1 -1
- package/dist/server/src/modules/tags/index.js.map +1 -1
- package/dist/server/src/modules/transactions/helpers/effective-date.helper.d.ts +1 -1
- package/dist/server/src/modules/transactions/index.js +3 -3
- package/dist/server/src/modules/transactions/index.js.map +1 -1
- package/dist/server/src/modules/vat/index.js +1 -1
- package/dist/server/src/modules/vat/index.js.map +1 -1
- package/dist/server/src/modules/vat/providers/vat.provider.d.ts +1 -1
- package/docs/implementation-guide.md +2 -2
- package/package.json +3 -3
- package/src/modules/accountant-approval/index.ts +1 -1
- package/src/modules/admin-context/index.ts +1 -1
- package/src/modules/bank-deposits/index.ts +1 -1
- package/src/modules/business-trips/index.ts +3 -3
- package/src/modules/charges/index.ts +4 -4
- package/src/modules/charges-matcher/README.md +12 -12
- package/src/modules/charges-matcher/documentation/SPEC.md +103 -103
- package/src/modules/charges-matcher/index.ts +1 -1
- package/src/modules/charts/index.ts +1 -1
- package/src/modules/common/index.ts +4 -4
- package/src/modules/contracts/index.ts +1 -1
- package/src/modules/corn-jobs/index.ts +1 -1
- package/src/modules/corporate-taxes/index.ts +1 -1
- package/src/modules/countries/index.ts +1 -1
- package/src/modules/deel/index.ts +1 -1
- package/src/modules/depreciation/index.ts +1 -1
- package/src/modules/dividends/index.ts +1 -1
- package/src/modules/documents/index.ts +3 -3
- package/src/modules/exchange-rates/index.ts +1 -1
- package/src/modules/financial-accounts/index.ts +2 -2
- package/src/modules/financial-entities/index.ts +6 -6
- package/src/modules/green-invoice/index.ts +1 -1
- package/src/modules/ledger/index.ts +1 -1
- package/src/modules/misc-expenses/index.ts +1 -1
- package/src/modules/reports/index.ts +12 -12
- package/src/modules/salaries/index.ts +3 -3
- package/src/modules/sort-codes/index.ts +1 -1
- package/src/modules/tags/index.ts +1 -1
- package/src/modules/transactions/index.ts +3 -3
- package/src/modules/vat/index.ts +1 -1
|
@@ -91,8 +91,8 @@ Avoids full GraphQL application boot:
|
|
|
91
91
|
Usage Pattern:
|
|
92
92
|
|
|
93
93
|
```typescript
|
|
94
|
-
const { injector, adminContext } = createLedgerTestContext({ pool, mockExchangeRates })
|
|
95
|
-
const result = await ledgerGenerationByCharge({ chargeId }, { injector, adminContext })
|
|
94
|
+
const { injector, adminContext } = createLedgerTestContext({ pool, mockExchangeRates })
|
|
95
|
+
const result = await ledgerGenerationByCharge({ chargeId }, { injector, adminContext })
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
## 8. Environment Isolation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accounter/server",
|
|
3
|
-
"version": "0.0.9-alpha-
|
|
3
|
+
"version": "0.0.9-alpha-20251211105553-850821f760a4152f9e24e7fca4d23874a887bbe3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@pgtyped/cli": "2.4.3",
|
|
34
34
|
"@pgtyped/runtime": "2.4.2",
|
|
35
35
|
"@whatwg-node/fetch": "0.10.13",
|
|
36
|
-
"ai": "5.0.
|
|
36
|
+
"ai": "5.0.110",
|
|
37
37
|
"basic-auth": "2.0.1",
|
|
38
38
|
"bcrypt": "6.0.0",
|
|
39
39
|
"cloudinary": "2.8.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/basic-auth": "1.1.8",
|
|
62
62
|
"@types/bcrypt": "6.0.0",
|
|
63
63
|
"@types/inline-css": "3.0.4",
|
|
64
|
-
"@types/pg": "8.
|
|
64
|
+
"@types/pg": "8.15.6",
|
|
65
65
|
"nodemon": "3.1.11",
|
|
66
66
|
"pino-pretty": "13.1.3",
|
|
67
67
|
"rimraf": "6.1.2",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import accountantApproval from './typeDefs/accountant-approval.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { accountantApprovalResolvers } from './resolvers/accountant-approval.resolver.js';
|
|
3
|
+
import accountantApproval from './typeDefs/accountant-approval.graphql.js';
|
|
4
4
|
|
|
5
5
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import adminContext from './typeDefs/admin-context.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { AdminContextProvider } from './providers/admin-context.provider.js';
|
|
4
3
|
import { adminContextResolvers } from './resolvers/admin-context.resolvers.js';
|
|
4
|
+
import adminContext from './typeDefs/admin-context.graphql.js';
|
|
5
5
|
|
|
6
6
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import bankDeposits from './typeDefs/bank-deposits.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { BankDepositTransactionsProvider } from './providers/bank-deposit-transactions.provider.js';
|
|
4
3
|
import { bankDepositTransactionsResolvers } from './resolvers/bank-deposit-transactions.resolver.js';
|
|
4
|
+
import bankDeposits from './typeDefs/bank-deposits.graphql.js';
|
|
5
5
|
|
|
6
6
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
7
7
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import businessTripAttendees from './typeDefs/business-trip-attendees.graphql.js';
|
|
2
|
-
import businessTripExpenses from './typeDefs/business-trip-expenses.graphql.js';
|
|
3
|
-
import businessTrips from './typeDefs/business-trips.graphql.js';
|
|
4
1
|
import { createModule } from 'graphql-modules';
|
|
5
2
|
import { BusinessTripAttendeesProvider } from './providers/business-trips-attendees.provider.js';
|
|
6
3
|
import { BusinessTripEmployeePaymentsProvider } from './providers/business-trips-employee-payments.provider.js';
|
|
@@ -16,6 +13,9 @@ import { BusinessTripsProvider } from './providers/business-trips.provider.js';
|
|
|
16
13
|
import { businessTripAttendeesResolvers } from './resolvers/business-trip-attendees.resolver.js';
|
|
17
14
|
import { businessTripExpensesResolvers } from './resolvers/business-trips-expenses.resolver.js';
|
|
18
15
|
import { businessTripsResolvers } from './resolvers/business-trips.resolver.js';
|
|
16
|
+
import businessTripAttendees from './typeDefs/business-trip-attendees.graphql.js';
|
|
17
|
+
import businessTripExpenses from './typeDefs/business-trip-expenses.graphql.js';
|
|
18
|
+
import businessTrips from './typeDefs/business-trips.graphql.js';
|
|
19
19
|
|
|
20
20
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
21
21
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import chargeSuggestions from './typeDefs/charge-suggestions.graphql.js';
|
|
2
|
-
import chargeValidation from './typeDefs/charge-validation.graphql.js';
|
|
3
|
-
import charges from './typeDefs/charges.graphql.js';
|
|
4
|
-
import financialCharges from './typeDefs/financial-charges.graphql.js';
|
|
5
1
|
import { createModule } from 'graphql-modules';
|
|
6
2
|
import { ChargeSpreadProvider } from './providers/charge-spread.provider.js';
|
|
7
3
|
import { ChargesProvider } from './providers/charges.provider.js';
|
|
8
4
|
import { chargeSuggestionsResolvers } from './resolvers/charge-suggestions/charge-suggestions.resolver.js';
|
|
9
5
|
import { chargesResolvers } from './resolvers/charges.resolver.js';
|
|
10
6
|
import { financialChargesResolvers } from './resolvers/financial-charges.resolver.js';
|
|
7
|
+
import chargeSuggestions from './typeDefs/charge-suggestions.graphql.js';
|
|
8
|
+
import chargeValidation from './typeDefs/charge-validation.graphql.js';
|
|
9
|
+
import charges from './typeDefs/charges.graphql.js';
|
|
10
|
+
import financialCharges from './typeDefs/financial-charges.graphql.js';
|
|
11
11
|
|
|
12
12
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
13
13
|
|
|
@@ -107,17 +107,17 @@ import {
|
|
|
107
107
|
createMockTransaction,
|
|
108
108
|
createMockDocument,
|
|
109
109
|
createMockAggregatedTransaction,
|
|
110
|
-
createMockAggregatedDocument
|
|
111
|
-
} from './__tests__/test-helpers.js'
|
|
110
|
+
createMockAggregatedDocument
|
|
111
|
+
} from './__tests__/test-helpers.js'
|
|
112
112
|
|
|
113
113
|
// Create a transaction with defaults
|
|
114
|
-
const transaction = createMockTransaction()
|
|
114
|
+
const transaction = createMockTransaction()
|
|
115
115
|
|
|
116
116
|
// Create with overrides
|
|
117
117
|
const customTransaction = createMockTransaction({
|
|
118
118
|
amount: '250.00',
|
|
119
|
-
currency: 'USD'
|
|
120
|
-
})
|
|
119
|
+
currency: 'USD'
|
|
120
|
+
})
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
### Helper Functions
|
|
@@ -128,19 +128,19 @@ import {
|
|
|
128
128
|
roundConfidence,
|
|
129
129
|
isValidConfidenceScore,
|
|
130
130
|
daysDifference,
|
|
131
|
-
isWithinDays
|
|
132
|
-
} from './__tests__/test-helpers.js'
|
|
131
|
+
isWithinDays
|
|
132
|
+
} from './__tests__/test-helpers.js'
|
|
133
133
|
|
|
134
134
|
// Calculate weighted confidence
|
|
135
|
-
const scores = { amount: 0.9, currency: 1.0, business: 0.5, date: 0.8 }
|
|
136
|
-
const confidence = calculateExpectedConfidence(scores)
|
|
135
|
+
const scores = { amount: 0.9, currency: 1.0, business: 0.5, date: 0.8 }
|
|
136
|
+
const confidence = calculateExpectedConfidence(scores) // 0.79
|
|
137
137
|
|
|
138
138
|
// Round to 2 decimal places
|
|
139
|
-
const rounded = roundConfidence(0.956789)
|
|
139
|
+
const rounded = roundConfidence(0.956789) // 0.96
|
|
140
140
|
|
|
141
141
|
// Validate score range
|
|
142
|
-
isValidConfidenceScore(0.95)
|
|
143
|
-
isValidConfidenceScore(1.5)
|
|
142
|
+
isValidConfidenceScore(0.95) // true
|
|
143
|
+
isValidConfidenceScore(1.5) // false
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
## Key Concepts
|
|
@@ -47,9 +47,9 @@ query FindChargeMatches($chargeId: UUID!) {
|
|
|
47
47
|
```typescript
|
|
48
48
|
{
|
|
49
49
|
matches: Array<{
|
|
50
|
-
chargeId: string
|
|
51
|
-
confidenceScore: number
|
|
52
|
-
}
|
|
50
|
+
chargeId: string // UUID
|
|
51
|
+
confidenceScore: number // 0.00 to 1.00, two decimal precision
|
|
52
|
+
}>
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
@@ -211,27 +211,27 @@ CREATE TABLE accounter_schema.documents (
|
|
|
211
211
|
|
|
212
212
|
```typescript
|
|
213
213
|
// types.ts
|
|
214
|
-
import type { IGetTransactionsByIdsResult } from '@modules/transactions'
|
|
215
|
-
import type { IGetAllDocumentsResult } from '@modules/documents'
|
|
216
|
-
import type { Currency, DocumentType } from '@modules/documents'
|
|
214
|
+
import type { IGetTransactionsByIdsResult } from '@modules/transactions'
|
|
215
|
+
import type { IGetAllDocumentsResult } from '@modules/documents'
|
|
216
|
+
import type { Currency, DocumentType } from '@modules/documents'
|
|
217
217
|
|
|
218
218
|
// Re-export with simpler names
|
|
219
|
-
export type Transaction = IGetTransactionsByIdsResult
|
|
220
|
-
export type Document = IGetAllDocumentsResult
|
|
219
|
+
export type Transaction = IGetTransactionsByIdsResult
|
|
220
|
+
export type Document = IGetAllDocumentsResult
|
|
221
221
|
```
|
|
222
222
|
|
|
223
223
|
**Simplified Transaction Interface (for matching purposes):**
|
|
224
224
|
|
|
225
225
|
```typescript
|
|
226
226
|
interface Transaction {
|
|
227
|
-
id: string
|
|
228
|
-
charge_id: string
|
|
229
|
-
amount: string
|
|
230
|
-
business_id: string | null
|
|
231
|
-
currency: string | null
|
|
232
|
-
event_date: Date
|
|
233
|
-
source_description: string | null
|
|
234
|
-
is_fee: boolean
|
|
227
|
+
id: string // UUID
|
|
228
|
+
charge_id: string // UUID
|
|
229
|
+
amount: string // numeric in DB, returned as string, converted to number
|
|
230
|
+
business_id: string | null // UUID
|
|
231
|
+
currency: string | null
|
|
232
|
+
event_date: Date // Used for date matching (always)
|
|
233
|
+
source_description: string | null
|
|
234
|
+
is_fee: boolean // Excluded if true
|
|
235
235
|
// Other fields exist but not used in matching
|
|
236
236
|
}
|
|
237
237
|
```
|
|
@@ -240,15 +240,15 @@ interface Transaction {
|
|
|
240
240
|
|
|
241
241
|
```typescript
|
|
242
242
|
interface Document {
|
|
243
|
-
id: string
|
|
244
|
-
charge_id: string | null
|
|
245
|
-
creditor_id: string | null
|
|
246
|
-
debtor_id: string | null
|
|
247
|
-
currency_code: string | null
|
|
248
|
-
date: Date | null
|
|
249
|
-
total_amount: number | null
|
|
250
|
-
type: DocumentType
|
|
251
|
-
serial_number: string | null
|
|
243
|
+
id: string // UUID
|
|
244
|
+
charge_id: string | null // UUID
|
|
245
|
+
creditor_id: string | null // UUID
|
|
246
|
+
debtor_id: string | null // UUID
|
|
247
|
+
currency_code: string | null
|
|
248
|
+
date: Date | null
|
|
249
|
+
total_amount: number | null // double precision in DB, returned as number
|
|
250
|
+
type: DocumentType
|
|
251
|
+
serial_number: string | null
|
|
252
252
|
// Legacy text fields 'debtor', 'creditor' are IGNORED
|
|
253
253
|
}
|
|
254
254
|
```
|
|
@@ -256,7 +256,7 @@ interface Document {
|
|
|
256
256
|
**Currency Type:**
|
|
257
257
|
|
|
258
258
|
```typescript
|
|
259
|
-
type Currency = 'ILS' | 'USD' | 'EUR' | 'GBP' | 'USDC' | 'GRT' | 'ETH'
|
|
259
|
+
type Currency = 'ILS' | 'USD' | 'EUR' | 'GBP' | 'USDC' | 'GRT' | 'ETH'
|
|
260
260
|
```
|
|
261
261
|
|
|
262
262
|
**DocumentType Enum:**
|
|
@@ -269,7 +269,7 @@ type DocumentType =
|
|
|
269
269
|
| 'OTHER'
|
|
270
270
|
| 'PROFORMA'
|
|
271
271
|
| 'RECEIPT'
|
|
272
|
-
| 'UNPROCESSED'
|
|
272
|
+
| 'UNPROCESSED'
|
|
273
273
|
```
|
|
274
274
|
|
|
275
275
|
**Custom Result Types:**
|
|
@@ -277,28 +277,28 @@ type DocumentType =
|
|
|
277
277
|
```typescript
|
|
278
278
|
// GraphQL result types
|
|
279
279
|
interface ChargeMatch {
|
|
280
|
-
chargeId: string
|
|
281
|
-
confidence: number
|
|
282
|
-
amount: number
|
|
283
|
-
currency: string | null
|
|
284
|
-
business: string | null
|
|
285
|
-
date: Date
|
|
286
|
-
description: string
|
|
280
|
+
chargeId: string
|
|
281
|
+
confidence: number
|
|
282
|
+
amount: number
|
|
283
|
+
currency: string | null
|
|
284
|
+
business: string | null
|
|
285
|
+
date: Date
|
|
286
|
+
description: string
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
interface MergedCharge {
|
|
290
|
-
baseChargeId: string
|
|
291
|
-
mergedChargeId: string
|
|
292
|
-
confidence: number
|
|
290
|
+
baseChargeId: string
|
|
291
|
+
mergedChargeId: string
|
|
292
|
+
confidence: number
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
interface ChargeMatchesResult {
|
|
296
|
-
matches: ChargeMatch[]
|
|
296
|
+
matches: ChargeMatch[]
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
interface AutoMatchChargesResult {
|
|
300
|
-
merged: MergedCharge[]
|
|
301
|
-
skipped: string[]
|
|
300
|
+
merged: MergedCharge[]
|
|
301
|
+
skipped: string[] // Charge IDs with multiple high-confidence matches
|
|
302
302
|
}
|
|
303
303
|
```
|
|
304
304
|
|
|
@@ -307,12 +307,12 @@ interface AutoMatchChargesResult {
|
|
|
307
307
|
```typescript
|
|
308
308
|
// Used by aggregation providers
|
|
309
309
|
interface AggregatedData {
|
|
310
|
-
amount: number
|
|
311
|
-
currency: string | null
|
|
312
|
-
businessId: string | null
|
|
313
|
-
date: Date
|
|
314
|
-
description: string
|
|
315
|
-
side?: 'debtor' | 'creditor'
|
|
310
|
+
amount: number
|
|
311
|
+
currency: string | null
|
|
312
|
+
businessId: string | null
|
|
313
|
+
date: Date
|
|
314
|
+
description: string
|
|
315
|
+
side?: 'debtor' | 'creditor' // Only for documents
|
|
316
316
|
}
|
|
317
317
|
```
|
|
318
318
|
|
|
@@ -1001,7 +1001,7 @@ __tests__/
|
|
|
1001
1001
|
1. **Single Charge Lookup:**
|
|
1002
1002
|
|
|
1003
1003
|
```typescript
|
|
1004
|
-
const charge = await context.injector.get(ChargesProvider).getChargeByIdLoader.load(chargeId)
|
|
1004
|
+
const charge = await context.injector.get(ChargesProvider).getChargeByIdLoader.load(chargeId)
|
|
1005
1005
|
```
|
|
1006
1006
|
|
|
1007
1007
|
2. **Transactions for Charge:**
|
|
@@ -1009,7 +1009,7 @@ __tests__/
|
|
|
1009
1009
|
```typescript
|
|
1010
1010
|
const transactions = await context.injector
|
|
1011
1011
|
.get(TransactionsProvider)
|
|
1012
|
-
.transactionsByChargeIDLoader.load(chargeId)
|
|
1012
|
+
.transactionsByChargeIDLoader.load(chargeId)
|
|
1013
1013
|
```
|
|
1014
1014
|
|
|
1015
1015
|
3. **Documents for Charge:**
|
|
@@ -1017,7 +1017,7 @@ __tests__/
|
|
|
1017
1017
|
```typescript
|
|
1018
1018
|
const documents = await context.injector
|
|
1019
1019
|
.get(ChargesProvider)
|
|
1020
|
-
.getDocumentsByChargeIdLoader.load(chargeId)
|
|
1020
|
+
.getDocumentsByChargeIdLoader.load(chargeId)
|
|
1021
1021
|
```
|
|
1022
1022
|
|
|
1023
1023
|
4. **Candidate Charges (with filters):**
|
|
@@ -1025,8 +1025,8 @@ __tests__/
|
|
|
1025
1025
|
const candidates = await chargesProvider.getChargesByFilters({
|
|
1026
1026
|
ownerIds: [adminBusinessId],
|
|
1027
1027
|
fromAnyDate: startDate,
|
|
1028
|
-
toAnyDate: endDate
|
|
1029
|
-
})
|
|
1028
|
+
toAnyDate: endDate
|
|
1029
|
+
})
|
|
1030
1030
|
```
|
|
1031
1031
|
|
|
1032
1032
|
**Filter Parameters Used:**
|
|
@@ -1068,43 +1068,43 @@ _Documents table:_
|
|
|
1068
1068
|
**Imported Types:**
|
|
1069
1069
|
|
|
1070
1070
|
```typescript
|
|
1071
|
-
import type { IGetTransactionsByIdsResult } from '@modules/transactions'
|
|
1072
|
-
import type { IGetAllDocumentsResult } from '@modules/documents'
|
|
1073
|
-
import type { Currency, DocumentType } from '@modules/documents'
|
|
1071
|
+
import type { IGetTransactionsByIdsResult } from '@modules/transactions'
|
|
1072
|
+
import type { IGetAllDocumentsResult } from '@modules/documents'
|
|
1073
|
+
import type { Currency, DocumentType } from '@modules/documents'
|
|
1074
1074
|
```
|
|
1075
1075
|
|
|
1076
1076
|
**Re-exported Types:**
|
|
1077
1077
|
|
|
1078
1078
|
```typescript
|
|
1079
|
-
export type Transaction = IGetTransactionsByIdsResult
|
|
1080
|
-
export type Document = IGetAllDocumentsResult
|
|
1079
|
+
export type Transaction = IGetTransactionsByIdsResult
|
|
1080
|
+
export type Document = IGetAllDocumentsResult
|
|
1081
1081
|
```
|
|
1082
1082
|
|
|
1083
1083
|
**Custom Types Defined:**
|
|
1084
1084
|
|
|
1085
1085
|
```typescript
|
|
1086
1086
|
export interface ChargeMatch {
|
|
1087
|
-
chargeId: string
|
|
1088
|
-
confidence: number
|
|
1089
|
-
amount: number
|
|
1090
|
-
currency: string | null
|
|
1091
|
-
business: string | null
|
|
1092
|
-
date: Date
|
|
1093
|
-
description: string
|
|
1087
|
+
chargeId: string
|
|
1088
|
+
confidence: number
|
|
1089
|
+
amount: number
|
|
1090
|
+
currency: string | null
|
|
1091
|
+
business: string | null
|
|
1092
|
+
date: Date
|
|
1093
|
+
description: string
|
|
1094
1094
|
}
|
|
1095
1095
|
|
|
1096
1096
|
export interface MergedCharge {
|
|
1097
|
-
baseChargeId: string
|
|
1098
|
-
mergedChargeId: string
|
|
1099
|
-
confidence: number
|
|
1097
|
+
baseChargeId: string
|
|
1098
|
+
mergedChargeId: string
|
|
1099
|
+
confidence: number
|
|
1100
1100
|
}
|
|
1101
1101
|
|
|
1102
1102
|
export interface AggregatedData {
|
|
1103
|
-
amount: number
|
|
1104
|
-
currency: string | null
|
|
1105
|
-
businessId: string | null
|
|
1106
|
-
date: Date
|
|
1107
|
-
description: string
|
|
1103
|
+
amount: number
|
|
1104
|
+
currency: string | null
|
|
1105
|
+
businessId: string | null
|
|
1106
|
+
date: Date
|
|
1107
|
+
description: string
|
|
1108
1108
|
}
|
|
1109
1109
|
```
|
|
1110
1110
|
|
|
@@ -1305,29 +1305,29 @@ export default gql`
|
|
|
1305
1305
|
|
|
1306
1306
|
```typescript
|
|
1307
1307
|
// resolvers/find-charge-matches.resolver.ts
|
|
1308
|
-
import { GraphQLError } from 'graphql'
|
|
1309
|
-
import type { ChargesMatcherResolvers } from '../types.js'
|
|
1308
|
+
import { GraphQLError } from 'graphql'
|
|
1309
|
+
import type { ChargesMatcherResolvers } from '../types.js'
|
|
1310
1310
|
|
|
1311
1311
|
export const findChargeMatchesResolver: ChargesMatcherResolvers = {
|
|
1312
1312
|
Query: {
|
|
1313
1313
|
findChargeMatches: async (_, { chargeId }, context) => {
|
|
1314
1314
|
try {
|
|
1315
|
-
const adminBusinessId = context.adminContext.defaultAdminBusinessId
|
|
1316
|
-
const chargesMatcherProvider = context.injector.get(ChargesMatcherProvider)
|
|
1315
|
+
const adminBusinessId = context.adminContext.defaultAdminBusinessId
|
|
1316
|
+
const chargesMatcherProvider = context.injector.get(ChargesMatcherProvider)
|
|
1317
1317
|
|
|
1318
1318
|
const matches = await chargesMatcherProvider.findMatchesForCharge(
|
|
1319
1319
|
chargeId,
|
|
1320
1320
|
adminBusinessId,
|
|
1321
|
-
context
|
|
1322
|
-
)
|
|
1321
|
+
context
|
|
1322
|
+
)
|
|
1323
1323
|
|
|
1324
|
-
return { matches }
|
|
1324
|
+
return { matches }
|
|
1325
1325
|
} catch (error) {
|
|
1326
|
-
throw new GraphQLError(error instanceof Error ? error.message : 'Failed to find matches')
|
|
1326
|
+
throw new GraphQLError(error instanceof Error ? error.message : 'Failed to find matches')
|
|
1327
1327
|
}
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
1331
|
```
|
|
1332
1332
|
|
|
1333
1333
|
### 13.3 Module Registration (Implemented)
|
|
@@ -1336,34 +1336,34 @@ export const findChargeMatchesResolver: ChargesMatcherResolvers = {
|
|
|
1336
1336
|
|
|
1337
1337
|
```typescript
|
|
1338
1338
|
// index.ts
|
|
1339
|
-
import { createModule } from 'graphql-modules'
|
|
1340
|
-
import { chargesMatcherResolvers } from './resolvers/index.js'
|
|
1341
|
-
import { ChargesMatcherProvider } from './providers/charges-matcher.provider.js'
|
|
1342
|
-
import typeDefs from './typeDefs/charges-matcher.graphql.js'
|
|
1339
|
+
import { createModule } from 'graphql-modules'
|
|
1340
|
+
import { chargesMatcherResolvers } from './resolvers/index.js'
|
|
1341
|
+
import { ChargesMatcherProvider } from './providers/charges-matcher.provider.js'
|
|
1342
|
+
import typeDefs from './typeDefs/charges-matcher.graphql.js'
|
|
1343
1343
|
|
|
1344
1344
|
export const chargesMatcherModule = createModule({
|
|
1345
1345
|
id: 'chargesMatcherModule',
|
|
1346
1346
|
dirname: __dirname,
|
|
1347
1347
|
typeDefs,
|
|
1348
1348
|
resolvers: [chargesMatcherResolvers],
|
|
1349
|
-
providers: [ChargesMatcherProvider]
|
|
1350
|
-
})
|
|
1349
|
+
providers: [ChargesMatcherProvider]
|
|
1350
|
+
})
|
|
1351
1351
|
```
|
|
1352
1352
|
|
|
1353
1353
|
**Application Integration:**
|
|
1354
1354
|
|
|
1355
1355
|
```typescript
|
|
1356
1356
|
// modules-app.ts (added after chargesModule)
|
|
1357
|
-
import { chargesMatcherModule } from './modules/charges-matcher/index.js'
|
|
1357
|
+
import { chargesMatcherModule } from './modules/charges-matcher/index.js'
|
|
1358
1358
|
|
|
1359
1359
|
export const application = createApplication({
|
|
1360
1360
|
modules: [
|
|
1361
1361
|
// ... other modules
|
|
1362
1362
|
chargesModule,
|
|
1363
|
-
chargesMatcherModule
|
|
1363
|
+
chargesMatcherModule // Added here
|
|
1364
1364
|
// ... more modules
|
|
1365
|
-
]
|
|
1366
|
-
})
|
|
1365
|
+
]
|
|
1366
|
+
})
|
|
1367
1367
|
```
|
|
1368
1368
|
|
|
1369
1369
|
### 13.4 Provider Implementation Pattern (Actual Code)
|
|
@@ -1371,20 +1371,20 @@ export const application = createApplication({
|
|
|
1371
1371
|
**Injectable Provider:**
|
|
1372
1372
|
|
|
1373
1373
|
```typescript
|
|
1374
|
-
import { Injectable, Scope } from 'graphql-modules'
|
|
1375
|
-
import type { GraphQLModules } from '@envelop/core'
|
|
1374
|
+
import { Injectable, Scope } from 'graphql-modules'
|
|
1375
|
+
import type { GraphQLModules } from '@envelop/core'
|
|
1376
1376
|
|
|
1377
1377
|
@Injectable({
|
|
1378
|
-
scope: Scope.Operation
|
|
1378
|
+
scope: Scope.Operation
|
|
1379
1379
|
})
|
|
1380
1380
|
export class ChargesMatcherProvider {
|
|
1381
1381
|
async findMatchesForCharge(
|
|
1382
1382
|
chargeId: string,
|
|
1383
1383
|
adminBusinessId: string,
|
|
1384
|
-
context: GraphQLModules.AppContext
|
|
1384
|
+
context: GraphQLModules.AppContext
|
|
1385
1385
|
): Promise<ChargeMatch[]> {
|
|
1386
|
-
const chargesProvider = context.injector.get(ChargesProvider)
|
|
1387
|
-
const transactionsProvider = context.injector.get(TransactionsProvider)
|
|
1386
|
+
const chargesProvider = context.injector.get(ChargesProvider)
|
|
1387
|
+
const transactionsProvider = context.injector.get(TransactionsProvider)
|
|
1388
1388
|
|
|
1389
1389
|
// Implementation...
|
|
1390
1390
|
}
|
|
@@ -1404,14 +1404,14 @@ export class ChargesMatcherProvider {
|
|
|
1404
1404
|
**Test Pattern Example:**
|
|
1405
1405
|
|
|
1406
1406
|
```typescript
|
|
1407
|
-
import { describe, it, expect, vi } from 'vitest'
|
|
1407
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
1408
1408
|
|
|
1409
1409
|
describe('amount-confidence.helper', () => {
|
|
1410
1410
|
it('should return 1.0 for exact match', () => {
|
|
1411
|
-
const result = calculateAmountConfidence(100, 100)
|
|
1412
|
-
expect(result).toBe(1.0)
|
|
1413
|
-
})
|
|
1414
|
-
})
|
|
1411
|
+
const result = calculateAmountConfidence(100, 100)
|
|
1412
|
+
expect(result).toBe(1.0)
|
|
1413
|
+
})
|
|
1414
|
+
})
|
|
1415
1415
|
```
|
|
1416
1416
|
|
|
1417
1417
|
### 13.6 Completion Status
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import chargesMatcherTypeDefs from './typeDefs/charges-matcher.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { ChargesMatcherProvider } from './providers/charges-matcher.provider.js';
|
|
4
3
|
import { chargesMatcherResolvers } from './resolvers/index.js';
|
|
4
|
+
import chargesMatcherTypeDefs from './typeDefs/charges-matcher.graphql.js';
|
|
5
5
|
|
|
6
6
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import charts from './typeDefs/charts.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { chartsResolvers } from './resolvers/charts.resolver.js';
|
|
3
|
+
import charts from './typeDefs/charts.graphql.js';
|
|
4
4
|
|
|
5
5
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
6
6
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import common from './typeDefs/common.graphql.js';
|
|
2
|
-
import errors from './typeDefs/errors.graphql.js';
|
|
3
|
-
import gmailListener from './typeDefs/gmail-listener.graphql.js';
|
|
4
|
-
import userContext from './typeDefs/user-context.graphql.js';
|
|
5
1
|
import { createModule } from 'graphql-modules';
|
|
6
2
|
import { scalarsResolvers } from './resolvers/common.resolver.js';
|
|
7
3
|
import { gmailListenerResolvers } from './resolvers/gmail-listener.resolver.js';
|
|
8
4
|
import { userContextResolvers } from './resolvers/user-context.resolver.js';
|
|
5
|
+
import common from './typeDefs/common.graphql.js';
|
|
6
|
+
import errors from './typeDefs/errors.graphql.js';
|
|
7
|
+
import gmailListener from './typeDefs/gmail-listener.graphql.js';
|
|
8
|
+
import userContext from './typeDefs/user-context.graphql.js';
|
|
9
9
|
|
|
10
10
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
11
11
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import contracts from './typeDefs/contracts.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { ContractsProvider } from './providers/contracts.provider.js';
|
|
4
3
|
import { contractsResolvers } from './resolvers/contracts.resolver.js';
|
|
4
|
+
import contracts from './typeDefs/contracts.graphql.js';
|
|
5
5
|
|
|
6
6
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import cornJobs from './typeDefs/corn-jobs.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { CornJobsProvider } from './providers/corn-jobs.provider.js';
|
|
4
3
|
import { cornJobsResolvers } from './resolvers/corn-jobs.resolver.js';
|
|
4
|
+
import cornJobs from './typeDefs/corn-jobs.graphql.js';
|
|
5
5
|
|
|
6
6
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import corporateTaxes from './typeDefs/corporate-taxes.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { CorporateTaxesProvider } from './providers/corporate-taxes.provider.js';
|
|
4
3
|
import { corporateTaxesResolvers } from './resolvers/corporate-taxes.resolver.js';
|
|
4
|
+
import corporateTaxes from './typeDefs/corporate-taxes.graphql.js';
|
|
5
5
|
|
|
6
6
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import countries from './typeDefs/countries.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { CountriesProvider } from './providers/countries.provider.js';
|
|
4
3
|
import { countriesResolvers } from './resolvers/countries.resolver.js';
|
|
4
|
+
import countries from './typeDefs/countries.graphql.js';
|
|
5
5
|
|
|
6
6
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import deel from './typeDefs/deel.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { DeelContractsProvider } from './providers/deel-contracts.provider.js';
|
|
4
3
|
import { DeelInvoicesProvider } from './providers/deel-invoices.provider.js';
|
|
5
4
|
import { deelResolvers } from './resolvers/deel.resolvers.js';
|
|
5
|
+
import deel from './typeDefs/deel.graphql.js';
|
|
6
6
|
|
|
7
7
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import depreciation from './typeDefs/depreciation.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { DepreciationCategoriesProvider } from './providers/depreciation-categories.provider.js';
|
|
4
3
|
import { DepreciationProvider } from './providers/depreciation.provider.js';
|
|
5
4
|
import { depreciationResolvers } from './resolvers/depreciation.resolver.js';
|
|
5
|
+
import depreciation from './typeDefs/depreciation.graphql.js';
|
|
6
6
|
|
|
7
7
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import dividends from './typeDefs/dividends.graphql.js';
|
|
2
1
|
import { createModule } from 'graphql-modules';
|
|
3
2
|
import { DividendsProvider } from './providers/dividends.provider.js';
|
|
3
|
+
import dividends from './typeDefs/dividends.graphql.js';
|
|
4
4
|
|
|
5
5
|
const __dirname = new URL('.', import.meta.url).pathname;
|
|
6
6
|
|