@things-factory/integration-accounting 8.0.6 → 9.0.0-beta.12

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.
Files changed (65) hide show
  1. package/dist-server/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +14 -14
  3. package/server/controllers/accounting-api/decorators.ts +0 -47
  4. package/server/controllers/accounting-api/index.ts +0 -72
  5. package/server/controllers/index.ts +0 -3
  6. package/server/controllers/xero/apis/contact/get-contact.ts +0 -38
  7. package/server/controllers/xero/apis/contact/get-contacts.ts +0 -16
  8. package/server/controllers/xero/apis/contact/index.ts +0 -2
  9. package/server/controllers/xero/apis/index.ts +0 -4
  10. package/server/controllers/xero/apis/invoice/create-invoice.ts +0 -12
  11. package/server/controllers/xero/apis/invoice/get-invoice.ts +0 -14
  12. package/server/controllers/xero/apis/invoice/get-invoices.ts +0 -76
  13. package/server/controllers/xero/apis/invoice/index.ts +0 -4
  14. package/server/controllers/xero/apis/invoice/update-invoice.ts +0 -12
  15. package/server/controllers/xero/apis/item/create-item.ts +0 -37
  16. package/server/controllers/xero/apis/item/delete-item.ts +0 -19
  17. package/server/controllers/xero/apis/item/get-item.ts +0 -41
  18. package/server/controllers/xero/apis/item/get-items.ts +0 -41
  19. package/server/controllers/xero/apis/item/index.ts +0 -6
  20. package/server/controllers/xero/apis/item/update-item.ts +0 -35
  21. package/server/controllers/xero/apis/item/update-items.ts +0 -43
  22. package/server/controllers/xero/apis/purchase-order/get-purchase-orders.ts +0 -61
  23. package/server/controllers/xero/apis/purchase-order/index.ts +0 -1
  24. package/server/controllers/xero/index.ts +0 -8
  25. package/server/controllers/xero/platform-action.ts +0 -53
  26. package/server/controllers/xero/xero.ts +0 -215
  27. package/server/engine/connector/accounting-connector.ts +0 -33
  28. package/server/engine/connector/index.ts +0 -1
  29. package/server/engine/index.ts +0 -2
  30. package/server/engine/task/accounting-api.ts +0 -64
  31. package/server/engine/task/index.ts +0 -1
  32. package/server/entities/account.ts +0 -86
  33. package/server/entities/index.ts +0 -5
  34. package/server/graphql/index.ts +0 -7
  35. package/server/graphql/resolvers/accounting/account.ts +0 -14
  36. package/server/graphql/resolvers/accounting/accounts.ts +0 -15
  37. package/server/graphql/resolvers/accounting/create-account.ts +0 -18
  38. package/server/graphql/resolvers/accounting/delete-account.ts +0 -20
  39. package/server/graphql/resolvers/accounting/delete-accounts.ts +0 -25
  40. package/server/graphql/resolvers/accounting/index.ts +0 -25
  41. package/server/graphql/resolvers/accounting/update-account.ts +0 -18
  42. package/server/graphql/resolvers/accounting/update-multiple-accounts.ts +0 -44
  43. package/server/graphql/resolvers/accounting/xero/deactivate-xero-account.ts +0 -57
  44. package/server/graphql/resolvers/accounting/xero/get-xero-auth-url.ts +0 -32
  45. package/server/graphql/resolvers/accounting/xero/index.ts +0 -13
  46. package/server/graphql/resolvers/accounting/xero/refresh-xero-access-token.ts +0 -67
  47. package/server/graphql/resolvers/accounting-api/accounting-invoice.ts +0 -36
  48. package/server/graphql/resolvers/accounting-api/accounting-item.ts +0 -42
  49. package/server/graphql/resolvers/accounting-api/accounting-purchase-order.ts +0 -14
  50. package/server/graphql/resolvers/accounting-api/index.ts +0 -14
  51. package/server/graphql/resolvers/index.ts +0 -5
  52. package/server/graphql/types/accounting/account-list.ts +0 -8
  53. package/server/graphql/types/accounting/account-patch.ts +0 -14
  54. package/server/graphql/types/accounting/account.ts +0 -25
  55. package/server/graphql/types/accounting/index.ts +0 -44
  56. package/server/graphql/types/accounting/new-account.ts +0 -12
  57. package/server/graphql/types/accounting-api/invoice.ts +0 -65
  58. package/server/graphql/types/accounting-api/item.ts +0 -64
  59. package/server/graphql/types/accounting-api/purchase-order.ts +0 -30
  60. package/server/graphql/types/index.ts +0 -10
  61. package/server/index.ts +0 -9
  62. package/server/migrations/index.ts +0 -9
  63. package/server/routers/xero-private-router.ts +0 -24
  64. package/server/routers/xero-router.ts +0 -154
  65. package/server/routes.ts +0 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-accounting",
