@things-factory/integration-accounting 5.0.7 → 6.0.0-alpha.0
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/dist-server/controllers/accounting-api/decorators.js +2 -4
- package/dist-server/controllers/accounting-api/decorators.js.map +1 -1
- package/dist-server/controllers/accounting-api/index.js +55 -63
- package/dist-server/controllers/accounting-api/index.js.map +1 -1
- package/dist-server/controllers/index.js +2 -15
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/xero/apis/contact/get-contact.js.map +1 -1
- package/dist-server/controllers/xero/apis/contact/get-contacts.js.map +1 -1
- package/dist-server/controllers/xero/apis/contact/index.js +3 -16
- package/dist-server/controllers/xero/apis/contact/index.js.map +1 -1
- package/dist-server/controllers/xero/apis/index.js +5 -18
- package/dist-server/controllers/xero/apis/index.js.map +1 -1
- package/dist-server/controllers/xero/apis/invoice/create-invoice.js.map +1 -1
- package/dist-server/controllers/xero/apis/invoice/get-invoice.js.map +1 -1
- package/dist-server/controllers/xero/apis/invoice/get-invoices.js.map +1 -1
- package/dist-server/controllers/xero/apis/invoice/index.js +5 -18
- package/dist-server/controllers/xero/apis/invoice/index.js.map +1 -1
- package/dist-server/controllers/xero/apis/invoice/update-invoice.js.map +1 -1
- package/dist-server/controllers/xero/apis/item/create-item.js.map +1 -1
- package/dist-server/controllers/xero/apis/item/delete-item.js.map +1 -1
- package/dist-server/controllers/xero/apis/item/get-item.js.map +1 -1
- package/dist-server/controllers/xero/apis/item/get-items.js.map +1 -1
- package/dist-server/controllers/xero/apis/item/index.js +7 -20
- package/dist-server/controllers/xero/apis/item/index.js.map +1 -1
- package/dist-server/controllers/xero/apis/item/update-item.js.map +1 -1
- package/dist-server/controllers/xero/apis/item/update-items.js.map +1 -1
- package/dist-server/controllers/xero/apis/purchase-order/get-purchase-orders.js.map +1 -1
- package/dist-server/controllers/xero/apis/purchase-order/index.js +2 -15
- package/dist-server/controllers/xero/apis/purchase-order/index.js.map +1 -1
- package/dist-server/controllers/xero/index.js +3 -28
- package/dist-server/controllers/xero/index.js.map +1 -1
- package/dist-server/controllers/xero/platform-action.js.map +1 -1
- package/dist-server/controllers/xero/xero.js +4 -6
- package/dist-server/controllers/xero/xero.js.map +1 -1
- package/dist-server/engine/connector/accounting-connector.js.map +1 -1
- package/dist-server/engine/connector/index.js.map +1 -1
- package/dist-server/engine/index.js.map +1 -1
- package/dist-server/engine/task/accounting-api.js +3 -3
- package/dist-server/engine/task/accounting-api.js.map +1 -1
- package/dist-server/engine/task/index.js.map +1 -1
- package/dist-server/entities/account.js +40 -49
- package/dist-server/entities/account.js.map +1 -1
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/graphql/index.js +3 -25
- package/dist-server/graphql/index.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/account.js +4 -4
- package/dist-server/graphql/resolvers/accounting/account.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/accounts.js +1 -2
- package/dist-server/graphql/resolvers/accounting/accounts.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/create-account.js +4 -3
- package/dist-server/graphql/resolvers/accounting/create-account.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/delete-account.js +5 -5
- package/dist-server/graphql/resolvers/accounting/delete-account.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/delete-accounts.js +5 -4
- package/dist-server/graphql/resolvers/accounting/delete-accounts.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/index.js +2 -24
- package/dist-server/graphql/resolvers/accounting/index.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/update-account.js +3 -3
- package/dist-server/graphql/resolvers/accounting/update-account.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/update-multiple-accounts.js +3 -3
- package/dist-server/graphql/resolvers/accounting/update-multiple-accounts.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/xero/deactivate-xero-account.js +6 -8
- package/dist-server/graphql/resolvers/accounting/xero/deactivate-xero-account.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/xero/get-xero-auth-url.js +5 -7
- package/dist-server/graphql/resolvers/accounting/xero/get-xero-auth-url.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/xero/index.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting/xero/refresh-xero-access-token.js +7 -9
- package/dist-server/graphql/resolvers/accounting/xero/refresh-xero-access-token.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting-api/accounting-invoice.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting-api/accounting-item.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting-api/accounting-purchase-order.js.map +1 -1
- package/dist-server/graphql/resolvers/accounting-api/index.js.map +1 -1
- package/dist-server/graphql/resolvers/index.js +2 -24
- package/dist-server/graphql/resolvers/index.js.map +1 -1
- package/dist-server/graphql/types/accounting/account-list.js +2 -4
- package/dist-server/graphql/types/accounting/account-list.js.map +1 -1
- package/dist-server/graphql/types/accounting/account-patch.js +2 -4
- package/dist-server/graphql/types/accounting/account-patch.js.map +1 -1
- package/dist-server/graphql/types/accounting/account.js +2 -4
- package/dist-server/graphql/types/accounting/account.js.map +1 -1
- package/dist-server/graphql/types/accounting/index.js.map +1 -1
- package/dist-server/graphql/types/accounting/new-account.js +2 -4
- package/dist-server/graphql/types/accounting/new-account.js.map +1 -1
- package/dist-server/graphql/types/accounting-api/invoice.js +2 -4
- package/dist-server/graphql/types/accounting-api/invoice.js.map +1 -1
- package/dist-server/graphql/types/accounting-api/item.js +2 -4
- package/dist-server/graphql/types/accounting-api/item.js.map +1 -1
- package/dist-server/graphql/types/accounting-api/purchase-order.js +2 -4
- package/dist-server/graphql/types/accounting-api/purchase-order.js.map +1 -1
- package/dist-server/graphql/types/index.js +5 -27
- package/dist-server/graphql/types/index.js.map +1 -1
- package/dist-server/index.js +5 -18
- package/dist-server/index.js.map +1 -1
- package/dist-server/migrations/index.js.map +1 -1
- package/dist-server/routers/xero-private-router.js +2 -4
- package/dist-server/routers/xero-private-router.js.map +1 -1
- package/dist-server/routers/xero-router.js +6 -9
- package/dist-server/routers/xero-router.js.map +1 -1
- package/dist-server/routes.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +16 -16
- package/server/controllers/accounting-api/index.ts +1 -1
- package/server/controllers/xero/xero.ts +1 -1
- package/server/engine/task/accounting-api.ts +3 -2
- package/server/graphql/resolvers/accounting/account.ts +4 -3
- package/server/graphql/resolvers/accounting/accounts.ts +2 -4
- package/server/graphql/resolvers/accounting/create-account.ts +9 -6
- package/server/graphql/resolvers/accounting/delete-account.ts +5 -4
- package/server/graphql/resolvers/accounting/delete-accounts.ts +7 -4
- package/server/graphql/resolvers/accounting/update-account.ts +4 -3
- package/server/graphql/resolvers/accounting/update-multiple-accounts.ts +4 -3
- package/server/graphql/resolvers/accounting/xero/deactivate-xero-account.ts +6 -4
- package/server/graphql/resolvers/accounting/xero/get-xero-auth-url.ts +6 -4
- package/server/graphql/resolvers/accounting/xero/refresh-xero-access-token.ts +7 -5
- package/server/graphql/resolvers/accounting-api/accounting-invoice.ts +9 -9
- package/server/graphql/resolvers/accounting-api/accounting-item.ts +11 -12
- package/server/graphql/resolvers/accounting-api/accounting-purchase-order.ts +1 -1
- package/server/routers/xero-router.ts +2 -3
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import fetch from 'node-fetch'
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { getRepository } from '@things-factory/shell'
|
|
4
|
+
|
|
4
5
|
import { ACCOUNTING_STATUS } from '../../../../controllers'
|
|
6
|
+
import { Account } from '../../../../entities'
|
|
5
7
|
|
|
6
8
|
const debug = require('debug')('things-factory:integration-accounting:deactivate-xero-account')
|
|
7
9
|
|
|
8
10
|
export const deactivateXeroAccount = {
|
|
9
|
-
async deactivateXeroAccount(_: any, { id }, context:
|
|
11
|
+
async deactivateXeroAccount(_: any, { id }, context: ResolverContext) {
|
|
10
12
|
const repository = getRepository(Account)
|
|
11
13
|
const account: any = await repository.findOne({
|
|
12
|
-
where: { domain: context.state.domain, id }
|
|
14
|
+
where: { domain: { id: context.state.domain.id }, id }
|
|
13
15
|
})
|
|
14
16
|
|
|
15
17
|
try {
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import crypto from 'crypto'
|
|
2
|
+
|
|
3
3
|
import { VerificationToken, VerificationTokenType } from '@things-factory/auth-base'
|
|
4
|
+
import { config } from '@things-factory/env'
|
|
5
|
+
import { getRepository } from '@things-factory/shell'
|
|
6
|
+
|
|
4
7
|
import { Xero } from '../../../../controllers/xero'
|
|
5
8
|
|
|
6
9
|
const xeroConfig = config.get('accountingIntegrationXero', {})
|
|
7
10
|
const { apiKey, apiSecret, callback } = xeroConfig
|
|
8
11
|
|
|
9
|
-
import crypto from 'crypto'
|
|
10
12
|
export function makeVerificationTokenForNonce() {
|
|
11
13
|
return crypto.randomBytes(16).toString('hex')
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export const getXeroAuthURL = {
|
|
15
|
-
async getXeroAuthURL(_: any, { accounting }, context:
|
|
17
|
+
async getXeroAuthURL(_: any, { accounting }, context: ResolverContext) {
|
|
16
18
|
const { user } = context.state
|
|
17
19
|
const xero = new Xero({ apiKey, apiSecret, callback })
|
|
18
20
|
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import fetch from 'node-fetch'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
|
-
import { Account } from '../../../../entities'
|
|
4
2
|
|
|
5
|
-
import { parseJwt } from '@things-factory/utils'
|
|
6
3
|
import { config } from '@things-factory/env'
|
|
4
|
+
import { getRepository } from '@things-factory/shell'
|
|
5
|
+
import { parseJwt } from '@things-factory/utils'
|
|
6
|
+
|
|
7
|
+
import { Account } from '../../../../entities'
|
|
8
|
+
|
|
7
9
|
const xeroConfig = config.get('accountingIntegrationXero', {})
|
|
8
10
|
const { apiKey, apiSecret } = xeroConfig
|
|
9
11
|
|
|
10
12
|
const debug = require('debug')('things-factory:integration-accounting:refresh-xero-access-token')
|
|
11
13
|
|
|
12
14
|
export const refreshXeroAccessToken = {
|
|
13
|
-
async refreshXeroAccessToken(_: any, { id }, context:
|
|
15
|
+
async refreshXeroAccessToken(_: any, { id }, context: ResolverContext) {
|
|
14
16
|
const repository = getRepository(Account)
|
|
15
17
|
const account: any = await repository.findOne({
|
|
16
|
-
where: { domain: context.state.domain, id }
|
|
18
|
+
where: { domain: { id: context.state.domain.id }, id }
|
|
17
19
|
})
|
|
18
20
|
|
|
19
21
|
const refreshRequestData = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AccountingAPI } from '../../../controllers/accounting-api'
|
|
2
2
|
|
|
3
3
|
export const queryAccountingInvoice = {
|
|
4
|
-
async getAccountingInvoices(_: any, { accountingId, params: ListParam
|
|
4
|
+
async getAccountingInvoices(_: any, { accountingId, params: ListParam }, context: ResolverContext) {
|
|
5
5
|
var accounting = await AccountingAPI.getAccounting(accountingId)
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
return await AccountingAPI.getInvoices(accounting, {
|
|
8
8
|
pagination: {
|
|
9
9
|
page: 0,
|
|
@@ -12,9 +12,9 @@ export const queryAccountingInvoice = {
|
|
|
12
12
|
})
|
|
13
13
|
},
|
|
14
14
|
|
|
15
|
-
async getAccountingInvoice(_: any, { accountingId, invoiceNo }, context:
|
|
15
|
+
async getAccountingInvoice(_: any, { accountingId, invoiceNo }, context: ResolverContext) {
|
|
16
16
|
var accounting = await AccountingAPI.getAccounting(accountingId)
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
return await AccountingAPI.getInvoice(accounting, {
|
|
19
19
|
invoiceNo
|
|
20
20
|
})
|
|
@@ -22,15 +22,15 @@ export const queryAccountingInvoice = {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export const mutateAccountingInvoice = {
|
|
25
|
-
async createAccountingInvoice(_: any, { accountingId, newInvoice }, context:
|
|
25
|
+
async createAccountingInvoice(_: any, { accountingId, newInvoice }, context: ResolverContext) {
|
|
26
26
|
var accounting = await AccountingAPI.getAccounting(accountingId)
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
return await AccountingAPI.createInvoice(accounting, newInvoice)
|
|
29
29
|
},
|
|
30
30
|
|
|
31
|
-
async updateAccountingInvoice(_: any, { accountingId, patch }, context:
|
|
31
|
+
async updateAccountingInvoice(_: any, { accountingId, patch }, context: ResolverContext) {
|
|
32
32
|
var accounting = await AccountingAPI.getAccounting(accountingId)
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
return await AccountingAPI.updateInvoice(accounting, patch)
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { convertListParams, ListParam } from '@things-factory/shell'
|
|
2
1
|
import { AccountingAPI } from '../../../controllers/accounting-api'
|
|
3
2
|
|
|
4
3
|
export const queryAccountingItem = {
|
|
5
|
-
async getAccountingItems(_: any, { accountingId, params: ListParam }, context:
|
|
4
|
+
async getAccountingItems(_: any, { accountingId, params: ListParam }, context: ResolverContext) {
|
|
6
5
|
var accounting = await AccountingAPI.getAccounting(accountingId)
|
|
7
|
-
|
|
6
|
+
|
|
8
7
|
return await AccountingAPI.getItems(accounting, {
|
|
9
8
|
pagination: {
|
|
10
9
|
page: 0,
|
|
@@ -13,9 +12,9 @@ export const queryAccountingItem = {
|
|
|
13
12
|
})
|
|
14
13
|
},
|
|
15
14
|
|
|
16
|
-
async getAccountingItem(_: any, { accountingId, itemId }, context:
|
|
15
|
+
async getAccountingItem(_: any, { accountingId, itemId }, context: ResolverContext) {
|
|
17
16
|
var accounting = await AccountingAPI.getAccounting(accountingId)
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
return await AccountingAPI.getItem(accounting, {
|
|
20
19
|
itemId
|
|
21
20
|
})
|
|
@@ -23,21 +22,21 @@ export const queryAccountingItem = {
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
export const mutateAccountingItem = {
|
|
26
|
-
async createAccountingItem(_: any, { accountingId, newItem }, context:
|
|
25
|
+
async createAccountingItem(_: any, { accountingId, newItem }, context: ResolverContext) {
|
|
27
26
|
var accounting = await AccountingAPI.getAccounting(accountingId)
|
|
28
|
-
|
|
27
|
+
|
|
29
28
|
return await AccountingAPI.createItem(accounting, newItem)
|
|
30
29
|
},
|
|
31
30
|
|
|
32
|
-
async updateAccountingItem(_: any, { accountingId, patch }, context:
|
|
31
|
+
async updateAccountingItem(_: any, { accountingId, patch }, context: ResolverContext) {
|
|
33
32
|
var accounting = await AccountingAPI.getAccounting(accountingId)
|
|
34
|
-
|
|
33
|
+
|
|
35
34
|
return await AccountingAPI.updateItem(accounting, patch)
|
|
36
35
|
},
|
|
37
36
|
|
|
38
|
-
async deleteAccountingItem(_: any, { accountingId, itemId }, context:
|
|
37
|
+
async deleteAccountingItem(_: any, { accountingId, itemId }, context: ResolverContext) {
|
|
39
38
|
var accounting = await AccountingAPI.getAccounting(accountingId)
|
|
40
|
-
|
|
39
|
+
|
|
41
40
|
return await AccountingAPI.deleteItem(accounting, itemId)
|
|
42
41
|
}
|
|
43
|
-
}
|
|
42
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountingAPI } from '../../../controllers/accounting-api'
|
|
2
2
|
|
|
3
3
|
export const queryAccountingPurchaseOrder = {
|
|
4
|
-
async getAccountingPurchaseOrders(_: any, { accountingId, params: ListParam }, context:
|
|
4
|
+
async getAccountingPurchaseOrders(_: any, { accountingId, params: ListParam }, context: ResolverContext) {
|
|
5
5
|
var accounting = await AccountingAPI.getAccounting(accountingId)
|
|
6
6
|
|
|
7
7
|
return await AccountingAPI.getPurchaseOrders(accounting, {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import Router from 'koa-router'
|
|
2
2
|
import fetch from 'node-fetch'
|
|
3
|
-
import { getRepository } from 'typeorm'
|
|
4
3
|
|
|
5
4
|
import { User, VerificationToken, VerificationTokenType } from '@things-factory/auth-base'
|
|
6
5
|
import { config } from '@things-factory/env'
|
|
7
|
-
import { getUrlFromContext } from '@things-factory/shell'
|
|
6
|
+
import { getRepository, getUrlFromContext } from '@things-factory/shell'
|
|
8
7
|
import { parseJwt } from '@things-factory/utils'
|
|
9
8
|
|
|
10
9
|
import { ACCOUNTING_STATUS, AccountingAPI } from '../controllers/accounting-api'
|
|
@@ -107,7 +106,7 @@ xeroRouter.get('/callback-xero', async (context, next) => {
|
|
|
107
106
|
expiresIn: new Date(exp * 1000)
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
var user = await getRepository(User).
|
|
109
|
+
var user = await getRepository(User).findOneBy({ id: userId })
|
|
111
110
|
|
|
112
111
|
account = await getRepository(Account).save({
|
|
113
112
|
...account,
|