Tuesday, 10 November 2015
posting PV to gl
IF NOT CONFIRM ('Are you sure you want to post this payment?') THEN
EXIT;
IF Status <> Status::Released THEN
ERROR('This document need to be approved');
DefaultCtl.GET();
//>Start create pv journal batch
IF NOT GenBatch.GET('PAYMENTS','PAYMENTS') THEN
BEGIN
GenBatch.INIT;
GenBatch."Journal Template Name":='PAYMENTS';
GenBatch.Name:='PAYMENTS';
GenBatch.INSERT;
END;
//<Stop
//>Start clear journal line
GenjLine.RESET;
GenjLine.SETRANGE(GenjLine."Journal Template Name",'PAYMENTS');
GenjLine.SETRANGE(GenjLine."Journal Batch Name",'PAYMENTS');
GenjLine.DELETEALL;
//<Stop
PaymentLine.RESET;
PaymentLine.SETRANGE(PaymentLine."No.","No.");
IF PaymentLine.FIND('-') THEN BEGIN
REPEAT
ExtDocNo:=PaymentLine."Applies-to Doc. No.";
//>Start expense line
LineNo:=LineNo+1000;
GenjLine.INIT;
GenjLine."Journal Template Name":= 'PAYMENTS';
GenjLine."Journal Batch Name":= 'PAYMENTS';
GenjLine."Source Code":='PAYMENTJNL' ;
GenjLine."Line No.":= LineNo;
GenjLine."Document Type":= GenjLine."Document Type"::Payment;
GenjLine."Document Date":= "Document Date";
GenjLine."Posting Date":= "Posting Date";
GenjLine."Document No.":= "No.";
GenjLine."Account Type":= PaymentLine."Account Type";
GenjLine.VALIDATE(GenjLine."Account No.",PaymentLine."Account No.");
GenjLine.Narration:=PaymentLine.Narration;
GenjLine.VALIDATE(GenjLine."Currency Code","Currency Code");
GenjLine.VALIDATE(GenjLine.Amount,PaymentLine."Net Amount");
GenjLine.VALIDATE(GenjLine."Fund No.","Fund No.");
//**GenjLine."Applies-to Doc. Type":=PaymentLine."Applies-to Doc. Type";
//**GenjLine."Applies-to Doc. No.":=PaymentLine."Applies-to Doc. No.";
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 1 Code",PaymentLine."Shortcut Dimension 1 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 2 Code",PaymentLine."Shortcut Dimension 2 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 3 Code",PaymentLine."Shortcut Dimension 3 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 4 Code",PaymentLine."Shortcut Dimension 4 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 5 Code",PaymentLine."Shortcut Dimension 5 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 6 Code",PaymentLine."Shortcut Dimension 6 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 7 Code",PaymentLine."Shortcut Dimension 7 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 8 Code",PaymentLine."Shortcut Dimension 8 Code");
GenjLine."Bal. Account Type":=GenjLine."Bal. Account Type"::"Bank Account";
GenjLine.VALIDATE(GenjLine."Bal. Account No.","Bank Account");
PayDetails;
GenjLine."Purch Order Ref":= PaymentLine."Applies-to Doc. No.";
GenjLine."External Document No.":= "Document No.";
IF GenjLine.Amount<>0 THEN
GenjLine.INSERT;
//<Stop
//>Start W/Tax
LineNo:=LineNo+1000;
GenjLine.INIT;
GenjLine."Journal Template Name":= 'PAYMENTS';
GenjLine."Journal Batch Name":= 'PAYMENTS';
GenjLine."Source Code":='PAYMENTJNL' ;
GenjLine."Line No.":= LineNo;
GenjLine."Document Type":= GenjLine."Document Type"::Payment;
GenjLine."Document Date":= "Document Date";
GenjLine."Posting Date":= "Posting Date";
GenjLine."Document No.":= "No.";
GenjLine."Account Type":= PaymentLine."Account Type";
GenjLine.VALIDATE(GenjLine."Account No.",PaymentLine."Account No.");
GenjLine.VALIDATE(GenjLine."Currency Code","Currency Code");
GenjLine.Narration:=PaymentLine.Narration;
GenjLine.VALIDATE(GenjLine.Amount,PaymentLine."W/Tax Amount");
GenjLine.VALIDATE(GenjLine."Fund No.","Fund No.");
//**GenjLine."Applies-to Doc. Type":=PaymentLine."Applies-to Doc. Type";
//**GenjLine."Applies-to Doc. No.":=PaymentLine."Applies-to Doc. No.";
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 1 Code",PaymentLine."Shortcut Dimension 1 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 2 Code",PaymentLine."Shortcut Dimension 2 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 3 Code",PaymentLine."Shortcut Dimension 3 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 4 Code",PaymentLine."Shortcut Dimension 4 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 5 Code",PaymentLine."Shortcut Dimension 5 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 6 Code",PaymentLine."Shortcut Dimension 6 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 7 Code",PaymentLine."Shortcut Dimension 7 Code");
GenjLine.VALIDATE(GenjLine."Shortcut Dimension 8 Code",PaymentLine."Shortcut Dimension 8 Code");
GenjLine."Bal. Account Type":=GenjLine."Bal. Account Type"::"G/L Account";
GenjLine.Description:= 'W/Tax on'+'-' +PaymentHeader."Payee Name";
GenjLine."Purch Order Ref":= PaymentLine."Applies-to Doc. No.";
//>Start get W/Tax account
VatPost.SETRANGE(VatPost."VAT Prod. Posting Group",PaymentLine."W/Tax");
VatPost.SETFILTER(VatPost."VAT Bus. Posting Group",'<>%1','');
IF VatPost.FIND('-')THEN BEGIN
GenjLine.VALIDATE(GenjLine."Bal. Account No.",VatPost."Purchase VAT Account");
END;
//<Stop
PayDetails;
GenjLine."External Document No.":="Document No.";
GenjLine."Purch Order Ref":= PaymentLine."Applies-to Doc. No.";
IF GenjLine.Amount<>0 THEN
GenjLine.INSERT;
//<Stop
UNTIL PaymentLine.NEXT=0;
END;
//Allow Automatic Submission since entries were Approved on petty cash Doc.
GLTranManagement.GenJournalSubmit(GenjLine);
GenjLine.RESET;
GenjLine.SETRANGE(GenjLine."Journal Template Name",'PAYMENTS');
GenjLine.SETRANGE(GenjLine."Journal Batch Name",'PAYMENTS');
CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post",GenjLine);
Status:=Status::Posted;
Posted:=TRUE;
MODIFY;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment