@goodsamsoftware/freshbooks-mcp 1.0.19 → 1.0.20
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journalentry-create.d.ts","sourceRoot":"","sources":["../../../src/tools/journal-entry/journalentry-create.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAG7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAyDxB,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,UAC5C,uBAAuB,GAC9B,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"journalentry-create.d.ts","sourceRoot":"","sources":["../../../src/tools/journal-entry/journalentry-create.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAG7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAyDxB,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,UAC5C,uBAAuB,GAC9B,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;CAsF3D,CAAC"}
|
|
@@ -64,11 +64,11 @@ NOTE: This is a create-only operation. Journal entries cannot be updated or dele
|
|
|
64
64
|
outputSchema: JournalEntryCreateOutputSchema,
|
|
65
65
|
async execute(input, client) {
|
|
66
66
|
const handler = ErrorHandler.wrapHandler('journalentry_create', async (input, _context) => {
|
|
67
|
-
const { accountId,
|
|
67
|
+
const { accountId, name, date, description, currencyCode, details } = input;
|
|
68
68
|
// Validate that debits equal credits
|
|
69
69
|
let totalDebits = 0;
|
|
70
70
|
let totalCredits = 0;
|
|
71
|
-
for (const detail of
|
|
71
|
+
for (const detail of details) {
|
|
72
72
|
if (detail.debit) {
|
|
73
73
|
totalDebits += parseFloat(detail.debit);
|
|
74
74
|
}
|
|
@@ -81,20 +81,50 @@ NOTE: This is a create-only operation. Journal entries cannot be updated or dele
|
|
|
81
81
|
if (difference > 0.01) {
|
|
82
82
|
throw ErrorHandler.createValidationError(`Journal entry must balance. Debits: ${totalDebits.toFixed(2)}, Credits: ${totalCredits.toFixed(2)}, Difference: ${difference.toFixed(2)}`, { tool: 'journalentry_create', accountId });
|
|
83
83
|
}
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
// POST the wire payload directly instead of via the SDK. The SDK's
|
|
85
|
+
// transformJournalEntryRequest has two defects (both live-confirmed):
|
|
86
|
+
// 1. It omits currency_code unless the caller's currencyCode survived
|
|
87
|
+
// schema parsing — and a journal entry WITHOUT currency_code makes the
|
|
88
|
+
// accounting API 500 with the opaque "There was an error accessing your
|
|
89
|
+
// account data." So default it here, in the handler, not the schema.
|
|
90
|
+
// 2. transformDateRequest parses "YYYY-MM-DD" as UTC midnight then reads
|
|
91
|
+
// local Y/M/D, shifting the stored date back a day in negative-UTC
|
|
92
|
+
// timezones. Sending the raw "YYYY-MM-DD" string avoids the shift.
|
|
93
|
+
// (Per-line `description` is intentionally not sent: the API ignores it.)
|
|
94
|
+
const body = {
|
|
95
|
+
journal_entry: {
|
|
96
|
+
name,
|
|
97
|
+
user_entered_date: date,
|
|
98
|
+
currency_code: currencyCode || 'USD',
|
|
99
|
+
details: details.map((d) => ({
|
|
100
|
+
sub_accountid: d.subAccountId,
|
|
101
|
+
...(d.debit !== undefined ? { debit: d.debit } : {}),
|
|
102
|
+
...(d.credit !== undefined ? { credit: d.credit } : {}),
|
|
103
|
+
})),
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
const result = await client.executeRawWithRetry('POST', `/accounting/account/${accountId}/journal_entries/journal_entries`, body, 'journalentry_create');
|
|
107
|
+
if (!result.ok) {
|
|
108
|
+
throw result.error ?? new Error('Journal entry creation failed');
|
|
109
|
+
}
|
|
110
|
+
// Accounting API returns { response: { result: { journal_entry: {...} } } }
|
|
111
|
+
// in snake_case; map it to the camelCase output contract.
|
|
112
|
+
const je = result.data?.response?.result?.journal_entry ?? result.data;
|
|
113
|
+
return {
|
|
114
|
+
id: je.id ?? je.entryid,
|
|
115
|
+
name: je.name,
|
|
116
|
+
description: je.description ?? description,
|
|
117
|
+
date: je.user_entered_date ?? date,
|
|
118
|
+
currencyCode: je.currency_code,
|
|
119
|
+
details: Array.isArray(je.details)
|
|
120
|
+
? je.details.map((d) => ({
|
|
121
|
+
subAccountId: d.sub_accountid,
|
|
122
|
+
debit: d.debit ?? undefined,
|
|
123
|
+
credit: d.credit ?? undefined,
|
|
124
|
+
description: d.description ?? undefined,
|
|
125
|
+
}))
|
|
126
|
+
: [],
|
|
127
|
+
};
|
|
98
128
|
});
|
|
99
129
|
return handler(input, { accountId: input.accountId });
|
|
100
130
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journalentry-create.js","sourceRoot":"","sources":["../../../src/tools/journal-entry/journalentry-create.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,6BAA6B,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,YAAY,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