Skip to content
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

feat: accounting category- Xero, QucikBooks #592

Merged
merged 19 commits into from
Aug 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added get many endpoint
manish-singh-bisht committed Jun 25, 2024
commit 2fcd11f202ea561032c03842a2c2c9d0ca996d8c
23 changes: 22 additions & 1 deletion fern/definition/accounting/account.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,12 @@ types:
properties:
status: types.ResponseStatus
result: unknown
GetAccountsResponse:
properties:
status: types.ResponseStatus
next: optional<string>
previous: optional<string>
results: unknown
CreateOrUpdateAccountRequest: unknown
CreateOrUpdateAccountResponse:
properties:
@@ -33,7 +39,7 @@ service:
- external
endpoints:
getAccount:
docs: Get details of a account
docs: Get details of an account
method: GET
path: /{id}
path-parameters:
@@ -47,6 +53,21 @@ service:
- errors.UnAuthorizedError
- errors.InternalServerError
- errors.NotFoundError
getAccounts:
docs: Get all the accounts
method: GET
path: ''
request:
name: GetAccountsRequest
query-parameters:
fields: optional<string>
pageSize: optional<string>
cursor: optional<string>
response: GetAccountsResponse
errors:
- errors.UnAuthorizedError
- errors.InternalServerError
- errors.NotFoundError
createAccount:
docs: Post Account
method: POST
19 changes: 18 additions & 1 deletion fern/definition/accounting/expense.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,12 @@ types:
properties:
status: types.ResponseStatus
result: unknown
GetExpensesResponse:
properties:
status: types.ResponseStatus
next: optional<string>
previous: optional<string>
results: unknown
CreateOrUpdateExpenseRequest: unknown
CreateOrUpdateExpenseResponse:
properties:
@@ -33,7 +39,7 @@ service:
- external
endpoints:
getExpense:
docs: Get details of a Expense
docs: Get details of an Expense
method: GET
path: /{id}
path-parameters:
@@ -47,6 +53,17 @@ service:
- errors.UnAuthorizedError
- errors.InternalServerError
- errors.NotFoundError
getExpenses:
docs: Get all the expenses
method: GET
path: ''
request:
name: GetExpensesRequest
query-parameters:
fields: optional<string>
pageSize: optional<string>
cursor: optional<string>
response: GetExpensesResponse
createExpense:
docs: Post Expense
method: POST
17 changes: 17 additions & 0 deletions fern/definition/accounting/vendor.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,12 @@ types:
properties:
status: types.ResponseStatus
result: unknown
GetVendorsResponse:
properties:
status: types.ResponseStatus
next: optional<string>
previous: optional<string>
results: unknown
CreateOrUpdateVendorRequest: unknown
CreateOrUpdateVendorResponse:
properties:
@@ -47,6 +53,17 @@ service:
- errors.UnAuthorizedError
- errors.InternalServerError
- errors.NotFoundError
getVendors:
docs: Get all the Vendors
method: GET
path: ''
request:
name: GetVendorsRequest
query-parameters:
fields: optional<string>
pageSize: optional<string>
cursor: optional<string>
response: GetVendorsResponse
createVendor:
docs: Post Vendor
method: POST
163 changes: 161 additions & 2 deletions packages/backend/oas/openapi.yml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ info:
paths:
/accounting/accounts/{id}:
get:
description: Get details of a account
description: Get details of an account
operationId: accounting_account_getAccount
tags:
- AccountingAccount
@@ -95,6 +95,55 @@ paths:
schema:
$ref: '#/components/schemas/accountingCreateOrUpdateAccountRequest'
/accounting/accounts:
get:
description: Get all the accounts
operationId: accounting_account_getAccounts
tags:
- AccountingAccount
parameters:
- name: fields
in: query
required: false
schema:
type: string
nullable: true
- name: pageSize
in: query
required: false
schema:
type: string
nullable: true
- name: cursor
in: query
required: false
schema:
type: string
nullable: true
responses:
'200':
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/accountingGetAccountsResponse'
'401':
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/commonBaseError'
'404':
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/commonBaseError'
'500':
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/commonBaseError'
post:
description: Post Account
operationId: accounting_account_createAccount
@@ -140,7 +189,7 @@ paths:
$ref: '#/components/schemas/accountingCreateOrUpdateAccountRequest'
/accounting/expenses/{id}:
get:
description: Get details of a Expense
description: Get details of an Expense
operationId: accounting_expense_getExpense
tags:
- AccountingExpense
@@ -230,6 +279,37 @@ paths:
schema:
$ref: '#/components/schemas/accountingCreateOrUpdateExpenseRequest'
/accounting/expenses:
get:
description: Get all the expenses
operationId: accounting_expense_getExpenses
tags:
- AccountingExpense
parameters:
- name: fields
in: query
required: false
schema:
type: string
nullable: true
- name: pageSize
in: query
required: false
schema:
type: string
nullable: true
- name: cursor
in: query
required: false
schema:
type: string
nullable: true
responses:
'200':
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/accountingGetExpensesResponse'
post:
description: Post Expense
operationId: accounting_expense_createExpense
@@ -403,6 +483,37 @@ paths:
schema:
$ref: '#/components/schemas/accountingCreateOrUpdateVendorRequest'
/accounting/vendors:
get:
description: Get all the Vendors
operationId: accounting_vendor_getVendors
tags:
- AccountingVendor
parameters:
- name: fields
in: query
required: false
schema:
type: string
nullable: true
- name: pageSize
in: query
required: false
schema:
type: string
nullable: true
- name: cursor
in: query
required: false
schema:
type: string
nullable: true
responses:
'200':
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/accountingGetVendorsResponse'
post:
description: Post Vendor
operationId: accounting_vendor_createVendor
@@ -3962,6 +4073,22 @@ components:
required:
- status
- result
accountingGetAccountsResponse:
title: accountingGetAccountsResponse
type: object
properties:
status:
$ref: '#/components/schemas/commonResponseStatus'
next:
type: string
nullable: true
previous:
type: string
nullable: true
results: {}
required:
- status
- results
accountingCreateOrUpdateAccountRequest:
title: accountingCreateOrUpdateAccountRequest
accountingCreateOrUpdateAccountResponse:
@@ -3987,6 +4114,22 @@ components:
required:
- status
- result
accountingGetExpensesResponse:
title: accountingGetExpensesResponse
type: object
properties:
status:
$ref: '#/components/schemas/commonResponseStatus'
next:
type: string
nullable: true
previous:
type: string
nullable: true
results: {}
required:
- status
- results
accountingCreateOrUpdateExpenseRequest:
title: accountingCreateOrUpdateExpenseRequest
accountingCreateOrUpdateExpenseResponse:
@@ -4034,6 +4177,22 @@ components:
required:
- status
- result
accountingGetVendorsResponse:
title: accountingGetVendorsResponse
type: object
properties:
status:
$ref: '#/components/schemas/commonResponseStatus'
next:
type: string
nullable: true
previous:
type: string
nullable: true
results: {}
required:
- status
- results
accountingCreateOrUpdateVendorRequest:
title: accountingCreateOrUpdateVendorRequest
accountingCreateOrUpdateVendorResponse:
40 changes: 40 additions & 0 deletions packages/backend/services/accounting/account.ts
Original file line number Diff line number Diff line change
@@ -77,6 +77,46 @@ const accountServiceAccounting = new AccountService(
}
},

