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;
};
import { JsonProperty, JsonSerialize, JsonDeserialize, JsonClassType } from "jackson-js";
import { TransactionWeightType, TransactionRelation, TransactionUnitaryCostConfiguration as dtoTransactionUnitaryCostConfiguration, PaymentFlat } from "../../dto";
import { DateSerializer } from "../../jack-x";
import _ from "lodash";
export class TransactionUnitaryCostConfiguration extends dtoTransactionUnitaryCostConfiguration {
    constructor() {
        super();
        this.generate = true;
    }
}
__decorate([
    JsonProperty()
], TransactionUnitaryCostConfiguration.prototype, "generate", void 0);
export 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 = TransactionWeightType.UNITARY;
        this.label = "";
        this.payments = [];
        this.relations = [];
        this.isCashflow = false;
        this.generateProfitability = false;
        this.idHints = [];
    }
    getRelationObjects() {
        return _.map(this.relations, r => (r.relationObject));
    }
}
__decorate([
    JsonProperty()
], Transaction.prototype, "id", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [Object]] })
], Transaction.prototype, "idHints", void 0);
__decorate([
    JsonProperty()
], Transaction.prototype, "accountableEntity", void 0);
__decorate([
    JsonProperty()
], Transaction.prototype, "accountableEntityType", void 0);
__decorate([
    JsonProperty(),
    JsonSerialize({ using: DateSerializer.serialize }),
    JsonDeserialize({ using: DateSerializer.deserialize }),
    JsonClassType({ type: () => [Date] })
], Transaction.prototype, "date", void 0);
__decorate([
    JsonProperty()
], Transaction.prototype, "namespace", void 0);
__decorate([
    JsonProperty()
], Transaction.prototype, "title", void 0);
__decorate([
    JsonProperty()
], Transaction.prototype, "notes", void 0);
__decorate([
    JsonProperty()
], Transaction.prototype, "label", void 0);
__decorate([
    JsonProperty()
], Transaction.prototype, "target", void 0);
__decorate([
    JsonProperty()
], Transaction.prototype, "weightType", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [PaymentFlat]] })
], Transaction.prototype, "payments", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [TransactionRelation]] })
], Transaction.prototype, "relations", void 0);
__decorate([
    JsonProperty()
], Transaction.prototype, "isCashflow", void 0);
__decorate([
    JsonProperty()
], Transaction.prototype, "generateProfitability", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [TransactionUnitaryCostConfiguration] })
], Transaction.prototype, "unitaryCostConfiguration", void 0);
export class TrackableTransaction {
    constructor(requestId, transaction) {
        this.requestId = requestId;
        this.transaction = transaction;
    }
}
__decorate([
    JsonProperty()
], TrackableTransaction.prototype, "requestId", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Transaction] })
], TrackableTransaction.prototype, "transaction", void 0);
export class BulkTransaction {
    constructor() {
        this.additions = [];
        this.deletions = [];
    }
}
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [TrackableTransaction]] })
], BulkTransaction.prototype, "additions", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [TrackableTransaction]] })
], BulkTransaction.prototype, "deletions", void 0);
export class TrackableTransactionResult {
    constructor(requestId, id) {
        this.requestId = requestId;
        this.id = id;
    }
}
__decorate([
    JsonProperty()
], TrackableTransactionResult.prototype, "requestId", void 0);
__decorate([
    JsonProperty()
], TrackableTransactionResult.prototype, "id", void 0);
export class BulkTransactionResult {
    constructor() {
        this.additions = [];
        this.deletions = [];
    }
}
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [TrackableTransactionResult]] })
], BulkTransactionResult.prototype, "additions", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [TrackableTransactionResult]] })
], BulkTransactionResult.prototype, "deletions", void 0);
//# sourceMappingURL=transaction.js.map