@things-factory/integration-accounting 4.0.0-y.0 → 4.0.4
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/index.js +14 -0
- package/dist-server/controllers/accounting-api/index.js.map +1 -1
- package/dist-server/controllers/xero/apis/contact/get-contact.js +33 -0
- package/dist-server/controllers/xero/apis/contact/get-contact.js.map +1 -0
- package/dist-server/controllers/xero/apis/contact/get-contacts.js +19 -0
- package/dist-server/controllers/xero/apis/contact/get-contacts.js.map +1 -0
- package/dist-server/controllers/xero/apis/contact/index.js +15 -0
- package/dist-server/controllers/xero/apis/contact/index.js.map +1 -0
- package/dist-server/controllers/xero/apis/index.js +2 -1
- package/dist-server/controllers/xero/apis/index.js.map +1 -1
- package/dist-server/controllers/xero/apis/invoice/get-invoice.js +4 -2
- package/dist-server/controllers/xero/apis/invoice/get-invoice.js.map +1 -1
- package/dist-server/controllers/xero/apis/invoice/get-invoices.js +28 -28
- package/dist-server/controllers/xero/apis/invoice/get-invoices.js.map +1 -1
- package/dist-server/controllers/xero/apis/purchase-order/get-purchase-orders.js +40 -0
- package/dist-server/controllers/xero/apis/purchase-order/get-purchase-orders.js.map +1 -0
- package/dist-server/controllers/xero/apis/purchase-order/index.js +14 -0
- package/dist-server/controllers/xero/apis/purchase-order/index.js.map +1 -0
- package/dist-server/controllers/xero/xero.js +1 -1
- package/dist-server/controllers/xero/xero.js.map +1 -1
- package/dist-server/routers/xero-private-router.js +19 -0
- package/dist-server/routers/xero-private-router.js.map +1 -0
- package/dist-server/routers/xero-router.js +11 -5
- package/dist-server/routers/xero-router.js.map +1 -1
- package/dist-server/routes.js +4 -0
- package/dist-server/routes.js.map +1 -1
- package/package.json +15 -15
- package/server/controllers/accounting-api/index.ts +7 -0
- package/server/controllers/xero/apis/contact/get-contact.ts +38 -0
- package/server/controllers/xero/apis/contact/get-contacts.ts +16 -0
- package/server/controllers/xero/apis/contact/index.ts +2 -0
- package/server/controllers/xero/apis/index.ts +2 -1
- package/server/controllers/xero/apis/invoice/get-invoice.ts +4 -2
- package/server/controllers/xero/apis/invoice/get-invoices.ts +52 -41
- package/server/controllers/xero/apis/{purchaseOrder → purchase-order}/get-purchase-orders.ts +2 -8
- package/server/controllers/xero/apis/{purchaseOrder → purchase-order}/index.ts +0 -0
- package/server/controllers/xero/xero.ts +1 -1
- package/server/routers/xero-private-router.ts +24 -0
- package/server/routers/xero-router.ts +26 -11
- package/server/routes.ts +5 -0
|
@@ -40,6 +40,8 @@ class AccountingAPI {
|
|
|
40
40
|
static createInvoice(accounting, req) { }
|
|
41
41
|
static updateInvoice(accounting, req) { }
|
|
42
42
|
static getPurchaseOrders(accounting, req) { }
|
|
43
|
+
static getContact(accounting, req) { }
|
|
44
|
+
static getContacts(accounting, req) { }
|
|
43
45
|
static getItem(accounting, req) { }
|
|
44
46
|
static getItems(accounting, req) { }
|
|
45
47
|
static createItem(accounting, req) { }
|
|
@@ -78,6 +80,18 @@ __decorate([
|
|
|
78
80
|
__metadata("design:paramtypes", [Object, Object]),
|
|
79
81
|
__metadata("design:returntype", Object)
|
|
80
82
|
], AccountingAPI, "getPurchaseOrders", null);
|
|
83
|
+
__decorate([
|
|
84
|
+
decorators_1.api,
|
|
85
|
+
__metadata("design:type", Function),
|
|
86
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
87
|
+
__metadata("design:returntype", Object)
|
|
88
|
+
], AccountingAPI, "getContact", null);
|
|
89
|
+
__decorate([
|
|
90
|
+
decorators_1.api,
|
|
91
|
+
__metadata("design:type", Function),
|
|
92
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
93
|
+
__metadata("design:returntype", Object)
|
|
94
|
+
], AccountingAPI, "getContacts", null);
|
|
81
95
|
__decorate([
|
|
82
96
|
decorators_1.api,
|
|
83
97
|
__metadata("design:type", Function),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/accounting-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAuC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/accounting-api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAuC;AAEvC,6CAAwC;AACxC,6CAAkC;AAErB,QAAA,iBAAiB,GAAG;IAC/B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;CACzB,CAAA;AAED,MAAa,aAAa;IAGxB,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI;QACxC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;YAC9B,MAAM;YACN,IAAI;SACL,CAAA;IACH,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAI;QACrB,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACtC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;QAC3B,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAA;QACzC,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC;YAC9B,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAA;IACJ,CAAC;IAGD,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAG1C,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAG3C,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAG7C,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAG7C,MAAM,CAAC,iBAAiB,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAGjD,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAG1C,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAG3C,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAGvC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAGxC,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAG1C,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAG1C,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;IAG3C,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,IAAQ,CAAC;;AA1DnC,uBAAS,GAAG,EAAE,CAAA;AAsBrB;IADC,gBAAG;;;;qCACsC;AAG1C;IADC,gBAAG;;;;sCACuC;AAG3C;IADC,gBAAG;;;;wCACyC;AAG7C;IADC,gBAAG;;;;wCACyC;AAG7C;IADC,gBAAG;;;;4CAC6C;AAGjD;IADC,gBAAG;;;;qCACsC;AAG1C;IADC,gBAAG;;;;sCACuC;AAG3C;IADC,gBAAG;;;;kCACmC;AAGvC;IADC,gBAAG;;;;mCACoC;AAGxC;IADC,gBAAG;;;;qCACsC;AAG1C;IADC,gBAAG;;;;qCACsC;AAG1C;IADC,gBAAG;;;;sCACuC;AAG3C;IADC,gBAAG;;;;qCACsC;AA3D5C,sCA4DC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getContact = void 0;
|
|
4
|
+
function getContact() {
|
|
5
|
+
return {
|
|
6
|
+
method: 'get',
|
|
7
|
+
path: '/Contacts/{contactId}',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
const { ContactID: contactId } = req;
|
|
10
|
+
return {
|
|
11
|
+
resource: { contactId }
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
normalize(res) {
|
|
15
|
+
const { Contacts: contacts } = res;
|
|
16
|
+
const { Name: attentionCompany, FirstName, LastName, EmailAddress: email, Addresses, Phones } = contacts[0];
|
|
17
|
+
const { AddressLine1, AddressLine2, AddressLine3, AddressLine4, City: city, PostalCode: postalCode, Country: country } = Addresses[0];
|
|
18
|
+
const mergedAddressLine = `${AddressLine1}, ${AddressLine2}, ${AddressLine3} ${AddressLine4}`;
|
|
19
|
+
return {
|
|
20
|
+
attentionCompany,
|
|
21
|
+
attentionTo: FirstName ? `${FirstName} ${LastName}` : null,
|
|
22
|
+
email,
|
|
23
|
+
deliveryAddress1: AddressLine1 ? mergedAddressLine : null,
|
|
24
|
+
billingAddress: AddressLine1 ? mergedAddressLine : null,
|
|
25
|
+
city: city ? city : null,
|
|
26
|
+
postalCode: postalCode ? postalCode : null,
|
|
27
|
+
country: country ? country : null
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.getContact = getContact;
|
|
33
|
+
//# sourceMappingURL=get-contact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-contact.js","sourceRoot":"","sources":["../../../../../server/controllers/xero/apis/contact/get-contact.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU;IACxB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,uBAAuB;QAC7B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,GAAG,CAAA;YACpC,OAAO;gBACL,QAAQ,EAAE,EAAE,SAAS,EAAE;aACxB,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;YAClC,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;YAE3G,MAAM,EACJ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EACjB,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;YAChB,MAAM,iBAAiB,GAAW,GAAG,YAAY,KAAK,YAAY,KAAK,YAAY,IAAI,YAAY,EAAE,CAAA;YAErG,OAAO;gBACL,gBAAgB;gBAChB,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI;gBAC1D,KAAK;gBACL,gBAAgB,EAAE,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;gBACzD,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;gBACvD,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;gBACxB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI;gBAC1C,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;aAClC,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AArCD,gCAqCC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getContacts = void 0;
|
|
4
|
+
function getContacts() {
|
|
5
|
+
return {
|
|
6
|
+
method: 'get',
|
|
7
|
+
path: '/Contacts',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
return {
|
|
10
|
+
payload: Object.assign({}, req)
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
normalize(res) {
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.getContacts = getContacts;
|
|
19
|
+
//# sourceMappingURL=get-contacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-contacts.js","sourceRoot":"","sources":["../../../../../server/controllers/xero/apis/contact/get-contacts.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW;IACzB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,WAAW;QACjB,WAAW,CAAC,GAAG;YACb,OAAO;gBACL,OAAO,oBACF,GAAG,CACP;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAfD,kCAeC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./get-contacts"), exports);
|
|
14
|
+
__exportStar(require("./get-contact"), exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../server/controllers/xero/apis/contact/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA8B;AAC9B,gDAA6B"}
|
|
@@ -12,5 +12,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./invoice"), exports);
|
|
14
14
|
__exportStar(require("./item"), exports);
|
|
15
|
-
__exportStar(require("./
|
|
15
|
+
__exportStar(require("./purchase-order"), exports);
|
|
16
|
+
__exportStar(require("./contact"), exports);
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/xero/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAyB;AACzB,yCAAsB;AACtB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/xero/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAyB;AACzB,yCAAsB;AACtB,mDAAgC;AAChC,4CAAyB"}
|
|
@@ -4,9 +4,11 @@ exports.getInvoice = void 0;
|
|
|
4
4
|
function getInvoice() {
|
|
5
5
|
return {
|
|
6
6
|
method: 'get',
|
|
7
|
-
path: '/Invoices/{
|
|
7
|
+
path: '/Invoices/{invoiceId}',
|
|
8
8
|
denormalize(req) {
|
|
9
|
-
return
|
|
9
|
+
return {
|
|
10
|
+
resource: { invoiceId: req.invoiceId }
|
|
11
|
+
};
|
|
10
12
|
},
|
|
11
13
|
normalize(res) {
|
|
12
14
|
return res;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-invoice.js","sourceRoot":"","sources":["../../../../../server/controllers/xero/apis/invoice/get-invoice.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU;IACxB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,uBAAuB;QAC7B,WAAW,CAAC,GAAG;YACb,OAAO,GAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"get-invoice.js","sourceRoot":"","sources":["../../../../../server/controllers/xero/apis/invoice/get-invoice.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU;IACxB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,uBAAuB;QAC7B,WAAW,CAAC,GAAG;YACb,OAAO;gBACL,QAAQ,EAAE,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE;aACvC,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAbD,gCAaC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInvoices = void 0;
|
|
4
|
+
const accounting_api_1 = require("../../../accounting-api");
|
|
4
5
|
function getInvoices() {
|
|
5
6
|
return {
|
|
6
7
|
method: 'get',
|
|
@@ -10,48 +11,47 @@ function getInvoices() {
|
|
|
10
11
|
payload: Object.assign({}, req)
|
|
11
12
|
};
|
|
12
13
|
},
|
|
13
|
-
normalize(res) {
|
|
14
|
+
async normalize(res, { accounting }) {
|
|
14
15
|
var { Invoices } = res;
|
|
15
16
|
let results = [];
|
|
16
|
-
results = Invoices.map(invoice => {
|
|
17
|
-
var {
|
|
17
|
+
results = await Promise.all(Invoices.filter(invoice => invoice.Type === 'ACCREC').map(async (invoice) => {
|
|
18
|
+
var { InvoiceID } = invoice;
|
|
19
|
+
var { Invoices } = await accounting_api_1.AccountingAPI.getInvoice(accounting, { invoiceId: InvoiceID });
|
|
20
|
+
var { InvoiceNumber: refNo, Reference: refNo2, DateString, Contact, LineItems } = Invoices[0];
|
|
18
21
|
var releaseDate = String(DateString.split('T')[0]);
|
|
19
|
-
var { ContactID
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
: ['undefined'];
|
|
25
|
-
var phoneArr = Phones.length
|
|
26
|
-
? Phones.map(phone => {
|
|
27
|
-
return `${phone.PhoneCountryCode}${phone.PhoneAreaCode}-${phone.PhoneNumber}`;
|
|
28
|
-
})
|
|
29
|
-
: ['undefined'];
|
|
22
|
+
var { ContactID } = Contact;
|
|
23
|
+
const { attentionCompany, attentionTo, email, deliveryAddress1, billingAddress, city, postalCode, country } = await accounting_api_1.AccountingAPI.getContact(accounting, {
|
|
24
|
+
ContactID
|
|
25
|
+
});
|
|
30
26
|
var products = LineItems.length
|
|
31
27
|
? LineItems.map(item => {
|
|
32
|
-
var { ItemCode: sku,
|
|
33
|
-
return { product: { sku },
|
|
28
|
+
var { ItemCode: sku, Quantity: releaseQty } = item;
|
|
29
|
+
return { product: { sku }, releaseQty };
|
|
34
30
|
})
|
|
35
31
|
: ['undefined'];
|
|
36
32
|
return {
|
|
37
33
|
refNo,
|
|
38
34
|
refNo2,
|
|
39
35
|
releaseDate,
|
|
40
|
-
|
|
41
|
-
accountNo,
|
|
42
|
-
name,
|
|
43
|
-
companyName: name,
|
|
44
|
-
phone: phoneArr[0],
|
|
45
|
-
email: 'null@mail.com',
|
|
46
|
-
address: addressArr[0],
|
|
47
|
-
billingAddress: addressArr[0]
|
|
48
|
-
},
|
|
49
|
-
orderInventories: products,
|
|
36
|
+
type: 'b2b',
|
|
50
37
|
exportOption: false,
|
|
51
38
|
ownTransport: true,
|
|
52
|
-
|
|
39
|
+
packingOption: false,
|
|
40
|
+
deliverTo: {
|
|
41
|
+
attentionTo,
|
|
42
|
+
attentionCompany,
|
|
43
|
+
email,
|
|
44
|
+
deliveryAddress1,
|
|
45
|
+
city,
|
|
46
|
+
postalCode,
|
|
47
|
+
country
|
|
48
|
+
},
|
|
49
|
+
billTo: {
|
|
50
|
+
billingAddress
|
|
51
|
+
},
|
|
52
|
+
orderInventories: products
|
|
53
53
|
};
|
|
54
|
-
});
|
|
54
|
+
}));
|
|
55
55
|
return results;
|
|
56
56
|
}
|
|
57
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-invoices.js","sourceRoot":"","sources":["../../../../../server/controllers/xero/apis/invoice/get-invoices.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW;IACzB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,WAAW;QACjB,WAAW,CAAC,GAAG;YACb,OAAO;gBACL,OAAO,oBACF,GAAG,CACP;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"get-invoices.js","sourceRoot":"","sources":["../../../../../server/controllers/xero/apis/invoice/get-invoices.ts"],"names":[],"mappings":";;;AAAA,4DAAuD;AAEvD,SAAgB,WAAW;IACzB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,WAAW;QACjB,WAAW,CAAC,GAAG;YACb,OAAO;gBACL,OAAO,oBACF,GAAG,CACP;aACF,CAAA;QACH,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE;YACjC,IAAI,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;YAEtB,IAAI,OAAO,GAAU,EAAE,CAAA;YAEvB,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CACzB,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,EAAC,OAAO,EAAC,EAAE;gBACxE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;gBAC3B,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,8BAAa,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAA;gBAEvF,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;gBAC7F,IAAI,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;gBAElD,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;gBAE3B,MAAM,EACJ,gBAAgB,EAChB,WAAW,EACX,KAAK,EACL,gBAAgB,EAChB,cAAc,EACd,IAAI,EACJ,UAAU,EACV,OAAO,EACR,GAAG,MAAM,8BAAa,CAAC,UAAU,CAAC,UAAU,EAAE;oBAC7C,SAAS;iBACV,CAAC,CAAA;gBAEF,IAAI,QAAQ,GAAG,SAAS,CAAC,MAAM;oBAC7B,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;wBACnB,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;wBAClD,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,CAAA;oBACzC,CAAC,CAAC;oBACJ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;gBAEjB,OAAO;oBACL,KAAK;oBACL,MAAM;oBACN,WAAW;oBACX,IAAI,EAAE,KAAK;oBACX,YAAY,EAAE,KAAK;oBACnB,YAAY,EAAE,IAAI;oBAClB,aAAa,EAAE,KAAK;oBACpB,SAAS,EAAE;wBACT,WAAW;wBACX,gBAAgB;wBAChB,KAAK;wBACL,gBAAgB;wBAChB,IAAI;wBACJ,UAAU;wBACV,OAAO;qBACR;oBACD,MAAM,EAAE;wBACN,cAAc;qBACf;oBACD,gBAAgB,EAAE,QAAQ;iBAC3B,CAAA;YACH,CAAC,CAAC,CACH,CAAA;YACD,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC;AAzED,kCAyEC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPurchaseOrders = void 0;
|
|
4
|
+
function getPurchaseOrders() {
|
|
5
|
+
return {
|
|
6
|
+
method: 'get',
|
|
7
|
+
path: '/PurchaseOrders',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
return {
|
|
10
|
+
payload: Object.assign({}, req)
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
normalize(res) {
|
|
14
|
+
var { PurchaseOrders } = res;
|
|
15
|
+
let results = [];
|
|
16
|
+
results = PurchaseOrders.map(purchaseOrder => {
|
|
17
|
+
var { PurchaseOrderNumber: refNo, Reference: refNo2, DeliveryDateString, LineItems } = purchaseOrder;
|
|
18
|
+
var etaDate = DeliveryDateString !== undefined ? String(DeliveryDateString.split('T')[0]) : 'undefined';
|
|
19
|
+
var products = LineItems.length
|
|
20
|
+
? LineItems.map(item => {
|
|
21
|
+
var { ItemCode: sku, Quantity: packQty, UnitAmount: unitPrice } = item;
|
|
22
|
+
return { product: { sku }, batchId: refNo, packQty, unitPrice };
|
|
23
|
+
})
|
|
24
|
+
: ['undefined'];
|
|
25
|
+
return {
|
|
26
|
+
refNo,
|
|
27
|
+
refNo2,
|
|
28
|
+
etaDate,
|
|
29
|
+
ownTransport: true,
|
|
30
|
+
importCargo: false,
|
|
31
|
+
container: false,
|
|
32
|
+
orderProducts: products
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
return results;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.getPurchaseOrders = getPurchaseOrders;
|
|
40
|
+
//# sourceMappingURL=get-purchase-orders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-purchase-orders.js","sourceRoot":"","sources":["../../../../../server/controllers/xero/apis/purchase-order/get-purchase-orders.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB;IAC/B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,iBAAiB;QACvB,WAAW,CAAC,GAAG;YACb,OAAO;gBACL,OAAO,oBACF,GAAG,CACP;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,IAAI,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;YAE5B,IAAI,OAAO,GAAU,EAAE,CAAA;YAEvB,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;gBAC3C,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,SAAS,EAAE,GAAG,aAAa,CAAA;gBAEpG,IAAI,OAAO,GAAG,kBAAkB,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;gBAEvG,IAAI,QAAQ,GAAG,SAAS,CAAC,MAAM;oBAC7B,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;wBACnB,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;wBACtE,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;oBACjE,CAAC,CAAC;oBACJ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;gBAEjB,OAAO;oBACL,KAAK;oBACL,MAAM;oBACN,OAAO;oBACP,YAAY,EAAE,IAAI;oBAClB,WAAW,EAAE,KAAK;oBAClB,SAAS,EAAE,KAAK;oBAChB,aAAa,EAAE,QAAQ;iBACxB,CAAA;YACH,CAAC,CAAC,CAAA;YACF,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC;AAzCD,8CAyCC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./get-purchase-orders"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../server/controllers/xero/apis/purchase-order/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAqC"}
|
|
@@ -12,7 +12,7 @@ class Xero {
|
|
|
12
12
|
this.config = Object.assign({}, config);
|
|
13
13
|
}
|
|
14
14
|
buildAuthURL(nonce) {
|
|
15
|
-
const scopes = 'offline_access openid profile email accounting.transactions accounting.settings';
|
|
15
|
+
const scopes = 'offline_access openid profile email accounting.transactions accounting.settings accounting.contacts';
|
|
16
16
|
const { apiKey, callback: redirectUrl } = this.config;
|
|
17
17
|
return `https://login.xero.com/identity/connect/authorize?response_type=code&client_id=${apiKey}&scope=${scopes}&redirect_uri=${redirectUrl}&state=${nonce}`;
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xero.js","sourceRoot":"","sources":["../../../server/controllers/xero/xero.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAE9B,MAAM,QAAQ,GAAG,kCAAkC,CAAA;AACnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,4CAA4C,CAAC,CAAA;AAU5E,MAAa,IAAI;IAGf,YAAY,MAAkB;QAC5B,IAAI,CAAC,MAAM,qBACN,MAAM,CACV,CAAA;IACH,CAAC;IAED,YAAY,CAAC,KAAK;QA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AI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAErC,MAAM,QAAQ,GAAG,GAAG,QAAQ,GAAG,IAAI,EAAE,CAAA;QACrC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAE3B,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,QAAQ,EAAE;YACrC,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,WAAW,EAAE;gBACtC,gBAAgB,EAAE,QAAQ;aAC3B;YACD,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;YAChB,MAAM,QAAQ,CAAA;SACf;QAED,IAAI,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAClC,KAAK,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAA;QAChC,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;QAEvC,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,iBAAiB,CAAC,MAA2B;QACnD,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,IAAI,CAAA;QAChD,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAnJD,oBAmJC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.xeroPrivateRouter = void 0;
|
|
7
|
+
const koa_router_1 = __importDefault(require("koa-router"));
|
|
8
|
+
const env_1 = require("@things-factory/env");
|
|
9
|
+
const shell_1 = require("@things-factory/shell");
|
|
10
|
+
const isPathBaseDomain = !env_1.config.get('subdomain') && !env_1.config.get('useVirtualHostBasedDomain');
|
|
11
|
+
const debug = require('debug')('things-factory:integration-accounting:xero-router');
|
|
12
|
+
exports.xeroPrivateRouter = new koa_router_1.default();
|
|
13
|
+
exports.xeroPrivateRouter.get(`${isPathBaseDomain ? '/domain/:domain' : ''}/callback-private-xero`, async (context, next) => {
|
|
14
|
+
const { domain } = context.state;
|
|
15
|
+
const xeroAccountingCookies = context.cookies.get('xero-accounting');
|
|
16
|
+
const { id, status, message } = JSON.parse(xeroAccountingCookies);
|
|
17
|
+
context.redirect(`${(0, shell_1.getRedirectSubdomainPath)(context, domain.subdomain)}account-xero/${id}/connect-callback?status=${status}&message=${message}`);
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=xero-private-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xero-private-router.js","sourceRoot":"","sources":["../../server/routers/xero-private-router.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAE/B,6CAA4C;AAC5C,iDAAgE;AAEhE,MAAM,gBAAgB,GAAG,CAAC,YAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AAE7F,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mDAAmD,CAAC,CAAA;AAEtE,QAAA,iBAAiB,GAAG,IAAI,oBAAM,EAAE,CAAA;AAE7C,yBAAiB,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,wBAAwB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAClH,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAEhC,MAAM,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;IACpE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;IAEjE,OAAO,CAAC,QAAQ,CACd,GAAG,IAAA,gCAAwB,EACzB,OAAO,EACP,MAAM,CAAC,SAAS,CACjB,gBAAgB,EAAE,4BAA4B,MAAM,YAAY,OAAO,EAAE,CAC3E,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -7,11 +7,12 @@ exports.xeroRouter = void 0;
|
|
|
7
7
|
const koa_router_1 = __importDefault(require("koa-router"));
|
|
8
8
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
9
9
|
const typeorm_1 = require("typeorm");
|
|
10
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
10
11
|
const env_1 = require("@things-factory/env");
|
|
12
|
+
const shell_1 = require("@things-factory/shell");
|
|
11
13
|
const utils_1 = require("@things-factory/utils");
|
|
12
|
-
const auth_base_1 = require("@things-factory/auth-base");
|
|
13
|
-
const entities_1 = require("../entities");
|
|
14
14
|
const accounting_api_1 = require("../controllers/accounting-api");
|
|
15
|
+
const entities_1 = require("../entities");
|
|
15
16
|
const { apiKey, apiSecret, hostname, callback: redirect_uri } = env_1.config.get('accountingIntegrationXero', {});
|
|
16
17
|
const debug = require('debug')('things-factory:integration-accounting:xero-router');
|
|
17
18
|
exports.xeroRouter = new koa_router_1.default();
|
|
@@ -88,13 +89,18 @@ exports.xeroRouter.get('/callback-xero', async (context, next) => {
|
|
|
88
89
|
};
|
|
89
90
|
var user = await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(userId);
|
|
90
91
|
account = await (0, typeorm_1.getRepository)(entities_1.Account).save(Object.assign(Object.assign(Object.assign({}, account), patch), { updater: user }));
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
context.cookies.set('xero-accounting', JSON.stringify(Object.assign(Object.assign({}, account), { message: 'success to activate' })), {
|
|
93
|
+
httpOnly: true
|
|
94
|
+
});
|
|
95
|
+
context.redirect((0, shell_1.getUrlFromContext)(context, '/callback-private-xero'));
|
|
93
96
|
}
|
|
94
97
|
catch (err) {
|
|
95
98
|
var message = err.message;
|
|
96
99
|
if (account) {
|
|
97
|
-
context.
|
|
100
|
+
context.cookies.set('xero-accounting', JSON.stringify(Object.assign(Object.assign({}, account), { message })), {
|
|
101
|
+
httpOnly: true
|
|
102
|
+
});
|
|
103
|
+
context.redirect((0, shell_1.getUrlFromContext)(context, '/callback-private-xero'));
|
|
98
104
|
return;
|
|
99
105
|
}
|
|
100
106
|
throw err;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xero-router.js","sourceRoot":"","sources":["../../server/routers/xero-router.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAC/B,4DAA8B;AAC9B,qCAAuC;
|
|
1
|
+
{"version":3,"file":"xero-router.js","sourceRoot":"","sources":["../../server/routers/xero-router.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAC/B,4DAA8B;AAC9B,qCAAuC;AAEvC,yDAA0F;AAC1F,6CAA4C;AAC5C,iDAAyD;AACzD,iDAAgD;AAEhD,kEAAgF;AAChF,0CAAqC;AAErC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAM,CAAC,GAAG,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAA;AAE3G,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mDAAmD,CAAC,CAAA;AAEtE,QAAA,UAAU,GAAG,IAAI,oBAAM,EAAE,CAAA;AAEtC,kBAAU,CAAC,GAAG,CAAC,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACvD,IAAI;QACF,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE5C,MAAM,2BAA2B,GAAG,IAAA,uBAAa,EAAC,6BAAiB,CAAC,CAAA;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es.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const xero_private_router_1 = require("./routers/xero-private-router");
|
|
3
4
|
const xero_router_1 = require("./routers/xero-router");
|
|
4
5
|
process.on('bootstrap-module-global-public-route', (app, globalPublicRouter) => {
|
|
5
6
|
globalPublicRouter.use(xero_router_1.xeroRouter.routes(), xero_router_1.xeroRouter.allowedMethods());
|
|
6
7
|
});
|
|
8
|
+
process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => {
|
|
9
|
+
domainPrivateRouter.use(xero_private_router_1.xeroPrivateRouter.routes(), xero_private_router_1.xeroPrivateRouter.allowedMethods());
|
|
10
|
+
});
|
|
7
11
|
//# sourceMappingURL=routes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,uDAAkD;AAElD,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF,kBAAkB,CAAC,GAAG,CAAC,wBAAU,CAAC,MAAM,EAAE,EAAE,wBAAU,CAAC,cAAc,EAAE,CAAC,CAAA;AAC1E,CAAC,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,uEAAiE;AACjE,uDAAkD;AAElD,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF,kBAAkB,CAAC,GAAG,CAAC,wBAAU,CAAC,MAAM,EAAE,EAAE,wBAAU,CAAC,cAAc,EAAE,CAAC,CAAA;AAC1E,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,mBAAmB,CAAC,GAAG,CAAC,uCAAiB,CAAC,MAAM,EAAE,EAAE,uCAAiB,CAAC,cAAc,EAAE,CAAC,CAAA;AACzF,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-accounting",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"test": "DEBUG=things-factory:* NODE_ENV=development npx mocha -r ts-node/register ./test/**/*spec.ts"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@things-factory/apptool-ui": "^4.0.
|
|
29
|
-
"@things-factory/auth-ui": "^4.0.
|
|
30
|
-
"@things-factory/biz-base": "^4.0.
|
|
31
|
-
"@things-factory/code-ui": "^4.0.
|
|
32
|
-
"@things-factory/context-ui": "^4.0.
|
|
33
|
-
"@things-factory/grist-ui": "^4.0.
|
|
34
|
-
"@things-factory/i18n-ui": "^4.0.
|
|
35
|
-
"@things-factory/integration-ui": "^4.0.
|
|
36
|
-
"@things-factory/more-ui": "^4.0.
|
|
37
|
-
"@things-factory/product-base": "^4.0.
|
|
38
|
-
"@things-factory/resource-ui": "^4.0.
|
|
39
|
-
"@things-factory/setting-ui": "^4.0.
|
|
40
|
-
"@things-factory/system-ui": "^4.0.
|
|
28
|
+
"@things-factory/apptool-ui": "^4.0.4",
|
|
29
|
+
"@things-factory/auth-ui": "^4.0.4",
|
|
30
|
+
"@things-factory/biz-base": "^4.0.4",
|
|
31
|
+
"@things-factory/code-ui": "^4.0.4",
|
|
32
|
+
"@things-factory/context-ui": "^4.0.4",
|
|
33
|
+
"@things-factory/grist-ui": "^4.0.1",
|
|
34
|
+
"@things-factory/i18n-ui": "^4.0.4",
|
|
35
|
+
"@things-factory/integration-ui": "^4.0.4",
|
|
36
|
+
"@things-factory/more-ui": "^4.0.4",
|
|
37
|
+
"@things-factory/product-base": "^4.0.4",
|
|
38
|
+
"@things-factory/resource-ui": "^4.0.4",
|
|
39
|
+
"@things-factory/setting-ui": "^4.0.4",
|
|
40
|
+
"@things-factory/system-ui": "^4.0.4",
|
|
41
41
|
"debug": "^4.1.1",
|
|
42
42
|
"node-fetch": "^2.6.0"
|
|
43
43
|
},
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"nock": "^13.0.2",
|
|
53
53
|
"should": "^13.2.3"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "292d7c4e2675d228d6be474ea6a0525d26ac1657"
|
|
56
56
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getRepository } from 'typeorm'
|
|
2
|
+
|
|
2
3
|
import { Account } from '../../entities'
|
|
3
4
|
import { api } from './decorators'
|
|
4
5
|
|
|
@@ -45,6 +46,12 @@ export class AccountingAPI {
|
|
|
45
46
|
@api
|
|
46
47
|
static getPurchaseOrders(accounting, req): any {}
|
|
47
48
|
|
|
49
|
+
@api
|
|
50
|
+
static getContact(accounting, req): any {}
|
|
51
|
+
|
|
52
|
+
@api
|
|
53
|
+
static getContacts(accounting, req): any {}
|
|
54
|
+
|
|
48
55
|
@api
|
|
49
56
|
static getItem(accounting, req): any {}
|
|
50
57
|
|
|
@@ -0,0 +1,38 @@
|
|
|
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,3 +1,5 @@
|
|
|
1
|
+
import { AccountingAPI } from '../../../accounting-api'
|
|
2
|
+
|
|
1
3
|
export function getInvoices() {
|
|
2
4
|
return {
|
|
3
5
|
method: 'get',
|
|
@@ -9,56 +11,65 @@ export function getInvoices() {
|
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
},
|
|
12
|
-
normalize(res) {
|
|
14
|
+
async normalize(res, { accounting }) {
|
|
13
15
|
var { Invoices } = res
|
|
14
16
|
|
|
15
17
|
let results: any[] = []
|
|
16
18
|
|
|
17
|
-
results =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 })
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
var { InvoiceNumber: refNo, Reference: refNo2, DateString, Contact, LineItems } = Invoices[0]
|
|
25
|
+
var releaseDate = String(DateString.split('T')[0])
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
? Addresses.map(address => {
|
|
26
|
-
return `${address.AddressLine1} ${address.AddressLine2} ${address.AddressLine3}`
|
|
27
|
-
})
|
|
28
|
-
: ['undefined']
|
|
27
|
+
var { ContactID } = Contact
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
})
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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']
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
+
)
|
|
62
73
|
return results
|
|
63
74
|
}
|
|
64
75
|
}
|
package/server/controllers/xero/apis/{purchaseOrder → purchase-order}/get-purchase-orders.ts
RENAMED
|
@@ -21,14 +21,8 @@ export function getPurchaseOrders() {
|
|
|
21
21
|
|
|
22
22
|
var products = LineItems.length
|
|
23
23
|
? LineItems.map(item => {
|
|
24
|
-
var {
|
|
25
|
-
|
|
26
|
-
LineItemID: batchId,
|
|
27
|
-
Quantity: packQty,
|
|
28
|
-
UnitAmount: unitPrice,
|
|
29
|
-
Description: remark
|
|
30
|
-
} = item
|
|
31
|
-
return { product: { sku }, batchId, packQty, unitPrice, remark }
|
|
24
|
+
var { ItemCode: sku, Quantity: packQty, UnitAmount: unitPrice } = item
|
|
25
|
+
return { product: { sku }, batchId: refNo, packQty, unitPrice }
|
|
32
26
|
})
|
|
33
27
|
: ['undefined']
|
|
34
28
|
|
|
File without changes
|
|
@@ -21,7 +21,7 @@ export class Xero {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
buildAuthURL(nonce) {
|
|
24
|
-
const scopes = 'offline_access openid profile email accounting.transactions accounting.settings'
|
|
24
|
+
const scopes = 'offline_access openid profile email accounting.transactions accounting.settings accounting.contacts'
|
|
25
25
|
const { apiKey, callback: redirectUrl } = this.config
|
|
26
26
|
|
|
27
27
|
return `https://login.xero.com/identity/connect/authorize?response_type=code&client_id=${apiKey}&scope=${scopes}&redirect_uri=${redirectUrl}&state=${nonce}`
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Router from 'koa-router'
|
|
2
|
+
|
|
3
|
+
import { config } from '@things-factory/env'
|
|
4
|
+
import { getRedirectSubdomainPath } from '@things-factory/shell'
|
|
5
|
+
|
|
6
|
+
const isPathBaseDomain = !config.get('subdomain') && !config.get('useVirtualHostBasedDomain')
|
|
7
|
+
|
|
8
|
+
const debug = require('debug')('things-factory:integration-accounting:xero-router')
|
|
9
|
+
|
|
10
|
+
export const xeroPrivateRouter = new Router()
|
|
11
|
+
|
|
12
|
+
xeroPrivateRouter.get(`${isPathBaseDomain ? '/domain/:domain' : ''}/callback-private-xero`, async (context, next) => {
|
|
13
|
+
const { domain } = context.state
|
|
14
|
+
|
|
15
|
+
const xeroAccountingCookies = context.cookies.get('xero-accounting')
|
|
16
|
+
const { id, status, message } = JSON.parse(xeroAccountingCookies)
|
|
17
|
+
|
|
18
|
+
context.redirect(
|
|
19
|
+
`${getRedirectSubdomainPath(
|
|
20
|
+
context,
|
|
21
|
+
domain.subdomain
|
|
22
|
+
)}account-xero/${id}/connect-callback?status=${status}&message=${message}`
|
|
23
|
+
)
|
|
24
|
+
})
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import Router from 'koa-router'
|
|
2
2
|
import fetch from 'node-fetch'
|
|
3
3
|
import { getRepository } from 'typeorm'
|
|
4
|
+
|
|
5
|
+
import { User, VerificationToken, VerificationTokenType } from '@things-factory/auth-base'
|
|
4
6
|
import { config } from '@things-factory/env'
|
|
7
|
+
import { getUrlFromContext } from '@things-factory/shell'
|
|
5
8
|
import { parseJwt } from '@things-factory/utils'
|
|
6
|
-
import { User, VerificationToken, VerificationTokenType } from '@things-factory/auth-base'
|
|
7
9
|
|
|
10
|
+
import { ACCOUNTING_STATUS, AccountingAPI } from '../controllers/accounting-api'
|
|
8
11
|
import { Account } from '../entities'
|
|
9
|
-
import { AccountingAPI, ACCOUNTING_STATUS } from '../controllers/accounting-api'
|
|
10
12
|
|
|
11
13
|
const { apiKey, apiSecret, hostname, callback: redirect_uri } = config.get('accountingIntegrationXero', {})
|
|
12
14
|
|
|
@@ -113,21 +115,34 @@ xeroRouter.get('/callback-xero', async (context, next) => {
|
|
|
113
115
|
updater: user
|
|
114
116
|
})
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
account
|
|
120
|
-
|
|
118
|
+
context.cookies.set(
|
|
119
|
+
'xero-accounting',
|
|
120
|
+
JSON.stringify({
|
|
121
|
+
...account,
|
|
122
|
+
message: 'success to activate'
|
|
123
|
+
}),
|
|
124
|
+
{
|
|
125
|
+
httpOnly: true
|
|
126
|
+
}
|
|
121
127
|
)
|
|
128
|
+
|
|
129
|
+
context.redirect(getUrlFromContext(context, '/callback-private-xero'))
|
|
122
130
|
} catch (err) {
|
|
123
131
|
var message: string = err.message
|
|
124
132
|
|
|
125
133
|
if (account) {
|
|
126
|
-
context.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
context.cookies.set(
|
|
135
|
+
'xero-accounting',
|
|
136
|
+
JSON.stringify({
|
|
137
|
+
...account,
|
|
138
|
+
message
|
|
139
|
+
}),
|
|
140
|
+
{
|
|
141
|
+
httpOnly: true
|
|
142
|
+
}
|
|
130
143
|
)
|
|
144
|
+
|
|
145
|
+
context.redirect(getUrlFromContext(context, '/callback-private-xero'))
|
|
131
146
|
return
|
|
132
147
|
}
|
|
133
148
|
|
package/server/routes.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { xeroPrivateRouter } from './routers/xero-private-router'
|
|
1
2
|
import { xeroRouter } from './routers/xero-router'
|
|
2
3
|
|
|
3
4
|
process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {
|
|
4
5
|
globalPublicRouter.use(xeroRouter.routes(), xeroRouter.allowedMethods())
|
|
5
6
|
})
|
|
7
|
+
|
|
8
|
+
process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
|
|
9
|
+
domainPrivateRouter.use(xeroPrivateRouter.routes(), xeroPrivateRouter.allowedMethods())
|
|
10
|
+
})
|