Skip to content

Commit

Permalink
Translate
Browse files Browse the repository at this point in the history
  • Loading branch information
DitriXNew committed May 28, 2024
1 parent 2c8d911 commit 2c5244d
Show file tree
Hide file tree
Showing 23 changed files with 2,198 additions and 1,138 deletions.
31 changes: 7 additions & 24 deletions IRP/src/Catalogs/AccountingOperations/AccountingOperations.mdo
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,6 @@
<value>8</value>
</code>
</content>
<content id="3139d27d-f017-4cd2-9371-581a24328085">
<name>PurchaseInvoice_DR_R1021B_VendorsTransactions_CR_R1020B_AdvancesToVendors_CurrencyRevaluation</name>
<code xsi:type="core:NumberValue">
<value>24</value>
</code>
</content>
<content id="bfff9af6-8d6a-4bb7-bc85-dcb122c941a7">
<name>PurchaseInvoice_DR_R4050B_StockInventory_R5022T_Expenses_CR_R1021B_VendorsTransactions_CurrencyRevaluation</name>
<code xsi:type="core:NumberValue">
<value>25</value>
</code>
</content>
</items>
<items id="2629786b-a1c8-4e5f-819b-76ffc472e4eb">
<name>Document_RetailSalesReceipt</name>
Expand Down Expand Up @@ -398,18 +386,6 @@
<value>18</value>
</code>
</content>
<content id="494bc5e0-6a57-4f1c-ad2d-657643e6436f">
<name>SalesInvoice_DR_R2020B_AdvancesFromCustomers_CR_R2021B_CustomersTransactions_CurrencyRevaluation</name>
<code xsi:type="core:NumberValue">
<value>22</value>
</code>
</content>
<content id="7c250c81-c5a7-4347-9445-d06ba1390361">
<name>SalesInvoice_DR_R2021B_CustomersTransactions_CR_R5021T_Revenues_CurrencyRevaluation</name>
<code xsi:type="core:NumberValue">
<value>23</value>
</code>
</content>
</items>
<items id="75cbb6bf-1e5f-4185-b83d-648393a21e9c">
<name>Document_ForeignCurrencyRevaluation</name>
Expand Down Expand Up @@ -721,6 +697,13 @@
<value>95</value>
</code>
</content>
<content id="787bf187-a0cc-4e5d-8115-9ecb8496fcd7">
<name>DebitNote_DR_R2020B_AdvancesFromCustomers_CR_R2021B_CustomersTransactions</name>
<description/>
<code xsi:type="core:NumberValue">
<value>139</value>
</code>
</content>
</items>
<items id="0dc9eae5-05d2-463e-89ce-6840f9a6a934">
<name>Document_CreditNote</name>
Expand Down
155 changes: 146 additions & 9 deletions IRP/src/CommonModules/AccountingServer/Module.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Function GetOperationsDefinition()
Map.Insert(AO.DebitNote_DR_R1021B_VendorsTransactions_CR_R1020B_AdvancesToVendors , New Structure("ByRow", True));
Map.Insert(AO.DebitNote_DR_R2021B_CustomersTransactions_CR_R5021_Revenues , New Structure("ByRow", True));
Map.Insert(AO.DebitNote_DR_R5015B_OtherPartnersTransactions_CR_R5021_Revenues , New Structure("ByRow", True));
Map.Insert(AO.DebitNote_DR_R2020B_AdvancesFromCustomers_CR_R2021B_CustomersTransactions , New Structure("ByRow", True));

// Credit note
Map.Insert(AO.CreditNote_DR_R5022T_Expenses_CR_R2021B_CustomersTransactions , New Structure("ByRow", True));
Expand All @@ -125,13 +126,9 @@ Function GetOperationsDefinition()
// receipt inventory
Map.Insert(AO.PurchaseInvoice_DR_R4050B_StockInventory_R5022T_Expenses_CR_R1021B_VendorsTransactions,
New Structure("ByRow, TransactionType", True, Enums.PurchaseTransactionTypes.Purchase));
Map.Insert(AO.PurchaseInvoice_DR_R4050B_StockInventory_R5022T_Expenses_CR_R1021B_VendorsTransactions_CurrencyRevaluation,
New Structure("ByRow, TransactionType", True, Enums.PurchaseTransactionTypes.Purchase));
// offset of advabces
Map.Insert(AO.PurchaseInvoice_DR_R1021B_VendorsTransactions_CR_R1020B_AdvancesToVendors,
New Structure("ByRow, TransactionType", False, Enums.PurchaseTransactionTypes.Purchase));
Map.Insert(AO.PurchaseInvoice_DR_R1021B_VendorsTransactions_CR_R1020B_AdvancesToVendors_CurrencyRevaluation,
New Structure("ByRow, TransactionType", False, Enums.PurchaseTransactionTypes.Purchase));

