Advertisement
Guest User

Untitled

a guest
Apr 12th, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.15 KB | None | 0 0
  1. //--> BIT CP-465 GOTolok@firstbit.ae 21.03.18
  2. AdditionalParametersStructure = New Structure;
  3.  
  4. //--> BIT CP-465 GOTolok@firstbit.ae 11.04.18
  5. Filters = New Structure;
  6. Filters.Insert("Beginofperiod", Object.RegistrationPeriod);
  7. Filters.Insert("Endofperiod", EndOfMonth(Object.RegistrationPeriod));
  8. CalculatParam = Catalogs.CalculationParameters.FindByAttribute("Id", "Payments");
  9. PaidDocuments = SmallBusinessServer.CalculateParameterValue(Filters, CalculatParam);
  10. //<-- BIT CP-465 GOTolok@firstbit.ae 11.04.18
  11. //<-- BIT CP-465 GOTolok@firstbit.ae 21.03.18
  12.  
  13. For each TabularSectionLine In Object.AccrualsDeductions Do
  14.  
  15. //--> BIT CP-465 GOTolok@firstbit.ae 21.03.18 - Fill in the structure for calculating the parameters
  16. FiltersStructure = FillFiltersStructure(TabularSectionLine);
  17.  
  18. //--> BIT CP-465 GOTolok@firstbit.ae 11.04.18
  19. FiltersStructure.Insert("Payments", PaidDocuments);
  20. //<-- BIT CP-465 GOTolok@firstbit.ae 11.04.18
  21. //<-- BIT CP-465 GOTolok@firstbit.ae 21.03.18
  22.  
  23. // 1. Check
  24. If NOT ValueIsFilled(TabularSectionLine.AccrualDeductionKind) Then
  25. Continue;
  26. EndIf;
  27. ArrayOfRepeats = QueryResult.FindRows(New Structure("Employee, AccrualDeductionKind", TabularSectionLine.Employee, TabularSectionLine.AccrualDeductionKind));
  28. If ArrayOfRepeats.Count() > 1 And ArrayOfRepeats[0].TotalForPeriod Then
  29.  
  30. TabularSectionLine.DaysWorked = 0;
  31. TabularSectionLine.HoursWorked = 0;
  32.  
  33. MessageText = NStr("ru = '%Employee%, %AccrualKind%: Данные об отработанном времени введены сводно. Расчет времени по каждому виду начисления (удержания) невозможен!'; en = '%Employee%, %AccrualKind%: Data on the worked time has been entered in a pivot table. Time calculation by each accrual cannot be done.'");
  34. MessageText = StrReplace(MessageText, "%Employee%", TabularSectionLine.Employee);
  35. MessageText = StrReplace(MessageText, "%AccrualKind%", TabularSectionLine.AccrualDeductionKind);
  36. MessageField = "Object.AccrualsDeductions[" + Object.AccrualsDeductions.IndexOf(TabularSectionLine) + "].Employee";
  37.  
  38. SmallBusinessServer.ShowMessageAboutError(Object, MessageText,,,MessageField);
  39.  
  40. EndIf;
  41.  
  42. // 2. Clearing
  43. For Counter = 1 To 3 Do
  44. TabularSectionLine["Indicator" + Counter] = "";
  45. TabularSectionLine["Presentation" + Counter] = Catalogs.CalculationParameters.EmptyRef();
  46. TabularSectionLine["Value" + Counter] = 0;
  47. EndDo;
  48.  
  49. // 3. Search all parameters-identifiers of formula
  50. ParametersStructure = New Structure;
  51. SmallBusinessServer.AddParametersToStructure(TabularSectionLine.AccrualDeductionKind.Formula, ParametersStructure);
  52. //--> BIT CP-465 GOTolok@firstbit.ae 21.03.18 - text
  53. ParametersStructure.Insert("PR");
  54. ParametersStructure.Insert("PRForSPA");
  55. If Not ParametersStructure.Property("SESPA") Then
  56. ParametersStructure.Insert("SESPA");
  57. EndIf;
  58. If Not ParametersStructure.Property("SESP") Then
  59. ParametersStructure.Insert("SESP");
  60. EndIf;
  61. If Not ParametersStructure.Property("TargetMin") Then
  62. ParametersStructure.Insert("TargetMin");
  63. EndIf;
  64. If Not ParametersStructure.Property("TargetMax") Then
  65. ParametersStructure.Insert("TargetMax");
  66. EndIf;
  67. ParametersStructure.Insert("Param21");
  68. ParametersStructure.Insert("Param22");
  69. ParametersStructure.Insert("Param31");
  70. ParametersStructure.Insert("Param211");
  71. ParametersStructure.Insert("Param212");
  72. ParametersStructure.Insert("Param321");
  73. ParametersStructure.Insert("Param322");
  74.  
  75. EmployeeNameStructure = New Structure;
  76. //<-- BIT CP-465 GOTolok@firstbit.ae 21.03.18
  77.  
  78. // 4. Add indicator
  79. Counter = 1; // BIT CP-465 GOTolok@firstbit.ae 21.03.18
  80. //--> BIT CP-465 GOTolok@firstbit.ae 11.04.18
  81. QueryText = "";
  82. QueryParameters = New Structure;
  83. //<-- BIT CP-465 GOTolok@firstbit.ae 11.04.18
  84. For Each StructureParameter In ParametersStructure Do
  85.  
  86. If StructureParameter.Key = "DaysWorked"
  87. OR StructureParameter.Key = "HoursWorked"
  88. OR StructureParameter.Key = "TariffRate" Then
  89. Continue;
  90. EndIf;
  91.  
  92. CalculationParameter = Catalogs.CalculationParameters.FindByAttribute("Id", StructureParameter.Key);
  93. If NOT ValueIsFilled(CalculationParameter) Then
  94. Message = New UserMessage();
  95. Message.Text = NStr("ru = 'Не найден параметр'; en = 'Parameter not found'") + CalculationParameter + NStr("ru = 'для сотрудника в строке №'; en = 'for the employee in the line #'") + (Object.AccrualsDeductions.IndexOf(TabularSectionLine) + 1);
  96. Message.Message();
  97. EndIf;
  98.  
  99. //--> BIT CP-465 GOTolok@firstbit.ae 20.03.18 - If the parameter is obtained by a query, then there is no need to display it.
  100. // If the parameter is obtained by a query, then calculate it.
  101. If Not CalculationParameter.SetValueDuringPayrollCalculation Then
  102. //--> BIT CP-465 GOTolok@firstbit.ae 11.04.18
  103. QueryText = QueryText + CalculationParameter.Query + ";";
  104.  
  105. For Each Parameter In CalculationParameter.QueryParameters Do
  106. If Not QueryParameters.Property(Parameter.Name) Then
  107. QueryParameters.Insert(Parameter.Name);
  108. EndIf;
  109. EndDo;
  110. //<-- BIT CP-465 GOTolok@firstbit.ae 11.04.18
  111. //EmployeeNameStructure.Insert(StructureParameter.Key, SmallBusinessServer.CalculateParameterValue(FiltersStructure, CalculationParameter, NStr("ru = 'для сотрудника в строке №'; en = 'for the employee in the line #'") + (Object.AccrualsDeductions.IndexOf(TabularSectionLine) + 1)));
  112. Continue;
  113. EndIf;
  114. //<-- BIT CP-465 GOTolok@firstbit.ae 20.03.18
  115.  
  116. If Counter > 3 Then
  117. Continue; // BIT CP-465 GOTolok@firstbit.ae 21.03.18 - proceed to the next parameter
  118. EndIf;
  119.  
  120. TabularSectionLine["Indicator" + Counter] = StructureParameter.Key;
  121. TabularSectionLine["Presentation" + Counter] = CalculationParameter;
  122.  
  123. //--> BIT CP-465 GOTolok@firstbit.ae 21.03.18
  124. Counter = Counter + 1;
  125. //<-- BIT CP-465 GOTolok@firstbit.ae 21.03.18
  126.  
  127. // 5. Calculate indicator
  128.  
  129. // BIT CP-465 GOTolok@firstbit.ae 21.03.18 - block deleted, code is put into function FillFiltersStructure()
  130.  
  131. EndDo;
  132. //--> BIT CP-465 GOTolok@firstbit.ae 11.04.18
  133. ResultArray = SmallBusinessServer.gto_CalculateParameters(FiltersStructure, QueryParameters, QueryText);
  134. If ResultArray <> Undefined Then
  135. j = ResultArray.Count();
  136. For i = 0 To j - 1 Do
  137. ResultRow = ResultArray[i].Unload();
  138. If ResultRow.Count() > 0 Then
  139. FillPropertyValues(ParametersStructure, ResultRow[0]);
  140. EndIf;
  141. EndDo;
  142. //For Each StructureParameter In ParametersStructure Do
  143. // EmployeeNameStructure.Insert(StructureParameter.Key, ResultArray[i].Unload()[0][0]);
  144. // i = i + 1;
  145. //EndDo;
  146. EndIf;
  147. //<-- BIT CP-465 GOTolok@firstbit.ae 11.04.18
  148.  
  149. //--> BIT CP-465 GOTolok@firstbit.ae 03.04.18
  150. AdditionalParametersStructure.Insert("_" + Format(TabularSectionLine.Employee.Code) + "_" + Format(StrReplace(TabularSectionLine.AccrualDeductionKind.Code, "-", "")), ParametersStructure);
  151. //<-- BIT CP-465 GOTolok@firstbit.ae 03.04.18
  152.  
  153. EndDo;
  154.  
  155. RefreshFormFooter();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement