Monday 28 August 2017

Dynamics NAV tax reporting





Value-Added Tax (VAT) is a tax on consumption that is paid by the end consumer. VAT is calculated on sales and purchases and reported to the tax authorities periodically.
In Dynamics NAV, VAT is calculated on sales and purchases invoices and credit memos. When the documents are posted, new VAT entries are created that will be used later on to report VAT to the authorities.
  • ·         All that is needed is to setup Dynamics NAV correctly
  • ·         Capture sales and purchases
  • ·         Run the VAT report
  • Dynamics updates the VAT record in real time every time a new entry is posted.  
I




Dynamics NAV Updating/ Checking WorkDate in code



Hello, there are times when you wish to perform an operation based on the work date set in NAV. For example, a colleague one time was modifying a POS system. He wanted to set the work date to the next day whenever it clocked 17 hrs in the evening. It was a requirement from a client. Definitely there were many proposals like
IF TIME > 17T THEN
  WORKDATE := TODAY +1 ;
// This only works if  the Days date is appropriately set for client PC
// It will modify the work date to today's date plus 1 day which sets it to tomorrow

In such a scenario, the risk is that you will only have correct results when the Operating System time on the client is correctly setup.
Details of the work date function are available on MSD Community. Click here





Thursday 10 August 2017

Dynamics NAV checking applied customer ledger entries in code




Hello, i was sorting out a problem at one of our clients, it became evident that i needed to check out for applied entries for a customer ledger entry. First let me put the problem in perspective then i show you how i walked around it.
A customization had been done to help users post refunds on payments made. The system creates a refund journal entry and applies it to the payment and then posts the entry. The problem is that a refund can be posted multiple times which results in jumbled customer balances. We need to stop this by making sure that a full refund is posted strictly once against a particular payment.
Here is how i go about it.


  • First pick out a specific payment using its document number and customer Number in customer ledger entry table (21)
  • Capture the entry Number of the entry above. The entry Number in customer ledger entry table is a foreign key in detailed customer ledger entry table (379). The field is renamed as "Customer Entry No"
  • Search for a record of type "Refund", Entry type "Application" whose Customer Ledger Entry Number corresponds to the one captured above.
  • If such a record exists, then its conclusive to say a refund is already posted


Here is a sample code

CustLdgEntry.RESET; // CustLdgEntry is record variable of table 21
CustLdgEntry.SETRANGE(CustLdgEntry."Document Type",CustLdgEntry."Document Type"::Payment);
CustLdgEntry.SETRANGE(CustLdgEntry.Open,FALSE);
CustLdgEntry.SETRANGE(CustLdgEntry."Sell-to Customer No.",CustomerNo);
CustLdgEntry.SETRANGE(CustLdgEntry."Document No.",PaymentDocumentNo);
IF CustLdgEntry.FINDFIRST THEN BEGIN
  DetailedLdgEntry.RESET;//DetailedLdgEntry is a record variable of table 379
  DetailedLdgEntry.SETRANGE(DetailedLdgEntry."Cust. Ledger Entry No.",CustLdgEntry."Entry No.");
  DetailedLdgEntry.SETRANGE(DetailedLdgEntry."Entry Type",DetailedLdgEntry."Entry Type"::Application);
  DetailedLdgEntry.SETRANGE(DetailedLdgEntry."Document Type",DetailedLdgEntry."Document Type"::Refund);
  IF DetailedLdgEntry.FINDFIRST THEN
    ERROR(TXT0004);// TXT0004 text variable informing user that a refund has already been posted against the payment

END;