web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Transferring PDC Line Entries to Journals as a Single Entry

(5) ShareShare
ReportReport
Posted on by 77

Hi everyone,

I hope you're all doing well!

I’m currently working on a custom document type page to manage Post Dated Cheque (PDC) records. In this implementation, users can enter multiple line items, and my objective is to transfer these line entries to the respective journals—specifically, the Cash Receipt Journal or Payment Journal.

What I am aiming to achieve is to post these multiple line entries as a single consolidated entry in the journal, similar to how the "Apply Entries" functionality works in standard processes.

Has anyone implemented something similar or could point me in the right direction on how best to achieve this? Any suggestions, best practices, or code examples would be greatly appreciated.

Thanks in advance for your support!

Warm regards,
Govind Sharma

I have the same question (0)
  • Sumit Singh Profile Picture
    8,417 on at
    Transferring PDC Line Entries to Journals as a Single Entry
    Conceptual Approach
    1. Group PDC Lines:
      • Group the lines by key fields like Customer No., Currency Code, Posting Date, etc., depending on your business rules.
      • Sum the Amount field for each group.
    2. Create a Single Journal Line per Group:
      • Use the Gen. Journal Line table (81) to insert a new line for each group.
      • Populate fields like Account Type, Account No., Bal. Account Type, Bal. Account No., Amount, Document No., etc.
    3. Optional: Link Back to PDC Lines:
      • Store a reference (e.g., PDC Document No. or a custom field) in the journal line to trace back to the original PDC lines.

    🧩 Code Snippet (AL Language)
    Sample AL procedure below:
    • Groups PDC lines by PDC Header
    • Sums the amount
    • Inserts a single line into either the Cash Receipt Journal or Payment Journal

    procedure PostConsolidatedPDC(PDCHeader: Record "PDC Header")
    var
        PDCLines: Record "PDC Line";
        GenJnlLine: Record "Gen. Journal Line";
        GenJnlTemplate: Code[10];
        GenJnlBatch: Code[10];
        TotalAmount: Decimal;
        IsReceipt: Boolean;
    begin
        // Define journal template and batch
        GenJnlTemplate := 'CASHRECPT'; // or 'PAYMENT'
        GenJnlBatch := 'DEFAULT';      // adjust as per your setup

        // Determine if it's a receipt or payment
        IsReceipt := PDCHeader."Document Type" = PDCHeader."Document Type"::Receipt;

        // Filter lines for the current PDC document
        PDCLines.SetRange("Document No.", PDCHeader."No.");

        if PDCLines.FindSet() then begin
            repeat
                TotalAmount += PDCLines.Amount;
            until PDCLines.Next() = 0;

            // Insert consolidated journal line
            GenJnlLine.Init();
            GenJnlLine."Journal Template Name" := GenJnlTemplate;
            GenJnlLine."Journal Batch Name" := GenJnlBatch;
            GenJnlLine."Line No." := 10000;
            GenJnlLine."Account Type" :=
                IsReceipt ? GenJnlLine."Account Type"::Customer : GenJnlLine."Account Type"::Vendor;
            GenJnlLine."Account No." := PDCHeader."Account No.";
            GenJnlLine."Document No." := PDCHeader."No.";
            GenJnlLine."Posting Date" := PDCHeader."Posting Date";
            GenJnlLine.Amount := TotalAmount;
            GenJnlLine."Bal. Account Type" := GenJnlLine."Bal. Account Type"::Bank;
            GenJnlLine."Bal. Account No." := PDCHeader."Bank Account No.";
            GenJnlLine.Insert();
        end;
    end;

    🧠 Best Practices
    • Validation: Ensure all PDC lines are valid and approved before posting.
    • Error Handling: Add checks for journal template/batch existence.
    • Posting Preview: Consider adding a preview function before actual posting.
    • Extensibility: Use events/subscribers if you're modifying standard objects.
    • Use GenJournalLine.Insert(true); if you want to trigger validations.
    • Consider using GenJournalLine.TransferFields(...) if you're copying from a template.
    • Add error handling for missing accounts or templates.
    • Optionally, use Codeunit 12 "Gen. Jnl.-Post" to post the journal after insertion.
    Remember to try all these steps in a test environment and change it as per your business requirement.
    Note: This response was developed in collaboration with Microsoft Copilot to ensure clarity and completeness. I hope it helps to some extent.
    Mark the Answer as Verified if this is Helpful.
     
  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    8,451 on at
    Transferring PDC Line Entries to Journals as a Single Entry

    Hi Govind,

    Consolidating multiple PDC line entries into a single journal entry is a smart way to streamline posting and mirror the behavior of “Apply Entries” in standard BC flows.

    Here’s what’s possible:

    • In your custom codeunit, you can loop through the PDC lines and aggregate the total amount, then create a single journal line in the Cash Receipt Journal or Payment Journal with that total. You’ll need to:
      • Set Document No., Posting Date, Account Type, Account No., and Amount
      • Optionally use a balancing account or dimension filters if needed
    • To preserve auditability, you can store the individual PDC line references in a custom field or dimension tag on the journal line — or log them in a separate tracking table.
    • If you want to simulate “Apply Entries” behavior, you can:
      • Create the journal line with the total amount
      • Use the ApplyCustLedgEntry or ApplyVendLedgEntry codeunit to apply the payment against open entries
      • This ensures the consolidated journal still clears individual invoices or PDC obligations
    • For best practice, wrap the posting logic in a transaction scope using COMMIT only after all validations pass. Also consider previewing the journal before posting using PreviewPosting to catch any issues.


    Helpful references:

    Create and process journal entries – Microsoft Learn
    Working with general journals – Microsoft Learn
    Avoid “Applies-to ID” errors – Stoneridge Software


    If you find this helpful, feel free to mark this as the suggested or verified answer.

    Cheers
    Jeffrey

  • Suggested answer
    YUN ZHU Profile Picture
    93,512 Super User 2025 Season 2 on at
    Transferring PDC Line Entries to Journals as a Single Entry
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,099 Super User 2025 Season 2 on at
    Transferring PDC Line Entries to Journals as a Single Entry

    You can definitely do this. Just loop through the PDC lines, sum the total amount, and create one journal line in the Cash Receipt or Payment Journal with that total. You can use the Description or External Document No. to note which PDC lines were included. Then insert it into the journal and post using Gen. Jnl.-Post Line. Works like applying entries, but custom logic controls the grouping.

     

     

    ✅ Mark this answer as verified if it helps you.

  • Govind_Sharma Profile Picture
    77 on at
    Transferring PDC Line Entries to Journals as a Single Entry
    Hi everyone,
    Thanks for your prompt responses and support so far!

     
    I've made good progress on a custom implementation to manage Post Dated Cheque (PDC) records.
    Here's what I’ve successfully achieved so far:
    • Loop through all PDC lines,
    • Sum the total amount,
    • Insert a single consolidated line into the appropriate journal (Cash Receipt Journal or Payment Journal),
    • And set the "Applies-to ID" for each related invoice under that consolidated journal line.

    However, I'm currently facing a challenge.

    Although the consolidated journal line posts correctly, the related open invoices do not get cleared. Their Remaining Amount remains unchanged. Interestingly, when I post the same entries individually (one journal line per PDC), each invoice gets applied and cleared as expected.
    It seems that setting "Applies-to ID" alone is not sufficient when dealing with a consolidated journal line. I’m looking for guidance on how to ensure that these multiple open invoices are properly applied and cleared when posting a single consolidated journal entry.

    Any insights or suggestions would be greatly appreciated!
    Thanks again for your time and help.
    Best regards,
    Govind Sharma
  • Govind_Sharma Profile Picture
    77 on at
    Transferring PDC Line Entries to Journals as a Single Entry
    Hi everyone,

    Just following up on my earlier post, I’m still facing the issue and would really appreciate any help or suggestions. Would be grateful if anyone could point me in the right direction.

    Thanks in advance!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,039

#2
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 1,863

#3
YUN ZHU Profile Picture

YUN ZHU 1,736 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans