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 F01280;
(function (F01280) {
    var ObasTableFields = (function (_super) {
        __extends(ObasTableFields, _super);
        function ObasTableFields() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        Object.defineProperty(ObasTableFields, "FotRubYearDataField", {
            get: function () {
                if (this._fotRubYearDataField == null) {
                    this._fotRubYearDataField = new BaseGenericObasTableField("Fot_Rub_Y");
                }
                return this._fotRubYearDataField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableFields, "FotUsdYearDataField", {
            get: function () {
                if (this._fotUsdYearDataField == null) {
                    this._fotUsdYearDataField = new BaseGenericObasTableField("Fot_Usd_Y");
                }
                return this._fotUsdYearDataField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableFields, "OtherRubField", {
            get: function () {
                if (this._otherRubField == null) {
                    this._otherRubField = new BaseGenericObasTableField("Other_Rub_Y");
                }
                return this._otherRubField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableFields, "PayYearDataField", {
            get: function () {
                if (this._payYearDataField == null) {
                    this._payYearDataField = new BaseGenericObasTableField("Pay_Y");
                }
                return this._payYearDataField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableFields, "CopiedRubRowFlagField", {
            get: function () {
                if (this._copiedRubRowFlagField == null) {
                    this._copiedRubRowFlagField = new BaseObasTableField("IsCopiedRub", false);
                }
                return this._copiedRubRowFlagField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableFields, "CopiedUsdRowFlagField", {
            get: function () {
                if (this._copiedUsdRowFlagField == null) {
                    this._copiedUsdRowFlagField = new BaseObasTableField("IsCopiedUsd", false);
                }
                return this._copiedUsdRowFlagField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableFields, "PositionField", {
            get: function () {
                if (this._positionField == null) {
                    this._positionField = new BaseObasTableField("Position_ID", false);
                }
                return this._positionField;
            },
            enumerable: true,
            configurable: true
        });
        return ObasTableFields;
    }(BaseObasTableFields));
    ObasTableFields._fotUsdYearDataField = null;
    ObasTableFields._fotRubYearDataField = null;
    ObasTableFields._otherRubField = null;
    ObasTableFields._positionField = null;
    ObasTableFields._copiedUsdRowFlagField = null;
    ObasTableFields._copiedRubRowFlagField = null;
    ObasTableFields._payYearDataField = null;
    F01280.ObasTableFields = ObasTableFields;
    var TableRules = (function () {
        function TableRules(document) {
            this._document = document;
        }
        TableRules.prototype.SumChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var table = this._document.Tables.getValue(tableId);
            if (!table.GetFieldValue(BaseObasTableFields.CalcRowFlagField.Id)) {
                var yearOffset = ObasHelper.GetYearOffsetById(fieldId) + 1;
                var destTable = this._document.TableP1;
                this._document.CommonRules.SetSumByKeys(destTable, destTable.KeyFieldIds, [6, 0], "" + ObasTableFields.InsuranceYearDataField.Id + yearOffset, oldValue, newValue);
            }
        };
        return TableRules;
    }());
    F01280.TableRules = TableRules;
    var ObasTablePXSp1 = (function (_super) {
        __extends(ObasTablePXSp1, _super);
        function ObasTablePXSp1() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        ObasTablePXSp1.prototype.SumChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var strKey = this.StrKey;
            switch (strKey) {
                case StrKeysPXSp1.Calced:
                case StrKeysPXSp1.Changed:
                    this.Document.CommonRules.SetSumByKeys(this.ParentTable, this.ParentTable.KeyFieldIds, [strKey], fieldId, oldValue, newValue);
            }
        };
        ObasTablePXSp1.prototype.AfterDeleteChildsEventHandler = function (tableId) {
            var _this = this;
            var changeData = function (fieldId) {
                _this.SumChangeEventHandler(_this.Id, _this.GetFieldValue(fieldId), 0, fieldId);
            };
            for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                changeData("" + ObasTableFields.FotUsdYearDataField.Id + i);
                changeData("" + ObasTableFields.FotRubYearDataField.Id + i);
                changeData("" + ObasTableFields.InsuranceYearDataField.Id + i);
            }
        };
        ObasTablePXSp1.prototype.IsUserEditRow = function (strKey) {
            if (strKey === void 0) { strKey = this.StrKey; }
            return strKey === StrKeysPXSp1.Changed;
        };
        ObasTablePXSp1.prototype.CopyData = function (srcYear, destYear) {
            var _this = this;
            var srcIndex = srcYear ? srcYear - ObasStageSettings.CurrentYear + 1 : ObasStageSettings.YearsCount - 1;
            var destIndex = destYear ? destYear - ObasStageSettings.CurrentYear + 1 : ObasStageSettings.YearsCount;
            var yearRubField = ObasTableFields.FotRubYearDataField;
            var srcRubFieldId = yearRubField.GenerateId(srcIndex);
            var destRubFieldId = yearRubField.GenerateId(destIndex);
            var insField = BaseObasTableFields.InsuranceYearDataField;
            var insSrcFieldId = insField.GenerateId(srcIndex);
            var insDestFieldId = insField.GenerateId(destIndex);
            var copy = function () {
                if (_this.IsUserEditRow()) {
                    _this.SetFieldValue(destRubFieldId, _this.GetFieldValue(srcRubFieldId));
                    _this.SetFieldValue(insDestFieldId, _this.GetFieldValue(insSrcFieldId));
                }
            };
            this.Iterate(copy);
        };
        ObasTablePXSp1.prototype.InitCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            result.setValue(this.OrgKeyField.Id, {
                Id: this.OrgKeyField.Id,
                IsData: false
            });
            result.setValue(this.StrKeyField.Id, {
                Id: this.StrKeyField.Id,
                IsData: false
            });
            var fotField = ObasTableFields.FotRubYearDataField;
            var insField = BaseObasTableFields.InsuranceYearDataField;
            for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                var fieldId = fotField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
                fieldId = insField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
            }
            return result;
        };
        ObasTablePXSp1.prototype.CollectUserData = function () {
            var _this = this;
            var filter = function () {
                return _this.IsUserEditRow();
            };
            return this.CollectTableData(this.InitCopyFieldsInfo(), filter);
        };
        ObasTablePXSp1.prototype.ResetData = function (keys) {
            var _this = this;
            var yearField = BaseObasTableFields.YearDataField;
            var yearFotField = BaseObasTableFields.FotYearDataField;
            var yearUsdFotField = ObasTableFields.FotUsdYearDataField;
            var yearRubFotField = ObasTableFields.FotRubYearDataField;
            var yearInsField = BaseObasTableFields.InsuranceYearDataField;
            var resetDataHandler = function () {
                for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                    _this.SetFieldValue(yearUsdFotField.GenerateId(i), 0);
                    _this.SetFieldValue(yearRubFotField.GenerateId(i), 0);
                    _this.SetFieldValue(yearFotField.GenerateId(i), 0);
                    _this.SetFieldValue(yearInsField.GenerateId(i), 0);
                    _this.SetFieldValue(yearField.GenerateId(i), 0);
                }
            };
            if (keys) {
                if (this.LocateByKeys(keys.ToArray())) {
                    resetDataHandler();
                }
            }
            else {
                this.Iterate(resetDataHandler);
            }
        };
        return ObasTablePXSp1;
    }(ObasTableWithOrgStrKeysParent));
    F01280.ObasTablePXSp1 = ObasTablePXSp1;
    var StrKeysP1Total;
    (function (StrKeysP1Total) {
        StrKeysP1Total[StrKeysP1Total["P2"] = 2] = "P2";
        StrKeysP1Total[StrKeysP1Total["P3"] = 3] = "P3";
        StrKeysP1Total[StrKeysP1Total["P4"] = 4] = "P4";
        StrKeysP1Total[StrKeysP1Total["P5"] = 5] = "P5";
        StrKeysP1Total[StrKeysP1Total["OtherIns"] = 6] = "OtherIns";
        StrKeysP1Total[StrKeysP1Total["Correction"] = 8] = "Correction";
        StrKeysP1Total[StrKeysP1Total["Total"] = 1] = "Total";
    })(StrKeysP1Total = F01280.StrKeysP1Total || (F01280.StrKeysP1Total = {}));
    var ObasTableP1 = (function (_super) {
        __extends(ObasTableP1, _super);
        function ObasTableP1(id, document) {
            var _this = _super.call(this, id, document) || this;
            _this._correctionData = null;
            return _this;
        }
        ObasTableP1.prototype.GetTotalKey = function () {
            return StrKeysP1Total.Total;
        };
        ObasTableP1.prototype.GetInsuranceKey = function () {
            return StrKeysP1Total.OtherIns;
        };
        ObasTableP1.prototype.P1PartsChangeEventHandler = function (tableId, oldValue, newValue, fieldId, fields) {
            var yearOffset = ObasHelper.GetYearOffsetById(fieldId) + 1;
            this.SumChangeEventHandler(tableId, oldValue, newValue, fieldId, true);
            this.SetFieldValue("" + fields.DestFieldId + yearOffset, this.GetFieldValue("" + fields.Field1Id + yearOffset) +
                this.GetFieldValue("" + fields.Field2Id + yearOffset));
        };
        ObasTableP1.prototype.P1SumPartsChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.P1PartsChangeEventHandler(tableId, oldValue, newValue, fieldId, {
                DestFieldId: ObasTableFields.YearDataField.Id,
                Field1Id: ObasTableFields.FotYearDataField.Id,
                Field2Id: ObasTableFields.InsuranceYearDataField.Id
            });
        };
        ObasTableP1.prototype.P1FotSumPartsChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.P1PartsChangeEventHandler(tableId, oldValue, newValue, fieldId, {
                DestFieldId: ObasTableFields.FotYearDataField.Id,
                Field1Id: ObasTableFields.FotUsdYearDataField.Id,
                Field2Id: ObasTableFields.FotRubYearDataField.Id
            });
        };
        ObasTableP1.prototype.SumChangeEventHandler = function (tableId, oldValue, newValue, fieldId, restorePosition) {
            if (restorePosition === void 0) { restorePosition = false; }
            var restoreKeys = null;
            if (this.StrKey === 100) {
                if ((fieldId.indexOf("Fot_Usd") > -1 || fieldId.indexOf("Fot_Rub") > -1 || fieldId.indexOf("Ins") > -1) &&
                    (this.GetFieldValue(fieldId) < -100 || this.GetFieldValue(fieldId) > 100)) {
                    Client.ShowMessage("\u041E\u0448\u0438\u0431\u043A\u0430", "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043B\u044F \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u044C\u0441\u044F \u0432 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435 \u043E\u0442 -100 \u0434\u043E 100.", MessageIcons.Error);
                    this.SetFieldValue(fieldId, oldValue);
                }
            }
            if (restorePosition) {
                restoreKeys = this.KeyFieldValues;
            }
            if (!this.IsTotal &&
                !ObasTableFields.FotYearDataField.Equal(fieldId) &&
                (!ObasTableFields.YearDataField.Equal(fieldId) ||
                    this.StrKey === StrKeysP1Total.Correction)) {
                this.SetSumByKeys(fieldId, this.GetKeys(StrKeysP1Total.Total), oldValue, newValue);
            }
            this.Document.CommonRules.TotalSumTableEditNotify(this, fieldId);
            if (restoreKeys != null) {
                this.LocateByKeys(restoreKeys);
            }
        };
        ObasTableP1.prototype.ResetData = function (keys) {
            var _this = this;
            var yearField = BaseObasTableFields.YearDataField;
            var yearFotField = BaseObasTableFields.FotYearDataField;
            var yearUsdFotField = ObasTableFields.FotUsdYearDataField;
            var yearRubFotField = ObasTableFields.FotRubYearDataField;
            var yearInsField = BaseObasTableFields.InsuranceYearDataField;
            var resetDataHandler = function () {
                for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                    _this.SetFieldValue(yearUsdFotField.GenerateId(i), 0);
                    _this.SetFieldValue(yearRubFotField.GenerateId(i), 0);
                    _this.SetFieldValue(yearFotField.GenerateId(i), 0);
                    _this.SetFieldValue(yearInsField.GenerateId(i), 0);
                    _this.SetFieldValue(yearField.GenerateId(i), 0);
                }
            };
            if (keys) {
                if (this.LocateByKeys(keys.ToArray())) {
                    resetDataHandler();
                }
            }
            else {
                this.Iterate(resetDataHandler);
            }
        };
        ObasTableP1.prototype.CollectUserData = function () {
            var _this = this;
            var filter = function () {
                return !_this.IsTotal;
            };
            var yearField = BaseObasTableFields.YearDataField;
            var result = this.CollectTableData(this.InitCopyFieldsInfo(), filter);
            var strKeyId = this.StrKeyField.Id;
            for (var _i = 0, result_1 = result; _i < result_1.length; _i++) {
                var record = result_1[_i];
                var data = record.Data;
                var strKey = data.getValue(strKeyId).Value;
                if (BaseInsuranceObasTable.CheckIsTaxDataRow(strKey)) {
                    for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                        data.remove(yearField.GenerateId(i));
                    }
                }
            }
            return result;
        };
        ObasTableP1.prototype.InitCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            result.setValue(this.StrKeyField.Id, {
                Id: this.StrKeyField.Id,
                IsData: false
            });
            result.setValue(BaseObasTableFields.TotalRowFlagField.Id, {
                Id: BaseObasTableFields.TotalRowFlagField.Id,
                IsData: false
            });
            var yearUsdFotField = ObasTableFields.FotUsdYearDataField;
            var yearRubFotField = ObasTableFields.FotRubYearDataField;
            var yearInsField = BaseObasTableFields.InsuranceYearDataField;
            for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                var fieldId = yearUsdFotField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
                fieldId = yearRubFotField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
                fieldId = yearInsField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
            }
            return result;
        };
        ObasTableP1.prototype.SaveCorrectionData = function () {
            var _this = this;
            if (this.LocateByKeys(this.GetKeys(StrKeysP1Total.Correction).ToArray())) {
                this._correctionData = [];
                var yearDataField_1 = BaseObasTableFields.YearDataField;
                this.Document.IterateByYears(function (yearIndex) {
                    _this._correctionData.push(_this.GetFieldValue(yearDataField_1.GenerateId(yearIndex)) || 0);
                });
            }
        };
        ObasTableP1.prototype.RestoreCorrectionData = function () {
            if (this._correctionData) {
                var yearDataField = BaseObasTableFields.YearDataField;
                var keys = this.GetKeys(StrKeysP1Total.Correction);
                for (var i = 0; i < this._correctionData.length; i++) {
                    this.SetValueByKeys(yearDataField.GenerateId(i + 1), keys, this._correctionData[i]);
                }
            }
        };
        return ObasTableP1;
    }(P1TotalObasTable));
    F01280.ObasTableP1 = ObasTableP1;
    var StrKeysPXSp1;
    (function (StrKeysPXSp1) {
        StrKeysPXSp1[StrKeysPXSp1["Total"] = 1] = "Total";
        StrKeysPXSp1[StrKeysPXSp1["Calced"] = 2] = "Calced";
        StrKeysPXSp1[StrKeysPXSp1["Changed"] = 3] = "Changed";
        StrKeysPXSp1[StrKeysPXSp1["Correction"] = 4] = "Correction";
    })(StrKeysPXSp1 = F01280.StrKeysPXSp1 || (F01280.StrKeysPXSp1 = {}));
    var ObasTablePXSp1Total = (function (_super) {
        __extends(ObasTablePXSp1Total, _super);
        function ObasTablePXSp1Total(id, document, _parentStrKey, _correction, _isCalcCorrection) {
            if (_isCalcCorrection === void 0) { _isCalcCorrection = false; }
            var _this = _super.call(this, id, document, document.TableP1) || this;
            _this._parentStrKey = _parentStrKey;
            _this._correction = _correction;
            _this._isCalcCorrection = _isCalcCorrection;
            return _this;
        }
        Object.defineProperty(ObasTablePXSp1Total.prototype, "IsCalcCorrection", {
            get: function () {
                return this._isCalcCorrection;
            },
            enumerable: true,
            configurable: true
        });
        ObasTablePXSp1Total.prototype.IsUserEditRow = function (strKey) {
            if (strKey === void 0) { strKey = this.StrKey; }
            return strKey === StrKeysPXSp1.Correction && !this.IsCalcCorrection;
        };
        ObasTablePXSp1Total.prototype.SumChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var strKey = this.StrKey;
            switch (strKey) {
                case StrKeysPXSp1.Calced:
                case StrKeysPXSp1.Changed:
                    if (this.IsCalcCorrection) {
                        var sumVal = this.GetValueByKeys(fieldId, this.GetKeys(StrKeysPXSp1.Calced));
                        var changeVal = this.GetValueByKeys(fieldId, this.GetKeys(StrKeysPXSp1.Changed));
                        var sum = sumVal + changeVal;
                        var correctionVal = sum * this._correction * -1;
                        this.SetValueByKeys(fieldId, this.GetKeys(StrKeysPXSp1.Correction), correctionVal);
                        this.SetValueByKeys(fieldId, this.GetKeys(StrKeysPXSp1.Total), sum + correctionVal);
                        break;
                    }
                case StrKeysPXSp1.Correction:
                    if (!this.IsCalcCorrection) {
                        var sumVal = this.GetValueByKeys(fieldId, this.GetKeys(StrKeysPXSp1.Calced));
                        var changeVal = this.GetValueByKeys(fieldId, this.GetKeys(StrKeysPXSp1.Changed));
                        var correctionVal = this.GetValueByKeys(fieldId, this.GetKeys(StrKeysPXSp1.Correction));
                        this.SetValueByKeys(fieldId, this.GetKeys(StrKeysPXSp1.Total), sumVal + changeVal + correctionVal);
                    }
                    break;
                case StrKeysPXSp1.Total:
                    this.ParentTable.SetValueByKeys(fieldId, this.ParentTable.GetKeys(this._parentStrKey), newValue);
                    break;
            }
        };
        ObasTablePXSp1Total.prototype.ResetData = function (keys) {
            var _this = this;
            var yearField = BaseObasTableFields.YearDataField;
            var yearFotField = BaseObasTableFields.FotYearDataField;
            var yearUsdFotField = ObasTableFields.FotUsdYearDataField;
            var yearRubFotField = ObasTableFields.FotRubYearDataField;
            var yearInsField = BaseObasTableFields.InsuranceYearDataField;
            var resetDataHandler = function () {
                for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                    _this.SetFieldValue(yearUsdFotField.GenerateId(i), 0);
                    _this.SetFieldValue(yearRubFotField.GenerateId(i), 0);
                    _this.SetFieldValue(yearFotField.GenerateId(i), 0);
                    _this.SetFieldValue(yearInsField.GenerateId(i), 0);
                    _this.SetFieldValue(yearField.GenerateId(i), 0);
                }
            };
            if (keys) {
                if (this.LocateByKeys(keys.ToArray())) {
                    resetDataHandler();
                }
            }
            else {
                this.Iterate(resetDataHandler);
            }
        };
        ObasTablePXSp1Total.prototype.CollectUserData = function () {
            var _this = this;
            var filter = function () {
                return _this.IsUserEditRow();
            };
            return this.CollectTableData(this.InitCopyFieldsInfo(), filter);
        };
        ObasTablePXSp1Total.prototype.CopyData = function (srcYear, destYear) {
            var _this = this;
            if (!this.IsCalcCorrection) {
                var srcIndex = srcYear ? srcYear - ObasStageSettings.CurrentYear + 1 : ObasStageSettings.YearsCount - 1;
                var destIndex = destYear ? destYear - ObasStageSettings.CurrentYear + 1 : ObasStageSettings.YearsCount;
                var yearUsdField = ObasTableFields.FotUsdYearDataField;
                var srcUsdFieldId_1 = yearUsdField.GenerateId(srcIndex);
                var destUsdFieldId_1 = yearUsdField.GenerateId(destIndex);
                var yearRubField = ObasTableFields.FotRubYearDataField;
                var srcRubFieldId_1 = yearRubField.GenerateId(srcIndex);
                var destRubFieldId_1 = yearRubField.GenerateId(destIndex);
                var insField = BaseObasTableFields.InsuranceYearDataField;
                var insSrcFieldId_1 = insField.GenerateId(srcIndex);
                var insDestFieldId_1 = insField.GenerateId(destIndex);
                var copy = function () {
                    if (_this.IsUserEditRow()) {
                        _this.SetFieldValue(destUsdFieldId_1, _this.GetFieldValue(srcUsdFieldId_1));
                        _this.SetFieldValue(destRubFieldId_1, _this.GetFieldValue(srcRubFieldId_1));
                        _this.SetFieldValue(insDestFieldId_1, _this.GetFieldValue(insSrcFieldId_1));
                    }
                };
                this.Iterate(copy);
            }
        };
        ObasTablePXSp1Total.prototype.InitCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            result.setValue(this.StrKeyField.Id, {
                Id: this.StrKeyField.Id,
                IsData: false
            });
            var fotUsdField = ObasTableFields.FotUsdYearDataField;
            var fotRubField = ObasTableFields.FotRubYearDataField;
            var insField = BaseObasTableFields.InsuranceYearDataField;
            for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                var fieldId = fotUsdField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
                fieldId = fotRubField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
                fieldId = insField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
            }
            return result;
        };
        return ObasTablePXSp1Total;
    }(ObasTableWithStrKeysParent));
    F01280.ObasTablePXSp1Total = ObasTablePXSp1Total;
    var StrKeysPXSp2;
    (function (StrKeysPXSp2) {
        StrKeysPXSp2[StrKeysPXSp2["FotUsd"] = 1] = "FotUsd";
        StrKeysPXSp2[StrKeysPXSp2["FotRub"] = 2] = "FotRub";
        StrKeysPXSp2[StrKeysPXSp2["Ins"] = 3] = "Ins";
        StrKeysPXSp2[StrKeysPXSp2["Total"] = 4] = "Total";
    })(StrKeysPXSp2 = F01280.StrKeysPXSp2 || (F01280.StrKeysPXSp2 = {}));
    var ObasTablePXSp2 = (function (_super) {
        __extends(ObasTablePXSp2, _super);
        function ObasTablePXSp2() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        ObasTablePXSp2.prototype.SumChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var strKey = this.StrKey;
            var destFieldId = null;
            switch (strKey) {
                case StrKeysPXSp2.FotUsd:
                    destFieldId = ObasTableFields.FotUsdYearDataField.Id;
                    break;
                case StrKeysPXSp2.FotRub:
                    destFieldId = ObasTableFields.FotRubYearDataField.Id;
                    break;
                case StrKeysPXSp2.Ins:
                    destFieldId = ObasTableFields.InsuranceYearDataField.Id;
                    break;
            }
            if (destFieldId) {
                var yearOffset = ObasHelper.GetYearOffsetById(fieldId) + 1;
                destFieldId = destFieldId + yearOffset.toString();
                this.ParentTable.SetValueByKeys(destFieldId, this.ParentTable.GetKeys(this.OrgKey, StrKeysPXSp1.Calced), newValue);
            }
        };
        ObasTablePXSp2.prototype.ResetData = function (keys) {
            var _this = this;
            var yearField = BaseObasTableFields.YearDataField;
            var resetDataHandler = function () {
                for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                    _this.SetFieldValue(yearField.GenerateId(i), 0);
                }
            };
            if (keys) {
                if (this.LocateByKeys(keys.ToArray())) {
                    resetDataHandler();
                }
            }
            else {
                this.Iterate(resetDataHandler);
            }
        };
        return ObasTablePXSp2;
    }(ObasTableWithOrgStrKeysParent));
    F01280.ObasTablePXSp2 = ObasTablePXSp2;
    var StrKeysPXIndex;
    (function (StrKeysPXIndex) {
        StrKeysPXIndex[StrKeysPXIndex["Fot"] = 1] = "Fot";
        StrKeysPXIndex[StrKeysPXIndex["Other"] = 2] = "Other";
        StrKeysPXIndex[StrKeysPXIndex["Indexation"] = 3] = "Indexation";
        StrKeysPXIndex[StrKeysPXIndex["OtherNoIndex"] = 4] = "OtherNoIndex";
        StrKeysPXIndex[StrKeysPXIndex["Total"] = 5] = "Total";
    })(StrKeysPXIndex = F01280.StrKeysPXIndex || (F01280.StrKeysPXIndex = {}));
    var ObasTablePXBaseIndex = (function (_super) {
        __extends(ObasTablePXBaseIndex, _super);
        function ObasTablePXBaseIndex(id, document, parentTable, _insTable, orgTable) {
            var _this = _super.call(this, id, document, parentTable, orgTable) || this;
            _this._insTable = _insTable;
            return _this;
        }
        Object.defineProperty(ObasTablePXBaseIndex.prototype, "InsuranceTable", {
            get: function () {
                return this._insTable;
            },
            enumerable: true,
            configurable: true
        });
        ObasTablePXBaseIndex.prototype.ResetData = function (keys) {
            var _this = this;
            var yearField = BaseObasTableFields.YearDataField;
            var resetDataHandler = function () {
                for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                    _this.SetFieldValue(yearField.GenerateId(i), 0);
                }
            };
            if (keys) {
                if (this.LocateByKeys(keys.ToArray())) {
                    resetDataHandler();
                }
            }
            else {
                this.Iterate(resetDataHandler);
            }
        };
        ObasTablePXBaseIndex.prototype.InitCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            result.setValue(this.OrgKeyField.Id, {
                Id: this.OrgKeyField.Id,
                IsData: false
            });
            result.setValue(this.StrKeyField.Id, {
                Id: this.StrKeyField.Id,
                IsData: false
            });
            var fotField = BaseObasTableFields.YearDataField;
            for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                var fieldId = fotField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
            }
            return result;
        };
        return ObasTablePXBaseIndex;
    }(ObasTableWithOrgStrKeysParent));
    F01280.ObasTablePXBaseIndex = ObasTablePXBaseIndex;
    var ObasTablePXIndex = (function (_super) {
        __extends(ObasTablePXIndex, _super);
        function ObasTablePXIndex() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        ObasTablePXIndex.prototype.SumChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var strKey = this.StrKey;
            var orgKey = this.OrgKey;
            var yearOffset = ObasHelper.GetYearOffsetById(fieldId);
            switch (strKey) {
                case StrKeysPXIndex.Fot:
                case StrKeysPXIndex.Other:
                case StrKeysPXIndex.OtherNoIndex:
                    var fotVal = this.GetValueByKeys(fieldId, this.GetKeys(orgKey, StrKeysPXIndex.Fot));
                    var otherVal = this.GetValueByKeys(fieldId, this.GetKeys(orgKey, StrKeysPXIndex.Other));
                    var sumVal = fotVal + otherVal;
                    var indexVal = this.Document.CanCalcIndexation
                        ? this.Document.CommonRules.CalcIndexationByYear(sumVal, ObasStageSettings.CurrentYear + yearOffset)
                        : 0;
                    sumVal += indexVal;
                    var otherNoIndexVal = this.GetValueByKeys(fieldId, this.GetKeys(orgKey, StrKeysPXIndex.OtherNoIndex));
                    sumVal += otherNoIndexVal;
                    this.SetValueByKeys(fieldId, this.GetKeys(orgKey, StrKeysPXIndex.Indexation), indexVal);
                    this.SetValueByKeys(fieldId, this.GetKeys(orgKey, StrKeysPXIndex.Total), sumVal);
                    break;
                case StrKeysPXIndex.Total:
                    this.InsuranceTable.SetFotValue(orgKey, yearOffset, oldValue, newValue);
                    this.ParentTable.SetValueByKeys(fieldId, this.ParentTable.GetKeys(orgKey, StrKeysPXSp2.FotRub), newValue);
                    break;
            }
        };
        ObasTablePXIndex.prototype.IsUserEditRow = function (strKey) {
            if (strKey === void 0) { strKey = this.StrKey; }
            return strKey === StrKeysPXIndex.Other || strKey === StrKeysPXIndex.OtherNoIndex;
        };
        ObasTablePXIndex.prototype.CopyData = function (srcYear, destYear) {
            var _this = this;
            var srcIndex = srcYear ? srcYear - ObasStageSettings.CurrentYear + 1 : ObasStageSettings.YearsCount - 1;
            var destIndex = destYear ? destYear - ObasStageSettings.CurrentYear + 1 : ObasStageSettings.YearsCount;
            var yearField = BaseObasTableFields.YearDataField;
            var srcFieldId = yearField.GenerateId(srcIndex);
            var destFieldId = yearField.GenerateId(destIndex);
            var copy = function () {
                if (_this.IsUserEditRow()) {
                    _this.SetFieldValue(destFieldId, _this.GetFieldValue(srcFieldId));
                }
            };
            this.Iterate(copy);
        };
        ObasTablePXIndex.prototype.CollectUserData = function () {
            var _this = this;
            var filter = function () {
                return _this.IsUserEditRow();
            };
            return this.CollectTableData(this.InitCopyFieldsInfo(), filter);
        };
        return ObasTablePXIndex;
    }(ObasTablePXBaseIndex));
    F01280.ObasTablePXIndex = ObasTablePXIndex;
    var StrKeysP4Index;
    (function (StrKeysP4Index) {
        StrKeysP4Index[StrKeysP4Index["Fot"] = 2] = "Fot";
        StrKeysP4Index[StrKeysP4Index["Indexation"] = 3] = "Indexation";
        StrKeysP4Index[StrKeysP4Index["Total"] = 1] = "Total";
    })(StrKeysP4Index = F01280.StrKeysP4Index || (F01280.StrKeysP4Index = {}));
    var ObasTableP4Index = (function (_super) {
        __extends(ObasTableP4Index, _super);
        function ObasTableP4Index() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        ObasTableP4Index.prototype.SumChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var strKey = this.StrKey;
            var orgKey = this.OrgKey;
            var yearOffset = ObasHelper.GetYearOffsetById(fieldId);
            switch (strKey) {
                case StrKeysP4Index.Fot:
                    var fotVal = this.GetValueByKeys(fieldId, this.GetKeys(orgKey, StrKeysP4Index.Fot));
                    var sumVal = fotVal;
                    var indexVal = this.Document.CommonRules
                        .CalcIndexationByYear(sumVal, ObasStageSettings.CurrentYear + yearOffset);
                    sumVal += indexVal;
                    this.SetValueByKeys(fieldId, this.GetKeys(orgKey, StrKeysP4Index.Indexation), indexVal);
                    this.SetValueByKeys(fieldId, this.GetKeys(orgKey, StrKeysP4Index.Total), sumVal);
                    break;
                case StrKeysP4Index.Total:
                    this.InsuranceTable.SetFotValue(orgKey, yearOffset, oldValue, newValue);
                    this.ParentTable.SetValueByKeys(fieldId, this.ParentTable.GetKeys(orgKey, StrKeysPXSp2.FotRub), newValue);
                    break;
            }
        };
        return ObasTableP4Index;
    }(ObasTablePXBaseIndex));
    F01280.ObasTableP4Index = ObasTableP4Index;
    var ObasTablePXIns = (function (_super) {
        __extends(ObasTablePXIns, _super);
        function ObasTablePXIns() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        ObasTablePXIns.prototype.UpdateParentSum = function (tableId, oldValue, newValue, fieldId) {
            this.ParentTable.SetSumByKeys(fieldId, this.ParentTable.GetKeys(this.OrgKey, StrKeysPXSp2.Ins), oldValue, newValue);
        };
        return ObasTablePXIns;
    }(OrgInsuranceObasTable));
    F01280.ObasTablePXIns = ObasTablePXIns;
    var ObasTableOnlyInsurance = (function (_super) {
        __extends(ObasTableOnlyInsurance, _super);
        function ObasTableOnlyInsurance() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        return ObasTableOnlyInsurance;
    }(OnlyInsuranceObasTable));
    F01280.ObasTableOnlyInsurance = ObasTableOnlyInsurance;
    var PartUniqueOrgsObasTable = (function (_super) {
        __extends(PartUniqueOrgsObasTable, _super);
        function PartUniqueOrgsObasTable(id, document, parentTable, keyFields) {
            if (keyFields === void 0) { keyFields = ["Organization_ID", "OKSM_ID"]; }
            var _this = _super.call(this, id, keyFields) || this;
            _this._countryField = null;
            _this._orgKey = null;
            _this._countryKey = null;
            _this._otherPartTables = [];
            _this._keys = null;
            _this._document = document;
            _this._parentTable = parentTable;
            _this.AddPartTable(_this);
            return _this;
        }
        Object.defineProperty(PartUniqueOrgsObasTable.prototype, "Document", {
            get: function () {
                return this._document;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartUniqueOrgsObasTable.prototype, "ParentTable", {
            get: function () {
                return this._parentTable;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartUniqueOrgsObasTable.prototype, "Country", {
            get: function () {
                if (this._countryField == null) {
                    this._countryField = new ObasSprTableField(ObasTableCollection.OksmSprTable, this);
                }
                return this._countryField;
            },
            enumerable: true,
            configurable: true
        });
        PartUniqueOrgsObasTable.prototype.AddPartTable = function (partTable) {
            if (this._otherPartTables.indexOf(partTable.Id) === -1) {
                this._otherPartTables.push(partTable.Id);
            }
        };
        PartUniqueOrgsObasTable.prototype.AddNewOrg = function (orgKey, countryKey) {
            if (this._parentTable != null && orgKey != null && countryKey != null) {
                this._document.CommonRules.AddNewLink(this._parentTable.Id, [this.Org.ForeignKey.Id, this.Country.ForeignKey.Id], [orgKey, countryKey]);
            }
        };
        PartUniqueOrgsObasTable.prototype.UniqKeyChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var orgField = this.Org.ForeignKey;
            var countryField = this.Country.ForeignKey;
            var orgKey = orgField.Value;
            var countryKey = countryField.Value;
            var oldOrgKey = fieldId === orgField.Id ? oldValue : orgKey;
            var oldCountryKey = fieldId === countryField.Id ? oldValue : countryKey;
            this.AfterDeleteEventHandler(tableId, oldOrgKey, oldCountryKey);
            this.AddNewOrg(orgKey, countryKey);
        };
        PartUniqueOrgsObasTable.prototype.DeleteEventHandler = function (tableId) {
            this._orgKey = this.Org.ForeignKey.Value;
            this._countryKey = this.Country.ForeignKey.Value;
        };
        PartUniqueOrgsObasTable.prototype.AfterDeleteEventHandler = function (tableId, orgKey, countryKey) {
            if (orgKey === void 0) { orgKey = this._orgKey; }
            if (countryKey === void 0) { countryKey = this._countryKey; }
            if (this._parentTable != null) {
                this._document.CommonRules.DeleteOldLink(this._parentTable.Id, this._otherPartTables, [this.Org.ForeignKey.Id, this.Country.ForeignKey.Id], [orgKey, countryKey]);
            }
        };
        PartUniqueOrgsObasTable.prototype.CalcBarsFilteringColumn = function () {
            return this.Country.ForeignKey.Value + "_" + this.Org.ForeignKey.Value;
        };
        PartUniqueOrgsObasTable.prototype.GetRecordKey = function (keys, addIfNotExists) {
            if (addIfNotExists === void 0) { addIfNotExists = false; }
            this.Document.CommonRules.GetValueByKeys(this, this.KeyFieldIds, keys.ToArray(), this.RecordKey.Id, addIfNotExists);
            return this.RecordKey.Value;
        };
        PartUniqueOrgsObasTable.prototype.GetKeys = function (orgKey, countryKey) {
            if (orgKey === void 0) { orgKey = this.Org.ForeignKey
                .Value; }
            if (countryKey === void 0) { countryKey = this.Country.ForeignKey.Value; }
            if (this._keys == null) {
                this._keys = new OrgCountryObasTableKeys(orgKey, countryKey);
            }
            else {
                this._keys.OrgKey = orgKey;
                this._keys.CountryKey = countryKey;
            }
            return this._keys;
        };
        return PartUniqueOrgsObasTable;
    }(UniqueOrgsObasTable));
    F01280.PartUniqueOrgsObasTable = PartUniqueOrgsObasTable;
    var YearPartUniqueOrgsObasTable = (function (_super) {
        __extends(YearPartUniqueOrgsObasTable, _super);
        function YearPartUniqueOrgsObasTable(id, document, parentTable) {
            var _this = _super.call(this, id, document, parentTable, ["Organization_ID", "OKSM_ID", "Year"]) || this;
            _this._year = null;
            _this._keys = null;
            return _this;
        }
        Object.defineProperty(YearPartUniqueOrgsObasTable.prototype, "Year", {
            get: function () {
                if (this._year == null) {
                    this._year = new NumberObasTableField(ObasTableFields.YearField.Id, this);
                }
                return this._year;
            },
            enumerable: true,
            configurable: true
        });
        YearPartUniqueOrgsObasTable.prototype.GetKeys = function (orgKey, countryKey, year) {
            if (orgKey === void 0) { orgKey = this.Org.ForeignKey.Value; }
            if (countryKey === void 0) { countryKey = this.Country.ForeignKey.Value; }
            if (year === void 0) { year = this.Year.NValue; }
            if (this._keys == null) {
                this._keys = new OrgCountryYearObasTableKeys(orgKey, countryKey, year);
            }
            else {
                this._keys.OrgKey = orgKey;
                this._keys.CountryKey = countryKey;
                this._keys.Year = year;
            }
            return this._keys;
        };
        return YearPartUniqueOrgsObasTable;
    }(PartUniqueOrgsObasTable));
    F01280.YearPartUniqueOrgsObasTable = YearPartUniqueOrgsObasTable;
    var ObasTablePXExecWrits = (function (_super) {
        __extends(ObasTablePXExecWrits, _super);
        function ObasTablePXExecWrits(id, document, parentOrgTable, parentSumTable) {
            var _this = _super.call(this, id, document, parentOrgTable) || this;
            _this._parentSumTable = parentSumTable;
            return _this;
        }
        ObasTablePXExecWrits.prototype.UsdChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var yearOffSet = ObasHelper.GetYearOffsetById(fieldId);
            this.SetFieldValue("" + ObasTableFields.YearDataField.Id + (yearOffSet + 1), this.Document.CommonRules.ConvertDollarToRuble(newValue, ObasStageSettings.CurrentYear + yearOffSet));
        };
        ObasTablePXExecWrits.prototype.SumChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var yearOffset = ObasHelper.GetYearOffsetById(fieldId) + 1;
            var orgKey = this.ParentTable.RecordKey
                .LookupByKeys([this.Org.ForeignKey.Value, this.Country.ForeignKey.Value]);
            this._parentSumTable.SetValueByKeys("" + ObasTableFields.FotUsdYearDataField.Id + yearOffset, this._parentSumTable.GetKeys(orgKey, StrKeysPXSp1.Changed), newValue);
        };
        ObasTablePXExecWrits.prototype.AfterDeleteChildsEventHandler = function (tableId) {
            for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                var fieldId = "" + ObasTableFields.YearDataField.Id + i;
                this.SumChangeEventHandler(this.Id, this.GetFieldValue(fieldId), 0, fieldId);
            }
        };
        ObasTablePXExecWrits.prototype.CopyData = function (srcYear, destYear) {
            var _this = this;
            var srcIndex = srcYear ? srcYear - ObasStageSettings.CurrentYear + 1 : ObasStageSettings.YearsCount - 1;
            var destIndex = destYear ? destYear - ObasStageSettings.CurrentYear + 1 : ObasStageSettings.YearsCount;
            var usdField = BaseObasTableFields.UsdYearDataField;
            var srcUsdFieldId = usdField.GenerateId(srcIndex);
            var destUsdFieldId = usdField.GenerateId(destIndex);
            var copy = function () {
                _this.SetFieldValue(destUsdFieldId, _this.GetFieldValue(srcUsdFieldId));
            };
            this.Iterate(copy);
        };
        ObasTablePXExecWrits.prototype.InitCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            result.setValue(this.Org.ForeignKey.Id, {
                Id: this.Org.ForeignKey.Id,
                IsData: false
            });
            result.setValue(this.Country.ForeignKey.Id, {
                Id: this.Country.ForeignKey.Id,
                IsData: false
            });
            var usdField = BaseObasTableFields.UsdYearDataField;
            for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                var fieldId = usdField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
            }
            return result;
        };
        ObasTablePXExecWrits.prototype.CollectUserData = function () {
            return this.CollectTableData(this.InitCopyFieldsInfo());
        };
        ObasTablePXExecWrits.prototype.ResetData = function () {
            var _this = this;
            var yearField = BaseObasTableFields.YearDataField;
            var usdField = BaseObasTableFields.UsdYearDataField;
            var resetDataHandler = function () {
                for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                    _this.SetFieldValue(usdField.GenerateId(i), 0);
                    _this.SetFieldValue(yearField.GenerateId(i), 0);
                }
            };
            this.Iterate(resetDataHandler);
        };
        return ObasTablePXExecWrits;
    }(PartUniqueOrgsObasTable));
    F01280.ObasTablePXExecWrits = ObasTablePXExecWrits;
    var CopyMode;
    (function (CopyMode) {
        CopyMode[CopyMode["All"] = 0] = "All";
        CopyMode[CopyMode["Usd"] = 1] = "Usd";
        CopyMode[CopyMode["Rub"] = 2] = "Rub";
    })(CopyMode = F01280.CopyMode || (F01280.CopyMode = {}));
    var ObasTablePXBaseSp3 = (function (_super) {
        __extends(ObasTablePXBaseSp3, _super);
        function ObasTablePXBaseSp3(id, document, parentTable, _tableFot, _tableIndexation, _tableInsurance) {
            var _this = _super.call(this, id, [
                "Organization_ID", "OKSM_ID", ObasTableFields.YearField.Id,
                ObasTableFields.PositionField.Id
            ], document, parentTable) || this;
            _this._tableFot = _tableFot;
            _this._tableIndexation = _tableIndexation;
            _this._tableInsurance = _tableInsurance;
            _this._positionKeyField = null;
            _this._fieldIds = null;
            _this._checkFieldIds = null;
            _this._uniqOrgTable = null;
            _this._copyUsdData = null;
            _this._copyRubData = null;
            _this._copyAllData = null;
            _this._isCopiedFieldUsd = null;
            _this._isCopiedFieldRub = null;
            _this._ownerKeyField =
                new ObasForeignKeyTableField(parentTable, _this, BaseObasTableFields.OwnerKeyField.Id, false, true);
            _this._yearField = new NumberObasTableField(ObasTableFields.YearField.Id, _this);
            _this._rubFotDataField = new ObasTableField("RubTotalFot", _this);
            _this._usdFotDataField = new ObasTableField("UsdTotalFot", _this);
            _this._usdDataField = new ObasTableField("UsdFot", _this);
            _this._orgKeyField = new ObasTableField("Organization_ID", _this);
            _this._countryKeyField = new ObasTableField("OKSM_ID", _this);
            _this._usdEmplCountField = new ObasTableField("UsdEmplNumber", _this);
            _this._rubEmplCountField = new ObasTableField("RubEmplNumber", _this);
            return _this;
        }
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "IsCopiedFieldRub", {
            get: function () {
                if (this._isCopiedFieldRub == null) {
                    this._isCopiedFieldRub =
                        new ObasTableField(ObasTableFields.CopiedRubRowFlagField.Id, this, true);
                }
                return this._isCopiedFieldRub;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "IsCopiedFieldUsd", {
            get: function () {
                if (this._isCopiedFieldUsd == null) {
                    this._isCopiedFieldUsd =
                        new ObasTableField(ObasTableFields.CopiedUsdRowFlagField.Id, this, true);
                }
                return this._isCopiedFieldUsd;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "CheckFieldIds", {
            get: function () {
                var strCodeFieldId = ObasTableFields.StrCodeField.Id.toLowerCase();
                if (this._checkFieldIds == null) {
                    this._checkFieldIds = this.FieldIds.filter(function (value) {
                        return value !== strCodeFieldId;
                    });
                }
                return this._checkFieldIds;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "FieldIds", {
            get: function () {
                if (this._fieldIds == null) {
                    this._fieldIds = this.GetFieldsIds();
                }
                return this._fieldIds;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "TableFot", {
            get: function () {
                return this._tableFot;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "TableIndexation", {
            get: function () {
                return this._tableIndexation;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "TableInsurance", {
            get: function () {
                return this._tableInsurance;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "OwnerKeyField", {
            get: function () {
                return this._ownerKeyField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "Year", {
            get: function () {
                return this._yearField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "OrgKey", {
            get: function () {
                return this._orgKeyField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "CountryKey", {
            get: function () {
                return this._countryKeyField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "PositionKey", {
            get: function () {
                if (this._positionKeyField == null) {
                    this._positionKeyField = new ObasTableField(ObasTableFields.PositionField.Id, this, true);
                }
                return this._positionKeyField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "UsdData", {
            get: function () {
                return this._usdDataField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "UsdFotData", {
            get: function () {
                return this._usdFotDataField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "RubFotData", {
            get: function () {
                return this._rubFotDataField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "UsdEmplCountField", {
            get: function () {
                return this._usdEmplCountField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "RubEmplCountField", {
            get: function () {
                return this._rubEmplCountField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "CopyUsdFieldsInfo", {
            get: function () {
                if (this._copyUsdData == null) {
                    this._copyUsdData = this.InitUsdCopyFieldsInfo();
                }
                return this.CollectTableRecordData(this._copyUsdData);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "CopyRubFieldsInfo", {
            get: function () {
                if (this._copyRubData == null) {
                    this._copyRubData = this.InitRubCopyFieldsInfo();
                }
                return this.CollectTableRecordData(this._copyRubData);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "CopyAllFieldsInfo", {
            get: function () {
                if (this._copyAllData == null) {
                    this._copyAllData = this.InitCopyFieldsInfo();
                }
                return this.CollectTableRecordData(this._copyAllData);
            },
            enumerable: true,
            configurable: true
        });
        ObasTablePXBaseSp3.prototype.CalcPercent = function (value) {
            return value / 100;
        };
        ObasTablePXBaseSp3.prototype.IsRedyForCopyUsd = function () {
            return ObasHelper.CheckIsReadyForCopy(this.CopyUsdFieldsInfo);
        };
        ObasTablePXBaseSp3.prototype.IsRedyForCopyRub = function () {
            return ObasHelper.CheckIsReadyForCopy(this.CopyRubFieldsInfo);
        };
        ObasTablePXBaseSp3.prototype.IsRedyForCopyAll = function () {
            return ObasHelper.CheckIsReadyForCopy(this.CopyAllFieldsInfo);
        };
        ObasTablePXBaseSp3.prototype.GetKeys = function (orgKey, countryKey, year, positionKey) {
            if (orgKey === void 0) { orgKey = this.OrgKey.Value; }
            if (countryKey === void 0) { countryKey = this.CountryKey.Value; }
            if (year === void 0) { year = this.Year.Value; }
            if (positionKey === void 0) { positionKey = this.PositionKey.Value; }
            if (this._keys == null) {
                this._keys = new OrgCountryYearPostObasTableKeys(orgKey, countryKey, year, positionKey);
            }
            else {
                this._keys.OrgKey = orgKey;
                this._keys.CountryKey = countryKey;
                this._keys.Year = year;
                this._keys.PositionKey = positionKey;
            }
            return this._keys;
        };
        ObasTablePXBaseSp3.prototype.CopyData = function (srcYear, destYear) {
            var _this = this;
            var endYear = ObasStageSettings.CurrentYear + ObasStageSettings.YearsCount;
            if (srcYear == null) {
                srcYear = endYear - 2;
            }
            if (destYear == null) {
                destYear = endYear - 1;
            }
            if (srcYear && destYear) {
                var copyHandler = function (table, recordKey) {
                    if (_this.Year.Value === srcYear) {
                        _this.InnerCopyData(recordKey, destYear, CopyMode.All);
                    }
                };
                this.Iterate(copyHandler);
            }
        };
        ObasTablePXBaseSp3.prototype.InnerCopyData = function (recordKey, endYear, mode) {
            if (this.Locate(this.RecordKey.Id, recordKey)) {
                var copyData = void 0;
                switch (mode) {
                    case CopyMode.Usd:
                        this.IsCopiedFieldUsd.Value = true;
                        copyData = this.CopyUsdFieldsInfo;
                        break;
                    case CopyMode.Rub:
                        this.IsCopiedFieldRub.Value = true;
                        copyData = this.CopyRubFieldsInfo;
                        break;
                    default:
                        this.IsCopiedFieldUsd.Value = true;
                        this.IsCopiedFieldRub.Value = true;
                        copyData = this.CopyAllFieldsInfo;
                }
                var keys = this.GetKeys();
                for (var year = keys.Year + 1; year <= endYear; year++) {
                    var ownerKey = this.ParentTable
                        .GetRecordKey(this.ParentTable.GetKeys(keys.OrgKey, keys.CountryKey, year), true);
                    copyData.getValue(this.OwnerKeyField.Id).Value = ownerKey;
                    keys.Year = year;
                    this.CopyTableRecordData(copyData, keys, mode);
                }
                this.RecordKey.Locate(recordKey);
            }
        };
        ObasTablePXBaseSp3.prototype.CopyTableRecordData = function (fieldsInfo, keys, mode) {
            if (mode === void 0) { mode = CopyMode.All; }
            var recordKey = this.RecordKey.LookupByKeys(keys.ToArray());
            var isExists = recordKey != null;
            var canCopy = true;
            if (isExists) {
                this.RecordKey.Locate(recordKey);
                switch (mode) {
                    case CopyMode.Usd:
                        canCopy = (this.IsCopiedFieldUsd.Value || false) === false;
                        break;
                    case CopyMode.Rub:
                        canCopy = (this.IsCopiedFieldRub.Value || false) === false;
                        break;
                    default:
                        canCopy = (this.IsCopiedFieldUsd.Value || false) === false &&
                            (this.IsCopiedFieldRub.Value || false) === false;
                }
            }
            if (canCopy) {
                _super.prototype.SetupTableRecordData.call(this, fieldsInfo, recordKey, false);
            }
        };
        ObasTablePXBaseSp3.prototype.EditEventHandler = function (tableId) {
            if (this.Document.NotOnUpdate) {
                var copyMode = null;
                var canCopyUsd = !this.IsCopiedFieldUsd.Value && this.IsRedyForCopyUsd();
                var canCopyRub = !this.IsCopiedFieldRub.Value && this.IsRedyForCopyRub();
                if (canCopyUsd && canCopyRub) {
                    copyMode = CopyMode.All;
                }
                else if (canCopyUsd) {
                    copyMode = CopyMode.Usd;
                }
                else if (canCopyRub) {
                    copyMode = CopyMode.Rub;
                }
                if (copyMode != null) {
                    this.InnerCopyData(this.RecordKey.Value, ObasStageSettings.CurrentYear + ObasStageSettings.YearsCount - 1, copyMode);
                }
            }
        };
        ObasTablePXBaseSp3.prototype.InitCopyFieldsInfo = function () {
            var result = this.InitUsdCopyFieldsInfo();
            var addFields = this.InitRubCopyFieldsInfo();
            if (addFields && addFields.size() > 0) {
                addFields.forEach(function (key, val) {
                    if (!result.containsKey(key)) {
                        result.setValue(key, val);
                    }
                });
            }
            return result;
        };
        ObasTablePXBaseSp3.prototype.UsdEmplNumberChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.UsdFotPartsChangeEventHandler(tableId, oldValue, newValue, fieldId);
            this.TableInsurance.SetCountValue(this.UniqueOrgKey, this.YearOffset, oldValue, newValue);
        };
        ObasTablePXBaseSp3.prototype.RubEmplNumberChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.TableInsurance.SetCountValue(this.UniqueOrgKey, this.YearOffset, oldValue, newValue);
            this.PositionChangeEventHandler(tableId, oldValue, newValue, fieldId);
        };
        ObasTablePXBaseSp3.prototype.UsdChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this._usdFotDataField.Value = this.Document.CommonRules.ConvertDollarToRuble(newValue, this.Year.Value);
        };
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "YearOffset", {
            get: function () {
                return ObasHelper.GetYearOffset(this);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "UniqueOrgTable", {
            get: function () {
                if (this._uniqOrgTable == null) {
                    this._uniqOrgTable = this.ParentTable.ParentTable;
                }
                return this._uniqOrgTable;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTablePXBaseSp3.prototype, "UniqueOrgKey", {
            get: function () {
                var keys = this.GetKeys();
                return this.UniqueOrgTable.GetRecordKey(this.UniqueOrgTable.GetKeys(keys.OrgKey, keys.CountryKey));
            },
            enumerable: true,
            configurable: true
        });
        ObasTablePXBaseSp3.prototype.SumChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.TableFot.SetSumByKeys(this.GenerateYearField(), this.TableFot.GetKeys(this.UniqueOrgKey, StrKeysPXSp2.FotUsd), oldValue, newValue);
        };
        ObasTablePXBaseSp3.prototype.GenerateYearField = function () {
            return ObasTableFields.YearDataField.GenerateId(this.YearOffset + 1);
        };
        ObasTablePXBaseSp3.prototype.CalcBarsId = function () {
            return this.ParentTable.CalcBarsFilteringColumn() + "_" + this.PositionKey.Value;
        };
        ObasTablePXBaseSp3.prototype.AfterDeleteChildsEventHandler = function (tableId) {
            this.UsdEmplCountField.Value = 0;
            this.RubEmplCountField.Value = 0;
        };
        ObasTablePXBaseSp3.prototype.CollectUserData = function () {
            return this.CollectTableData(this.InitCopyFieldsInfo());
        };
        ObasTablePXBaseSp3.prototype.ResetData = function (keys) {
            if (keys) {
                if (this.LocateByKeys(keys.ToArray())) {
                    this.InnerResetData(this, this.RecordKey.Value);
                }
            }
            else {
                this.Iterate(this.InnerResetData);
            }
        };
        return ObasTablePXBaseSp3;
    }(ObasTableWithKeysParent));
    F01280.ObasTablePXBaseSp3 = ObasTablePXBaseSp3;
    var ObasTablePXSp3 = (function (_super) {
        __extends(ObasTablePXSp3, _super);
        function ObasTablePXSp3() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        ObasTablePXSp3.prototype.TotalFotChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.TableIndexation.SetSumByKeys(this.GenerateYearField(), this.TableIndexation.GetKeys(this.UniqueOrgKey, StrKeysPXIndex.Fot), oldValue, newValue);
        };
        return ObasTablePXSp3;
    }(ObasTablePXBaseSp3));
    F01280.ObasTablePXSp3 = ObasTablePXSp3;
    var ObasTableP2Sp3 = (function (_super) {
        __extends(ObasTableP2Sp3, _super);
        function ObasTableP2Sp3(id, document, parentTable, tableFot, tableIndexation, tableInsurance, _uniqPosTable) {
            var _this = _super.call(this, id, document, parentTable, tableFot, tableIndexation, tableInsurance) || this;
            _this._uniqPosTable = _uniqPosTable;
            _this._orgKey = null;
            _this._countryKey = null;
            _this._positionKey = null;
            return _this;
        }
        Object.defineProperty(ObasTableP2Sp3.prototype, "RubEmplCountField", {
            get: function () {
                return this.UsdEmplCountField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP2Sp3.prototype, "CountMonth", {
            get: function () {
                return this._document.CountMonthForCalcTable.GetCountMonthByYear(this.Year.Value);
            },
            enumerable: true,
            configurable: true
        });
        ObasTableP2Sp3.prototype.UsdFotPartsChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.UsdData.Value = this.CountMonth *
                this.UsdEmplCountField.Value *
                this.GetFieldValue("g5") *
                (this.GetFieldValue("g6") + this.CalcPercent(this.GetFieldValue("g7")) + this.CalcPercent(this.GetFieldValue("g8")) + 1);
        };
        ObasTableP2Sp3.prototype.InitUsdCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            result.setValue(this.IsCopiedFieldUsd.Id, {
                Id: this.IsCopiedFieldUsd.Id,
                IsData: false
            });
            result.setValue(this.OwnerKeyField.Id, {
                Id: this.OwnerKeyField.Id,
                IsData: false
            });
            result.setValue(this.PositionKey.Id, {
                Id: this.PositionKey.Id,
                IsData: false
            });
            result.setValue(this.UsdEmplCountField.Id, {
                Id: this.UsdEmplCountField.Id,
                IsData: true
            });
            for (var i = 5; i < 9; i++) {
                result.setValue("g" + i, {
                    Id: "g" + i,
                    IsData: true
                });
            }
            return result;
        };
        ObasTableP2Sp3.prototype.InitRubCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            return result;
        };
        ObasTableP2Sp3.prototype.PositionChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var uniqOrgKey = this.UniqueOrgKey;
            var orgKey = this.OrgKey.Value;
            var countryKey = this.CountryKey.Value;
            this.AfterDeleteEventHandler(tableId, orgKey, countryKey, oldValue);
            this.Document.CommonRules.AddNewLink(this._uniqPosTable.Id, this._uniqPosTable.KeyFieldIds, [uniqOrgKey, newValue]);
        };
        ObasTableP2Sp3.prototype.DeleteEventHandler = function (tableId) {
            this._orgKey = this.OrgKey.Value;
            this._countryKey = this.CountryKey.Value;
            this._positionKey = this.PositionKey.Value;
        };
        ObasTableP2Sp3.prototype.AfterDeleteEventHandler = function (tableId, orgKey, countryKey, positionKey) {
            if (orgKey === void 0) { orgKey = this._orgKey; }
            if (countryKey === void 0) { countryKey = this._countryKey; }
            if (positionKey === void 0) { positionKey = this._positionKey; }
            this.Document.CommonRules.DeleteOldLink(this._uniqPosTable.Id, [this.Id], this._uniqPosTable.UniqIndexFieldIds, [orgKey, countryKey, positionKey]);
        };
        ObasTableP2Sp3.prototype.InnerResetData = function (table, recordKey) {
            table.SetFieldValue("UsdEmplNumber", 0);
            table.SetFieldValue("UsdFot", 0);
            table.SetFieldValue("UsdTotalFot", 0);
            for (var i = 5; i < 9; i++) {
                table.SetFieldValue("g" + i, 0);
            }
        };
        ObasTableP2Sp3.prototype.CountMonthChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var countMonth = this.CountMonth;
            if (countMonth >= 0 && countMonth <= 12) {
                this.UsdFotPartsChangeEventHandler(tableId, oldValue, newValue, fieldId);
            }
            else {
                Client.ShowMessage("\u041E\u0448\u0438\u0431\u043A\u0430", "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043B\u044F \u00AB\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u044F\u0446\u0435\u0432\u00BB \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u044C\u0441\u044F \u0432 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435 \u043E\u0442 0 \u0434\u043E 12.", MessageIcons.Error);
                this.SetFieldValue("CountMonth", oldValue);
            }
        };
        return ObasTableP2Sp3;
    }(ObasTablePXSp3));
    F01280.ObasTableP2Sp3 = ObasTableP2Sp3;
    var ObasTableP3Sp3 = /** @class */ (function (_super) {
        __extends(ObasTableP3Sp3, _super);
        function ObasTableP3Sp3() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this._salary = null;
            return _this;
        }
        Object.defineProperty(ObasTableP3Sp3.prototype, "Salary", {
            get: function () {
                if (this._salary == null) {
                    this._salary = new ObasTableField("g7_3_7", this);
                }
                return this._salary;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP3Sp3.prototype, "RubEmplCountField", {
            get: function () {
                return this.UsdEmplCountField;
            },
            enumerable: true,
            configurable: true
        });
        ObasTableP3Sp3.prototype.InitG15P3Sp7 = function () {
            return 2;
        };
        ObasTableP3Sp3.prototype.InitG16P3Sp7 = function () {
            return 3;
        };
        Object.defineProperty(ObasTableP3Sp3.prototype, "UsdCountMonth", {
            get: function () {
                return this._document.CountMonthForCalcTable.GetCountMonthByYear(this.Year.Value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP3Sp3.prototype, "RubCountMonth", {
            get: function () {
                return this._document.CountMonthForCalcTable.GetCountMonthByYear(this.Year.Value);
            },
            enumerable: true,
            configurable: true
        });
        ObasTableP3Sp3.prototype.UsdFotPartsChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.UsdData.Value = this.UsdCountMonth *
                this.UsdEmplCountField.Value *
                this.GetFieldValue("g7") *
                (this.CalcPercent(this.GetFieldValue("g8")) +
                    this.CalcPercent(this.GetFieldValue("g9")) +
                    this.CalcPercent(this.GetFieldValue("g10")) +
                    this.CalcPercent(this.GetFieldValue("g11")) +
                    1);
        };
        ObasTableP3Sp3.prototype.UpdatePayment = function (fieldIndex) {
            this.SetFieldValue("g" + fieldIndex + "_3_8", this.RubCountMonth * this.UsdEmplCountField.Value * this.GetFieldValue("g" + fieldIndex + "_3_7"));
        };
        ObasTableP3Sp3.prototype.InitUsdCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            var order = 1;
            result.setValue(this.IsCopiedFieldUsd.Id, {
                Id: this.IsCopiedFieldUsd.Id,
                IsData: false,
                Order: order++
            });
            result.setValue(this.OwnerKeyField.Id, {
                Id: this.OwnerKeyField.Id,
                IsData: false,
                Order: order++
            });
            result.setValue(this.PositionKey.Id, {
                Id: this.PositionKey.Id,
                IsData: false,
                Order: order++
            });
            for (var i = 7; i < 12; i++) {
                result.setValue("g" + i, {
                    Id: "g" + i,
                    IsData: true,
                    Order: order++
                });
            }
            result.setValue(this.UsdEmplCountField.Id, {
                Id: this.UsdEmplCountField.Id,
                IsData: true,
                Order: 1000
            });
            return result;
        };
        ObasTableP3Sp3.prototype.InitRubCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            var order = 1;
            result.setValue(this.IsCopiedFieldRub.Id, {
                Id: this.IsCopiedFieldRub.Id,
                IsData: false,
                Order: order++
            });
            result.setValue(this.OwnerKeyField.Id, {
                Id: this.OwnerKeyField.Id,
                IsData: false,
                Order: order++
            });
            result.setValue(this.PositionKey.Id, {
                Id: this.PositionKey.Id,
                IsData: false,
                Order: order++
            });
            result.setValue("g8_3_7", {
                Id: "g8_3_7",
                IsData: true,
                Order: order++
            });
            result.setValue("g15_3_7", {
                Id: "g15_3_7",
                IsData: true,
                Order: order++
            });
            result.setValue("g16_3_7", {
                Id: "g16_3_7",
                IsData: true,
                Order: order++
            });
            result.setValue(this.UsdEmplCountField.Id, {
                Id: this.UsdEmplCountField.Id,
                IsData: true,
                Order: 1000
            });
            return result;
        };
        ObasTableP3Sp3.prototype.PositionChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.UpdatePayment(7);
            this.UpdatePayment(8);
            var salary = this.UsdEmplCountField.Value * this.Salary.Value;
            for (var i = 10; i < 14; i++) {
                this.SetFieldValue("g" + i + "_3_8", salary * this.GetFieldValue("g" + i + "_3_7") * (this.RubCountMonth / 12));
            }
            salary = (this.GetFieldValue("g10_3_7") / 12 + 1) * salary;
            for (var i = 15; i < 17; i++) {
                this.SetFieldValue("g" + i + "_3_8", salary * this.GetFieldValue("g" + i + "_3_7") * (this.RubCountMonth / 12));
            }
            var fotSum = 0;
            var awardSumSalary = 0;
            var awardSumCount = 0;
            for (var i = 7; i < 17; i++) {
                if (i !== 9 && i !== 14) {
                    var value = this.GetFieldValue("g" + i + "_3_8");
                    if (i > 9 && i < 14) {
                        awardSumSalary += value;
                    }
                    else if (i > 14) {
                        awardSumCount += value;
                    }
                    fotSum += value;
                }
            }
            this.SetFieldValue("g9_3_8", awardSumSalary);
            this.SetFieldValue("g14_3_8", awardSumCount);
            this.RubFotData.Value = fotSum * 0.5;
        };
        ObasTableP3Sp3.prototype.UsdEmplNumberChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            _super.prototype.UsdEmplNumberChangeEventHandler.call(this, tableId, oldValue, newValue, fieldId);
            this.RubEmplNumberChangeEventHandler(tableId, oldValue, newValue, fieldId);
        };
        ObasTableP3Sp3.prototype.InnerResetData = function (table, recordKey) {
            table.SetFieldValue("UsdEmplNumber", 0);
            table.SetFieldValue("UsdFot", 0);
            table.SetFieldValue("UsdTotalFot", 0);
            table.SetFieldValue("RubTotalFot", 0);
            for (var i = 7; i < 17; i++) {
                if (i >= 7 && i <= 11) {
                    table.SetFieldValue("g" + i, 0);
                }
                if (i === 8 || i === 9 || (i >= 14 && i <= 16)) {
                    table.SetFieldValue("g" + i + "_3_7", 0);
                }
                table.SetFieldValue("g" + i + "_3_8", 0);
            }
        };
        ObasTableP3Sp3.prototype.UsdCountMonthChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var countMonth = this.UsdCountMonth;
            if (countMonth >= 0 && countMonth <= 12) {
                this.UsdFotPartsChangeEventHandler(tableId, oldValue, newValue, fieldId);
            }
            else {
                Client.ShowMessage("\u041E\u0448\u0438\u0431\u043A\u0430", "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043B\u044F \u00AB\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u044F\u0446\u0435\u0432\u00BB \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u044C\u0441\u044F \u0432 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435 \u043E\u0442 0 \u0434\u043E 12.", MessageIcons.Error);
                this.SetFieldValue("UsdCountMonth", oldValue);
            }
        };
        ObasTableP3Sp3.prototype.RubCountMonthChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var countMonth = this.RubCountMonth;
            if (countMonth >= 0 && countMonth <= 12) {
                this.PositionChangeEventHandler(tableId, oldValue, newValue, fieldId);
            }
            else {
                Client.ShowMessage("\u041E\u0448\u0438\u0431\u043A\u0430", "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043B\u044F \u00AB\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u044F\u0446\u0435\u0432\u00BB \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u044C\u0441\u044F \u0432 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435 \u043E\u0442 0 \u0434\u043E 12.", MessageIcons.Error);
                this.SetFieldValue("RubCountMonth", oldValue);
            }
        };
        return ObasTableP3Sp3;
    }(ObasTablePXSp3));
    F01280.ObasTableP3Sp3 = ObasTableP3Sp3;
    var ObasTableP5Sp3 = (function (_super) {
        __extends(ObasTableP5Sp3, _super);
        function ObasTableP5Sp3() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this._salary = null;
            return _this;
        }
        Object.defineProperty(ObasTableP5Sp3.prototype, "Salary", {
            get: function () {
                if (this._salary == null) {
                    this._salary = new ObasTableField("g5_5_5", this);
                }
                return this._salary;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP5Sp3.prototype, "UsdCountMonth", {
            get: function () {
                return this._document.CountMonthForCalcTable.GetCountMonthByYear(this.Year.Value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP5Sp3.prototype, "RubCountMonth", {
            get: function () {
                return this._document.CountMonthForCalcTable.GetCountMonthByYear(this.Year.Value);
            },
            enumerable: true,
            configurable: true
        });
        ObasTableP5Sp3.prototype.UsdFotPartsChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.UsdData.Value = this.UsdCountMonth *
                this.UsdEmplCountField.Value * this.GetFieldValue("g5") * (this.CalcPercent(this.GetFieldValue("g6")) + 1);
        };
        ObasTableP5Sp3.prototype.InitG7P5Sp5 = function () {
            return 10;
        };
        ObasTableP5Sp3.prototype.InitG9P5Sp5 = function () {
            return 3;
        };
        ObasTableP5Sp3.prototype.InitUsdCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            var order = 1;
            result.setValue(this.IsCopiedFieldUsd.Id, {
                Id: this.IsCopiedFieldUsd.Id,
                IsData: false,
                Order: order++
            });
            result.setValue(this.OwnerKeyField.Id, {
                Id: this.OwnerKeyField.Id,
                IsData: false,
                Order: order++
            });
            result.setValue(this.PositionKey.Id, {
                Id: this.PositionKey.Id,
                IsData: false,
                Order: order++
            });
            for (var i = 5; i < 7; i++) {
                result.setValue("g" + i, {
                    Id: "g" + i,
                    IsData: true,
                    Order: order++
                });
            }
            result.setValue(this.UsdEmplCountField.Id, {
                Id: this.UsdEmplCountField.Id,
                IsData: true,
                Order: 1000
            });
            return result;
        };
        ObasTableP5Sp3.prototype.InitRubCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            var order = 1;
            result.setValue(this.IsCopiedFieldRub.Id, {
                Id: this.IsCopiedFieldRub.Id,
                IsData: false,
                Order: order++
            });
            result.setValue(this.OwnerKeyField.Id, {
                Id: this.OwnerKeyField.Id,
                IsData: false,
                Order: order++
            });
            result.setValue(this.PositionKey.Id, {
                Id: this.PositionKey.Id,
                IsData: false,
                Order: order++
            });
            result.setValue("g7_5_5", {
                Id: "g7_5_5",
                IsData: true,
                Order: order++
            });
            result.setValue("g9_5_5", {
                Id: "g9_5_5",
                IsData: true,
                Order: order++
            });
            result.setValue(this.RubEmplCountField.Id, {
                Id: this.RubEmplCountField.Id,
                IsData: true,
                Order: 1001
            });
            return result;
        };
        ObasTableP5Sp3.prototype.PositionChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var salary = this.RubEmplCountField.Value * this.Salary.Value;
            var fot = salary * this.RubCountMonth;
            this.SetFieldValue("g5_5_6", fot);
            for (var i = 7; i < 12; i++) {
                this.SetFieldValue("g" + i + "_5_6", salary * this.GetFieldValue("g" + i + "_5_5") * (this.RubCountMonth / 12));
            }
            var sum = 0;
            for (var i = 7; i < 12; i++) {
                sum += this.GetFieldValue("g" + i + "_5_6");
            }
            this.SetFieldValue("g6_5_6", sum);
            sum += fot;
            this.RubFotData.Value = sum * 0.5;
        };
        ObasTableP5Sp3.prototype.InnerResetData = function (table, recordKey) {
            table.SetFieldValue("UsdEmplNumber", 0);
            table.SetFieldValue("UsdFot", 0);
            table.SetFieldValue("UsdTotalFot", 0);
            table.SetFieldValue("RubEmplNumber", 0);
            table.SetFieldValue("RubTotalFot", 0);
            for (var i = 5; i < 12; i++) {
                if (i === 5 || i === 6) {
                    table.SetFieldValue("g" + i, 0);
                }
                if (i === 6 || i === 7 || i === 9) {
                    table.SetFieldValue("g" + i + "_5_5", 0);
                }
                table.SetFieldValue("g" + i + "_5_6", 0);
            }
        };
        ObasTableP5Sp3.prototype.UsdCountMonthChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var countMonth = this.UsdCountMonth;
            if (countMonth >= 0 && countMonth <= 12) {
                this.UsdFotPartsChangeEventHandler(tableId, oldValue, newValue, fieldId);
            }
            else {
                Client.ShowMessage("\u041E\u0448\u0438\u0431\u043A\u0430", "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043B\u044F \u00AB\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u044F\u0446\u0435\u0432\u00BB \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u044C\u0441\u044F \u0432 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435 \u043E\u0442 0 \u0434\u043E 12.", MessageIcons.Error);
                this.SetFieldValue("UsdCountMonth", oldValue);
            }
        };
        ObasTableP5Sp3.prototype.RubCountMonthChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var countMonth = this.RubCountMonth;
            if (countMonth >= 0 && countMonth <= 12) {
                this.PositionChangeEventHandler(tableId, oldValue, newValue, fieldId);
            }
            else {
                Client.ShowMessage("\u041E\u0448\u0438\u0431\u043A\u0430", "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043B\u044F \u00AB\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u044F\u0446\u0435\u0432\u00BB \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u044C\u0441\u044F \u0432 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435 \u043E\u0442 0 \u0434\u043E 12.", MessageIcons.Error);
                this.SetFieldValue("RubCountMonth", oldValue);
            }
        };
        return ObasTableP5Sp3;
    }(ObasTablePXSp3));
    F01280.ObasTableP5Sp3 = ObasTableP5Sp3;
    var ObasTableP4Sp3 = (function (_super) {
        __extends(ObasTableP4Sp3, _super);
        function ObasTableP4Sp3() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        ObasTableP4Sp3.prototype.TotalFotChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.TableIndexation.SetSumByKeys(this.GenerateYearField(), this.TableIndexation.GetKeys(this.UniqueOrgKey, StrKeysP4Index.Fot), oldValue, newValue);
        };
        Object.defineProperty(ObasTableP4Sp3.prototype, "UsdCountMonth", {
            get: function () {
                return this._document.CountMonthForCalcTable.GetCountMonthByYear(this.Year.Value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP4Sp3.prototype, "RubCountMonth", {
            get: function () {
                return this._document.CountMonthForCalcTable.GetCountMonthByYear(this.Year.Value);
            },
            enumerable: true,
            configurable: true
        });
        ObasTableP4Sp3.prototype.UsdFotPartsChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.UsdData.Value = this.UsdCountMonth *
                this.UsdEmplCountField.Value * (this.GetFieldValue("g6") + this.GetFieldValue("g7"));
        };
        ObasTableP4Sp3.prototype.PositionChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var salary = 0;
            for (var i = 6; i < 9; i++) {
                salary += this.GetFieldValue("g" + i + "_4_6");
            }
            this.SetFieldValue("g5_4_6", salary);
            this.RubFotData.Value = this.RubCountMonth * this.RubEmplCountField.Value * salary;
        };
        ObasTableP4Sp3.prototype.InitUsdCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            result.setValue(this.IsCopiedFieldUsd.Id, {
                Id: this.IsCopiedFieldUsd.Id,
                IsData: false
            });
            result.setValue(this.OwnerKeyField.Id, {
                Id: this.OwnerKeyField.Id,
                IsData: false
            });
            result.setValue(this.PositionKey.Id, {
                Id: this.PositionKey.Id,
                IsData: false
            });
            result.setValue(this.UsdEmplCountField.Id, {
                Id: this.UsdEmplCountField.Id,
                IsData: true
            });
            for (var i = 6; i < 8; i++) {
                result.setValue("g" + i, {
                    Id: "g" + i,
                    IsData: true
                });
            }
            return result;
        };
        ObasTableP4Sp3.prototype.InitRubCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            result.setValue(this.IsCopiedFieldRub.Id, {
                Id: this.IsCopiedFieldRub.Id,
                IsData: false
            });
            result.setValue(this.OwnerKeyField.Id, {
                Id: this.OwnerKeyField.Id,
                IsData: false
            });
            result.setValue(this.PositionKey.Id, {
                Id: this.PositionKey.Id,
                IsData: false
            });
            result.setValue(this.RubEmplCountField.Id, {
                Id: this.RubEmplCountField.Id,
                IsData: true
            });
            for (var i = 6; i < 9; i++) {
                result.setValue("g" + i + "_4_6", {
                    Id: "g" + i + "_4_6",
                    IsData: true
                });
            }
            return result;
        };
        ObasTableP4Sp3.prototype.InnerResetData = function (table, recordKey) {
            table.SetFieldValue("UsdEmplNumber", 0);
            table.SetFieldValue("UsdFot", 0);
            table.SetFieldValue("UsdTotalFot", 0);
            table.SetFieldValue("RubEmplNumber", 0);
            table.SetFieldValue("RubTotalFot", 0);
            for (var i = 5; i < 9; i++) {
                if (i < 8) {
                    table.SetFieldValue("g" + i, 0);
                }
                table.SetFieldValue("g" + i + "_4_6", 0);
            }
        };
        ObasTableP4Sp3.prototype.UsdCountMonthChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var countMonth = this.UsdCountMonth;
            if (countMonth >= 0 && countMonth <= 12) {
                this.UsdFotPartsChangeEventHandler(tableId, oldValue, newValue, fieldId);
            }
            else {
                Client.ShowMessage("\u041E\u0448\u0438\u0431\u043A\u0430", "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043B\u044F \u00AB\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u044F\u0446\u0435\u0432\u00BB \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u044C\u0441\u044F \u0432 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435 \u043E\u0442 0 \u0434\u043E 12.", MessageIcons.Error);
                this.SetFieldValue("UsdCountMonth", oldValue);
            }
        };
        ObasTableP4Sp3.prototype.RubCountMonthChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var countMonth = this.RubCountMonth;
            if (countMonth >= 0 && countMonth <= 12) {
                this.PositionChangeEventHandler(tableId, oldValue, newValue, fieldId);
            }
            else {
                Client.ShowMessage("\u041E\u0448\u0438\u0431\u043A\u0430", "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043B\u044F \u00AB\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u044F\u0446\u0435\u0432\u00BB \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u044C\u0441\u044F \u0432 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435 \u043E\u0442 0 \u0434\u043E 12.", MessageIcons.Error);
                this.SetFieldValue("RubCountMonth", oldValue);
            }
        };
        return ObasTableP4Sp3;
    }(ObasTablePXBaseSp3));
    F01280.ObasTableP4Sp3 = ObasTableP4Sp3;
    var ObasTableP2Sp6 = (function (_super) {
        __extends(ObasTableP2Sp6, _super);
        function ObasTableP2Sp6(_parentTable, _tableInsurance) {
            var _this = _super.call(this, "F01_280_r2_5_V2", [ObasTableFields.OrgKeyField.Id, ObasTableFields.PositionField.Id]) || this;
            _this._parentTable = _parentTable;
            _this._tableInsurance = _tableInsurance;
            _this._document = null;
            _this._orgKeyField = null;
            _this._positionKeyField = null;
            _this._uniqIndexFieldIds = _this.OrgTable.KeyFieldIds.concat([ObasTableFields.PositionField.Id]);
            return _this;
        }
        Object.defineProperty(ObasTableP2Sp6.prototype, "UniqIndexFieldIds", {
            get: function () {
                return this._uniqIndexFieldIds;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP2Sp6.prototype, "Document", {
            get: function () {
                if (this._document == null) {
                    this._document = this._parentTable.Document;
                }
                return this._document;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP2Sp6.prototype, "ParentTable", {
            get: function () {
                return this._parentTable;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP2Sp6.prototype, "OrgTable", {
            get: function () {
                return this._parentTable.OrgTable;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP2Sp6.prototype, "PositionKeyField", {
            get: function () {
                if (this._positionKeyField == null) {
                    this._positionKeyField = new ObasTableField(ObasTableFields.PositionField.Id, this);
                }
                return this._positionKeyField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP2Sp6.prototype, "OrgKeyField", {
            get: function () {
                if (this._orgKeyField == null) {
                    this._orgKeyField = new ObasTableField(ObasTableFields.OrgKeyField.Id, this);
                }
                return this._orgKeyField;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP2Sp6.prototype, "OrgKey", {
            get: function () {
                return this.OrgKeyField.Value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObasTableP2Sp6.prototype, "TableInsurance", {
            get: function () {
                return this._tableInsurance;
            },
            enumerable: true,
            configurable: true
        });
        ObasTableP2Sp6.prototype.UpdateFot = function (yearOffset) {
            this.SetFieldValue(ObasTableFields.YearDataField.GenerateId(yearOffset),
            	this.Document.CountMonthForCalcTable.GetCountMonthByYearOffset(yearOffset) *
                this.GetFieldValue(ObasTableFields.CountYearDataField.GenerateId(yearOffset)) *
                this.GetFieldValue("Pay_Y" + yearOffset));
        };
        ObasTableP2Sp6.prototype.RubEmplNumberChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var yearOffset = ObasHelper.GetYearOffsetById(fieldId);
            this.TableInsurance.SetCountValue(this.OrgKey, yearOffset, oldValue, newValue);
            this.UpdateFot(yearOffset + 1);
        };
        ObasTableP2Sp6.prototype.PositionChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                this.UpdateFot(i);
            }
        };
        ObasTableP2Sp6.prototype.TotalFotChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.ParentTable.SetSumByKeys(fieldId, this.ParentTable.GetKeys(this.OrgKey, StrKeysPXIndex.Fot), oldValue, newValue);
        };
        ObasTableP2Sp6.prototype.CalcBarsId = function () {
            return this.OrgTable.CalcBarsFilteringColumn() + "_" + this.PositionKeyField.Value;
        };
        ObasTableP2Sp6.prototype.AfterDeleteChildsEventHandler = function (tableId) {
            for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                this.SetFieldValue(ObasTableFields.CountYearDataField.GenerateId(i), 0);
            }
        };
        ObasTableP2Sp6.prototype.CopyData = function (srcYear, destYear) {
            var _this = this;
            var srcIndex = srcYear ? srcYear - ObasStageSettings.CurrentYear + 1 : ObasStageSettings.YearsCount - 1;
            var destIndex = destYear ? destYear - ObasStageSettings.CurrentYear + 1 : ObasStageSettings.YearsCount;
            var yearField = BaseObasTableFields.CountYearDataField;
            var srcFieldId = yearField.GenerateId(srcIndex);
            var destFieldId = yearField.GenerateId(destIndex);
            var copy = function () {
                _this.SetFieldValue(destFieldId, _this.GetFieldValue(srcFieldId));
            };
            this.Iterate(copy);
        };
        ObasTableP2Sp6.prototype.InitCopyFieldsInfo = function () {
            var result = new collections.Dictionary();
            result.setValue(this.OrgKeyField.Id, {
                Id: this.OrgKeyField.Id,
                IsData: false
            });
            result.setValue(this.PositionKeyField.Id, {
                Id: this.PositionKeyField.Id,
                IsData: false
            });
            var countField = BaseObasTableFields.CountYearDataField;
            for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                var fieldId = countField.GenerateId(i);
                result.setValue(fieldId, {
                    Id: fieldId,
                    IsData: true
                });
            }
            return result;
        };
        ObasTableP2Sp6.prototype.CollectUserData = function () {
            return this.CollectTableData(this.InitCopyFieldsInfo());
        };
        ObasTableP2Sp6.prototype.ResetData = function () {
            var _this = this;
            var yearField = BaseObasTableFields.YearDataField;
            var countField = BaseObasTableFields.CountYearDataField;
            var resetDataHandler = function () {
                for (var i = 1; i <= ObasStageSettings.YearsCount; i++) {
                    _this.SetFieldValue(countField.GenerateId(i), 0);
                    _this.SetFieldValue(yearField.GenerateId(i), 0);
                }
            };
            this.Iterate(resetDataHandler);
        };
        ObasTableP2Sp6.prototype.CountMonthChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            if (fieldId.indexOf("CountMonth") === 0) {
                var countMonth = this.GetFieldValue(fieldId);
                if (countMonth >= 0 && countMonth <= 12) {
                    this.PositionChangeEventHandler(tableId, oldValue, newValue, fieldId);
                }
                else {
                    Client.ShowMessage("\u041E\u0448\u0438\u0431\u043A\u0430", "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043B\u044F \u00AB\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u044F\u0446\u0435\u0432\u00BB \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u044C\u0441\u044F \u0432 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435 \u043E\u0442 0 \u0434\u043E 12.", MessageIcons.Error);
                    this.SetFieldValue(fieldId, oldValue);
                }
            }
        };
        return ObasTableP2Sp6;
    }(ObasTable));
    F01280.ObasTableP2Sp6 = ObasTableP2Sp6;
    var StrTransposedObasTable = (function (_super) {
        __extends(StrTransposedObasTable, _super);
        function StrTransposedObasTable(id, _document) {
            var _this = _super.call(this, id, null, [ObasTableFields.OrgKeyField.Id], [ObasTableFields.StrKeyField.Id]) || this;
            _this._document = _document;
            return _this;
        }
        StrTransposedObasTable.prototype.GetFieldsCount = function () {
            if (this.FieldsCount == null) {
                this.FieldsCount = this._document.RowPartsCount;
            }
            return this.FieldsCount;
        };
        StrTransposedObasTable.prototype.GetFieldIndexEventHandler = function (strKey) {
            return strKey;
        };
        StrTransposedObasTable.prototype.GetFieldValueEventHandler = function (fieldIndex, fieldId) {
            return fieldId === ObasTableFields.StrKeyField.Id ? fieldIndex : undefined;
        };
        return StrTransposedObasTable;
    }(TransposedObasTable));
    F01280.StrTransposedObasTable = StrTransposedObasTable;
    var PositionsSpr0116 = (function (_super) {
        __extends(PositionsSpr0116, _super);
        function PositionsSpr0116() {
            var _this = _super.call(this, "Spr_01_16") || this;
            _this._salary = null;
            return _this;
        }
        Object.defineProperty(PositionsSpr0116.prototype, "Salary", {
            get: function () {
                if (this._salary == null) {
                    this._salary = new ObasTableField("Salary", this);
                }
                return this._salary;
            },
            enumerable: true,
            configurable: true
        });
        return PositionsSpr0116;
    }(SprTable));
    F01280.PositionsSpr0116 = PositionsSpr0116;
    var CountMonthForCalcTable = (function (_super) {
        __extends(CountMonthForCalcTable, _super);
        function CountMonthForCalcTable(id, _document) {
            var _this = _super.call(this, id) || this;
            _this._document = _document;
            return _this;
        }
        CountMonthForCalcTable.prototype.GetCountMonthByYear = function (year) {
            var yearOffset = year - ObasStageSettings.CurrentYear + 1;
            return this.GetFieldValue("CountMonthY" + yearOffset);
        };
        CountMonthForCalcTable.prototype.GetCountMonthByYearOffset = function (yearOffset) {
            return this.GetFieldValue("CountMonthY" + yearOffset);
        };
        CountMonthForCalcTable.prototype.CountMonthChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var countMonth = this.GetFieldValue(fieldId);
            if (countMonth >= 0 && countMonth <= 12) {
                var year = ObasStageSettings.CurrentYear + ObasHelper.GetYearOffsetById(fieldId);
                var p2Sp3Table = this._document.TableP2Sp3;
                while (p2Sp3Table.Locate(p2Sp3Table.Year.Id, year, true)) {
                    p2Sp3Table.SetFieldValue("CountMonth", countMonth);
                }
                p2Sp3Table.ClearLocateFlag();
                var p2Sp6Table = this._document.TableP2Sp6;
                var reader = p2Sp6Table.CreateReader();
                while (reader.Read()) {
                    p2Sp6Table.SetFieldValue("CountMonth_Y" + (ObasHelper.GetYearOffsetById(fieldId) + 1), countMonth);
                }
                p2Sp6Table.ClearLocateFlag();
                var p3Sp3Table = this._document.TableP3Sp3;
                while (p3Sp3Table.Locate(p3Sp3Table.Year.Id, year, true)) {
                    p3Sp3Table.SetFieldValue("UsdCountMonth", countMonth);
                    p3Sp3Table.SetFieldValue("RubCountMonth", countMonth);
                }
                p3Sp3Table.ClearLocateFlag();
                var p4Sp3Table = this._document.TableP4Sp3;
                while (p4Sp3Table.Locate(p4Sp3Table.Year.Id, year, true)) {
                    p4Sp3Table.SetFieldValue("UsdCountMonth", countMonth);
                    p4Sp3Table.SetFieldValue("RubCountMonth", countMonth);
                }
                p4Sp3Table.ClearLocateFlag();
                var p5Sp3Table = this._document.TableP5Sp3;
                while (p5Sp3Table.Locate(p5Sp3Table.Year.Id, year, true)) {
                    p5Sp3Table.SetFieldValue("UsdCountMonth", countMonth);
                    p5Sp3Table.SetFieldValue("RubCountMonth", countMonth);
                }
                p5Sp3Table.ClearLocateFlag();
            }
            else {
                Client.ShowMessage("\u041E\u0448\u0438\u0431\u043A\u0430", "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u043E\u043B\u044F \u00AB\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043C\u0435\u0441\u044F\u0446\u0435\u0432\u00BB \u0434\u043E\u043B\u0436\u043D\u043E \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u044C\u0441\u044F \u0432 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D\u0435 \u043E\u0442 0 \u0434\u043E 12.", MessageIcons.Error);
                this.SetFieldValue(fieldId, oldValue);
            }
        };
        return CountMonthForCalcTable;
    }(SprTable));
    F01280.CountMonthForCalcTable = CountMonthForCalcTable;
    var PurchaseObjectsSprTable = (function (_super) {
        __extends(PurchaseObjectsSprTable, _super);
        function PurchaseObjectsSprTable() {
            var _this = _super.call(this, "PurchaseObjects") || this;
            _this._number = null;
            _this._npaGroupKey = null;
            _this._npaGroup = null;
            return _this;
        }
        Object.defineProperty(PurchaseObjectsSprTable.prototype, "Number", {
            get: function () {
                if (this._number == null) {
                    this._number = new ObasTableField("Number", this);
                }
                return this._number;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PurchaseObjectsSprTable.prototype, "NpaGroupKey", {
            get: function () {
                if (this._npaGroupKey == null) {
                    this._npaGroupKey = new NumberObasTableField("SubgroupNormativeExpenses_ID", this);
                }
                return this._npaGroupKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PurchaseObjectsSprTable.prototype, "NpaGroup", {
            get: function () {
                if (this._npaGroup == null) {
                    this._npaGroup = new ObasSprTableField(ObasTableCollection.SubgroupNormativeExpensesSprTable, this);
                }
                return this._npaGroup;
            },
            enumerable: true,
            configurable: true
        });
        return PurchaseObjectsSprTable;
    }(SprTable));
    F01280.PurchaseObjectsSprTable = PurchaseObjectsSprTable;
    var PartObjectDataTable = (function (_super) {
        __extends(PartObjectDataTable, _super);
        function PartObjectDataTable(id, document, parentTable, _descTable) {
            var _this = _super.call(this, id, document, parentTable) || this;
            _this._descTable = _descTable;
            _this._objectKey = null;
            _this._object = _this._document.PurchaseObjectsSprTable;
            _this._deletedObjKey = 0;
            return _this;
        }
        Object.defineProperty(PartObjectDataTable.prototype, "ObjectKey", {
            get: function () {
                if (this._objectKey == null) {
                    this._objectKey = new NumberObasTableField("PurchaseObjects_ID", this);
                }
                return this._objectKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartObjectDataTable.prototype, "ObjectName", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.Name;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartObjectDataTable.prototype, "ObjectNumber", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.Number;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartObjectDataTable.prototype, "ObjectNpaGroupCode", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.NpaGroup.Code;
            },
            enumerable: true,
            configurable: true
        });
        PartObjectDataTable.prototype.CalcSubgroupNormativeExpensesName = function () {
            this._object.LocateByKeys(this.ObjectKey.Value);
            return this._object.NpaGroup.Name || "";
        };
        PartObjectDataTable.prototype.ObjectChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.AfterDeleteEventHandler(this.Id, oldValue);
            this._descTable.AddObject(newValue);
        };
        PartObjectDataTable.prototype.DeleteEventHandler = function (tableId) {
            this._deletedObjKey = this.ObjectKey.Value;
        };
        PartObjectDataTable.prototype.AfterDeleteEventHandler = function (tableId, objKey) {
            if (objKey === void 0) { objKey = this._deletedObjKey; }
            this._descTable.DeleteObject(tableId, objKey);
        };
        return PartObjectDataTable;
    }(ObasTableWithSimpleKeysParent));
    F01280.PartObjectDataTable = PartObjectDataTable;
    var PartOkpdTable = (function (_super) {
        __extends(PartOkpdTable, _super);
        function PartOkpdTable(id, document, parent) {
            var _this = _super.call(this, id, document, parent) || this;
            _this._okpdKey = null;
            _this._okpd = null;
            return _this;
        }
        Object.defineProperty(PartOkpdTable.prototype, "OKPDKey", {
            get: function () {
                if (this._okpdKey == null) {
                    this._okpdKey = new NumberObasTableField("OKPD_ID", this);
                }
                return this._okpdKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartOkpdTable.prototype, "Okpd", {
            get: function () {
                if (this._okpd == null) {
                    this._okpd = new ObasSprTableField(ObasTableCollection.OkpdSprTable, this);
                }
                return this._okpd;
            },
            enumerable: true,
            configurable: true
        });
        return PartOkpdTable;
    }(ObasTableWithSimpleKeysParent));
    F01280.PartOkpdTable = PartOkpdTable;
    var PartKosguTable = (function (_super) {
        __extends(PartKosguTable, _super);
        function PartKosguTable(id, document, parent) {
            var _this = _super.call(this, id, document, parent) || this;
            _this._kosguKey = null;
            _this._kosgu = null;
            _this._analysisFeatureKey = null;
            _this._analysisFeature = null;
            _this._year = null;
            return _this;
        }
        Object.defineProperty(PartKosguTable.prototype, "KosguKey", {
            get: function () {
                if (this._kosguKey == null) {
                    this._kosguKey = new NumberObasTableField("KOSGU_ID", this);
                }
                return this._kosguKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartKosguTable.prototype, "Kosgu", {
            get: function () {
                if (this._kosgu == null) {
                    this._kosgu = new ObasSprTableField(ObasTableCollection.KosguSprTable, this);
                }
                return this._kosgu;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartKosguTable.prototype, "AnalysisFeatureKey", {
            get: function () {
                if (this._analysisFeatureKey == null) {
                    this._analysisFeatureKey = new NumberObasTableField("AddAnalysisFeature_ID", this);
                }
                return this._analysisFeatureKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartKosguTable.prototype, "AnalysisFeature", {
            get: function () {
                if (this._analysisFeature == null) {
                    this._analysisFeature = new ObasSprTableField(ObasTableCollection.AddAnalysisFeatureSprtable, this);
                }
                return this._analysisFeature;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartKosguTable.prototype, "Year", {
            get: function () {
                if (this._year == null) {
                    this._year = new NumberObasTableField(BaseObasTableFields.YearField.Id, this);
                }
                return this._year;
            },
            enumerable: true,
            configurable: true
        });
        return PartKosguTable;
    }(ObasTableWithSimpleKeysParent));
    F01280.PartKosguTable = PartKosguTable;
    var UsdPartKosguTable = (function (_super) {
        __extends(UsdPartKosguTable, _super);
        function UsdPartKosguTable(id, document, parent) {
            return _super.call(this, id, document, parent) || this;
        }
        UsdPartKosguTable.prototype.SumPartsChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.SetFieldValue(BaseObasTableFields.YearDataField.GenerateId(fieldId), (this.GetFieldValue(BaseObasTableFields.RubYearDataField.GenerateId(fieldId)) || 0) +
                (this.GetFieldValue(ObasTableFields.OtherRubField.GenerateId(fieldId)) || 0));
        };
        UsdPartKosguTable.prototype.UsdChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var yearOffSet = ObasHelper.GetYearOffsetById(fieldId);
            var usdValue = this.Document.CommonRules.GetDollarRateByYear(ObasStageSettings.CurrentYear + yearOffSet);
            this.SetFieldValue(BaseObasTableFields.RubYearDataField.GenerateId(yearOffSet + 1), usdValue * newValue);
        };
        return UsdPartKosguTable;
    }(PartKosguTable));
    F01280.UsdPartKosguTable = UsdPartKosguTable;
    var ObjectDescTable = (function (_super) {
        __extends(ObjectDescTable, _super);
        function ObjectDescTable(id, _document) {
            var _this = _super.call(this, id) || this;
            _this._document = _document;
            _this._program = null;
            _this._action = null;
            _this._result = null;
            _this._rationale = null;
            _this._info = null;
            _this._objectKey = null;
            _this._object = _this._document.PurchaseObjectsSprTable;
            return _this;
        }
        Object.defineProperty(ObjectDescTable.prototype, "Info", {
            get: function () {
                if (this._info == null) {
                    this._info = new ObasTableField("Info", this);
                }
                return this._info;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "Rationale", {
            get: function () {
                if (this._rationale == null) {
                    this._rationale = new ObasTableField("Rationale", this);
                }
                return this._rationale;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "Result", {
            get: function () {
                if (this._result == null) {
                    this._result = new ObasTableField("Result", this);
                }
                return this._result;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "Action", {
            get: function () {
                if (this._action == null) {
                    this._action = new ObasTableField("ActionName", this);
                }
                return this._action;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "Program", {
            get: function () {
                if (this._program == null) {
                    this._program = new ObasTableField("ProgName", this);
                }
                return this._program;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "ObjectKey", {
            get: function () {
                if (this._objectKey == null) {
                    this._objectKey = new NumberObasTableField("PurchaseObjects_ID", this);
                }
                return this._objectKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "ObjectName", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.Name;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "ObjectNumber", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.Number;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "ObjectNpaGroupCode", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.NpaGroup.Code;
            },
            enumerable: true,
            configurable: true
        });
        ObjectDescTable.prototype.CalcSubgroupNormativeExpensesName = function () {
            this._object.LocateByKeys(this.ObjectKey.Value);
            return this._object.NpaGroup.Name || "";
        };
        ObjectDescTable.prototype.AddObject = function (objKey) {
            this._document.CommonRules.AddNewLink(this.Id, [this.ObjectKey.Id], [objKey]);
        };
        ObjectDescTable.prototype.DeleteObject = function (objectDataTable, objKey) {
            this._document.CommonRules.DeleteOldLink(this.Id, [objectDataTable], [this.ObjectKey.Id], [objKey]);
        };
        return ObjectDescTable;
    }(ObasTable));
    F01280.ObjectDescTable = ObjectDescTable;
    var ObjectDescNpaTable = (function (_super) {
        __extends(ObjectDescNpaTable, _super);
        function ObjectDescNpaTable() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this._npaFields = null;
            return _this;
        }
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaFields", {
            get: function () {
                if (this._npaFields == null) {
                    this._npaFields = new NpaRequisitesFields(this);
                }
                return this._npaFields;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaNumber", {
            get: function () {
                return this.NpaFields.NpaNumber;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaName", {
            get: function () {
                return this.NpaFields.NpaName;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaDate", {
            get: function () {
                return this.NpaFields.NpaDate;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaType", {
            get: function () {
                return this.NpaFields.NpaType;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaStatus", {
            get: function () {
                return this.NpaFields.NpaStatus;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaStatusChangeDate", {
            get: function () {
                return this.NpaFields.NpaStatusChangeDate;
            },
            enumerable: true,
            configurable: true
        });
        return ObjectDescNpaTable;
    }(ObasTableWithSimpleKeysParent));
    F01280.ObjectDescNpaTable = ObjectDescNpaTable;
})(F01280 || (F01280 = {}));