Map.Insert(AO.PurchaseInvoice_DR_R1040B_TaxesOutgoing_CR_R1021B_VendorsTransactions,
New Structure("ByRow, TransactionType", True, Enums.PurchaseTransactionTypes.Purchase));
Expand All @@ -140,13 +137,9 @@ Function GetOperationsDefinition()
// sales inventory
Map.Insert(AO.SalesInvoice_DR_R2021B_CustomersTransactions_CR_R5021T_Revenues,
New Structure("ByRow, TransactionType", True, Enums.SalesTransactionTypes.Sales));
Map.Insert(AO.SalesInvoice_DR_R2021B_CustomersTransactions_CR_R5021T_Revenues_CurrencyRevaluation,
New Structure("ByRow, TransactionType", True, Enums.SalesTransactionTypes.Sales));
// offset of advances
Map.Insert(AO.SalesInvoice_DR_R2020B_AdvancesFromCustomers_CR_R2021B_CustomersTransactions,
New Structure("ByRow, TransactionType", False, Enums.SalesTransactionTypes.Sales));
Map.Insert(AO.SalesInvoice_DR_R2020B_AdvancesFromCustomers_CR_R2021B_CustomersTransactions_CurrencyRevaluation,
New Structure("ByRow, TransactionType", False, Enums.SalesTransactionTypes.Sales));

