bkper 2.5.1 → 2.5.8

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/lib/index.d.ts CHANGED
@@ -490,6 +490,17 @@ export declare class Book {
490
490
  * @returns This Book, for chainning.
491
491
  */
492
492
  setLockDate(lockDate: string): Book;
493
+ /**
494
+ * @returns The closing date of the Book in ISO format yyyy-MM-dd
495
+ */
496
+ getClosingDate(): string;
497
+ /**
498
+ *
499
+ * Sets the closing date of the Book in ISO format yyyy-MM-dd.
500
+ *
501
+ * @returns This Book, for chainning.
502
+ */
503
+ setClosingDate(closingDate: string): Book;
493
504
  /**
494
505
  * @returns The decimal separator of the Book
495
506
  */
@@ -560,6 +571,12 @@ export declare class Book {
560
571
  * @returns The date formated
561
572
  */
562
573
  formatDate(date: Date, timeZone?: string): string;
574
+ /**
575
+ * Parse a date string according to date pattern and timezone of the Book.
576
+ *
577
+ * Also parse ISO yyyy-mm-dd format.
578
+ */
579
+ parseDate(date: string): Date;
563
580
  /**
564
581
  * Formats a value according to [[DecimalSeparator]] and fraction digits of the Book.
565
582
  *
@@ -855,7 +872,7 @@ export declare class Group {
855
872
  *
856
873
  * @returns This Group, for chainning.
857
874
  */
858
- setParent(group: Group): Group;
875
+ setParent(group: Group | null): Group;
859
876
  /**
860
877
  * @returns The name of this Group
861
878
  */
package/lib/model/Book.js CHANGED
@@ -206,6 +206,25 @@ class Book {
206
206
  this.wrapped.lockDate = lockDate;
207
207
  return this;
208
208
  }
209
+ /**
210
+ * @returns The closing date of the Book in ISO format yyyy-MM-dd
211
+ */
212
+ getClosingDate() {
213
+ return this.wrapped.closingDate;
214
+ }
215
+ /**
216
+ *
217
+ * Sets the closing date of the Book in ISO format yyyy-MM-dd.
218
+ *
219
+ * @returns This Book, for chainning.
220
+ */
221
+ setClosingDate(closingDate) {
222
+ if (closingDate == null) {
223
+ closingDate = "1900-00-00";
224
+ }
225
+ this.wrapped.closingDate = closingDate;
226
+ return this;
227
+ }
209
228
  /**
210
229
  * @returns The decimal separator of the Book
211
230
  */
@@ -314,6 +333,14 @@ class Book {
314
333
  }
315
334
  return Utils.formatDate(date, this.getDatePattern(), timeZone);
316
335
  }
336
+ /**
337
+ * Parse a date string according to date pattern and timezone of the Book.
338
+ *
339
+ * Also parse ISO yyyy-mm-dd format.
340
+ */
341
+ parseDate(date) {
342
+ return Utils.parseDate(date, this.getDatePattern(), this.getTimeZone());
343
+ }
317
344
  /**
318
345
  * Formats a value according to [[DecimalSeparator]] and fraction digits of the Book.
319
346
  *
package/lib/utils.js CHANGED
@@ -127,7 +127,14 @@ function formatDateISO(date, timeZone) {
127
127
  }
128
128
  exports.formatDateISO = formatDateISO;
129
129
  function parseDate(date, pattern, timeZone) {
130
- return luxon_1.DateTime.fromFormat(date, pattern, { zone: timeZone }).toJSDate();
130
+ let dateObject = luxon_1.DateTime.fromFormat(date, pattern, { zone: timeZone }).toJSDate();
131
+ if (dateObject instanceof Date && !isNaN(dateObject.getTime())) {
132
+ console.log(dateObject);
133
+ return dateObject;
134
+ }
135
+ else {
136
+ return luxon_1.DateTime.fromFormat(date, 'yyyy-MM-dd', { zone: timeZone }).toJSDate();
137
+ }
131
138
  }
132
139
  exports.parseDate = parseDate;
133
140
  function getDateFormatterPattern(datePattern, periodicity) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper",
3
- "version": "2.5.1",
3
+ "version": "2.5.8",
4
4
  "description": "Node.js client for Bkper REST API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -46,7 +46,7 @@
46
46
  "open": "^7.3.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@bkper/bkper-api-types": "^5.0.0",
49
+ "@bkper/bkper-api-types": "^5.1.4",
50
50
  "@microsoft/api-extractor": "^7.12.1",
51
51
  "@types/big.js": "^6.0.2",
52
52
  "@types/chai": "^4.2.14",