0

I want to work out the VAT on the total items on the Purchase receipts page. I can just select the correct TaxRev class using BQL I was wondering does the system have a static class where I can get the same value. Same as Accessinfo will have the userID.

using PX.Data;
using PX.Objects.TX;

namespace PX.Objects.PO
{
    // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
    public class POReceiptEntry_Extension : PXGraphExtension<POReceiptEntry>
    {
        #region Event Handlers

        protected void POReceipt_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            var row = (POReceipt)e.Row;
            if (row is null) return;
            
            decimal totalVat = 0;
            decimal totalUnitCost = 0;

            foreach (POReceiptLine item in Base.transactions.Select())
            {
                if (item.UnitCost is null || item.Qty is null) continue;
                
                totalUnitCost += item.UnitCost.Value * item.Qty.Value;  
            }

            // TODO remove hard coded 0.15 below
            totalVat = totalUnitCost * (decimal)0.15;

            // cache.SetValueExt<POReceiptExt.usrTotalVAT>(row, totalVat);
            // cache.SetValueExt<POReceiptExt.usrTotalInclVAT>(row, totalUnitCost);

        }

        #endregion
    }
}
JvD
  • 473
  • 3
  • 18

1 Answers1

0

There is no 'global' or 'system wide' VAT rate. It is defined at the inventory item level - as InventoryItem.TaxCategoryID and it also depends by the Tax Zone which is defined at the vendor's location level. The same item can have different VAT amount, even VAT exempt, for different partners.

POReceiptTax and POReceiptTaxTran were removed from receipts in newer versions of Acumatica and one trick to determine them is to create a dummy PO Order with the same vendor and items and check the VAT over there, but you should not calculate them in RowSelected.

Lucian
  • 309
  • 2
  • 8