@accounty/e-accounting 0.1.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/CHANGELOG.md +12 -0
- package/README.md +1 -0
- package/package.json +19 -0
- package/src/e-accounting.d.ts +26 -0
- package/src/e-accounting.interface.d.ts +251 -0
- package/src/e-accounting.interface.js +3 -0
- package/src/e-accounting.interface.js.map +1 -0
- package/src/e-accounting.js +137 -0
- package/src/e-accounting.js.map +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +8 -0
- package/src/index.js.map +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
# 0.1.0 (2025-12-11)
|
|
3
|
+
|
|
4
|
+
### Dependency Updates
|
|
5
|
+
|
|
6
|
+
* `packages-core` updated to version `1.3.1`
|
|
7
|
+
* `packages-oauth` updated to version `1.0.8`
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **e-accounting:** Add initial package setup for e-accounting library ([25e17da](https://github.com/PalmTreeCoding/Accounty/commit/25e17dad2aba5a5f9b515ff252547e8603aabe84))
|
|
12
|
+
* **e-accounting:** Enhance phone number fallback logic ([af454e8](https://github.com/PalmTreeCoding/Accounty/commit/af454e8941676bae912c98c80f6a44d642bbc927))
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @accounty/e-accounting
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@accounty/e-accounting",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"axios": "^1.13.2",
|
|
6
|
+
"bignumber.js": "^9.3.1",
|
|
7
|
+
"date-fns": "^4.1.0",
|
|
8
|
+
"debug": "^4.4.3",
|
|
9
|
+
"libphonenumber-js": "^1.12.31",
|
|
10
|
+
"validator": "^13.15.23",
|
|
11
|
+
"@accounty/core": "1.3.1",
|
|
12
|
+
"@accounty/oauth": "1.0.8",
|
|
13
|
+
"tslib": "2.8.1"
|
|
14
|
+
},
|
|
15
|
+
"packageManager": "yarn@4.10.3",
|
|
16
|
+
"types": "./src/index.d.ts",
|
|
17
|
+
"main": "./src/index.js",
|
|
18
|
+
"type": "commonjs"
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AccountyRateLimiter, Company, FetchInvoicesOptions, FetchResponse, SalesInvoice, SalesInvoiceWithCompany } from '@accounty/core';
|
|
2
|
+
import AccountyOauthProvider, { OauthCredentials, OauthOptions } from '@accounty/oauth';
|
|
3
|
+
import debug from 'debug';
|
|
4
|
+
import type { EAccountingCustomer, EAccountingCustomerInvoice } from './e-accounting.interface';
|
|
5
|
+
/**
|
|
6
|
+
* Used docs
|
|
7
|
+
* - https://developer.vismaonline.com/docs/lets-get-started
|
|
8
|
+
* - https://eaccountingapi.vismaonline.com/scalar/v2
|
|
9
|
+
*/
|
|
10
|
+
export default class EAccounting extends AccountyOauthProvider<OauthCredentials> {
|
|
11
|
+
protected readonly options: OauthOptions;
|
|
12
|
+
protected log: debug.Debugger;
|
|
13
|
+
protected tokenUri: string;
|
|
14
|
+
protected authorizeUri: string;
|
|
15
|
+
private readonly client;
|
|
16
|
+
protected rateLimiter: AccountyRateLimiter;
|
|
17
|
+
constructor(options: OauthOptions);
|
|
18
|
+
getAuthorizeURL(state: string, redirectUri?: string, additionalParams?: object): string;
|
|
19
|
+
testCredentials(): Promise<boolean>;
|
|
20
|
+
downloadInvoice(remoteId: string): Promise<Buffer>;
|
|
21
|
+
fetchCompanies(): Promise<FetchResponse<Array<Company<EAccountingCustomer>>>>;
|
|
22
|
+
fetchInvoices(options?: FetchInvoicesOptions): Promise<FetchResponse<Array<SalesInvoice<EAccountingCustomerInvoice>>>>;
|
|
23
|
+
fetchInvoicesWithCompany(options?: FetchInvoicesOptions): Promise<FetchResponse<Array<SalesInvoiceWithCompany>>>;
|
|
24
|
+
private getJson;
|
|
25
|
+
private get;
|
|
26
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import type { RemoteDataJson } from '@accounty/core';
|
|
2
|
+
import type { OauthAdministration } from '@accounty/oauth';
|
|
3
|
+
export type EAccountingAdministration = OauthAdministration;
|
|
4
|
+
export interface EAccountingResponse<Response> {
|
|
5
|
+
data: Response[];
|
|
6
|
+
meta: {
|
|
7
|
+
currentPage: number;
|
|
8
|
+
pageSize: number;
|
|
9
|
+
totalCount: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface EAccountingCustomerInvoice extends RemoteDataJson {
|
|
13
|
+
'id': '123e4567-e89b-12d3-a456-426614174000';
|
|
14
|
+
'euThirdParty': true;
|
|
15
|
+
'isCreditInvoice': true;
|
|
16
|
+
'currencyCode': null;
|
|
17
|
+
'currencyRate': null;
|
|
18
|
+
'createdByUserId': null;
|
|
19
|
+
'totalAmount': 1;
|
|
20
|
+
'totalVatAmount': 1;
|
|
21
|
+
'totalRoundings': 1;
|
|
22
|
+
'totalAmountInvoiceCurrency': 1;
|
|
23
|
+
'totalVatAmountInvoiceCurrency': 1;
|
|
24
|
+
'setOffAmountInvoiceCurrency': 1;
|
|
25
|
+
'customerId': '123e4567-e89b-12d3-a456-426614174000';
|
|
26
|
+
'rows': [
|
|
27
|
+
{
|
|
28
|
+
'id': '123e4567-e89b-12d3-a456-426614174000';
|
|
29
|
+
'articleNumber': null;
|
|
30
|
+
'articleId': null;
|
|
31
|
+
'isServiceArticle': true;
|
|
32
|
+
'amountNoVat': 1;
|
|
33
|
+
'vatRate': null;
|
|
34
|
+
'lineNumber': 1;
|
|
35
|
+
'isTextRow': true;
|
|
36
|
+
'text': null;
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
'vatSpecification': [
|
|
40
|
+
{
|
|
41
|
+
'amountInvoiceCurrency': 1;
|
|
42
|
+
'vatAmountInvoiceCurrency': 1;
|
|
43
|
+
'vatPercent': 1;
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
'invoiceDate': null;
|
|
47
|
+
'dueDate': null;
|
|
48
|
+
'deliveryDate': null;
|
|
49
|
+
'rotReducedInvoicingType': 0;
|
|
50
|
+
'maxAllowedTaxReductionAmount': 1;
|
|
51
|
+
'rotReducedInvoicingAmount': null;
|
|
52
|
+
'rotReducedInvoicingPercent': 1;
|
|
53
|
+
'rotReducedInvoicingPropertyName': null;
|
|
54
|
+
'rotReducedInvoicingOrgNumber': null;
|
|
55
|
+
'persons': [
|
|
56
|
+
{
|
|
57
|
+
'id': '123e4567-e89b-12d3-a456-426614174000';
|
|
58
|
+
'ssn': null;
|
|
59
|
+
'amount': 1;
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
'rotReducedInvoicingAutomaticDistribution': true;
|
|
63
|
+
'electronicReference': null;
|
|
64
|
+
'subscriptionNumber': null;
|
|
65
|
+
'contractNumber': null;
|
|
66
|
+
'electronicAddress': null;
|
|
67
|
+
'ediServiceDelivererId': null;
|
|
68
|
+
'ourReference': null;
|
|
69
|
+
'yourReference': null;
|
|
70
|
+
'buyersOrderReference': null;
|
|
71
|
+
'invoiceCustomerName': null;
|
|
72
|
+
'invoiceAddress1': null;
|
|
73
|
+
'invoiceAddress2': null;
|
|
74
|
+
'invoicePostalCode': null;
|
|
75
|
+
'invoiceCity': null;
|
|
76
|
+
'invoiceCountryCode': null;
|
|
77
|
+
'deliveryCustomerName': null;
|
|
78
|
+
'deliveryAddress1': null;
|
|
79
|
+
'deliveryAddress2': null;
|
|
80
|
+
'deliveryPostalCode': null;
|
|
81
|
+
'deliveryCity': null;
|
|
82
|
+
'deliveryCountryCode': null;
|
|
83
|
+
'deliveryMethodName': null;
|
|
84
|
+
'deliveryTermName': null;
|
|
85
|
+
'deliveryMethodCode': null;
|
|
86
|
+
'deliveryTermCode': null;
|
|
87
|
+
'customerIsPrivatePerson': true;
|
|
88
|
+
'termsOfPaymentId': '123e4567-e89b-12d3-a456-426614174000';
|
|
89
|
+
'customerEmail': null;
|
|
90
|
+
'invoiceNumber': 1;
|
|
91
|
+
'customerNumber': null;
|
|
92
|
+
'customerName': null;
|
|
93
|
+
'paymentReferenceNumber': null;
|
|
94
|
+
'rotPropertyType': null;
|
|
95
|
+
'salesDocumentAttachments': [
|
|
96
|
+
'123e4567-e89b-12d3-a456-426614174000'
|
|
97
|
+
];
|
|
98
|
+
'messageThreads': [
|
|
99
|
+
'123e4567-e89b-12d3-a456-426614174000'
|
|
100
|
+
];
|
|
101
|
+
'notes': [
|
|
102
|
+
'123e4567-e89b-12d3-a456-426614174000'
|
|
103
|
+
];
|
|
104
|
+
'hasAutoInvoiceError': true;
|
|
105
|
+
'isNotDelivered': true;
|
|
106
|
+
'reverseChargeOnConstructionServices': true;
|
|
107
|
+
'workHouseOtherCosts': null;
|
|
108
|
+
'remainingAmount': 1;
|
|
109
|
+
'remainingAmountInvoiceCurrency': 1;
|
|
110
|
+
'referringInvoiceId': null;
|
|
111
|
+
'createdFromOrderId': null;
|
|
112
|
+
'createdFromQuoteId': null;
|
|
113
|
+
'createdFromDraftId': null;
|
|
114
|
+
'voucherNumber': null;
|
|
115
|
+
'voucherId': '123e4567-e89b-12d3-a456-426614174000';
|
|
116
|
+
'createdUtc': null;
|
|
117
|
+
'modifiedUtc': null;
|
|
118
|
+
'reversedConstructionVatInvoicing': true;
|
|
119
|
+
'includesVat': true;
|
|
120
|
+
'sendType': 0;
|
|
121
|
+
'paymentReminderIssued': true;
|
|
122
|
+
'paymentRemindersCount': 1;
|
|
123
|
+
'lastPaymentReminderSentDate': null;
|
|
124
|
+
'usesGreenTechnology': true;
|
|
125
|
+
'isSold': true;
|
|
126
|
+
'factoringInvoiceStatus': 0;
|
|
127
|
+
'paymentDate': null;
|
|
128
|
+
'paymentStatus': 0;
|
|
129
|
+
'creditedBy': [
|
|
130
|
+
{
|
|
131
|
+
'creditInvoiceId': '123e4567-e89b-12d3-a456-426614174000';
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
'contributionMargin': {
|
|
135
|
+
'amount': null;
|
|
136
|
+
'percentage': null;
|
|
137
|
+
};
|
|
138
|
+
'isDirectDebit': null;
|
|
139
|
+
'isQuickInvoice': true;
|
|
140
|
+
'isCollectiveInvoice': true;
|
|
141
|
+
'collectiveCustomerInvoiceRowsRelationToOrders': [
|
|
142
|
+
{
|
|
143
|
+
'orderId': '123e4567-e89b-12d3-a456-426614174000';
|
|
144
|
+
'orderNumber': null;
|
|
145
|
+
'orderReference': null;
|
|
146
|
+
'deliveryDate': null;
|
|
147
|
+
'relatedInvoiceRows': [
|
|
148
|
+
1
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
];
|
|
152
|
+
'replaceUnitPriceWhenZero': true;
|
|
153
|
+
'taxDeductionStatus': 0;
|
|
154
|
+
'backgroundId': null;
|
|
155
|
+
}
|
|
156
|
+
export interface EAccountingCustomer extends RemoteDataJson {
|
|
157
|
+
'id': '123e4567-e89b-12d3-a456-426614174000';
|
|
158
|
+
'invoiceCity': 'string';
|
|
159
|
+
'invoicePostalCode': 'string';
|
|
160
|
+
'gln': null;
|
|
161
|
+
'emailAddressOrder': null;
|
|
162
|
+
'emailAddressQuote': null;
|
|
163
|
+
'payToAccountId': null;
|
|
164
|
+
'termsOfPayment': {
|
|
165
|
+
'id': '123e4567-e89b-12d3-a456-426614174000';
|
|
166
|
+
'name': null;
|
|
167
|
+
'nameEnglish': null;
|
|
168
|
+
'numberOfDays': 1;
|
|
169
|
+
'termsOfPaymentTypeId': 1;
|
|
170
|
+
'termsOfPaymentTypeText': null;
|
|
171
|
+
'availableForSales': true;
|
|
172
|
+
'availableForPurchase': true;
|
|
173
|
+
};
|
|
174
|
+
'lastInvoiceDate': null;
|
|
175
|
+
'taxDeductionNumber': null;
|
|
176
|
+
'propertyType': null;
|
|
177
|
+
'propertyReference': null;
|
|
178
|
+
'changedUtc': null;
|
|
179
|
+
'customerLabels': [
|
|
180
|
+
{
|
|
181
|
+
'id': '123e4567-e89b-12d3-a456-426614174000';
|
|
182
|
+
'name': 'string';
|
|
183
|
+
'description': null;
|
|
184
|
+
}
|
|
185
|
+
];
|
|
186
|
+
'messageThreads': [
|
|
187
|
+
'123e4567-e89b-12d3-a456-426614174000'
|
|
188
|
+
];
|
|
189
|
+
'notes': [
|
|
190
|
+
'123e4567-e89b-12d3-a456-426614174000'
|
|
191
|
+
];
|
|
192
|
+
'isFutureInvoiceDateAllowed': true;
|
|
193
|
+
'iban': null;
|
|
194
|
+
'isDirectDebitEnabled': null;
|
|
195
|
+
'directDebitCustomerSettings': {
|
|
196
|
+
'mandateId': null;
|
|
197
|
+
'mandateType': 1;
|
|
198
|
+
'sequenceType': 1;
|
|
199
|
+
'signingDate': null;
|
|
200
|
+
'endDate': null;
|
|
201
|
+
'latestDirectDebit': null;
|
|
202
|
+
'bic': null;
|
|
203
|
+
};
|
|
204
|
+
'discountAgreementId': null;
|
|
205
|
+
'unpaidInvoicesAmount': 1;
|
|
206
|
+
'customerNumber': null;
|
|
207
|
+
'corporateIdentityNumber': null;
|
|
208
|
+
'contactPersonEmail': null;
|
|
209
|
+
'contactPersonMobile': null;
|
|
210
|
+
'contactPersonName': null;
|
|
211
|
+
'contactPersonPhone': null;
|
|
212
|
+
'currencyCode': null;
|
|
213
|
+
'emailAddress': null;
|
|
214
|
+
'invoiceAddress1': null;
|
|
215
|
+
'invoiceAddress2': null;
|
|
216
|
+
'invoiceCountryCode': null;
|
|
217
|
+
'deliveryAddress1': null;
|
|
218
|
+
'deliveryAddress2': null;
|
|
219
|
+
'deliveryCity': null;
|
|
220
|
+
'deliveryCountryCode': null;
|
|
221
|
+
'deliveryPostalCode': null;
|
|
222
|
+
'deliveryCustomerName': null;
|
|
223
|
+
'deliveryMethodId': null;
|
|
224
|
+
'deliveryTermId': null;
|
|
225
|
+
'name': 'string';
|
|
226
|
+
'note': null;
|
|
227
|
+
'reverseChargeOnConstructionServices': true;
|
|
228
|
+
'webshopCustomerNumber': null;
|
|
229
|
+
'mobilePhone': null;
|
|
230
|
+
'telephone': null;
|
|
231
|
+
'termsOfPaymentId': '123e4567-e89b-12d3-a456-426614174000';
|
|
232
|
+
'vatNumber': null;
|
|
233
|
+
'wwwAddress': null;
|
|
234
|
+
'isPrivatePerson': true;
|
|
235
|
+
'isNorthernIreland': null;
|
|
236
|
+
'discountPercentage': 0;
|
|
237
|
+
'isActive': true;
|
|
238
|
+
'forceBookkeepVat': true;
|
|
239
|
+
'ediGlnNumber': null;
|
|
240
|
+
'salesDocumentLanguage': null;
|
|
241
|
+
'electronicAddress': null;
|
|
242
|
+
'electronicReference': null;
|
|
243
|
+
'ediServiceDelivererId': null;
|
|
244
|
+
'autoInvoiceActivationEmailSentDate': null;
|
|
245
|
+
'autoInvoiceRegistrationRequestSentDate': null;
|
|
246
|
+
'emailAddresses': [
|
|
247
|
+
'string'
|
|
248
|
+
];
|
|
249
|
+
'deliveryBasedVat': true;
|
|
250
|
+
'salesPriceListId': null;
|
|
251
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e-accounting.interface.js","sourceRoot":"","sources":["../../../../packages/e-accounting/src/e-accounting.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@accounty/core");
|
|
5
|
+
const oauth_1 = tslib_1.__importDefault(require("@accounty/oauth"));
|
|
6
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
7
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
8
|
+
/**
|
|
9
|
+
* Used docs
|
|
10
|
+
* - https://developer.vismaonline.com/docs/lets-get-started
|
|
11
|
+
* - https://eaccountingapi.vismaonline.com/scalar/v2
|
|
12
|
+
*/
|
|
13
|
+
class EAccounting extends oauth_1.default {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(options.clientId, options.clientSecret, options.redirectUri);
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.log = (0, debug_1.default)('accounty:e-accounting');
|
|
18
|
+
this.tokenUri = 'https://identity.vismaonline.com/connect/token';
|
|
19
|
+
this.authorizeUri = 'https://identity.vismaonline.com/connect/authorize';
|
|
20
|
+
this.client = axios_1.default.create({
|
|
21
|
+
baseURL: 'https://eaccountingapi.vismaonline.com/v2'
|
|
22
|
+
});
|
|
23
|
+
this.rateLimiter = new core_1.AccountyRateLimiter(10 // 600 requests per minute
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
getAuthorizeURL(state, redirectUri, additionalParams = {}) {
|
|
27
|
+
return super.getAuthorizeURL(state, redirectUri, {
|
|
28
|
+
...additionalParams,
|
|
29
|
+
prompt: 'select_account',
|
|
30
|
+
scope: 'ea:sales_readonly'
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async testCredentials() {
|
|
34
|
+
return Boolean(await this.get('/customerinvoices'));
|
|
35
|
+
}
|
|
36
|
+
async downloadInvoice(remoteId) {
|
|
37
|
+
return this.get(`/customerinvoices/${remoteId}/print`);
|
|
38
|
+
}
|
|
39
|
+
async fetchCompanies() {
|
|
40
|
+
const customers = await this.getJson('/customers');
|
|
41
|
+
return {
|
|
42
|
+
version: undefined,
|
|
43
|
+
data: customers.map((customer) => ({
|
|
44
|
+
remoteId: customer.id,
|
|
45
|
+
name: customer.name,
|
|
46
|
+
country: customer.invoiceCountryCode,
|
|
47
|
+
reference: customer.customerNumber,
|
|
48
|
+
registrationNr: customer.corporateIdentityNumber,
|
|
49
|
+
taxNr: customer.vatNumber,
|
|
50
|
+
variant: customer.isPrivatePerson ? 'PERSON' : 'COMPANY',
|
|
51
|
+
address: customer.invoiceAddress1 && {
|
|
52
|
+
streetName: customer.invoiceAddress1,
|
|
53
|
+
zipcode: customer.invoicePostalCode,
|
|
54
|
+
city: customer.invoiceCity,
|
|
55
|
+
country: core_1.utils.toCountry(customer.invoiceCountryCode)
|
|
56
|
+
},
|
|
57
|
+
postalAddress: customer.deliveryAddress1 && {
|
|
58
|
+
streetName: customer.deliveryAddress1,
|
|
59
|
+
zipcode: customer.deliveryPostalCode,
|
|
60
|
+
city: customer.deliveryCity,
|
|
61
|
+
country: core_1.utils.toCountry(customer.deliveryCountryCode)
|
|
62
|
+
},
|
|
63
|
+
contacts: [
|
|
64
|
+
{
|
|
65
|
+
remoteId: customer.id,
|
|
66
|
+
email: core_1.utils.toEmail(customer.emailAddress),
|
|
67
|
+
phoneNr: core_1.utils.toPhoneNumber(core_1.utils.toCountry(customer.invoiceCountryCode), customer.telephone, false)
|
|
68
|
+
|| core_1.utils.toPhoneNumber(core_1.utils.toCountry(customer.invoiceCountryCode), customer.mobilePhone, false),
|
|
69
|
+
mobileNr: core_1.utils.toPhoneNumber(core_1.utils.toCountry(customer.invoiceCountryCode), customer.mobilePhone, true)
|
|
70
|
+
|| core_1.utils.toPhoneNumber(core_1.utils.toCountry(customer.invoiceCountryCode), customer.telephone, true)
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
remoteData: customer
|
|
74
|
+
}))
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async fetchInvoices(options) {
|
|
78
|
+
const invoices = await this.getJson('/customerinvoices', {});
|
|
79
|
+
// TODO:: Implement options support
|
|
80
|
+
return {
|
|
81
|
+
version: undefined,
|
|
82
|
+
data: invoices.map((invoice) => {
|
|
83
|
+
const centAmount = core_1.utils.toCentAmount(invoice.totalAmount);
|
|
84
|
+
const centAmountOpen = core_1.utils.toCentAmount(invoice.totalAmount); // TODO
|
|
85
|
+
return {
|
|
86
|
+
remoteId: invoice.id,
|
|
87
|
+
companyId: invoice.customerId,
|
|
88
|
+
reference: `${invoice.invoiceNumber || invoice.yourReference}` || null,
|
|
89
|
+
centAmount,
|
|
90
|
+
centAmountPaid: centAmount - centAmountOpen,
|
|
91
|
+
centAmountOpen,
|
|
92
|
+
currency: invoice.currencyCode,
|
|
93
|
+
...this.getInvoiceDateAndDueDate(invoice.invoiceDate, invoice.dueDate),
|
|
94
|
+
remoteData: invoice
|
|
95
|
+
};
|
|
96
|
+
})
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async fetchInvoicesWithCompany(options) {
|
|
100
|
+
const invoices = await this.fetchInvoices(options);
|
|
101
|
+
const companies = await this.fetchCompanies();
|
|
102
|
+
return {
|
|
103
|
+
version: undefined,
|
|
104
|
+
data: invoices.data.map((invoice) => {
|
|
105
|
+
const company = companies.data.find((company) => company.remoteId === invoice.companyId);
|
|
106
|
+
return {
|
|
107
|
+
...invoice,
|
|
108
|
+
company
|
|
109
|
+
};
|
|
110
|
+
})
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async getJson(url, params = {}) {
|
|
114
|
+
const { data, meta } = await this.get(url, params);
|
|
115
|
+
// Handle pagination - fetch all pages if there are more
|
|
116
|
+
if (data && meta && data.length >= meta.pageSize && meta.currentPage * meta.pageSize < meta.totalCount) {
|
|
117
|
+
const nextPageData = await this.getJson(url, {
|
|
118
|
+
...params,
|
|
119
|
+
page: meta.currentPage + 1
|
|
120
|
+
});
|
|
121
|
+
return [...data, ...nextPageData];
|
|
122
|
+
}
|
|
123
|
+
return data || [];
|
|
124
|
+
}
|
|
125
|
+
async get(url, params = {}) {
|
|
126
|
+
await this.rateLimiter.waitForRateLimit();
|
|
127
|
+
const response = await this.client.get(url, {
|
|
128
|
+
headers: this.getOauthHeaders(),
|
|
129
|
+
validateStatus: this.validateRequestStatus,
|
|
130
|
+
params
|
|
131
|
+
});
|
|
132
|
+
this.throwIfRevoked(response);
|
|
133
|
+
return response.data;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.default = EAccounting;
|
|
137
|
+
//# sourceMappingURL=e-accounting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e-accounting.js","sourceRoot":"","sources":["../../../../packages/e-accounting/src/e-accounting.ts"],"names":[],"mappings":";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M,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAW,GAAG,EAAE;YACpD,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE;YAC/B,cAAc,EAAE,IAAI,CAAC,qBAAqB;YAC1C,MAAM;SACP,CAAC,CAAA;QAEF,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAA;QAE7B,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;CAEF;AAjKD,8BAiKC"}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
var e_accounting_1 = require("./e-accounting");
|
|
6
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(e_accounting_1).default; } });
|
|
7
|
+
tslib_1.__exportStar(require("./e-accounting"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/e-accounting/src/index.ts"],"names":[],"mappings":";;;;AAAA,+CAAwC;AAA/B,gIAAA,OAAO,OAAA;AAChB,yDAA8B"}
|