3
- "version": "8.0.6",
3
+ "version": "9.0.0-beta.12",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -25,18 +25,18 @@
25
25
  "test": "DEBUG=things-factory:* NODE_ENV=development npx mocha -r ts-node/register ./test/**/*spec.ts"
26
26
  },
27
27
  "dependencies": {
28
- "@operato/data-grist": "^8.0.0",
29
- "@things-factory/apptool-ui": "^8.0.5",
30
- "@things-factory/auth-ui": "^8.0.5",
31
- "@things-factory/biz-base": "^8.0.6",
32
- "@things-factory/code-ui": "^8.0.5",
33
- "@things-factory/context-ui": "^8.0.2",
34
- "@things-factory/i18n-base": "^8.0.5",
35
- "@things-factory/integration-ui": "^8.0.5",
36
- "@things-factory/more-ui": "^8.0.2",
37
- "@things-factory/product-base": "^8.0.6",
38
- "@things-factory/resource-ui": "^8.0.5",
39
- "@things-factory/setting-ui": "^8.0.5",
28
+ "@operato/data-grist": "^9.0.0-beta",
29
+ "@things-factory/apptool-ui": "^9.0.0-beta.12",
30
+ "@things-factory/auth-ui": "^9.0.0-beta.12",
31
+ "@things-factory/biz-base": "^9.0.0-beta.12",
32
+ "@things-factory/code-ui": "^9.0.0-beta.12",
33
+ "@things-factory/context-ui": "^9.0.0-beta.12",
34
+ "@things-factory/i18n-base": "^9.0.0-beta.12",
35
+ "@things-factory/integration-ui": "^9.0.0-beta.12",
36
+ "@things-factory/more-ui": "^9.0.0-beta.12",
37
+ "@things-factory/product-base": "^9.0.0-beta.12",
38
+ "@things-factory/resource-ui": "^9.0.0-beta.12",
39
+ "@things-factory/setting-ui": "^9.0.0-beta.12",
40
40
  "debug": "^4.1.1",
41
41
  "node-fetch": "^2.6.0"
42
42
  },
@@ -50,5 +50,5 @@
50
50
  "nock": "^13.0.2",
51
51
  "should": "^13.2.3"
52
52
  },
53
- "gitHead": "89abb01bba2376bc5f074e0bc0088e32188d0396"
53
+ "gitHead": "5e9ade1c2d4b4c96b89396e36c3afa1caaf18ef0"
54
54
  }
