Compatible VAT Codes in the STL Segments

Now that Sterling Gentran:Server® has counted (and deleted) the STL segments and counted the ILD groups in the invoice, you want the system to determine which VAT code is used for each line item (each instance of the ILD group). Next, you want to group the line items that use the same VAT code so you can determine the VAT rate percentage (based on each VAT code) and then calculate the total VAT payable for each group of line items.

If the system finds a VAT code that is the same in both an ILD group and an STL segment (compatible VAT codes), then you want the system to execute the following operations:

  • Add the extended line cost (ILD:2 LEXC element) into the lines subtotal (ILD:2 LVLA element) to add the line item from the ILD group to the compatible STL segment
  • Increment a counter in the STL segment of how many of the existing ILD segments are compatible with that STL segment

If the system does not find an STL segment with the same VAT code as the ILD group it is visiting, then it executes the following operations:

  • Creates an STL segment with the VAT code of the current ILD group
  • Sets the number of STL segments (STL SEQA:7 element) to be the number of the last STL segment (the current segment, which was just created)
  • Sets the VAT rate percentage of the STL segment (STL VATP:2 element) to equal the VAT rate percentage of the ILD group (ILD:2 VATP element)
  • Sets the VAT code of the STL segment (STL CD12:2 element) to equal the VAT code of the ILD group (ILD:2 CD12 element)
  • Sets the lines subtotal of the STL segment (STL LVLA element) to be the extended line cost of the ILD group (ILD:2 LEXC element)
  • Sets the number of line items to be "1" (STL NRIL element)
  • Sets the number of STL segments to be the number of the current STL segment (which was just created)

Finally, you want the system to repeat the process described above (finding compatible VAT codes in the STL segments and ILD segments) until it has no more ILD groups to count (each line item has been assessed).