"use strict";
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 __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BulkTransactionResult = exports.TrackableTransactionResult = exports.BulkTransaction = exports.TrackableTransaction = exports.Transaction = exports.TransactionUnitaryCostConfiguration = void 0;
const jackson_js_1 = require("jackson-js");
const dto_1 = require("../../dto");
const jack_x_1 = require("../../jack-x");
const lodash_1 = __importDefault(require("lodash"));
class TransactionUnitaryCostConfiguration extends dto_1.TransactionUnitaryCostConfiguration {
    constructor() {
        super();
        this.generate = true;
    }
}
__decorate([
    (0, jackson_js_1.JsonProperty)()
], TransactionUnitaryCostConfiguration.prototype, "generate", void 0);
exports.TransactionUnitaryCostConfiguration = TransactionUnitaryCostConfiguration;
class Transaction {
    constructor(id, date) {
        this.id = id;
        this.accountableEntityType = "";
        this.accountableEntity = "";
        this.namespace = "";
        this.date = date;
        this.title = "";
        this.target = "";
        this.notes = "";
        this.weightType = dto_1.TransactionWeightType.UNITARY;
        this.label = "";
        this.payments = [];
        this.relations = [];
        this.isCashflow = false;
        this.generateProfitability = false;
        this.idHints = [];
    }
    getRelationObjects() {
        return lodash_1.default.map(this.relations, r => (r.relationObject));
    }
}
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "id", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [Object]] })
], Transaction.prototype, "idHints", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "accountableEntity", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "accountableEntityType", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonSerialize)({ using: jack_x_1.DateSerializer.serialize }),
    (0, jackson_js_1.JsonDeserialize)({ using: jack_x_1.DateSerializer.deserialize }),
    (0, jackson_js_1.JsonClassType)({ type: () => [Date] })
], Transaction.prototype, "date", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "namespace", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "title", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "notes", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "label", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "target", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "weightType", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [dto_1.PaymentFlat]] })
], Transaction.prototype, "payments", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [dto_1.TransactionRelation]] })
], Transaction.prototype, "relations", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "isCashflow", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Transaction.prototype, "generateProfitability", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [TransactionUnitaryCostConfiguration] })
], Transaction.prototype, "unitaryCostConfiguration", void 0);
exports.Transaction = Transaction;
class TrackableTransaction {
    constructor(requestId, transaction) {
        this.requestId = requestId;
        this.transaction = transaction;
    }
}
__decorate([
    (0, jackson_js_1.JsonProperty)()
], TrackableTransaction.prototype, "requestId", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Transaction] })
], TrackableTransaction.prototype, "transaction", void 0);
exports.TrackableTransaction = TrackableTransaction;
class BulkTransaction {
    constructor() {
        this.additions = [];
        this.deletions = [];
    }
}
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [TrackableTransaction]] })
], BulkTransaction.prototype, "additions", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [TrackableTransaction]] })
], BulkTransaction.prototype, "deletions", void 0);
exports.BulkTransaction = BulkTransaction;
class TrackableTransactionResult {
    constructor(requestId, id) {
        this.requestId = requestId;
        this.id = id;
    }
}
__decorate([
    (0, jackson_js_1.JsonProperty)()
], TrackableTransactionResult.prototype, "requestId", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], TrackableTransactionResult.prototype, "id", void 0);
exports.TrackableTransactionResult = TrackableTransactionResult;
class BulkTransactionResult {
    constructor() {
        this.additions = [];
        this.deletions = [];
    }
}
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [TrackableTransactionResult]] })
], BulkTransactionResult.prototype, "additions", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [TrackableTransactionResult]] })
], BulkTransactionResult.prototype, "deletions", void 0);
exports.BulkTransactionResult = BulkTransactionResult;
//# sourceMappingURL=transaction.js.map