-
Notifications
You must be signed in to change notification settings - Fork 1
Create tests for account templates #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6569561
817eb57
8151798
bb835b7
5270726
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -404,6 +404,30 @@ async function removeSharedPartFromAccountTemplate(type, envId, sharedPartId, ac | |
| } | ||
| } | ||
|
|
||
| async function getAccountTemplateCustom(type, envId, companyId, periodId, accountTemplateId, page = 1) { | ||
| const instance = AxiosFactory.createInstance(type, envId); | ||
| try { | ||
| const response = await instance.get(`/companies/${companyId}/periods/${periodId}/accounts/${accountTemplateId}/custom`, { params: { page: page, per_page: 200 } }); | ||
| apiUtils.responseSuccessHandler(response); | ||
| return response; | ||
| } catch (error) { | ||
| const response = await apiUtils.responseErrorHandler(error); | ||
| return response; | ||
| } | ||
| } | ||
|
|
||
| async function getAccountTemplateResults(type, envId, companyId, periodId, accountTemplateId) { | ||
| const instance = AxiosFactory.createInstance(type, envId); | ||
| try { | ||
| const response = await instance.get(`/companies/${companyId}/periods/${periodId}/accounts/${accountTemplateId}/results`); | ||
| apiUtils.responseSuccessHandler(response); | ||
| return response; | ||
| } catch (error) { | ||
| const response = await apiUtils.responseErrorHandler(error); | ||
| return response; | ||
| } | ||
| } | ||
|
|
||
| async function createTestRun(firmId, attributes, templateType) { | ||
| const instance = AxiosFactory.createInstance("firm", firmId); | ||
| let response; | ||
|
|
@@ -615,6 +639,33 @@ async function getAccountDetails(firmId, companyId, periodId, accountId) { | |
| } | ||
| } | ||
|
|
||
| async function findAccountByNumber(firmId, companyId, periodId, accountNumber, page = 1) { | ||
| const instance = AxiosFactory.createInstance("firm", firmId); | ||
| try { | ||
| const response = await instance.get(`companies/${companyId}/periods/${periodId}/accounts`, { | ||
| params: { page: page }, | ||
| }); | ||
|
|
||
| const accounts = response.data; | ||
|
|
||
| // No data - end of pagination | ||
| if (accounts.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| // Look for the account in this page | ||
| const account = accounts.find((acc) => acc.account.number === accountNumber); | ||
| if (account) { | ||
| return account; | ||
| } | ||
|
|
||
| // Not found in this page, try next page | ||
| return findAccountByNumber(firmId, companyId, periodId, accountNumber, page + 1); | ||
| } catch (error) { | ||
| apiUtils.responseErrorHandler(error); | ||
| } | ||
| } | ||
|
Comment on lines
+642
to
+667
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing return statement in error handler will silently swallow errors. The catch block calls } catch (error) {
- apiUtils.responseErrorHandler(error);
+ const response = await apiUtils.responseErrorHandler(error);
+ return response;
}
}Additionally, consider adding a
🤖 Prompt for AI Agents |
||
|
|
||
| // Liquid Linter | ||
| // attributes should be JSON | ||
| async function verifyLiquid(firmId, attributes) { | ||
|
|
@@ -674,6 +725,8 @@ module.exports = { | |
| findAccountTemplateByName, | ||
| addSharedPartToAccountTemplate, | ||
| removeSharedPartFromAccountTemplate, | ||
| getAccountTemplateCustom, | ||
| getAccountTemplateResults, | ||
| readTestRun, | ||
| createTestRun, | ||
| createPreviewRun, | ||
|
|
@@ -688,6 +741,7 @@ module.exports = { | |
| findReconciliationInWorkflow, | ||
| findReconciliationInWorkflows, | ||
| getAccountDetails, | ||
| findAccountByNumber, | ||
| verifyLiquid, | ||
| getFirmDetails, | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing changelog entry for the new account template test creation feature.
This PR introduces significant new functionality (create-test support for account templates), but the CHANGELOG does not document this change. Consider adding an entry similar to:
🤖 Prompt for AI Agents