var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var F02300;
(function (F02300) {
    var InterfaceRules = (function (_super) {
        __extends(InterfaceRules, _super);
        function InterfaceRules() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        InterfaceRules.prototype.CalcYearCaption = function (year) {
            if (year < this.Document.Settings.StartYear) {
                return "\u0432 " + year + " \u0433\u043E\u0434\u0443";
            }
            else {
                return "\u043D\u0430 " + year + " \u0433\u043E\u0434";
            }
        };
        InterfaceRules.prototype.RecalcCoefficients = function () {
            var table = this.Document.P2Sp1DataTable;
            if (table.LocateByKeys(table.GetKeys(P2Sp1RowsKeys.C0110).ToArray())) {
                table.UpdateExpensesVolume();
            }
            if (table.LocateByKeys(table.GetKeys(P2Sp1RowsKeys.C0120).ToArray())) {
                table.UpdateExpensesVolume();
            }
        };
        InterfaceRules.prototype.ObjectDescSheetFormatEventHandler = function (sheetId, row, column, groupIndex) {
            switch (column) {
                case 0:
                case 1:
                case 2:
                    return SheetFormatCollection.Related;
                case 8:
                    return SheetFormatCollection.Default;
                case 9:
                case 13:
                    return SheetFormatCollection.Spr;
                default:
                    return SheetFormatCollection.Free;
            }
        };
        InterfaceRules.prototype.ObjectDescSheetCalcEventHandler = function (sheetId, row, column, fieldId) {
            if (BaseObasTableFields.StrCodeField.Equal(fieldId)) {
                return ObasHelper.FillWithCharacter(row + 1, 6);
            }
            return undefined;
        };
        InterfaceRules.prototype.ObjectDescSheetCanAddEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return column > 7;
        };
        InterfaceRules.prototype.ObjectDescSheetCanEditEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            var table = this._document.Sheets.getValue(sheetId).Table;
            if (column > 7) {
                return table.GetKeyBySourceTable(this._document.P6RefObjDescNpaTable) != null;
            }
            else {
                return table.GetKeyBySourceTable(this._document.P6RefObjDescNpaTable.ParentTable) != null;
            }
        };
        InterfaceRules.prototype.ObjectDescSheetCanDeleteEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            var table = this._document.Sheets.getValue(sheetId).Table;
            if (column > 7) {
                return table.GetKeyBySourceTable(this._document.P6RefObjDescNpaTable) != null;
            }
            else {
                return false;
            }
        };
        InterfaceRules.prototype.FilterOKPD = function () {
            var okpdCode = ObasTableCollection.OkpdSprTable.Code.Value || "";
            return okpdCode.length >= 5;
        };
        InterfaceRules.prototype.FilterKosgu = function () {
            var kosguCode = ObasTableCollection.KosguSprTable.Code.Value || "";
            var analyticsDataTable = this._document.AnalyticsDataTable;
            return analyticsDataTable.Locate(analyticsDataTable.AnalyticCode.Id, kosguCode);
        };
        InterfaceRules.prototype.FilterNPAStatuses = function () {
            var npaStatusesTable = ObasTableCollection.NpaStatusesSprTable;
            return npaStatusesTable.RecordKey.Value === 1 || npaStatusesTable.RecordKey.Value === 2;
        };
        InterfaceRules.RowCodeColumn = 1;
        return InterfaceRules;
    }(BaseInterfaceRules));
    F02300.InterfaceRules = InterfaceRules;
    var P1Sheet = (function (_super) {
        __extends(P1Sheet, _super);
        function P1Sheet(id, document) {
            return _super.call(this, id, document, InterfaceRules.RowCodeColumn) || this;
        }
        P1Sheet.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            switch (column) {
                case this.RowNameColumn:
                case this.RowCodeColumn:
                    return SheetFormatCollection.Default;
                default:
                    if (row === 0) {
                        return SheetFormatCollection.Calc;
                    }
                    else if (row === this.RowCount - 1) {
                        return SheetFormatCollection.Free;
                    }
                    else {
                        return SheetFormatCollection.Related;
                    }
            }
        };
        P1Sheet.prototype.EditingCellEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return (column > this.RowCodeColumn) && (row === this.RowCount - 1);
        };
        return P1Sheet;
    }(YearsSheetTyped));
    F02300.P1Sheet = P1Sheet;
    var NpaSheetColumns;
    (function (NpaSheetColumns) {
        NpaSheetColumns[NpaSheetColumns["NpaType"] = 0] = "NpaType";
        NpaSheetColumns[NpaSheetColumns["NpaDate"] = 1] = "NpaDate";
        NpaSheetColumns[NpaSheetColumns["NpaNumber"] = 2] = "NpaNumber";
        NpaSheetColumns[NpaSheetColumns["NpaName"] = 3] = "NpaName";
        NpaSheetColumns[NpaSheetColumns["NpaStatus"] = 4] = "NpaStatus";
        NpaSheetColumns[NpaSheetColumns["NpaChangeDate"] = 5] = "NpaChangeDate";
    })(NpaSheetColumns || (NpaSheetColumns = {}));
    var NpaSheet = (function (_super) {
        __extends(NpaSheet, _super);
        function NpaSheet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        NpaSheet.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            switch (column) {
                case NpaSheetColumns.NpaType:
                case NpaSheetColumns.NpaStatus:
                    return SheetFormatCollection.Spr;
                default:
                    return SheetFormatCollection.Free;
            }
        };
        return NpaSheet;
    }(Sheet));
    F02300.NpaSheet = NpaSheet;
    var IndexationSheet = (function (_super) {
        __extends(IndexationSheet, _super);
        function IndexationSheet(id, _document) {
            var _this = _super.call(this, id, true) || this;
            _this._document = _document;
            return _this;
        }
        IndexationSheet.prototype.GetFieldRangeEventHandler = function (sheetId) {
            if (sheetId === void 0) { sheetId = ""; }
            return this._document.CommonRules.GetDollarRateYearsFieldRangeEventHandler(sheetId, this._document.FullYearsCount);
        };
        IndexationSheet.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            return SheetFormatCollection.Free;
        };
        IndexationSheet.prototype.GetYearsCaptionEventHandler = function (tableId, index, defaultCaption, fieldCaption) {
            return (this._document.InitYear + index).toString();
        };
        return IndexationSheet;
    }(Sheet));
    F02300.IndexationSheet = IndexationSheet;
    var P2InfoSheet = (function (_super) {
        __extends(P2InfoSheet, _super);
        function P2InfoSheet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        P2InfoSheet.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            return SheetFormatCollection.Free;
        };
        return P2InfoSheet;
    }(Sheet));
    F02300.P2InfoSheet = P2InfoSheet;
    var BaseExpenseInfoSheet = (function (_super) {
        __extends(BaseExpenseInfoSheet, _super);
        function BaseExpenseInfoSheet(id, document, _rowsTable) {
            var _this = _super.call(this, id, document, InterfaceRules.RowCodeColumn) || this;
            _this._rowsTable = _rowsTable;
            _this._agrKeys = null;
            _this.InitAgrKeys();
            return _this;
        }
        Object.defineProperty(BaseExpenseInfoSheet.prototype, "RowsTable", {
            get: function () {
                return this._rowsTable;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BaseExpenseInfoSheet.prototype, "AgrKeys", {
            get: function () {
                if (this._agrKeys == null) {
                    this.InitAgrKeys();
                }
                return this._agrKeys;
            },
            enumerable: true,
            configurable: true
        });
        BaseExpenseInfoSheet.prototype.InitAgrKeys = function () {
            var _this = this;
            if (this._agrKeys == null) {
                this._agrKeys = [];
                var rowsTable_1 = this.RowsTable;
                var rowIndex_1 = 0;
                var callback = function () {
                    if (rowsTable_1.IsAgr.Value) {
                        _this._agrKeys.push(rowIndex_1);
                    }
                    rowIndex_1++;
                };
                rowsTable_1.Iterate(callback, true);
                if (this._agrKeys.length === 0) {
                    this._agrKeys = null;
                }
            }
        };
        BaseExpenseInfoSheet.prototype.IsAgrRow = function (row) {
            return this.AgrKeys.indexOf(row) > -1;
        };
        return BaseExpenseInfoSheet;
    }(YearsSheetTyped));
    var P2Sp1SheetColumns;
    (function (P2Sp1SheetColumns) {
        P2Sp1SheetColumns[P2Sp1SheetColumns["RowName"] = 0] = "RowName";
        P2Sp1SheetColumns[P2Sp1SheetColumns["RowCode"] = 1] = "RowCode";
        P2Sp1SheetColumns[P2Sp1SheetColumns["CountP2"] = 2] = "CountP2";
        P2Sp1SheetColumns[P2Sp1SheetColumns["PaymentP2Third"] = 3] = "PaymentP2Third";
        P2Sp1SheetColumns[P2Sp1SheetColumns["PaymentP2Second"] = 4] = "PaymentP2Second";
        P2Sp1SheetColumns[P2Sp1SheetColumns["PaymentP2Next"] = 5] = "PaymentP2Next";
        P2Sp1SheetColumns[P2Sp1SheetColumns["CountP1"] = 6] = "CountP1";
        P2Sp1SheetColumns[P2Sp1SheetColumns["PaymentP1Second"] = 7] = "PaymentP1Second";
        P2Sp1SheetColumns[P2Sp1SheetColumns["PaymentP1Next"] = 8] = "PaymentP1Next";
        P2Sp1SheetColumns[P2Sp1SheetColumns["CountP0"] = 9] = "CountP0";
        P2Sp1SheetColumns[P2Sp1SheetColumns["PaymentP0Next"] = 10] = "PaymentP0Next";
    })(P2Sp1SheetColumns || (P2Sp1SheetColumns = {}));
    var P2Sp1Sheet = (function (_super) {
        __extends(P2Sp1Sheet, _super);
        function P2Sp1Sheet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        P2Sp1Sheet.prototype.IsCountColumn = function (column) {
            var columnName = P2Sp1SheetColumns[column];
            return columnName != null && columnName.indexOf("Count") > -1;
        };
        P2Sp1Sheet.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            switch (column) {
                case P2Sp1SheetColumns.RowName:
                case P2Sp1SheetColumns.RowCode:
                    return SheetFormatCollection.Default;
                default:
                    if (this.IsFooterRow(row)) {
                        return SheetFormatCollection.Calc;
                    }
                    else if (this.IsAgrRow(row)) {
                        if (this.IsCountColumn(column)) {
                            return SheetFormatCollection.Free;
                        }
                        else {
                            return SheetFormatCollection.Calc;
                        }
                    }
                    else {
                        if (this.IsCountColumn(column)) {
                            return SheetFormatCollection.Default;
                        }
                        else {
                            return SheetFormatCollection.Free;
                        }
                    }
            }
        };
        P2Sp1Sheet.prototype.CalcEventHandler = function (sheetId, row, column, fieldId) {
            if (!this.IsAgrRow(row) && this.IsCountColumn(column)) {
                return ObasHelper.X;
            }
            return undefined;
        };
        P2Sp1Sheet.prototype.EditingCellEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return !this.IsAgrRow(row) || this.IsCountColumn(column) && !this.IsFooterRow(row);
        };
        P2Sp1Sheet.prototype.GetThirdPrevYearsFieldRangeEventHandler = function (sheetId) {
            if (sheetId === void 0) { sheetId = ""; }
            return ["P3", "P2", "P1"];
        };
        P2Sp1Sheet.prototype.GetSecondPrevYearsFieldRangeEventHandler = function (sheetId) {
            if (sheetId === void 0) { sheetId = ""; }
            return ["P2", "P1"];
        };
        P2Sp1Sheet.prototype.GetEmptyFieldRangeEventHandler = function (sheetId) {
            if (sheetId === void 0) { sheetId = ""; }
            return [""];
        };
        P2Sp1Sheet.prototype.CreateCaptionEventHandler = function (sheetId, oldText) {
            var sheetYear = this.Document.CurYear;
            oldText = oldText.replace(DocumentSettings.YearSign, sheetYear.toString());
            return oldText;
        };
        P2Sp1Sheet.prototype.GetSecondPrevColumnsYearCaptionEventHandler = function (tableId, index, defaultCaption, fieldCaption) {
            return this.GetYearsCaptionEventHandler(tableId, index + 1, defaultCaption, fieldCaption);
        };
        P2Sp1Sheet.prototype.GetYearsCaptionEventHandler = function (tableId, index, defaultCaption, fieldCaption) {
            return (this.Document.InitYear + index).toString();
        };
        P2Sp1Sheet.prototype.GetThirdPrevYearCaptionEventHandler = function () {
            return this.GetYearsCaptionEventHandler(null, 0, null, null);
        };
        P2Sp1Sheet.prototype.GetSecondPrevYearCaptionEventHandler = function () {
            return this.GetYearsCaptionEventHandler(null, 1, null, null);
        };
        P2Sp1Sheet.prototype.GetNextPrevYearCaptionEventHandler = function () {
            return this.GetYearsCaptionEventHandler(null, 2, null, null);
        };
        return P2Sp1Sheet;
    }(BaseExpenseInfoSheet));
    F02300.P2Sp1Sheet = P2Sp1Sheet;
    var P2Sp2SheetColumnBlocks;
    (function (P2Sp2SheetColumnBlocks) {
        P2Sp2SheetColumnBlocks[P2Sp2SheetColumnBlocks["PlannedCount"] = 0] = "PlannedCount";
        P2Sp2SheetColumnBlocks[P2Sp2SheetColumnBlocks["StandardExpens"] = 1] = "StandardExpens";
        P2Sp2SheetColumnBlocks[P2Sp2SheetColumnBlocks["PlannedDeviation"] = 2] = "PlannedDeviation";
        P2Sp2SheetColumnBlocks[P2Sp2SheetColumnBlocks["PlannedExpens"] = 3] = "PlannedExpens";
    })(P2Sp2SheetColumnBlocks || (P2Sp2SheetColumnBlocks = {}));
    var P2Sp2Sheet = (function (_super) {
        __extends(P2Sp2Sheet, _super);
        function P2Sp2Sheet(id, document) {
            return _super.call(this, id, document, InterfaceRules.RowCodeColumn) || this;
        }
        P2Sp2Sheet.prototype.IsCalcColumn = function (column) {
            return this.IsColumnInDataBlock(column, P2Sp2SheetColumnBlocks.StandardExpens) ||
                this.IsColumnInDataBlock(column, P2Sp2SheetColumnBlocks.PlannedExpens);
        };
        P2Sp2Sheet.prototype.IsDeviationColumn = function (column) {
            return this.IsColumnInDataBlock(column, P2Sp2SheetColumnBlocks.PlannedDeviation);
        };
        Object.defineProperty(P2Sp2Sheet.prototype, "YearsCount", {
            get: function () {
                return this.Document.Settings.YearsCount;
            },
            enumerable: true,
            configurable: true
        });
        P2Sp2Sheet.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            switch (column) {
                case this.RowNameColumn:
                case this.RowCodeColumn:
                    return SheetFormatCollection.Default;
                default:
                    if (this.IsFooterRow(row)) {
                        if (this.IsDeviationColumn(column)) {
                            return SheetFormatCollection.Default;
                        }
                        else {
                            return SheetFormatCollection.Calc;
                        }
                    }
                    else if (this.IsCalcColumn(column)) {
                        return SheetFormatCollection.Calc;
                    }
                    else {
                        return SheetFormatCollection.Free;
                    }
            }
        };
        P2Sp2Sheet.prototype.CalcEventHandler = function (sheetId, row, column, fieldId) {
            if (this.IsFooterRow(row) && this.IsDeviationColumn(column)) {
                return ObasHelper.X;
            }
            return undefined;
        };
        P2Sp2Sheet.prototype.EditingCellEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return !(this.IsFooterRow(row) || this.IsCalcColumn(column));
        };
        P2Sp2Sheet.prototype.EditCellEventHandler = function (sheetId, row, column, fieldId, rowLevel, oldValue, newValue) {
            var message = null;
            if (this.IsDeviationColumn(column)) {
                if (Math.abs(newValue) > P2Sp2Sheet._deviationBound) {
                    message = "\u041F\u0440\u043E\u0433\u043D\u043E\u0437\u0438\u0440\u0443\u0435\u043C\u043E\u0435 \u043E\u0442\u043A\u043B\u043E\u043D\u0435\u043D\u0438\u0435 \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0442\u044C " + P2Sp2Sheet._deviationBound + "% \u043F\u043E \u043C\u043E\u0434\u0443\u043B\u044E!";
                }
            }
            if (message) {
                Client.ShowMessage("Ошибка", message, MessageIcons.Error);
                return false;
            }
            else {
                return true;
            }
        };
        P2Sp2Sheet.prototype.GetYearsCaptionEventHandler = function (tableId, index, defaultCaption, fieldCaption) {
            return (this.Document.Settings.StartYear + index).toString();
        };
        P2Sp2Sheet.prototype.GetYearsFieldRangeEventHandler = function (sheetId, yearsCount) {
            if (sheetId === void 0) { sheetId = ""; }
            if (yearsCount === void 0) { yearsCount = this.Document.Settings.YearsCount; }
            var result = [];
            for (var i = 1; i <= yearsCount; i++) {
                result.push(i);
            }
            return result;
        };
        P2Sp2Sheet._deviationBound = 10;
        return P2Sp2Sheet;
    }(YearsSheetTyped));
    F02300.P2Sp2Sheet = P2Sp2Sheet;
    var ExpenseInfoSheetColumnsBlocks;
    (function (ExpenseInfoSheetColumnsBlocks) {
        ExpenseInfoSheetColumnsBlocks[ExpenseInfoSheetColumnsBlocks["Count"] = 0] = "Count";
        ExpenseInfoSheetColumnsBlocks[ExpenseInfoSheetColumnsBlocks["Insurance"] = 1] = "Insurance";
        ExpenseInfoSheetColumnsBlocks[ExpenseInfoSheetColumnsBlocks["Payment"] = 2] = "Payment";
        ExpenseInfoSheetColumnsBlocks[ExpenseInfoSheetColumnsBlocks["Salary"] = 3] = "Salary";
    })(ExpenseInfoSheetColumnsBlocks || (ExpenseInfoSheetColumnsBlocks = {}));
    var ExpenseInfoSheet = (function (_super) {
        __extends(ExpenseInfoSheet, _super);
        function ExpenseInfoSheet() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this._paymentEndColumn = null;
            _this._paymentStartCalcColumn = null;
            return _this;
        }
        Object.defineProperty(ExpenseInfoSheet.prototype, "PaymentStartCalcColumn", {
            get: function () {
                if (this._paymentStartCalcColumn == null) {
                    this._paymentStartCalcColumn = this.PaymentEndColumn - this.YearsCount / 2;
                }
                return this._paymentStartCalcColumn;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ExpenseInfoSheet.prototype, "PaymentEndColumn", {
            get: function () {
                if (this._paymentEndColumn == null) {
                    this._paymentEndColumn = this.CalcEndBlockColumn(ExpenseInfoSheetColumnsBlocks.Payment);
                }
                return this._paymentEndColumn;
            },
            enumerable: true,
            configurable: true
        });
        ExpenseInfoSheet.prototype.GetYearsCaptionEventHandler = function (tableId, index, defaultCaption, fieldCaption) {
            var year = this.Document.InitYear + index;
            if (year >= this.Document.CurYear) {
                year++;
            }
            return this.Document.InterfaceRules.CalcYearCaption(year);
        };
        ExpenseInfoSheet.prototype.GetYearsFieldRangeEventHandler = function (sheetId, yearsCount) {
            if (sheetId === void 0) { sheetId = ""; }
            if (yearsCount === void 0) { yearsCount = this.Document.FullYearsCount; }
            var result = [];
            var addYearsCount = this.Document.AddYearsCount;
            for (var i = 1; i <= yearsCount; i++) {
                var index = i - addYearsCount;
                if (index === 0) {
                    continue;
                }
                else {
                    if (i < addYearsCount) {
                        result.push("P" + Math.abs(index));
                    }
                    else {
                        result.push(index);
                    }
                }
            }
            return result;
        };
        Object.defineProperty(ExpenseInfoSheet.prototype, "YearsCount", {
            get: function () {
                return this.Document.FullYearsCount - 1;
            },
            enumerable: true,
            configurable: true
        });
        ;
        ExpenseInfoSheet.prototype.IsXColumn = function (column) {
            return this.IsColumnInDataBlock(column, ExpenseInfoSheetColumnsBlocks.Count) ||
                this.IsColumnInDataBlock(column, ExpenseInfoSheetColumnsBlocks.Salary);
        };
        ExpenseInfoSheet.prototype.IsCalcPaymentColumn = function (column) {
            return column > this.PaymentStartCalcColumn && column <= this.PaymentEndColumn;
        };
        ExpenseInfoSheet.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            switch (column) {
                case this.RowNameColumn:
                case this.RowCodeColumn:
                case this.ColumnCount - 1:
                    return SheetFormatCollection.Default;
                default:
                    if (row === 0) {
                        if (this.IsXColumn(column)) {
                            return SheetFormatCollection.Free;
                        }
                        else {
                            return SheetFormatCollection.Calc;
                        }
                    }
                    else {
                        if (this.IsXColumn(column)) {
                            return SheetFormatCollection.Default;
                        }
                        else {
                            if (this.IsCalcPaymentColumn(column)) {
                                return SheetFormatCollection.Calc;
                            }
                            else {
                                return SheetFormatCollection.Free;
                            }
                        }
                    }
            }
        };
        ExpenseInfoSheet.prototype.CalcEventHandler = function (sheetId, row, column, fieldId) {
            var isAgrRow = this.IsAgrRow(row);
            if ((!isAgrRow && this.IsXColumn(column)) || (isAgrRow && column === (this.ColumnCount - 1))) {
                return ObasHelper.X;
            }
            return undefined;
        };
        ExpenseInfoSheet.prototype.EditingCellEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            var isReadonlyColumn = this.IsCalcPaymentColumn(column) || this.IsAgrRow(row) && !this.IsXColumn(column);
            return !isReadonlyColumn;
        };
        return ExpenseInfoSheet;
    }(BaseExpenseInfoSheet));
    F02300.ExpenseInfoSheet = ExpenseInfoSheet;
    var ExpenseSheet = (function (_super) {
        __extends(ExpenseSheet, _super);
        function ExpenseSheet(id, document) {
            return _super.call(this, id, document, InterfaceRules.RowCodeColumn) || this;
        }
        ExpenseSheet.prototype.IsPlanColumn = function (column) {
            return column >= this.ColumnCount - 3;
        };
        ExpenseSheet.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            switch (column) {
                case this.RowNameColumn:
                case this.RowCodeColumn:
                    return SheetFormatCollection.Default;
                default:
                    if (this.IsPlanColumn(column)) {
                        if (this.IsFooterRow(row)) {
                            return SheetFormatCollection.Related;
                        }
                        else {
                            return SheetFormatCollection.Default;
                        }
                    }
                    else {
                        return SheetFormatCollection.Free;
                    }
            }
        };
        ExpenseSheet.prototype.CalcEventHandler = function (sheetId, row, column, fieldId) {
            if (!this.IsFooterRow(row) && this.IsPlanColumn(column)) {
                return ObasHelper.X;
            }
            return undefined;
        };
        ExpenseSheet.prototype.GetYearsCaptionEventHandler = function (tableId, index, defaultCaption, fieldCaption) {
            var year = this.Document.InitYear + index;
            return this.Document.InterfaceRules.CalcYearCaption(year);
        };
        ExpenseSheet.prototype.GetYearsFieldRangeEventHandler = function (sheetId, yearsCount) {
            if (sheetId === void 0) { sheetId = ""; }
            if (yearsCount === void 0) { yearsCount = this.Document.FullYearsCount; }
            var result = [];
            var addYearsCount = this.Document.AddYearsCount;
            for (var i = 1; i <= yearsCount; i++) {
                var index = i - addYearsCount;
                if (i < addYearsCount) {
                    result.push("P" + Math.abs(index));
                }
                else {
                    result.push(index);
                }
            }
            return result;
        };
        ExpenseSheet.prototype.EditingCellEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return this.IsDataColumn(column) && !this.IsPlanColumn(column);
        };
        return ExpenseSheet;
    }(YearsSheetTyped));
    F02300.ExpenseSheet = ExpenseSheet;
})(F02300 || (F02300 = {}));
