(function () {
    BemsWebApplication.FmsBudgetCodeClassViewModel = function (data) {
        this.SiteId = ko.observable();
        this.BudgetClassId = ko.observable();
        this.RootBudgetClassId = ko.observable();
        this.ParentBudgetClassId = ko.observable();

        this.RootBudgetName = ko.observable();
        this.ParentBudgetName = ko.observable();

        this.Depth = ko.observable();
        this.Name = ko.observable();
        this.Abbreviation = ko.observable();
        this.IsUse = ko.observable();
        this.BudgetSeq = ko.observable();
        this.YearlyBudget = ko.observable();
        this.MonthlyBudget = ko.observable();

        if (data)
            this.fromJS(data);
    };

    $.extend(BemsWebApplication.FmsBudgetCodeClassViewModel.prototype, {
        toJS: function () {
            return {
                SiteId: this.SiteId(),
                BudgetClassId: this.BudgetClassId(),

                RootBudgetClassId: this.RootBudgetClassId(),
                ParentBudgetClassId: this.ParentBudgetClassId(),

                RootBudgetName: this.RootBudgetName(),
                ParentBudgetName: this.ParentBudgetName(),

                Depth: this.Depth(),
                Name: this.Name(),
                Abbreviation: this.Abbreviation(),
                IsUse: this.IsUse(),
                BudgetSeq: this.BudgetSeq(),

                YearlyBudget: this.YearlyBudget(),
                MonthlyBudget: this.MonthlyBudget(),
            };
        },

        fromJS: function (data) {
            if (data) {
                this.SiteId(data.SiteId);
                this.BudgetClassId(data.BudgetClassId);
                
                this.RootBudgetClassId(data.RootBudgetClassId);
                this.ParentBudgetClassId(data.ParentBudgetClassId);

                this.RootBudgetName(data.RootBudgetName);
                this.ParentBudgetName(data.ParentBudgetName);

                this.Depth(data.Depth);
                this.Name(data.Name);
                this.Abbreviation(data.Abbreviation);
                this.IsUse(data.IsUse);
                this.BudgetSeq(data.BudgetSeq);
                this.YearlyBudget(data.YearlyBudget);
                this.MonthlyBudget(data.MonthlyBudget);

            }
        }
    });
})();