Map.Insert(AO.SalesInvoice_DR_R5021T_Revenues_CR_R2040B_TaxesIncoming,
New Structure("ByRow, TransactionType", True, Enums.SalesTransactionTypes.Sales));
Expand Down Expand Up @@ -1527,10 +1520,13 @@ Procedure UpdateAccountingTables(Object,

ObjectData = GetDocumentData(Object, Undefined, Undefined).ObjectData;

ArrayOfNotUsedOperations = New Array();

For Each Operation In OperationsByLedgerType Do
If Operation.OperationInfo.ByRow Then
Continue;
EndIf;

Parameters = New Structure();
Parameters.Insert("Object" , Object);
Parameters.Insert("Operation" , Operation.OperationInfo.Operation);
Expand All @@ -1545,7 +1541,7 @@ Procedure UpdateAccountingTables(Object,

FillAccountingRowAnalytics(Parameters);
EndDo;

If MainTableName = Undefined Then
For Each Operation In OperationsByLedgerType Do
If Not Operation.OperationInfo.RequestTable Then
Expand Down Expand Up @@ -1578,6 +1574,12 @@ Procedure UpdateAccountingTables(Object,
If Not Operation.OperationInfo.ByRow Then
Continue;
EndIf;

If IsNotUsedOperation(Operation.OperationInfo.Operation, ObjectData, RowData) Then
AddNotUsedOperation(ArrayOfNotUsedOperations, Operation.OperationInfo.Operation, Row.Key);
Continue;
EndIf;

Parameters = New Structure();
Parameters.Insert("Object" , Object);
Parameters.Insert("Operation" , Operation.OperationInfo.Operation);
Expand All @@ -1597,6 +1599,51 @@ Procedure UpdateAccountingTables(Object,

AccountingRowAnalytics.FillValues(Object.Ref, "Document");
AccountingExtDimensions.FillValues(Object.Ref, "Document");

RemoveNotUsedOperations(ArrayOfNotUsedOperations, AccountingRowAnalytics);
RemoveNotUsedOperations(ArrayOfNotUsedOperations, AccountingExtDimensions);
EndProcedure

Function IsNotUsedOperation(Operation, ObjectData, RowData)
// custom flter for each document
DocMetadata = ObjectData.Ref.Metadata();

If DocMetadata = Metadata.Documents.SalesInvoice Then
Return IsNotUsedOperation_SalesInvoice(Operation, ObjectData, RowData);
ElsIf DocMetadata = Metadata.Documents.SalesReturn Then
Return IsNotUsedOperation_SalesReturn(Operation, ObjectData, RowData);
ElsIf DocMetadata = Metadata.Documents.CreditNote Then
Return IsNotUsedOperation_CreditNote(Operation, ObjectData, RowData);
ElsIf DocMetadata = Metadata.Documents.DebitNote Then
Return IsNotUsedOperation_DebitNote(Operation, ObjectData, RowData);
EndIf;

Return False; // is used operation
EndFunction

Procedure AddNotUsedOperation(ArrayOfNotUsedOperations, Operation, RowKey = Undefined)
ArrayOfNotUsedOperations.Add(New Structure("Operation, RowKey", Operation, RowKey));
EndProcedure

Procedure RemoveNotUsedOperations(ArrayOfNotUsedOperations, AccountingTable)
ArrayForDelete = New Array();
For Each ItemOfNotUsedOperation In ArrayOfNotUsedOperations Do
For Each Row In AccountingTable Do
If Row.Operation = ItemOfNotUsedOperation.Operation Then
If ValueIsFilled(ItemOfNotUsedOperation.RowKey) Then
If Row.Key = ItemOfNotUsedOperation.RowKey Then
ArrayForDelete.Add(Row);
EndIf;
Else
ArrayForDelete.Add(Row);
EndIf;
EndIf;
EndDo;
EndDo;

For Each ItemForDelete In ArrayForDelete Do
AccountingTable.Delete(ItemForDelete);
EndDo;
EndProcedure

Function GetDocumentData(Object, TableRow, MainTableName)
Expand Down Expand Up @@ -1721,6 +1768,11 @@ Procedure ClearAccountingTables(Object, AccountingRowAnalytics, AccountingExtDim
Continue;
EndIf;

If Row.Operation.DeletionMark Then
ArrayForDelete.Add(Row);
Continue;
EndIf;

OpDef = Def.Get(Row.Operation);
If OpDef.Property("ReferTableName") And OpDef.ReferTableName <> MainTableName Then
Continue;
Expand Down Expand Up @@ -1762,6 +1814,11 @@ Procedure ClearAccountingTables(Object, AccountingRowAnalytics, AccountingExtDim
Continue;
EndIf;

If Row.Operation.DeletionMark Then
ArrayForDelete.Add(Row);
Continue;
EndIf;

OpDef = Def.Get(Row.Operation);
If OpDef.Property("ReferTableName") And OpDef.ReferTableName <> MainTableName Then
Continue;
Expand Down Expand Up @@ -2306,6 +2363,86 @@ EndProcedure

#EndRegion

#Region OperationFilters

Function IsNotUsedOperation_SalesInvoice(Operation, ObjectData, RowData)
AO = Catalogs.AccountingOperations;
If Operation = AO.SalesInvoice_DR_R5022T_Expenses_CR_R4050B_StockInventory Then
If RowData <> Undefined And RowData.IsService Then
Return True;
ENdIf;
EndIf;
Return False;
EndFunction

Function IsNotUsedOperation_SalesReturn(Operation, ObjectData, RowData)
AO = Catalogs.AccountingOperations;
If Operation = AO.SalesReturn_DR_R5022T_Expenses_CR_R4050B_StockInventory Then
If RowData <> Undefined And RowData.IsService Then
Return True;
ENdIf;
EndIf;
Return False;
EndFunction

Function IsNotUsedOperation_CreditNote(Operation, ObjectData, RowData)
AO = Catalogs.AccountingOperations;
If RowData = Undefined Then
Return True;
EndIf;

If Not ValueIsFilled(RowData.Agreement) Then
Return True;
EndIf;

IsVendor = RowData.Agreement.Type = Enums.AgreementTypes.Vendor;
IsCustomer = RowData.Agreement.Type = Enums.AgreementTypes.Customer;
IsOther = RowData.Agreement.Type = Enums.AgreementTypes.Other;

If IsVendor And Operation = AO.CreditNote_DR_R1021B_VendorsTransactions_CR_R1020B_AdvancesToVendors Then
Return False;
ElsIf IsCustomer And Operation = AO.CreditNote_DR_R2020B_AdvancesFromCustomers_CR_R2021B_CustomersTransactions Then
Return False;
ElsIf IsVendor And Operation = AO.CreditNote_DR_R5022T_Expenses_CR_R1021B_VendorsTransactions Then
Return False;
ElsIf IsCustomer And Operation = AO.CreditNote_DR_R5022T_Expenses_CR_R2021B_CustomersTransactions Then
Return False;
ElsIf IsOther And Operation = AO.CreditNote_DR_R5022T_Expenses_CR_R5015B_OtherPartnersTransactions Then
Return False;
EndIf;
Return True;
EndFunction

Function IsNotUsedOperation_DebitNote(Operation, ObjectData, RowData)
AO = Catalogs.AccountingOperations;
If RowData = Undefined Then
Return True;
EndIf;

If Not ValueIsFilled(RowData.Agreement) Then
Return True;
EndIf;

IsVendor = RowData.Agreement.Type = Enums.AgreementTypes.Vendor;
IsCustomer = RowData.Agreement.Type = Enums.AgreementTypes.Customer;
IsOther = RowData.Agreement.Type = Enums.AgreementTypes.Other;

If IsVendor And Operation = AO.DebitNote_DR_R1021B_VendorsTransactions_CR_R1020B_AdvancesToVendors Then
Return False;
ElsIf IsVendor And Operation = AO.DebitNote_DR_R1021B_VendorsTransactions_CR_R5021_Revenues Then
Return False;
ElsIf IsCustomer And Operation = AO.DebitNote_DR_R2020B_AdvancesFromCustomers_CR_R2021B_CustomersTransactions Then
Return False;
ElsIf IsCustomer And Operation = AO.DebitNote_DR_R2021B_CustomersTransactions_CR_R5021_Revenues Then
Return False;
ElsIf IsOther And Operation = AO.DebitNote_DR_R5015B_OtherPartnersTransactions_CR_R5021_Revenues Then
Return False;
EndIf;
Return True;
EndFunction

#EndRegion

#Region FixDocumentProblems

Function IsAccountingAnalyticsRegister(RegisterName) Export
Expand Down
98 changes: 50 additions & 48 deletions IRP/src/CommonModules/CommonFunctionsServer/Module.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -1526,55 +1526,57 @@ EndProcedure
Procedure CheckUniqueDescription(Cancel, Object) Export
FullName = Object.Metadata().FullName();

//@skip-check begin-transaction
BeginTransaction(DataLockControlMode.Managed);
DataLock = New DataLock();
ItemLock = DataLock.Add(FullName);
ItemLock.Mode = DataLockMode.Exclusive;
//@skip-check lock-out-of-try
DataLock.Lock();

QueryParameters = New Structure();
For Each Attr In Metadata.CommonAttributes Do
If StrStartsWith(Attr.Name, "Description_")
And CommonFunctionsClientServer.ObjectHasProperty(Object, Attr.Name)
And ValueIsFilled(Object[Attr.Name]) Then
QueryParameters.Insert(Attr.Name, Object[Attr.Name]);
EndIf;
EndDo;

If QueryParameters.Count() = 0 Then
Return;
EndIf;

Query = New Query();
Query.Text =
"SELECT
| Table.Ref
|FROM
| %1 AS Table
|WHERE
| Table.Ref <> &Ref
| AND (%2)";

Query.SetParameter("Ref", Object.Ref);

Array_where = New Array(); // Array Of String

For Each KeyValue In QueryParameters Do
Array_where.Add(StrTemplate("Table.%1 = &%1", KeyValue.Key));
Query.SetParameter(KeyValue.Key, KeyValue.Value);
EndDo;

Query.Text = StrTemplate(Query.Text, FullName, StrConcat(Array_where, " OR "));
QueryResult = Query.Execute();
QuerySelection = QueryResult.Select();

While QuerySelection.Next() Do
Cancel = True;
//@skip-check invocation-parameter-type-intersect, property-return-type
CommonFunctionsClientServer.ShowUsersMessage(StrTemplate(R().Error_139, QuerySelection.Ref));
EndDo;
Try
DataLock = New DataLock();
ItemLock = DataLock.Add(FullName);
ItemLock.Mode = DataLockMode.Exclusive;
DataLock.Lock();

QueryParameters = New Structure();
For Each Attr In Metadata.CommonAttributes Do
If StrStartsWith(Attr.Name, "Description_")
And CommonFunctionsClientServer.ObjectHasProperty(Object, Attr.Name)
And ValueIsFilled(Object[Attr.Name]) Then
QueryParameters.Insert(Attr.Name, Object[Attr.Name]);
EndIf;
EndDo;

If QueryParameters.Count() > 0 Then
Query = New Query();
Query.Text =
"SELECT
| Table.Ref
|FROM
| %1 AS Table
|WHERE
| Table.Ref <> &Ref
| AND (%2)";

Query.SetParameter("Ref", Object.Ref);

Array_where = New Array(); // Array Of String

For Each KeyValue In QueryParameters Do
Array_where.Add(StrTemplate("Table.%1 = &%1", KeyValue.Key));
Query.SetParameter(KeyValue.Key, KeyValue.Value);
EndDo;

Query.Text = StrTemplate(Query.Text, FullName, StrConcat(Array_where, " OR "));
QueryResult = Query.Execute();
QuerySelection = QueryResult.Select();

While QuerySelection.Next() Do
Cancel = True;
//@skip-check invocation-parameter-type-intersect, property-return-type
CommonFunctionsClientServer.ShowUsersMessage(StrTemplate(R().Error_139, QuerySelection.Ref));
EndDo;
EndIf;
CommitTransaction();
Except
RollbackTransaction();
Raise ErrorProcessing.DetailErrorDescription(ErrorInfo());
EndTry;
EndProcedure

#EndRegion
Expand Down
Loading

0 comments on commit 2c5244d

Please sign in to comment.