BE Dynamics NAV 5.0 - Codeunit 12

jsinisajsinisa Member Posts: 27
Hi all,
I need some help.
My colleagues in Belgium having problem with Payment Discount on Service. After Service Order is posted, in Customer Ledger they are getting value "Original Pmt. Disc. Possible" = 0 although "Payment Discount %" is not 0 and "Pmt. Discount Date" is correct posted.

Comparing CU12 from NAV5.0 W1 with CU12 from BE NAV 5.0 I have noticed that part of code calculating "Original Pmt. Disc. Possible" in function "PostCust" is completely missing:
  IF "Amount (LCY)" <> 0 THEN BEGIN
    IF GLSetup."Pmt. Disc. Excl. VAT" THEN
      CVLedgEntryBuf."Original Pmt. Disc. Possible" := "Sales/Purch. (LCY)" * Amount / "Amount (LCY)"
    ELSE
      CVLedgEntryBuf."Original Pmt. Disc. Possible" := Amount;
    CVLedgEntryBuf."Original Pmt. Disc. Possible" :=
      ROUND(
        CVLedgEntryBuf."Original Pmt. Disc. Possible" * "Payment Discount %" / 100,
        Currency."Amount Rounding Precision");

    CVLedgEntryBuf."Remaining Pmt. Disc. Possible" := CVLedgEntryBuf."Original Pmt. Disc. Possible";
  END;

In test DB I have added missing code in BE version of CU12. Posting of Service Order have correctly posted "Original Pmt. Disc. Possible" in Customer Ledger Entry.

I am not sure if that is locally changed by former NAV provider or is just like that in BE Dynamics NAV 5.0. There are no comments in code.

It would help me a lot if someone can post complete Code from CU12, function PostCust().

