Create a payment through page service in NAV 2013 R2

DeepakNairDeepakNair Member Posts: 6
edited 2014-04-29 in NAV Three Tier
I am trying to integrate my system with the NAV to read the vendor ledger entries for invoices and process the payment outside the NAV. The problem that i am facing is, after reading the invoices from ledger entries table and making the payments against those invoices through my system, i want to update the payment details back to the NAV which I coudn't identify a way so far. So to summarize, i am looking a way to update the payment information in NAV, possibly through API(page web services) or by any means. I have got a vague idea, that it has to be through the payment journals but i am not very sure. Any help on this issue is much appreciated.

Comments

  • geordiegeordie Member Posts: 655
    You need to publish Payment Journal page as web service (basically adding it in Web Service table) and insert a record through it filling the proper field, including Applies-to Doc. Type and Applies-to Doc. No. which allow to post the application between the payment and the invoice.
  • DeepakNairDeepakNair Member Posts: 6
    Thanks for the reply.
    So as you say, if i need to update the payment details, i need to make an entry in the payment journal table for the corresponding Document No. In that case, similar to the manual updation process of the payments through UI, we might need to post the payment journal entry as well, after which the record will be moved to vendor ledger entries table as a doc.type Payment.If this is the case, then how can we post a payment journal through web services.
    Hope my understanding about the process is right, otherwise please do explain the correct process.
  • geordiegeordie Member Posts: 655
    Hi, if also the posting has to be done via web service, I suggest to use a different approach and develop a new codeunit to be exposed as WS.
    A function called by your system, accepting all the necessary parameters, will perform:
    - Insert of a record in Gen. Journal Line table (this method allows you also to do additional checks on value accuracy).
    - Call of Gen. Jnl.-Post Batch codeunit to post the line .
  • DeepakNairDeepakNair Member Posts: 6
    Hi Daniele, thanks again, i think i am kind of reaching close to the solution, need few more clarifications from your side.
    As you have suggested to use code unit service for inserting Journal Line and to post the line, I am seeing two code units already available with the demo version which are
    1.Gen. Jnl.-Post Line
    2.Gen. Jnl.-Post Batch

    So, can i use these code units to post the line and the batch ?
  • geordiegeordie Member Posts: 655
    Yes, it's possible to use Gen. Jnl.-Post Line codeunit (sorry, I meant this one in my previous post) to post the line, but you cannot expose this codeunit as web service since it receives a record variable as parameter and this is not a type of interface allowed.
    Anyway as said before you can include a call to this codeunit inside a "wrapping" object which can be used by an external systems.
  • DeepakNairDeepakNair Member Posts: 6
    So you mean by "wrapping" object, is to create a code unit accepting all the parameters for inserting a payment journal through the Gen. Jnl.-Post Line CU and once the line is created, then call the Gen. Jnl.-Post Batch CU to post the journal line entry.
    Please let me know if my understanding is correct.
    If this is the case, which are the functions that has to be called from the respective code units to Insert as well as posting the line.
    Appreciate your patience in answering my questions.
  • geordiegeordie Member Posts: 655
    You just have to call the codeunit passing the journal record filled with the payment data. Here's a very rough example:
    OBJECT Codeunit 50000 VendorPaymentWS
    {
      OBJECT-PROPERTIES
      {
        Date=04/28/14;
        Time=[ 3:46:13 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        OnRun=BEGIN
              END;
    
      }
      CODE
      {
    
        PROCEDURE CreateAndPostPayment@1000000000(pVendorNo@1000000000 : Code[20];pPaymAmount@1000000001 : Decimal;pPostingDate@1000000002 : Date;pDocNo@1000000003 : Code[20];pApplToDocType@1000000007 : ' ,Payment,Invoice,Credit Memo,Finance Charge Memo,Reminder,Refund';pApplToDocNo@1000000008 : Code[20]);
        VAR
          GenJnlLine@1000000004 : Record 81;
          LineNo@1000000005 : Integer;
          GenJnlPostLine@1000000006 : Codeunit 12;
        BEGIN
          GenJnlLine.SETRANGE("Journal Template Name",'PAYMENT');
          GenJnlLine.SETRANGE("Journal Batch Name",'GENERAL');
          IF GenJnlLine.FINDLAST THEN
            LineNo := GenJnlLine."Line No." + 10000
          ELSE
            LineNo := 10000;
    
          GenJnlLine.INIT;
          GenJnlLine."Journal Template Name" := 'PAYMENT';  //Fill with journal used for payments
          GenJnlLine."Journal Batch Name" := 'GENERAL';  //Fill with journal used for payments
          GenJnlLine."Line No." := LineNo;
          GenJnlLine.VALIDATE("Account Type",GenJnlLine."Account Type"::Vendor);
          GenJnlLine.VALIDATE("Account No.",pVendorNo);
          GenJnlLine.VALIDATE(Amount,pPaymAmount);
          GenJnlLine.VALIDATE("Posting Date",pPostingDate);
          GenJnlLine.VALIDATE("Document No.",pDocNo);
          GenJnlLine.VALIDATE("Bal. Account Type",GenJnlLine."Bal. Account Type"::"Bank Account");  //Fill an appropriate bal. account
          GenJnlLine.VALIDATE("Bal. Account No.",'001');  //Fill an appropriate bal. account
          GenJnlLine.VALIDATE("Applies-to Doc. Type",pApplToDocType);
          GenJnlLine.VALIDATE("Applies-to Doc. No.",pApplToDocNo);
          GenJnlLine.INSERT;
    
          GenJnlPostLine.RUN(GenJnlLine);
        END;
    
        BEGIN
        END.
      }
    }
    
  • DeepakNairDeepakNair Member Posts: 6
    That rough one will surely help me , especially being a newbie to NAV and to C/AL language. :)
    But the problem is I dont have the permissions to create a code unit, this i figured out is for the developers license, after going through the forums .
    Here i was just wondering if i need a developer's license for just creating one code unit, or is there any other options available in the terms of license.
    If there are no other options, what would be the minimum version needed to create a single codeunit in NAV?
Sign In or Register to comment.