Monday 31 August 2015

Requisition Post


//>Start if batch does not exist create
IF NOT GenBatch.GET('PAYMENTS','PETTYCASH') THEN
BEGIN
GenBatch.INIT;
GenBatch."Journal Template Name":='PAYMENTS';
GenBatch.Name:='PETTYCASH';
GenBatch.INSERT;
END;
//<Stop

//TBLAntho.. Posting petty cash req.
 // TESTFIELD(Status,Status::Released);
  TESTFIELD("Fund No.");
IF ApprovalMgt.ImprestPrePostApprovalCheck(Rec) THEN BEGIN
IF CONFIRM ('Do you want to post this transaction ?')THEN BEGIN
    PettyApp.SETRANGE(PettyApp."No.","No.");
    PettyApp.SETRANGE(Status,PettyApp.Status::Released);
  IF PettyApp.FIND('-')THEN BEGIN
      GenJnlLine.RESET;
      GenJnlLine.SETRANGE(GenJnlLine."Journal Template Name",'PAYMENTS');
      GenJnlLine.SETRANGE(GenJnlLine."Journal Batch Name",'PETTYCASH');
      IF GenJnlLine.FIND('-')THEN
      GenJnlLine.DELETEALL;
      //Start insert to JNL
     GenJnlLine.RESET;
     GenJnlLine.INIT;
     GenJnlLine.SETRANGE(GenJnlLine."Journal Template Name",'PAYMENTS');
     GenJnlLine.SETRANGE(GenJnlLine."Journal Batch Name",'PETTYCASH');
     GenJnlLine."Journal Template Name":= 'PAYMENTS';
     GenJnlLine."Journal Batch Name":= 'PETTYCASH';
     GenJnlLine."Source Code":='PAYMENTJNL' ;
     GenJnlLine."Document Type":=GenJnlLine."Document Type"::Refund ;
     GenJnlLine."Line No.":="LineNo."+10000;
     GenJnlLine."Posting Date":="Posting Date";
     GenJnlLine."Account Type":="Account Type";
     GenJnlLine.VALIDATE("Account Type");
     GenJnlLine."Account No.":="Account No.";
     GenJnlLine.VALIDATE("Account No.");
     GenJnlLine."Document No.":="No.";
     GenJnlLine.Description:=COPYSTR(Narration,1,250);
     GenJnlLine.Narration:= COPYSTR(Narration,1,250);
     GenJnlLine.Amount:=Amount;
     GenJnlLine."Bal. Account Type":= GenJnlLine."Bal. Account Type"::"Bank Account";
     GenJnlLine."Bal. Account No.":="Bank Account";
     GenJnlLine.VALIDATE("Bal. Account No.");
     GenJnlLine."Shortcut Dimension 1 Code":="Shortcut Dimension 1 Code";
     GenJnlLine."Shortcut Dimension 2 Code":="Shortcut Dimension 2 Code";
     GenJnlLine."Shortcut Dimension 3 Code":="Shortcut Dimension 3 code";
     GenJnlLine."Shortcut Dimension 4 Code":="Shortcut Dimension 4 code";
     GenJnlLine."Shortcut Dimension 1 Code":="Account No.";
     GenJnlLine."Currency Code":="Currency Code";
     GenJnlLine.VALIDATE("Currency Code");
     GenJnlLine."Ctl. Fund No.":="Ctl. Fund No.";
     GenJnlLine.INSERT;
     {//Allow Automatic Submission since entries were Approved on petty cash Doc.
     GLTranManagement.GenJournalSubmit(GenJnlLine);
     GenJnlLine.RESET;
     GenJnlLine.SETRANGE(GenJnlLine."Journal Template Name",'PAYMENTS');
     GenJnlLine.SETRANGE(GenJnlLine."Journal Batch Name",'PETTYCASH');
     CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post",GenJnlLine);
     Status:=Status::Posted;
     MODIFY;}

  END;
 END;
END;


Name    DataType    Subtype    Length
PettyApp    Record    Imprest Requisition   
ChangeExchangeRate    Form    Change Exchange Rate   
LineNo.    Integer       
GenJnlLine    Record    Gen. Journal Line   
GenBatch    Record    Gen. Journal Batch   
ApprovalMgt    Codeunit    Approvals Management   
GLTranManagement    Codeunit    GLTranManagement   

Name    ConstValue
Text001    Requstion %1 is peding Approval.
Text002    Requstion %1 has already been Approved.

No comments:

Post a Comment