phx-node
Version: 
PHX NODE
43 lines • 2.44 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var PHXTransactionContentService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PHXTransactionContentService = void 0;
const common_1 = require("@nestjs/common");
const tuition_1 = require("../../../lib/types/tuition");
let PHXTransactionContentService = PHXTransactionContentService_1 = class PHXTransactionContentService {
    constructor() {
        this.logger = new common_1.Logger(PHXTransactionContentService_1.name);
    }
    buildContent({ student_id, module_code, month_id, detail_id, }) {
        const content = [student_id, module_code, month_id];
        if (detail_id)
            content.push(detail_id);
        return `Z${content.join(".")}W`;
    }
    parseContent(transactionContent) {
        var _a, _b, _c;
        const contentReal = transactionContent.match(/Z(.*?)W/);
        let result = {};
        if (contentReal && contentReal[1]) {
            const splitContent = contentReal[1].split(".");
            result = {
                student_id: Number((_a = splitContent[tuition_1.INDEX_TRANSACTION_CONTENT.STUDENT_ID]) !== null && _a !== void 0 ? _a : 0),
                module_code: splitContent[tuition_1.INDEX_TRANSACTION_CONTENT.MODULE_CODE],
                month_id: Number((_b = splitContent[tuition_1.INDEX_TRANSACTION_CONTENT.MONTH_ID]) !== null && _b !== void 0 ? _b : 0),
                detail_id: Number((_c = splitContent[tuition_1.INDEX_TRANSACTION_CONTENT.DETAIL_ID]) !== null && _c !== void 0 ? _c : 0),
            };
        }
        return result;
    }
};
exports.PHXTransactionContentService = PHXTransactionContentService;
exports.PHXTransactionContentService = PHXTransactionContentService = PHXTransactionContentService_1 = __decorate([
    (0, common_1.Injectable)()
], PHXTransactionContentService);
//# sourceMappingURL=create-content-transaction.service.js.map