Comments

  • matthiasclaesmatthiasclaes Member Posts: 18
    This is from our Belgian NAV 5.0sp1 build 26084 implementation.
    It has been altered by our NAV partner; at least the parts between //gss and //gmi remarks have been added by them.
    I do not know about other modifications.
    PostCust()
    
    Name	DataType	Subtype	Length
    CustLedgEntry	Record	Cust. Ledger Entry	
    OldCustLedgEntry	Record	Cust. Ledger Entry	
    CVLedgEntryBuf	Record	CV Ledger Entry Buffer	
    DtldCVLedgEntryBuf	Record	Detailed CV Ledg. Entry Buffer	
    DtldCustLedgEntry	Record	Detailed Cust. Ledg. Entry	
    
    
    WITH GenJnlLine DO BEGIN
      IF Cust."No." <> "Account No." THEN
        Cust.GET("Account No.");
      Cust.CheckBlockedCustOnJnls(Cust,"Document Type",TRUE);
    
      IF "Posting Group" = '' THEN BEGIN
        Cust.TESTFIELD("Customer Posting Group");
        "Posting Group" := Cust."Customer Posting Group";
      END;
      CustPostingGr.GET("Posting Group");
      CustPostingGr.TESTFIELD("Receivables Account");
    
      DtldCustLedgEntry.LOCKTABLE;
      CustLedgEntry.LOCKTABLE;
    
      CustLedgEntry.INIT;
      CustLedgEntry."Customer No." := "Account No.";
      CustLedgEntry."Posting Date" := "Posting Date";
      CustLedgEntry."Document Date" := "Document Date";
      CustLedgEntry."Document Type" := "Document Type";
      CustLedgEntry."Document No." := "Document No.";
      CustLedgEntry."External Document No." := "External Document No.";
      CustLedgEntry.Description := Description;
      CustLedgEntry."Currency Code" := "Currency Code";
      CustLedgEntry."Sales (LCY)" := "Sales/Purch. (LCY)";
      CustLedgEntry."Profit (LCY)" := "Profit (LCY)";
      CustLedgEntry."Inv. Discount (LCY)" := "Inv. Discount (LCY)";
      CustLedgEntry."Sell-to Customer No." := "Sell-to/Buy-from No.";
      CustLedgEntry."Customer Posting Group" := "Posting Group";
      CustLedgEntry."Global Dimension 1 Code" := "Shortcut Dimension 1 Code";
      CustLedgEntry."Global Dimension 2 Code" := "Shortcut Dimension 2 Code";
      CustLedgEntry."Salesperson Code" := "Salespers./Purch. Code";
      CustLedgEntry."Source Code" := "Source Code";
      CustLedgEntry."On Hold" := "On Hold";
      CustLedgEntry."Applies-to Doc. Type" := "Applies-to Doc. Type";
      CustLedgEntry."Applies-to Doc. No." := "Applies-to Doc. No.";
      CustLedgEntry."Due Date" := "Due Date";
      CustLedgEntry."Due Date (Liquidity)" := "Due Date"; // gmi - dvc
      CustLedgEntry."Pmt. Discount Date" := "Pmt. Discount Date";
      CustLedgEntry."Applies-to ID" := "Applies-to ID";
      CustLedgEntry."Journal Batch Name" := "Journal Batch Name";
      CustLedgEntry."Reason Code" := "Reason Code";
      CustLedgEntry."Entry No." := NextEntryNo;
      CustLedgEntry."Transaction No." := NextTransactionNo;
      CustLedgEntry."User ID" := USERID;
      CustLedgEntry."Bal. Account Type" := "Bal. Account Type";
      CustLedgEntry."Bal. Account No." := "Bal. Account No.";
      CustLedgEntry."No. Series" := "Posting No. Series";
      CustLedgEntry."IC Partner Code" := "IC Partner Code";
      CustLedgEntry.Prepayment := Prepayment;
      CustLedgEntry."Journal Template Name" := "Journal Template Name";
      // Gss 191007
      CustLedgEntry."Job No." := "Job No.";
      CustLedgEntry."Job Description" := "Job Description";
      CustLedgEntry."Job Task No." := "Job Task No.";
      CustLedgEntry."Progress State No." := "Progress State No.";
      CustLedgEntry.Sub := Sub;
      CustLedgEntry."Received intrest" := "Received intrest";
      CustLedgEntry."Intrest invoiced" := "Intrest invoiced";
      //gss
      IF NOT Cust."Block Payment Tolerance" AND
         ((CustLedgEntry."Document Type" = CustLedgEntry."Document Type"::Invoice) OR
          (CustLedgEntry."Document Type" = CustLedgEntry."Document Type"::"Credit Memo"))
      THEN BEGIN
    
        IF (CustLedgEntry."Pmt. Discount Date" <> 0D) AND
           (CustLedgEntry."Pmt. Discount Date" <> CustLedgEntry."Document Date")
        THEN
          CustLedgEntry."Pmt. Disc. Tolerance Date" :=
            CALCDATE(GLSetup."Payment Discount Grace Period",CustLedgEntry."Pmt. Discount Date")
        ELSE
          CustLedgEntry."Pmt. Disc. Tolerance Date" := CustLedgEntry."Pmt. Discount Date";
    
        IF CustLedgEntry."Currency Code" = '' THEN BEGIN
          IF (GLSetup."Max. Payment Tolerance Amount" <
             (ABS(GLSetup."Payment Tolerance %" / 100 * "Amount (LCY)"))) OR (GLSetup."Payment Tolerance %" = 0)
          THEN BEGIN
            IF (GLSetup."Max. Payment Tolerance Amount" = 0) AND (GLSetup."Payment Tolerance %" > 0) THEN
              CustLedgEntry."Max. Payment Tolerance" :=
                ROUND(GLSetup."Payment Tolerance %" * "Amount (LCY)" / 100,GLSetup."Amount Rounding Precision")
            ELSE
              IF CustLedgEntry."Document Type" = CustLedgEntry."Document Type"::"Credit Memo" THEN
                CustLedgEntry."Max. Payment Tolerance" := -GLSetup."Max. Payment Tolerance Amount"
              ELSE
                CustLedgEntry."Max. Payment Tolerance" := GLSetup."Max. Payment Tolerance Amount"
          END ELSE
            CustLedgEntry."Max. Payment Tolerance" :=
              GLSetup."Payment Tolerance %" * "Amount (LCY)" / 100
        END ELSE BEGIN
          IF (Currency."Max. Payment Tolerance Amount" <
             (ABS(Currency."Payment Tolerance %" / 100 * Amount))) OR (Currency."Payment Tolerance %" = 0)
          THEN BEGIN
            IF (Currency."Max. Payment Tolerance Amount" = 0) AND (Currency."Payment Tolerance %" > 0) THEN
              CustLedgEntry."Max. Payment Tolerance" :=
                ROUND(Currency."Payment Tolerance %" * Amount / 100,Currency."Amount Rounding Precision")
            ELSE
              IF CustLedgEntry."Document Type" = CustLedgEntry."Document Type"::"Credit Memo" THEN
                CustLedgEntry."Max. Payment Tolerance" := -Currency."Max. Payment Tolerance Amount"
              ELSE
                CustLedgEntry."Max. Payment Tolerance" := Currency."Max. Payment Tolerance Amount"
          END ELSE
            CustLedgEntry."Max. Payment Tolerance" :=
              ROUND(Currency."Payment Tolerance %" * Amount / 100,Currency."Amount Rounding Precision");
        END;
        IF ABS(CustLedgEntry."Max. Payment Tolerance") > ABS(Amount) THEN
          CustLedgEntry."Max. Payment Tolerance" := Amount;
    
      END;
    
      DtldCVLedgEntryBuf.DELETEALL;
      DtldCVLedgEntryBuf.INIT;
      DtldCVLedgEntryBuf."Cust. Ledger Entry No." := CustLedgEntry."Entry No.";
      DtldCVLedgEntryBuf."Entry Type" := DtldCVLedgEntryBuf."Entry Type"::"Initial Entry";
      DtldCVLedgEntryBuf."Posting Date" := "Posting Date";
      DtldCVLedgEntryBuf."Document Type" := "Document Type";
      DtldCVLedgEntryBuf."Document No." := "Document No.";
      DtldCVLedgEntryBuf.Amount := Amount;
      DtldCVLedgEntryBuf."Amount (LCY)" := "Amount (LCY)";
      DtldCVLedgEntryBuf."Additional-Currency Amount" := Amount;
      DtldCVLedgEntryBuf."Customer No." := "Account No.";
      DtldCVLedgEntryBuf."Currency Code" := "Currency Code";
      DtldCVLedgEntryBuf."User ID" := USERID;
      DtldCVLedgEntryBuf."Initial Entry Due Date" := "Due Date";
      DtldCVLedgEntryBuf."Initial Entry Global Dim. 1" := "Shortcut Dimension 1 Code";
      DtldCVLedgEntryBuf."Initial Entry Global Dim. 2" := "Shortcut Dimension 2 Code";
      DtldCVLedgEntryBuf."Initial Document Type" := "Document Type";
      // gmi
      DtldCVLedgEntryBuf."Job No." := "Job No.";
      DtldCVLedgEntryBuf."Progress State No." := "Progress State No.";
      DtldCVLedgEntryBuf.Sub := Sub;
      DtldCVLedgEntryBuf."Received intrest" := "Received intrest";
      DtldCVLedgEntryBuf."Intrest invoiced" := "Intrest invoiced";
      // gmi
    
      TransferCustLedgEntry(CVLedgEntryBuf,CustLedgEntry,TRUE);
      InsertDtldCVLedgEntry(DtldCVLedgEntryBuf,CVLedgEntryBuf,TRUE);
      CVLedgEntryBuf.Open := CVLedgEntryBuf."Remaining Amount" <> 0;
      CVLedgEntryBuf.Positive := CVLedgEntryBuf."Remaining Amount" > 0;
    
      IF "Currency Code" <> '' THEN BEGIN
        TESTFIELD("Currency Factor");
        CVLedgEntryBuf."Original Currency Factor" := "Currency Factor"
      END ELSE
        CVLedgEntryBuf."Original Currency Factor" := 1;
      CVLedgEntryBuf."Adjusted Currency Factor" := CVLedgEntryBuf."Original Currency Factor";
    
      IF "Amount (LCY)" <> 0 THEN BEGIN
        CVLedgEntryBuf."Original Pmt. Disc. Possible" :=
          ROUND("Original Pmt. Disc. Possible",Currency."Amount Rounding Precision");
        CVLedgEntryBuf."Org. Pmt. Disc. Possible (LCY)" :=
          ROUND("Org. Pmt. Disc. Possible (LCY)");
        CVLedgEntryBuf."Remaining Pmt. Disc. Possible" :=
          CVLedgEntryBuf."Original Pmt. Disc. Possible";
      END;
    
      // Check the document no.
      IF "Recurring Method" = 0 THEN
        IF "Document Type" IN
           ["Document Type"::Invoice,
            "Document Type"::"Credit Memo",
            "Document Type"::"Finance Charge Memo",
            "Document Type"::Reminder]
        THEN BEGIN
          OldCustLedgEntry.RESET;
          IF NOT RECORDLEVELLOCKING THEN
            OldCustLedgEntry.SETCURRENTKEY("Document No.");
          OldCustLedgEntry.SETRANGE("Document No.",CVLedgEntryBuf."Document No.");
          OldCustLedgEntry.SETRANGE("Document Type",CVLedgEntryBuf."Document Type");
          // moet weg voor import
    {      IF NOT OldCustLedgEntry.ISEMPTY THEN // Moet terug op gezet worden !!!
            ERROR(
              Text001,
              "Document Type","Document No.");}
    
          IF SalesSetup."Ext. Doc. No. Mandatory" THEN
            IF "Document Type" IN
               ["Document Type"::Invoice,
                "Document Type"::"Credit Memo",
                "Document Type"::Payment,
                "Document Type"::Refund,
                "Document Type"::" "]
            THEN
              TESTFIELD("External Document No.");
        END;
    
      // Post the application
      ApplyCustLedgEntry(
        CVLedgEntryBuf,DtldCVLedgEntryBuf,GenJnlLine,GLSetup."Appln. Rounding Precision");
    
      // Post customer entry
      TransferCustLedgEntry(CVLedgEntryBuf,CustLedgEntry,FALSE);
      CustLedgEntry."Amount to Apply" := 0;
      CustLedgEntry."Applies-to Doc. No." := '';
      CustLedgEntry.INSERT;
    
      DimMgt.MoveJnlLineDimToLedgEntryDim(
        TempJnlLineDim,DATABASE::"Cust. Ledger Entry",CustLedgEntry."Entry No.");
    
      // Post Dtld. customer entry
      PostDtldCustLedgEntries(
        GenJnlLine,DtldCVLedgEntryBuf,CustPostingGr,GLSetup,NextTransactionNo,TRUE);
    END;
    
  • jsinisajsinisa Member Posts: 27
    This is from our Belgian NAV 5.0sp1 build 26084 implementation.
    It has been altered by our NAV partner; at least the parts between //gss and //gmi remarks have been added by them.
    I do not know about other modifications.
    PostCust()
    
    Name	DataType	Subtype	Length
    CustLedgEntry	Record	Cust. Ledger Entry	
    OldCustLedgEntry	Record	Cust. Ledger Entry	
    CVLedgEntryBuf	Record	CV Ledger Entry Buffer	
    DtldCVLedgEntryBuf	Record	Detailed CV Ledg. Entry Buffer	
    DtldCustLedgEntry	Record	Detailed Cust. Ledg. Entry	
    
    
    WITH GenJnlLine DO BEGIN
      IF Cust."No." <> "Account No." THEN
        Cust.GET("Account No.");
      Cust.CheckBlockedCustOnJnls(Cust,"Document Type",TRUE);
    
      IF "Posting Group" = '' THEN BEGIN
        Cust.TESTFIELD("Customer Posting Group");
        "Posting Group" := Cust."Customer Posting Group";
      END;
      CustPostingGr.GET("Posting Group");
      CustPostingGr.TESTFIELD("Receivables Account");
    
      DtldCustLedgEntry.LOCKTABLE;
      CustLedgEntry.LOCKTABLE;
    
      CustLedgEntry.INIT;
      CustLedgEntry."Customer No." := "Account No.";
      CustLedgEntry."Posting Date" := "Posting Date";
      CustLedgEntry."Document Date" := "Document Date";
      CustLedgEntry."Document Type" := "Document Type";
      CustLedgEntry."Document No." := "Document No.";
      CustLedgEntry."External Document No." := "External Document No.";
      CustLedgEntry.Description := Description;
      CustLedgEntry."Currency Code" := "Currency Code";
      CustLedgEntry."Sales (LCY)" := "Sales/Purch. (LCY)";
      CustLedgEntry."Profit (LCY)" := "Profit (LCY)";
      CustLedgEntry."Inv. Discount (LCY)" := "Inv. Discount (LCY)";
      CustLedgEntry."Sell-to Customer No." := "Sell-to/Buy-from No.";
      CustLedgEntry."Customer Posting Group" := "Posting Group";
      CustLedgEntry."Global Dimension 1 Code" := "Shortcut Dimension 1 Code";
      CustLedgEntry."Global Dimension 2 Code" := "Shortcut Dimension 2 Code";
      CustLedgEntry."Salesperson Code" := "Salespers./Purch. Code";
      CustLedgEntry."Source Code" := "Source Code";
      CustLedgEntry."On Hold" := "On Hold";
      CustLedgEntry."Applies-to Doc. Type" := "Applies-to Doc. Type";
      CustLedgEntry."Applies-to Doc. No." := "Applies-to Doc. No.";
      CustLedgEntry."Due Date" := "Due Date";
      CustLedgEntry."Due Date (Liquidity)" := "Due Date"; // gmi - dvc
      CustLedgEntry."Pmt. Discount Date" := "Pmt. Discount Date";
      CustLedgEntry."Applies-to ID" := "Applies-to ID";
      CustLedgEntry."Journal Batch Name" := "Journal Batch Name";
      CustLedgEntry."Reason Code" := "Reason Code";
      CustLedgEntry."Entry No." := NextEntryNo;
      CustLedgEntry."Transaction No." := NextTransactionNo;
      CustLedgEntry."User ID" := USERID;
      CustLedgEntry."Bal. Account Type" := "Bal. Account Type";
      CustLedgEntry."Bal. Account No." := "Bal. Account No.";
      CustLedgEntry."No. Series" := "Posting No. Series";
      CustLedgEntry."IC Partner Code" := "IC Partner Code";
      CustLedgEntry.Prepayment := Prepayment;
      CustLedgEntry."Journal Template Name" := "Journal Template Name";
      // Gss 191007
      CustLedgEntry."Job No." := "Job No.";
      CustLedgEntry."Job Description" := "Job Description";
      CustLedgEntry."Job Task No." := "Job Task No.";
      CustLedgEntry."Progress State No." := "Progress State No.";
      CustLedgEntry.Sub := Sub;
      CustLedgEntry."Received intrest" := "Received intrest";
      CustLedgEntry."Intrest invoiced" := "Intrest invoiced";
      //gss
      IF NOT Cust."Block Payment Tolerance" AND
         ((CustLedgEntry."Document Type" = CustLedgEntry."Document Type"::Invoice) OR
          (CustLedgEntry."Document Type" = CustLedgEntry."Document Type"::"Credit Memo"))
      THEN BEGIN
    
        IF (CustLedgEntry."Pmt. Discount Date" <> 0D) AND
           (CustLedgEntry."Pmt. Discount Date" <> CustLedgEntry."Document Date")
        THEN
          CustLedgEntry."Pmt. Disc. Tolerance Date" :=
            CALCDATE(GLSetup."Payment Discount Grace Period",CustLedgEntry."Pmt. Discount Date")
        ELSE
          CustLedgEntry."Pmt. Disc. Tolerance Date" := CustLedgEntry."Pmt. Discount Date";
    
        IF CustLedgEntry."Currency Code" = '' THEN BEGIN
          IF (GLSetup."Max. Payment Tolerance Amount" <
             (ABS(GLSetup."Payment Tolerance %" / 100 * "Amount (LCY)"))) OR (GLSetup."Payment Tolerance %" = 0)
          THEN BEGIN
            IF (GLSetup."Max. Payment Tolerance Amount" = 0) AND (GLSetup."Payment Tolerance %" > 0) THEN
              CustLedgEntry."Max. Payment Tolerance" :=
                ROUND(GLSetup."Payment Tolerance %" * "Amount (LCY)" / 100,GLSetup."Amount Rounding Precision")
            ELSE
              IF CustLedgEntry."Document Type" = CustLedgEntry."Document Type"::"Credit Memo" THEN
                CustLedgEntry."Max. Payment Tolerance" := -GLSetup."Max. Payment Tolerance Amount"
              ELSE
                CustLedgEntry."Max. Payment Tolerance" := GLSetup."Max. Payment Tolerance Amount"
          END ELSE
            CustLedgEntry."Max. Payment Tolerance" :=
              GLSetup."Payment Tolerance %" * "Amount (LCY)" / 100
        END ELSE BEGIN
          IF (Currency."Max. Payment Tolerance Amount" <
             (ABS(Currency."Payment Tolerance %" / 100 * Amount))) OR (Currency."Payment Tolerance %" = 0)
          THEN BEGIN
            IF (Currency."Max. Payment Tolerance Amount" = 0) AND (Currency."Payment Tolerance %" > 0) THEN
              CustLedgEntry."Max. Payment Tolerance" :=
                ROUND(Currency."Payment Tolerance %" * Amount / 100,Currency."Amount Rounding Precision")
            ELSE
              IF CustLedgEntry."Document Type" = CustLedgEntry."Document Type"::"Credit Memo" THEN
                CustLedgEntry."Max. Payment Tolerance" := -Currency."Max. Payment Tolerance Amount"
              ELSE
                CustLedgEntry."Max. Payment Tolerance" := Currency."Max. Payment Tolerance Amount"
          END ELSE
            CustLedgEntry."Max. Payment Tolerance" :=
              ROUND(Currency."Payment Tolerance %" * Amount / 100,Currency."Amount Rounding Precision");
        END;
        IF ABS(CustLedgEntry."Max. Payment Tolerance") > ABS(Amount) THEN
          CustLedgEntry."Max. Payment Tolerance" := Amount;
    
      END;
    
      DtldCVLedgEntryBuf.DELETEALL;
      DtldCVLedgEntryBuf.INIT;
      DtldCVLedgEntryBuf."Cust. Ledger Entry No." := CustLedgEntry."Entry No.";
      DtldCVLedgEntryBuf."Entry Type" := DtldCVLedgEntryBuf."Entry Type"::"Initial Entry";
      DtldCVLedgEntryBuf."Posting Date" := "Posting Date";
      DtldCVLedgEntryBuf."Document Type" := "Document Type";
      DtldCVLedgEntryBuf."Document No." := "Document No.";
      DtldCVLedgEntryBuf.Amount := Amount;
      DtldCVLedgEntryBuf."Amount (LCY)" := "Amount (LCY)";
      DtldCVLedgEntryBuf."Additional-Currency Amount" := Amount;
      DtldCVLedgEntryBuf."Customer No." := "Account No.";
      DtldCVLedgEntryBuf."Currency Code" := "Currency Code";
      DtldCVLedgEntryBuf."User ID" := USERID;
      DtldCVLedgEntryBuf."Initial Entry Due Date" := "Due Date";
      DtldCVLedgEntryBuf."Initial Entry Global Dim. 1" := "Shortcut Dimension 1 Code";
      DtldCVLedgEntryBuf."Initial Entry Global Dim. 2" := "Shortcut Dimension 2 Code";
      DtldCVLedgEntryBuf."Initial Document Type" := "Document Type";
      // gmi
      DtldCVLedgEntryBuf."Job No." := "Job No.";
      DtldCVLedgEntryBuf."Progress State No." := "Progress State No.";
      DtldCVLedgEntryBuf.Sub := Sub;
      DtldCVLedgEntryBuf."Received intrest" := "Received intrest";
      DtldCVLedgEntryBuf."Intrest invoiced" := "Intrest invoiced";
      // gmi
    
      TransferCustLedgEntry(CVLedgEntryBuf,CustLedgEntry,TRUE);
      InsertDtldCVLedgEntry(DtldCVLedgEntryBuf,CVLedgEntryBuf,TRUE);
      CVLedgEntryBuf.Open := CVLedgEntryBuf."Remaining Amount" <> 0;
      CVLedgEntryBuf.Positive := CVLedgEntryBuf."Remaining Amount" > 0;
    
      IF "Currency Code" <> '' THEN BEGIN
        TESTFIELD("Currency Factor");
        CVLedgEntryBuf."Original Currency Factor" := "Currency Factor"
      END ELSE
        CVLedgEntryBuf."Original Currency Factor" := 1;
      CVLedgEntryBuf."Adjusted Currency Factor" := CVLedgEntryBuf."Original Currency Factor";
    
      IF "Amount (LCY)" <> 0 THEN BEGIN
        CVLedgEntryBuf."Original Pmt. Disc. Possible" :=
          ROUND("Original Pmt. Disc. Possible",Currency."Amount Rounding Precision");
        CVLedgEntryBuf."Org. Pmt. Disc. Possible (LCY)" :=
          ROUND("Org. Pmt. Disc. Possible (LCY)");
        CVLedgEntryBuf."Remaining Pmt. Disc. Possible" :=
          CVLedgEntryBuf."Original Pmt. Disc. Possible";
      END;
    
      // Check the document no.
      IF "Recurring Method" = 0 THEN
        IF "Document Type" IN
           ["Document Type"::Invoice,
            "Document Type"::"Credit Memo",
            "Document Type"::"Finance Charge Memo",
            "Document Type"::Reminder]
        THEN BEGIN
          OldCustLedgEntry.RESET;
          IF NOT RECORDLEVELLOCKING THEN
            OldCustLedgEntry.SETCURRENTKEY("Document No.");
          OldCustLedgEntry.SETRANGE("Document No.",CVLedgEntryBuf."Document No.");
          OldCustLedgEntry.SETRANGE("Document Type",CVLedgEntryBuf."Document Type");
          // moet weg voor import
    {      IF NOT OldCustLedgEntry.ISEMPTY THEN // Moet terug op gezet worden !!!
            ERROR(
              Text001,
              "Document Type","Document No.");}
    
          IF SalesSetup."Ext. Doc. No. Mandatory" THEN
            IF "Document Type" IN
               ["Document Type"::Invoice,
                "Document Type"::"Credit Memo",
                "Document Type"::Payment,
                "Document Type"::Refund,
                "Document Type"::" "]
            THEN
              TESTFIELD("External Document No.");
        END;
    
      // Post the application
      ApplyCustLedgEntry(
        CVLedgEntryBuf,DtldCVLedgEntryBuf,GenJnlLine,GLSetup."Appln. Rounding Precision");
    
      // Post customer entry
      TransferCustLedgEntry(CVLedgEntryBuf,CustLedgEntry,FALSE);
      CustLedgEntry."Amount to Apply" := 0;
      CustLedgEntry."Applies-to Doc. No." := '';
      CustLedgEntry.INSERT;
    
      DimMgt.MoveJnlLineDimToLedgEntryDim(
        TempJnlLineDim,DATABASE::"Cust. Ledger Entry",CustLedgEntry."Entry No.");
    
      // Post Dtld. customer entry
      PostDtldCustLedgEntries(
        GenJnlLine,DtldCVLedgEntryBuf,CustPostingGr,GLSetup,NextTransactionNo,TRUE);
    END;
    


    thank you,bit late :)
Sign In or Register to comment.