"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BankUploadedTransactionItem = void 0;
const lodash_1 = __importDefault(require("lodash"));
const column_desciptions_helper_1 = require("../helpers/column-desciptions.helper");
const collaterals_enum_1 = require("../enums/collaterals.enum");
class BankUploadedTransactionItem {
    date = new Date();
    accountNumber = '';
    amount = 0;
    transactionType = '';
    reference = '';
    detail1 = '';
    detail2 = '';
    detail3 = '';
    isConverted = false;
    splitTransactions = [];
    order;
    constructor(item, options) {
        if (options && options.bankAccountNumber && (!item.accountNumber || item.accountNumber.toString().trim() === '')) {
            item.accountNumber = options.bankAccountNumber;
        }
        const itemWithDates = (0, column_desciptions_helper_1.convertIntoDates)(item, collaterals_enum_1.ECollaterals.UPLOADED_BANK_TRANSACTIONS);
        const itemWithoutNulls = lodash_1.default.omitBy(itemWithDates, (value) => value === null);
        Object.assign(this, itemWithoutNulls);
        this.amount = item.amount ?? 0;
        if (!this.amount) {
            this.amount = item.credit - item.debit;
        }
    }
}
exports.BankUploadedTransactionItem = BankUploadedTransactionItem;