@@ -1,47 +0,0 @@
1
- import Debug from 'debug'
2
- const debug = Debug('things-factory:integration-accounting:accounting-api-decorator')
3
-
4
- import { Account } from '../../entities'
5
-
6
- const NOOP = v => v
7
-
8
- export const api = (target: Object, property: string, descriptor: TypedPropertyDescriptor<any>): any => {
9
- const method = descriptor.value
10
-
11
- descriptor.value = async function (accounting: Account, request) {
12
- const AccountingAPI = this
13
-
14
- var { platform } = accounting
15
-
16
- var { action: platformAction, apis } = AccountingAPI.getPlatform(platform)
17
-
18
- var m = apis[method.name]
19
- if (!m) {
20
- throw Error(`Accounting Platform '${platform}' doesn't have API ${method.name}`)
21
- }
22
-
23
- var {
24
- path,
25
- method: httpMethod = 'post',
26
- denormalize = NOOP,
27
- normalize = NOOP,
28
- action = platformAction
29
- } = m.apply(this, [request])
30
-
31
- var denormalized = await denormalize(request || {}, { accounting })
32
- debug('request', denormalized)
33
-
34
- var response = await action.apply(this, [
35
- { accounting, method: httpMethod, path, request: denormalized, platformAction }
36
- ])
37
-
38
- debug('response', response)
39
- if (!response.ok) {
40
- throw response
41
- }
42
-
43
- return await normalize(response, { accounting })
44
- }
45
-
46
- return descriptor
47
- }
@@ -1,72 +0,0 @@
1
- import { getRepository } from '@things-factory/shell'
2
-
3
- import { Account } from '../../entities'
4
- import { api } from './decorators'
5
-
6
- export const ACCOUNTING_STATUS = {
7
- ACTIVE: 'active',
8
- INACTIVE: 'inactive',
9
- TERMINATED: 'terminated'
10
- }
11
-
12
- export class AccountingAPI {
13
- static platforms = {}
14
-
15
- static registerPlatform(name, action, apis) {
16
- AccountingAPI.platforms[name] = {
17
- action,
18
- apis
19
- }
20
- }
21
-
22
- static getPlatform(name) {
23
- return AccountingAPI.platforms[name]
24
- }
25
-
26
- static async getAccounting(id) {
27
- const repository = getRepository(Account)
28
- return await repository.findOne({
29
- where: { id },
30
- relations: ['domain']
31
- })
32
- }
33
-
34
- @api
35
- static getInvoice(accounting, req): any {}
36
-
37
- @api
38
- static getInvoices(accounting, req): any {}
39
-
40
- @api
41
- static createInvoice(accounting, req): any {}
42
-
43
- @api
44
- static updateInvoice(accounting, req): any {}
45
-
46
- @api
47
- static getPurchaseOrders(accounting, req): any {}
48
-
49
- @api
50
- static getContact(accounting, req): any {}
51
-
52
- @api
53
- static getContacts(accounting, req): any {}
54
-
55
- @api
56
- static getItem(accounting, req): any {}
57
-
58
- @api
59
- static getItems(accounting, req): any {}
60
-
61
- @api
62
- static createItem(accounting, req): any {}
63
-
64
- @api
65
- static updateItem(accounting, req): any {}
66
-
67
- @api
68
- static updateItems(accounting, req): any {}
69
-
70
- @api
71
- static deleteItem(accounting, req): any {}
72
- }
@@ -1,3 +0,0 @@
1
- import './xero'
2
-
3
- export * from './accounting-api'
@@ -1,38 +0,0 @@
1
- export function getContact() {
2
- return {
3
- method: 'get',
4
- path: '/Contacts/{contactId}',
5
- denormalize(req) {
6
- const { ContactID: contactId } = req
7
- return {
8
- resource: { contactId }
9
- }
10
- },
11
- normalize(res) {
12
- const { Contacts: contacts } = res
13
- const { Name: attentionCompany, FirstName, LastName, EmailAddress: email, Addresses, Phones } = contacts[0]
14
-
15
- const {
16
- AddressLine1,
17
- AddressLine2,
18
- AddressLine3,
19
- AddressLine4,
20
- City: city,
21
- PostalCode: postalCode,
22
- Country: country
23
- } = Addresses[0]
24
- const mergedAddressLine: string = `${AddressLine1}, ${AddressLine2}, ${AddressLine3} ${AddressLine4}`
25
-
26
- return {
27
- attentionCompany,
28
- attentionTo: FirstName ? `${FirstName} ${LastName}` : null,
29
- email,
30
- deliveryAddress1: AddressLine1 ? mergedAddressLine : null,
31
- billingAddress: AddressLine1 ? mergedAddressLine : null,
32
- city: city ? city : null,
33
- postalCode: postalCode ? postalCode : null,
34
- country: country ? country : null
35
- }
36
- }
37
- }
38
- }
@@ -1,16 +0,0 @@
1
- export function getContacts() {
2
- return {
3
- method: 'get',
4
- path: '/Contacts',
5
- denormalize(req) {
6
- return {
7
- payload: {
8
- ...req
9
- }
10
- }
11
- },
12
- normalize(res) {
13
- return res
14
- }
15
- }
16
- }
@@ -1,2 +0,0 @@
1
- export * from './get-contacts'
2
- export * from './get-contact'
@@ -1,4 +0,0 @@
1
- export * from './invoice'
2
- export * from './item'
3
- export * from './purchase-order'
4
- export * from './contact'
@@ -1,12 +0,0 @@
1
- export function createInvoice() {
2
- return {
3
- method: 'post',
4
- path: '/Invoices/{invoiceNo}',
5
- denormalize(req) {
6
- return req
7
- },
8
- normalize(res) {
9
- return res
10
- }
11
- }
12
- }
@@ -1,14 +0,0 @@
1
- export function getInvoice() {
2
- return {
3
- method: 'get',
4
- path: '/Invoices/{invoiceId}',
5
- denormalize(req) {
6
- return {
7
- resource: { invoiceId: req.invoiceId }
8
- }
9
- },
10
- normalize(res) {
11
- return res
12
- }
13
- }
14
- }
@@ -1,76 +0,0 @@
1
- import { AccountingAPI } from '../../../accounting-api'
2
-
3
- export function getInvoices() {
4
- return {
5
- method: 'get',
6
- path: '/Invoices',
7
- denormalize(req) {
8
- return {
9
- payload: {
10
- ...req
11
- }
12
- }
13
- },
14
- async normalize(res, { accounting }) {
15
- var { Invoices } = res
16
-
17
- let results: any[] = []
18
-
19
- results = await Promise.all(
20
- Invoices.filter(invoice => invoice.Type === 'ACCREC').map(async invoice => {
21
- var { InvoiceID } = invoice
22
- var { Invoices } = await AccountingAPI.getInvoice(accounting, { invoiceId: InvoiceID })
23
-
24
- var { InvoiceNumber: refNo, Reference: refNo2, DateString, Contact, LineItems } = Invoices[0]
25
- var releaseDate = String(DateString.split('T')[0])
26
-
27
- var { ContactID } = Contact
28
-
29
- const {
30
- attentionCompany,
31
- attentionTo,
32
- email,
33
- deliveryAddress1,
34
- billingAddress,
35
- city,
36
- postalCode,
37
- country
38
- } = await AccountingAPI.getContact(accounting, {
39
- ContactID
40
- })
41
-
42
- var products = LineItems.length
43
- ? LineItems.map(item => {
44
- var { ItemCode: sku, Quantity: releaseQty } = item
45
- return { product: { sku }, releaseQty }
46
- })
47
- : ['undefined']
48
-
49
- return {
50
- refNo,
51
- refNo2,
52
- releaseDate,
53
- type: 'b2b',
54
- exportOption: false,
55
- ownTransport: true,
56
- packingOption: false,
57
- deliverTo: {
58
- attentionTo,
59
- attentionCompany,
60
- email,
61
- deliveryAddress1,
62
- city,
63
- postalCode,
64
- country
65
- },
66
- billTo: {
67
- billingAddress
68
- },
69
- orderInventories: products
70
- }
71
- })
72
- )
73
- return results
74
- }
75
- }
76
- }
@@ -1,4 +0,0 @@
1
- export * from './get-invoice'
2
- export * from './get-invoices'
3
- export * from './create-invoice'
4
- export * from './update-invoice'
@@ -1,12 +0,0 @@
1
- export function updateInvoice() {
2
- return {
3
- method: 'put',
4
- path: '/Invoices/{invoiceNo}',
5
- denormalize(req) {
6
- return req
7
- },
8
- normalize(res) {
9
- return res
10
- }
11
- }
12
- }
@@ -1,37 +0,0 @@
1
- export function createItem() {
2
- return {
3
- method: 'post',
4
- path: '/Items',
5
- denormalize(req) {
6
- var {
7
- sku: Code,
8
- name: Name,
9
- description: Description,
10
- inventoryAccountCode: InventoryAssetAccountCode,
11
- cogsAccountCode: COGSAccountCode
12
- } = req
13
-
14
- let IsSold: Boolean = true
15
- let IsPurchased: Boolean = true
16
-
17
- var PurchaseDetails: Object = {
18
- COGSAccountCode
19
- }
20
-
21
- return {
22
- payload: {
23
- Code,
24
- Description,
25
- Name,
26
- PurchaseDetails,
27
- IsSold,
28
- IsPurchased,
29
- InventoryAssetAccountCode
30
- }
31
- }
32
- },
33
- normalize(res) {
34
- return res
35
- }
36
- }
37
- }
@@ -1,19 +0,0 @@
1
- export function deleteItem() {
2
- return {
3
- method: 'put',
4
- path: '/Items/{itemId}',
5
- denormalize(req) {
6
- return {
7
- resource: {
8
- itemId: req.itemId
9
- },
10
- payload: {
11
- ...req
12
- }
13
- }
14
- },
15
- normalize(res) {
16
- return res
17
- }
18
- }
19
- }
@@ -1,41 +0,0 @@
1
- export function getItem() {
2
- return {
3
- method: 'get',
4
- path: '/Items/{Code}',
5
- denormalize(req) {
6
- return {
7
- resource: {
8
- Code: req.itemCode
9
- }
10
- }
11
- },
12
- normalize(res) {
13
- var { Items } = res
14
-
15
- let results: any[] = []
16
-
17
- results = Items.map(item => {
18
- var {
19
- Code: sku,
20
- Description: description,
21
- PurchaseDetails,
22
- Name: name,
23
- IsTrackedAsInventory: isTrackedAsInventory,
24
- InventoryAssetAccountCode: inventoryAccountCode
25
- } = item
26
- var { AccountCode: cogsAccountCode } = PurchaseDetails
27
-
28
- return {
29
- sku,
30
- description,
31
- name,
32
- isTrackedAsInventory,
33
- inventoryAccountCode,
34
- cogsAccountCode
35
- }
36
- })
37
-
38
- return results[0]
39
- }
40
- }
41
- }
@@ -1,41 +0,0 @@
1
- export function getItems() {
2
- return {
3
- method: 'get',
4
- path: '/Items',
5
- denormalize(req) {
6
- return {
7
- payload: {
8
- ...req
9
- }
10
- }
11
- },
12
- normalize(res) {
13
- var { Items } = res
14
-
15
- let results: any[] = []
16
-
17
- results = Items.map(item => {
18
- var {
19
- Code: sku,
20
- Description: description,
21
- PurchaseDetails,
22
- Name: name,
23
- IsTrackedAsInventory: isTrackedAsInventory,
24
- InventoryAssetAccountCode: inventoryAccountCode
25
- } = item
26
- var { AccountCode: cogsAccountCode } = PurchaseDetails
27
-
28
- return {
29
- sku,
30
- description,
31
- name,
32
- isTrackedAsInventory,
33
- inventoryAccountCode,
34
- cogsAccountCode
35
- }
36
- })
37
-
38
- return results
39
- }
40
- }
41
- }
@@ -1,6 +0,0 @@
1
- export * from './get-item'
2
- export * from './get-items'
3
- export * from './create-item'
4
- export * from './update-item'
5
- export * from './update-items'
6
- export * from './delete-item'
@@ -1,35 +0,0 @@
1
- export function updateItem() {
2
- return {
3
- method: 'post',
4
- path: '/Items',
5
- denormalize(req) {
6
- var {
7
- sku: Code,
8
- name: Name,
9
- description: Description,
10
- inventoryAccountCode: InventoryAssetAccountCode,
11
- cogsAccountCode: COGSAccountCode
12
- } = req
13
-
14
- let IsSold: Boolean = true
15
- let IsPurchased: Boolean = true
16
-
17
- var PurchaseDetails: Object = {
18
- COGSAccountCode
19
- }
20
-
21
- return {
22
- Code,
23
- Description,
24
- Name,
25
- PurchaseDetails,
26
- IsSold,
27
- IsPurchased,
28
- InventoryAssetAccountCode
29
- }
30
- },
31
- normalize(res) {
32
- return res
33
- }
34
- }
35
- }
@@ -1,43 +0,0 @@
1
- export function updateItems() {
2
- return {
3
- method: 'post',
4
- path: '/Items',
5
- denormalize(req) {
6
- let { products } = req
7
-
8
- const Items = products.map(item => {
9
- var {
10
- sku: Code,
11
- name: Name,
12
- description: Description,
13
- inventoryAccountCode: InventoryAssetAccountCode,
14
- cogsAccountCode: COGSAccountCode
15
- } = item
16
-
17
- let IsPurchased: Boolean = true
18
-
19
- var PurchaseDetails: Object = {
20
- COGSAccountCode
21
- }
22
-
23
- return {
24
- Code,
25
- Description,
26
- Name,
27
- PurchaseDetails,
28
- IsPurchased,
29
- InventoryAssetAccountCode
30
- }
31
- })
32
-
33
- return {
34
- payload: {
35
- Items
36
- }
37
- }
38
- },
39
- normalize(res) {
40
- return res
41
- }
42
- }
43
- }
@@ -1,61 +0,0 @@
1
- export function getPurchaseOrders() {
2
- return {
3
- method: 'get',
4
- path: '/PurchaseOrders',
5
- denormalize(req) {
6
- return {
7
- payload: {
8
- ...req
9
- }
10
- }
11
- },
12
- normalize(res) {
13
- const { PurchaseOrders } = res
14
-
15
- let results: any[] = PurchaseOrders.map(purchaseOrder => {
16
- const { PurchaseOrderNumber: refNo, Reference: refNo2, DeliveryDateString, LineItems } = purchaseOrder
17
- const etaDate: any = DeliveryDateString !== undefined ? String(DeliveryDateString.split('T')[0]) : 'undefined'
18
-
19
- let products: any[] = LineItems.map(lineItem => {
20
- return {
21
- product: { sku: lineItem.ItemCode },
22
- batchId: refNo,
23
- packQty: lineItem.Quantity,
24
- unitPrice: lineItem.UnitAmount
25
- }
26
- }).reduce((newItem, item) => {
27
- var foundItem = newItem.find(
28
- newItem => newItem.batchId === item.batchId && newItem.product.sku === item.product.sku
29
- )
30
- if (!foundItem) {
31
- newItem.push({ ...item })
32
- return newItem
33
- } else {
34
- return newItem.map(ni => {
35
- if (ni.batchId === item.batchId && ni.product.sku === item.product.sku) {
36
- return {
37
- ...ni,
38
- packQty: ni.packQty + item.packQty
39
- }
40
- } else {
41
- return ni
42
- }
43
- })
44
- }
45
- }, [])
46
-
47
- return {
48
- refNo,
49
- refNo2,
50
- etaDate,
51
- ownTransport: true,
52
- importCargo: false,
53
- container: false,
54
- orderProducts: products
55
- }
56
- })
57
-
58
- return results
59
- }
60
- }
61
- }
@@ -1 +0,0 @@
1
- export * from './get-purchase-orders'
@@ -1,8 +0,0 @@
1
- export * from './xero'
2
-
3
- import { AccountingAPI } from '../accounting-api'
4
- import { action } from './platform-action'
5
-
6
- import * as APIS from './apis'
7
-
8
- AccountingAPI.registerPlatform('xero', action, APIS)