async getAccounts(req, res) {
try {
const connection = res.locals.connection;
const account = res.locals.account;
const fields: any = req.query.fields ? JSON.parse(req.query.fields as string) : undefined;
const pageSize = parseInt(String(req.query.pageSize));
const cursor = req.query.cursor;
const thirdPartyId = connection.tp_id;
const thirdPartyToken = connection.tp_access_token;
const tenantId = connection.t_id;

logInfo(
'Revert::GET ALL ACCOUNTS',
connection.app?.env?.accountId,
tenantId,
thirdPartyId,
thirdPartyToken
);
switch (thirdPartyId) {
case TP_ID.quickbooks: {
res.send({
status: 'ok',
results: 'This endpoint is currently not supported',
});
break;
}
default: {
throw new NotFoundError({ error: 'Unrecognized app' });
}
}
} catch (error: any) {
logError(error);
console.error('Could not fetch accounts', error);
if (isStandardError(error)) {
throw error;
}
throw new InternalServerError({ error: 'Internal server error' });
}
},

async createAccount(req, res) {
try {
const accountData: any = req.body as unknown as UnifiedAccount;
39 changes: 39 additions & 0 deletions packages/backend/services/accounting/expense.ts
Original file line number Diff line number Diff line change
@@ -76,6 +76,45 @@ const expenseServiceAccounting = new ExpenseService(
throw new InternalServerError({ error: 'Internal server error' });
}
},
async getExpenses(req, res) {
try {
const connection = res.locals.connection;
const account = res.locals.account;
const fields: any = req.query.fields ? JSON.parse(req.query.fields as string) : undefined;
const pageSize = parseInt(String(req.query.pageSize));
const cursor = req.query.cursor;
const thirdPartyId = connection.tp_id;
const thirdPartyToken = connection.tp_access_token;
const tenantId = connection.t_id;

logInfo(
'Revert::GET ALL EXPENSES',
connection.app?.env?.accountId,
tenantId,
thirdPartyId,
thirdPartyToken
);
switch (thirdPartyId) {
case TP_ID.quickbooks: {
res.send({
status: 'ok',
results: 'This endpoint is currently not supported',
});
break;
}
default: {
throw new NotFoundError({ error: 'Unrecognized app' });
}
}
} catch (error: any) {
logError(error);
console.error('Could not fetch expenses', error);
if (isStandardError(error)) {
throw error;
}
throw new InternalServerError({ error: 'Internal server error' });
}
},

async createExpense(req, res) {
try {
39 changes: 39 additions & 0 deletions packages/backend/services/accounting/vendor.ts
Original file line number Diff line number Diff line change
@@ -76,6 +76,45 @@ const vendorServiceAccounting = new VendorService(
throw new InternalServerError({ error: 'Internal server error' });
}
},
async getVendors(req, res) {
try {
const connection = res.locals.connection;
const account = res.locals.account;
const fields: any = req.query.fields ? JSON.parse(req.query.fields as string) : undefined;
const pageSize = parseInt(String(req.query.pageSize));
const cursor = req.query.cursor;
const thirdPartyId = connection.tp_id;
const thirdPartyToken = connection.tp_access_token;
const tenantId = connection.t_id;

logInfo(
'Revert::GET ALL VENDORS',
connection.app?.env?.accountId,
tenantId,
thirdPartyId,
thirdPartyToken
);
switch (thirdPartyId) {
case TP_ID.quickbooks: {
res.send({
status: 'ok',
results: 'This endpoint is currently not supported',
});
break;
}
default: {
throw new NotFoundError({ error: 'Unrecognized app' });
}
}
} catch (error: any) {
logError(error);
console.error('Could not fetch vendors', error);
if (isStandardError(error)) {
throw error;
}
throw new InternalServerError({ error: 'Internal server error' });
}
},

async createVendor(req, res) {
try {