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 { JsonClassType, JsonProperty } from "jackson-js";
import { TagCategory, TagNamespace, TagDiscriminator, Tag } from "../tag";
export var Contributions;
(function (Contributions) {
    Contributions["GROSS_REVENUE"] = "gross_revenue";
    Contributions["PROMOTIONS"] = "promotions";
    Contributions["NET_REVENUE"] = "net_revenue";
    Contributions["GROSS_PROFIT"] = "gross_profit";
    Contributions["NET_PROFIT"] = "net_profit";
    Contributions["GROSS_MARGIN"] = "gross_margin";
    Contributions["NET_MARGIN"] = "net_margin";
    Contributions["SALE_NET_PROFIT"] = "sale_net_profit";
    Contributions["ADV_COST"] = "adv_cost";
    Contributions["EXTERNAL_EXPENSES"] = "external_expenses";
    Contributions["COGS"] = "cogs";
    Contributions["FEES"] = "fees";
    Contributions["TAX_IN"] = "tax_in";
    Contributions["TAX_OUT"] = "tax_out";
    Contributions["RETURNS_VALUE"] = "returns_value";
    Contributions["REIMBURSEMENT_VALUE"] = "reimbursement_value";
    Contributions["OPERATIONS"] = "operations";
})(Contributions || (Contributions = {}));
export class FinancialEntryType {
    constructor(tag) {
        this.tag = tag;
        this.contributesTo = [];
        const tagCategory = tag.getCategory();
        const tagNamespace = tag.getNamespace();
        this.contributesTo = this.contributesTo.concat(this.contributorsFromTagCategory(tagCategory));
        this.contributesTo = this.contributesTo.concat(this.contributorsFromTagNamespace(tagNamespace));
        this.contributesTo = this.contributesTo.concat(this.contributorsFromTagDiscriminator(tag));
    }
    contributorsFromTagCategory(category) {
        const categoryContributions = [];
        switch (category) {
            case TagCategory.FEE:
                categoryContributions.push(Contributions.FEES);
                return categoryContributions;
            case TagCategory.REIMBURSEMENT:
                categoryContributions.push(Contributions.REIMBURSEMENT_VALUE);
                return categoryContributions;
            case TagCategory.SALE:
                categoryContributions.push(Contributions.SALE_NET_PROFIT);
                categoryContributions.push(Contributions.GROSS_REVENUE);
                categoryContributions.push(Contributions.NET_REVENUE);
                categoryContributions.push(Contributions.GROSS_MARGIN);
                categoryContributions.push(Contributions.NET_MARGIN);
                categoryContributions.push(Contributions.GROSS_PROFIT);
                categoryContributions.push(Contributions.NET_PROFIT);
                return categoryContributions;
            case TagCategory.REFUND:
                categoryContributions.push(Contributions.RETURNS_VALUE);
                return categoryContributions;
            case TagCategory.REVENUE:
                categoryContributions.push(Contributions.GROSS_REVENUE);
                return categoryContributions;
            default:
                return [];
        }
    }
    contributorsFromTagNamespace(namespace) {
        const categoryContributions = [];
        switch (namespace) {
            case TagNamespace.EXPENSE:
                categoryContributions.push(Contributions.NET_PROFIT);
                categoryContributions.push(Contributions.NET_MARGIN);
                categoryContributions.push(Contributions.EXTERNAL_EXPENSES);
                return categoryContributions;
            case TagNamespace.ORDER:
                categoryContributions.push(Contributions.SALE_NET_PROFIT);
                return categoryContributions;
            case TagNamespace.ADVERTISING:
                categoryContributions.push(Contributions.ADV_COST);
                return categoryContributions;
            case TagNamespace.COGS:
                categoryContributions.push(Contributions.SALE_NET_PROFIT);
                categoryContributions.push(Contributions.GROSS_PROFIT);
                categoryContributions.push(Contributions.NET_PROFIT);
                categoryContributions.push(Contributions.GROSS_MARGIN);
                categoryContributions.push(Contributions.NET_MARGIN);
                categoryContributions.push(Contributions.COGS);
                return categoryContributions;
            case TagNamespace.OPERATION:
                categoryContributions.push(Contributions.OPERATIONS);
                return categoryContributions;
            default:
                return [];
        }
    }
    contributorsFromTagDiscriminator(tag) {
        if (tag.discriminator() != TagDiscriminator.VAT) {
            return [];
        }
        if (tag.getCategory() == TagCategory.SALE) {
            return [Contributions.TAX_OUT];
        }
        return [Contributions.TAX_IN];
    }
}
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Tag] })
], FinancialEntryType.prototype, "tag", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [String]] })
], FinancialEntryType.prototype, "contributesTo", void 0);
//# sourceMappingURL=financial_entry_type.js.map