bkper-js 1.14.1 → 1.15.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/lib/index.d.ts +4 -0
- package/lib/model/Transaction.js +10 -0
- package/lib/utils.js +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1773,6 +1773,10 @@ export declare class Transaction {
|
|
|
1773
1773
|
* @returns The amount of the transaction.
|
|
1774
1774
|
*/
|
|
1775
1775
|
getAmount(): Amount | undefined;
|
|
1776
|
+
/**
|
|
1777
|
+
* @returns The amount of the transaction, formatted according to the Book format.
|
|
1778
|
+
*/
|
|
1779
|
+
getAmountFormatted(): string | undefined;
|
|
1776
1780
|
/**
|
|
1777
1781
|
*
|
|
1778
1782
|
* Sets the amount of the Transaction.
|
package/lib/model/Transaction.js
CHANGED
|
@@ -393,6 +393,16 @@ export class Transaction {
|
|
|
393
393
|
getAmount() {
|
|
394
394
|
return this.payload.amount != null && this.payload.amount.trim() != '' ? new Amount(this.payload.amount) : undefined;
|
|
395
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* @returns The amount of the transaction, formatted according to the Book format.
|
|
398
|
+
*/
|
|
399
|
+
getAmountFormatted() {
|
|
400
|
+
const amount = this.getAmount();
|
|
401
|
+
if (amount) {
|
|
402
|
+
return this.book.formatValue(amount);
|
|
403
|
+
}
|
|
404
|
+
return undefined;
|
|
405
|
+
}
|
|
396
406
|
/**
|
|
397
407
|
*
|
|
398
408
|
* Sets the amount of the Transaction.
|
package/lib/utils.js
CHANGED
|
@@ -36,7 +36,7 @@ export function formatValue(value, decimalSeparator, fractionDigits) {
|
|
|
36
36
|
if (value == null) {
|
|
37
37
|
return "";
|
|
38
38
|
}
|
|
39
|
-
if (
|
|
39
|
+
if (fractionDigits == null) {
|
|
40
40
|
fractionDigits = 2;
|
|
41
41
|
}
|
|
42
42
|
var formattedValue = (value.toFixed(fractionDigits)) + "";
|