myinvois-sdk
Version:
TypeScript SDK for interacting with the Malaysia e-invoicing system (MyInvois) API
103 lines (102 loc) • 2.84 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaxSubtotal = void 0;
const base_model_1 = require("./base-model");
/**
* Represents a tax subtotal
*/
class TaxSubtotal extends base_model_1.BaseModel {
constructor() {
super(...arguments);
this._taxableAmount = 0;
this._taxAmount = 0;
this._taxType = '';
this._taxRate = 0;
this._taxExemptionReason = '';
}
// Getter and Setter for taxableAmount
get taxableAmount() {
return this._taxableAmount;
}
set taxableAmount(value) {
this._taxableAmount = value;
}
// Getter and Setter for taxAmount
get taxAmount() {
return this._taxAmount;
}
set taxAmount(value) {
this._taxAmount = value;
}
// Getter and Setter for taxType
get taxType() {
return this._taxType;
}
set taxType(value) {
this._taxType = value;
}
// Getter and Setter for taxRate
get taxRate() {
return this._taxRate;
}
set taxRate(value) {
this._taxRate = value;
}
// Getter and Setter for taxExemptionReason
get taxExemptionReason() {
return this._taxExemptionReason;
}
set taxExemptionReason(value) {
this._taxExemptionReason = value;
}
/**
* Converts the tax subtotal to a JSON representation
*/
toJSON() {
return {
"TaxableAmount": [
{
"_": this._taxableAmount,
"currencyID": "MYR"
}
],
"TaxAmount": [
{
"_": this._taxAmount,
"currencyID": "MYR"
}
],
"TaxCategory": [
{
"ID": [
{
"_": this._taxType
}
],
"Percent": [
{
"_": this._taxRate
}
],
"TaxExemptionReason": this._taxType === 'E' && this._taxExemptionReason ? [
{
"_": this._taxExemptionReason
}
] : null,
"TaxScheme": [
{
"ID": [
{
"_": "OTH",
"schemeID": "UN/ECE 5153",
"schemeAgencyID": "6"
}
]
}
]
}
]
};
}
}
exports.TaxSubtotal = TaxSubtotal;