UNPKG

myinvois-sdk

Version:

TypeScript SDK for interacting with the Malaysia e-invoicing system (MyInvois) API

69 lines (68 loc) 1.99 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.InvoicePeriod = void 0; const base_model_1 = require("./base-model"); const moment_timezone_1 = __importDefault(require("moment-timezone")); /** * Represents an invoice period */ class InvoicePeriod extends base_model_1.BaseModel { constructor() { super(...arguments); this._startDate = null; this._endDate = null; this._description = ''; } // Getter and Setter for startDate get startDate() { return this._startDate; } set startDate(value) { this._startDate = value; } // Getter and Setter for endDate get endDate() { return this._endDate; } set endDate(value) { this._endDate = value; } // Getter and Setter for description get description() { return this._description; } set description(value) { this._description = value; } /** * Converts the invoice period to a JSON representation */ toJSON() { if (!this._startDate && !this._endDate && !this._description) { return []; } return [ { "StartDate": this._startDate ? [ { "_": (0, moment_timezone_1.default)(this._startDate).format('YYYY-MM-DD') } ] : [], "EndDate": this._endDate ? [ { "_": (0, moment_timezone_1.default)(this._endDate).format('YYYY-MM-DD') } ] : [], "Description": this._description ? [ { "_": this._description } ] : [] } ]; } } exports.InvoicePeriod = InvoicePeriod;