LOG0204 Create VAT Sales Ledger Entries

Basic Information

Module Logistics.Inventory
Code LOG0204
Parent Document StoreTransaction
Sub-document Entry
Full Name Create VAT sales ledger entries
Status NEW
Deterministic/Non-deterministic YES
Transitional Documents No
Replace Generation Procedures GenerateEntry
Processing Orphan Rows Reverse
Settings Table TransationEntryTemplate
Introduced In Version
Date of Suspension

Business Logic

The generation procedure is used to generate VAT sales ledger entries in cases of VAT-self-accruement, when the VAT data is part of the Store Transaction and it does not reach the invoices. These records contain the VAT amount and its base from the current store transaction and the deal type is specified in the document route. The records are used to create data for the current document in the sales VAT register in the VAT declaration of the respective month.

VAT amount and VAT base for the specified deal type are calculated as described in Defining VAT And Base For VAT Entries. The deal type is part of the TransactionEntryTemplate table. The algorithm forms a list of deal types and for each deal type there are two values - AmountBase (the VAT base) and VATAmountBase (the VAT amount).

Also, the To Party attribute from the Store Transaction provide the RegistrationVATNumber and the RegistrationNumber of the Entry. If the party in the To Party attribute is a Company - then the data is extracted from the Company definition, if the party is Person then the RegistrationNumber is the person's NationalNumber and the RegistrationVATNumber is empty string.

If the To Party attribute is null then the generation procedure breaks and an error is thrown:

> The To Party attribute is required because it is used in the RegistrationNumber and RegistrationVATNumber establishment in the Entry record.

> Please, fill in To Party.

The TransactionEntryTemplate table also has DocumentNotesFixedText attribute which provides VAT notes.

If the document route has no TransactionEntryTemplate specified, the generation procedure breaks and and error is thrown:

> No entry generation template for this document route was found. The user doesn't have access to the template or the template was never created. Entry generation template for this route can be created from the definition of the document route (or in the routes section in the definition of the document type).

Then, for each DealType, StoreTransaction.ToParty.RegistrationNumber, StoreTransaction.ToParty.RegistrationVATNumber and StoreTransaction.DocumentDate the unfulfilled through VAT Entries values are defined - EntryRemainingAmountBase and EntryRemainingVATAmountBase. This is calculated by the principles of the Discrepancy System. If at least one of these values is not equal to 0, than a new Entry is generated. Also, if both values are equal to 0 - a new record may still be created but this happens only if there is no record created for the DealType, RegistrationNumber, RegistrationVATNumber and Apply Date (i.e. the initial values - before the unfulfilled values are calculated - are 0 and no Entry is created by now).

The Entry is generated from the current Store Transaction as follows:

Entry.EntryType = Sales

Entry.DealType = DealType

Entry.Party = StoreTransaction.ToParty

Entry.RegistrationVATNumber = StoreTransaction.ToParty.RegistrationVATNumber

if StoreTransaction.ToParty.RegistrationNumber.HasValue then

​       Entry .RegistrationNumber = StoreTransaction.ToParty.RegistrationNumber

Entry.ReferencedDocumentType = StoreTransaction.DocumentType

Entry.ReferencedDocumentNo = StoreTransaction.DocumentNo

Entry.AmountBase = REMAINING(MAmountBase)

Entry.VATAmountBase = REMAINING(MVATAmountBase)

Entry.ApplyDate = StoreTransaction.DocumentDate

if (DocumentNotesFixedText != null) then

  Entry.Notes = DocumentNotesFixedText

else if (StoreTransaction.Notes != null || StoreTransaction.Notes != "")

  Entry.Notes = StoreTransaction.Notes

else if (Entry.EnterpriseCompany.Company.Country == Bulgaria) && (StoreTransaction.Notes == null || StoreTransaction.Notes == "")

  Entry.Notes = "VAT-self-accruement."

else Entry.Notes = null
Note

The attributes which are not specified here are filled in as described in Standard Document Attributes

Fulfillments

Name DocumentAmountToEntry
Parent Entity DocumentAmount
Child Entity Entry
Parent / Child Relationship Entry.ParentDocument = StoreTransaction; Entry.DealType = DealType;Entry.RegistrationVATNumber = StoreTransaction.ToParty.RegistrationVATNumber; Entry.RegistrationNumber = StoreTransaction.ToParty.RegistrationNumber; Entry.ApplyDate = StoreTransaction.DocumentDate;

Metrics

Fulfillment Name Metric Name Measurement Unit Parent Value Child Value New Record
DocumentAmountToEntry MAmountBase StoreTransaction.EnterpriseCompany.BaseCurrency DocumentAmount[StoreTransaction; StoreTransaction.EnterpriseCompany.VATDocumentAmountType].BaseAmount(in StoreTransaction.EnterpriseCompany.BaseCurrency) Entry.AmountBase If (ParentValue.MAmountBase == 0 OR REMAINIG(MAmountBase) > 0) {New Record = YES},else {New Record = NO}
MVATAmountBase StoreTransaction.EnterpriseCompany.BaseCurrency DocumentAmount[StoreTransaction; StoreTransaction.EnterpriseCompany.VATDocumentAmountType].TotalDistributedAmount(in StoreTransaction.EnterpriseCompany.BaseCurrency) Entry.VATAmountBase If (ParentValue.MVATAmountBase == 0 OR REMAINIG(MVATAmountBase) > 0) {New Record = YES},else {New Record = NO}