---
title: "Codeunit 131332 Library - Cash Flow Helper"
author: "JOP-AL"
url: https://jonas-paprotka.de/ref/codeunit/131332-library-cash-flow-helper/
type: codeunit
id: 131332
name: "Library - Cash Flow Helper"
app: "Application Test Library"
versions: "28-29"
build: 29.0.54011.55644
countries: "W1, DE, US"
source: "https://jonas-paprotka.de/ref/codeunit/131332-library-cash-flow-helper/source/"
checked: 2026-11-20
changed: 2026-10-05
subject: "Microsoft Dynamics 365 Business Central"
license: "Metadata from Microsoft's symbol packages. AL source MIT, Copyright (c) Microsoft Corporation. Selection and wording © 2026 JOP-AL. https://jonas-paprotka.de/licenses/"
---

# Codeunit 131332 Library - Cash Flow Helper

JOP-AL, https://jonas-paprotka.de/ref/codeunit/131332-library-cash-flow-helper/

| | |
| --- | --- |
| App | Application Test Library |
| Versions | 28-29 |
| Minors | W1 28.0-29.0; DE 28.0-29.0; US 28.0-29.0, [every minor](https://jonas-paprotka.de/ref/codeunit/131332-library-cash-flow-helper/editions.json) |
| Subtype | Normal |
| Source file | LibraryCashFlowHelper.Codeunit.al |

## Procedures

| Name | Parameters | Returns | Access | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- | --- |
| AddAndPostSOPrepaymentInvoice | (var SalesHeader: Record "Sales Header"; PrepaymentPercentage: Decimal) | Code[20] | public | 28-29 | - | - |
| AddSOPrepayment | (var SalesHeader: Record "Sales Header"; PrepaymentPercentage: Decimal) | - | public | 28-29 | - | - |
| PostSOPrepaymentInvoice | (var SalesHeader: Record "Sales Header") | Code[20] | public | 28-29 | - | - |
| AddAndPostPOPrepaymentInvoice | (var PurchaseHeader: Record "Purchase Header"; PrepaymentPercentage: Decimal) | Code[20] | public | 28-29 | - | - |
| AddPOPrepayment | (var PurchaseHeader: Record "Purchase Header"; PrepaymentPercentage: Decimal) | - | public | 28-29 | - | - |
| PostPOPrepaymentInvoice | (var PurchaseHeader: Record "Purchase Header") | Code[20] | public | 28-29 | - | - |
| AssignCFPaymentTermToCustomer | (var Customer: Record Customer; PaymentTermsCode: Code[10]) | - | public | 28-29 | - | - |
| AssignPaymentTermToCustomer | (var Customer: Record Customer; PaymentTermsCode: Code[10]) | - | public | 28-29 | - | - |
| AssignCFPaymentTermToVendor | (var Vendor: Record Vendor; PaymentTermsCode: Code[10]) | - | public | 28-29 | - | - |
| AssignPaymentTermToVendor | (var Vendor: Record Vendor; PaymentTermsCode: Code[10]) | - | public | 28-29 | - | - |
| ApplyInvoicePayment | (var GenJournalLine: Record "Gen. Journal Line"; PartnerNo: Code[20]; PartnerAccountType: Enum "Gen. Journal Account Type"; InvoiceNoToApply: Code[20]; AmountToApply: Decimal) | - | public | 28-29 | - | - |
| CalcDiscAmtFromGenJnlLine | (GenJnlLine: Record "Gen. Journal Line"; DiscountPercentage: Decimal) | Decimal | public | 28-29 | - | - |
| CalcCustDiscAmtLCY | (CustLedgEntry: Record "Cust. Ledger Entry"; DiscountPercentage: Decimal; ExchRateAmount: Decimal) | Decimal | public | 28-29 | - | - |
| CalcVendDiscAmtLCY | (VendLedgEntry: Record "Vendor Ledger Entry"; DiscountPercentage: Decimal; ExchRateAmount: Decimal) | Decimal | public | 28-29 | - | - |
| CalcCustDiscAmt | (CustLedgEntry: Record "Cust. Ledger Entry"; DiscountPercentage: Decimal) | Decimal | public | 28-29 | - | - |
| CalcVendDiscAmt | (VendLedgEntry: Record "Vendor Ledger Entry"; DiscountPercentage: Decimal) | Decimal | public | 28-29 | - | - |
| CalcSalesExpectedPrepmtAmounts | (SalesHeader: Record "Sales Header"; DiscountPercentage: Decimal; var ExpectedOrderAmount: Decimal; var ExpectedPrePmtAmount: Decimal) | - | public | 28-29 | - | - |
| CalcPurchExpectedPrepmtAmounts | (PurchaseHeader: Record "Purchase Header"; DiscountPercentage: Decimal; var ExpectedOrderAmount: Decimal; var ExpectedPrePmtAmount: Decimal) | - | public | 28-29 | - | - |
| CalculateDiscountAmount | (Amount: Decimal; DiscountPercentage: Decimal) | Decimal | public | 28-29 | - | - |
| ChangeWorkdateByDateFormula | (BaseDateFormula: DateFormula; CustomDateFormula: DateFormula; AdditionalDateFormula: DateFormula) | Date | public | 28-29 | - | - |
| ChangeWorkdate | (NewWorkDate: Date) | Date | public | 28-29 | - | - |
| CreateLedgerEntry | (var GenJournalLine: Record "Gen. Journal Line"; PartnerNo: Code[20]; Amount: Decimal; AccountType: Enum "Gen. Journal Account Type"; DocumentType: Enum "Gen. Journal Document Type") | - | public | 28-29 | - | - |
| CreateAndApplySalesInvPayment | (var GenJournalLine: Record "Gen. Journal Line"; CustomerNo: Code[20]; SalesInvoiceAmount: Decimal; AmountToApply: Decimal; DateFormula1: DateFormula; DateFormula2: DateFormula; DateFormula3: DateFormula) | - | public | 28-29 | - | - |
| CreateAndApplyVendorInvPmt | (var GenJournalLine: Record "Gen. Journal Line"; VendorNo: Code[20]; InvoiceAmount: Decimal; AmountToApply: Decimal; DateFormula1: DateFormula; DateFormula2: DateFormula; DateFormula3: DateFormula) | - | public | 28-29 | - | - |
| CreateBudgetEntry | (var GLBudgetEntry: Record "G/L Budget Entry"; BudgetDate: Date) | - | public | 28-29 | - | - |
| CreateDefaultPaymentTerms | (var PaymentTerms: Record "Payment Terms") | - | public | 28-29 | - | - |
| CreateCustWithCFDsctPmtTerm | (var Customer: Record Customer; var PaymentTerms: Record "Payment Terms") | - | public | 28-29 | - | - |
| CreateVendorWithCFDsctPmtTerm | (var Vendor: Record Vendor; var PaymentTerms: Record "Payment Terms") | - | public | 28-29 | - | - |
| CreateFixedAssetForInvestment | (var FixedAsset: Record "Fixed Asset"; DepreciationBookCode: Code[10]; FAPostingDateFormula: DateFormula; InvestmentAmount: Decimal) | - | public | 28-29 | - | - |
| CreateFixedAssetForDisposal | (var FixedAsset: Record "Fixed Asset"; DepreciationBookCode: Code[10]; DepreciationStartDateFormula: DateFormula; DepreciationEndDateFormula: DateFormula; DisposalDateFormula: DateFormula; ExpDisposalAmount: Decimal) | - | public | 28-29 | - | - |
| CreateManualPayment | (var CFManualExpense: Record "Cash Flow Manual Expense") | - | public | 28-29 | - | - |
| CreateManualRevenue | (var CFManualRevenue: Record "Cash Flow Manual Revenue") | - | public | 28-29 | - | - |
| CreateRandomDateFormula | (var ResultDateFormula: DateFormula) | - | public | 28-29 | - | - |
| CreateSpecificCashFlowCard | (var CashFlowForecast: Record "Cash Flow Forecast"; ConsiderDiscount: Boolean; ConsiderPmtTerms: Boolean) | - | public | 28-29 | - | - |
| CreateCashFlowForecastDefault | (var CashFlowForecast: Record "Cash Flow Forecast") | - | public | 28-29 | - | - |
| CreateCashFlowForecastConsiderDiscount | (var CashFlowForecast: Record "Cash Flow Forecast") | - | public | 28-29 | - | - |
| CreateCashFlowForecastConsiderCFPmtTerms | (var CashFlowForecast: Record "Cash Flow Forecast") | - | public | 28-29 | - | - |
| CreateCashFlowForecastConsiderDiscountAndCFPmtTerms | (var CashFlowForecast: Record "Cash Flow Forecast") | - | public | 28-29 | - | - |
| CreateSalesOrder | (var SalesHeader: Record "Sales Header"; GLAccount: Record "G/L Account"; PaymentTermsCode: Code[10]; CFPaymentTermsCode: Code[10]) | - | public | 28-29 | - | - |
| CreateSpecificSalesOrder | (var SalesHeader: Record "Sales Header"; PaymentTermsCode: Code[10]; CFPaymentTermsCode: Code[10]) | - | public | 28-29 | - | - |
| CreateDefaultSalesOrder | (var SalesHeader: Record "Sales Header") | - | public | 28-29 | - | - |
| CreatePrepmtSalesOrder | (var SalesHeader: Record "Sales Header"; PaymentTermsCode: Code[10]; CFPaymentTermsCode: Code[10]) | - | public | 28-29 | - | - |
| CreateSalesLine | (SalesHeader: Record "Sales Header"; GLAccount: Record "G/L Account") | - | public | 28-29 | - | - |
| CreatePurchaseOrder | (var PurchaseHeader: Record "Purchase Header"; GLAccount: Record "G/L Account"; PaymentTermsCode: Code[10]; CFPaymentTermsCode: Code[10]) | - | public | 28-29 | - | - |
| CreateSpecificPurchaseOrder | (var PurchaseHeader: Record "Purchase Header"; PaymentTermsCode: Code[10]; CFPaymentTermsCode: Code[10]) | - | public | 28-29 | - | - |
| CreateDefaultPurchaseOrder | (var PurchaseHeader: Record "Purchase Header") | - | public | 28-29 | - | - |
| CreatePrepmtPurchaseOrder | (var PurchaseHeader: Record "Purchase Header"; PaymentTermsCode: Code[10]; CFPaymentTermsCode: Code[10]) | - | public | 28-29 | - | - |
| CreatePurchaseLine | (PurchaseHeader: Record "Purchase Header"; GLAccount: Record "G/L Account") | - | public | 28-29 | - | - |
| CreateSpecificServiceOrder | (var ServiceHeader: Record "Service Header"; PaymentTermsCode: Code[10]; CFPaymentTermsCode: Code[10]) | - | public | 28-29 | Pending 27.0 | Moved to codeunit Library Service |
| CreateDefaultServiceOrder | (var ServiceHeader: Record "Service Header") | - | public | 28-29 | Pending 27.0 | Moved to codeunit Library Service |
| CreateServiceLines | (ServiceHeader: Record "Service Header") | - | public | 28-29 | Pending 27.0 | Moved to codeunit Library Service |
| CreatePrepaymentAccount | (GeneralPostingSetup: Record "General Posting Setup"; VATBusPostingGroup: Code[20]; VATProdPostingGroup: Code[20]) | Code[20] | public | 28-29 | - | - |
| CreateDefaultJob | (var Job: Record Job) | - | public | 28-29 | - | - |
| CreateDefaultJobForCustomer | (var Job: Record Job; CustomerNo: Code[20]) | - | public | 28-29 | - | - |
| CreateJobPlanningLine | (Job: Record Job; LineType: Enum "Job Planning Line Line Type"; var JobPlanningLine: Record "Job Planning Line") | - | public | 28-29 | - | - |
| FillJournal | (ConsiderSource: array[16] of Boolean; CFNo: Code[20]; GroupByDocumentType: Boolean) | - | public | 28-29 | - | - |
| FillJnlOnCertDateFormulas | (ConsiderSource: array[16] of Boolean; CFNo: Code[20]; BaseDateFormula: DateFormula; CustomDateFormula: DateFormula; AdditionalDateFormula: DateFormula) | - | public | 28-29 | - | - |
| FillJournalOnCertainDate | (ConsiderSource: array[16] of Boolean; CFNo: Code[20]; ForecastDate: Date) | - | public | 28-29 | - | - |
| FilterSingleJournalLine | (var CFWorksheetLine: Record "Cash Flow Worksheet Line"; DocumentNo: Code[20]; SourceType: Enum "Cash Flow Source Type"; CashFlowNo: Code[20]) | Integer | public | 28-29 | - | - |
| FindCFLiquidFundAccount | (var CFAccount: Record "Cash Flow Account") | - | public | 28-29 | - | - |
| FindCFBudgetAccount | (var CFAccount: Record "Cash Flow Account") | - | public | 28-29 | - | - |
| FindFirstGLAccFromCFAcc | (var GLAccount: Record "G/L Account"; CFAccount: Record "Cash Flow Account") | - | public | 28-29 | - | - |
| FindFirstCustLEFromSO | (var CustLedgerEntry: Record "Cust. Ledger Entry"; SalesOrderNo: Code[20]) | - | public | 28-29 | - | - |
| FindFirstVendorLEFromPO | (var VendorLedgerEntry: Record "Vendor Ledger Entry"; PurchaseOrderNo: Code[20]) | - | public | 28-29 | - | - |
| FindCustomerCFPaymentTerms | (var PaymentTerms: Record "Payment Terms"; CustomerNo: Code[20]) | - | public | 28-29 | - | - |
| FindSalesLine | (var SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header") | - | public | 28-29 | - | - |
| FindPurchaseLine | (var PurchaseLine: Record "Purchase Line"; PurchaseHeader: Record "Purchase Header") | - | public | 28-29 | - | - |
| GenerateDateFromFormulaArray | (BaseDate: Date; DateFormulas: array[3] of DateFormula) | Date | public | 28-29 | - | - |
| GenerateDateFromFormulas | (BaseDate: Date; DateFormula1: DateFormula; DateFormula2: DateFormula; DateFormula3: DateFormula) | Date | public | 28-29 | - | - |
| GetDifferentDsctPaymentTerms | (var PaymentTerms: Record "Payment Terms"; PmtTermsCodeToDifferFrom: Code[20]) | - | public | 28-29 | - | - |
| GetTotalSalesAmount | (SalesHeader: Record "Sales Header"; ConsiderDefaultPmtDiscount: Boolean) | Decimal | public | 28-29 | - | - |
| GetTotalPurchaseAmount | (PurchaseHeader: Record "Purchase Header"; ConsiderDefaultPmtDiscount: Boolean) | Decimal | public | 28-29 | - | - |
| GetTotalServiceAmount | (ServiceHeader: Record "Service Header"; ConsiderDefaultPmtDiscount: Boolean) | Decimal | public | 28-29 | - | - |
| GetTotalAmountForSalesOrderWithCashFlowPaymentTermsDiscount | (SalesHeader: Record "Sales Header") | Decimal | public | 28-29 | - | - |
| GetTotalAmountForPurchaseOrderWithCashFlowPaymentTermsDiscount | (PurchaseHeader: Record "Purchase Header") | Decimal | public | 28-29 | - | - |
| GetTotalAmountForServiceOrderWithCashFlowPaymentTermsDiscount | (ServiceHeader: Record "Service Header") | Decimal | public | 28-29 | - | - |
| GetTotalJobsAmount | (Job: Record Job; PlanningDate: Date) | Decimal | public | 28-29 | - | - |
| GetTotalTaxAmount | (TaxDueDate: Date; SourceTableNum: Integer) | Decimal | public | 28-29 | - | - |
| InsertCFLedgerEntry | (CFNo: Code[20]; AccountNo: Code[20]; SourceType: Enum "Cash Flow Source Type"; CFDate: Date; Amount: Decimal) | - | public | 28-29 | - | - |
| SelectAndClearGenJournalBatch | (var GenJournalBatch: Record "Gen. Journal Batch") | - | public | 28-29 | - | - |
| SetExpectedDsctAPmtTermValues | (DocType: Option; DocumentNo: Code[20]; PartnerNo: Code[20]; CFSourceDate: Date; ConsiderDsctAndCFPmtTerms: Boolean; var ExpectedCFDate: Date; var ExpectedAmount: Decimal) | - | public | 28-29 | - | - |
| SetDefaultDepreciationBook | (DepreciationBookCode: Code[10]) | - | public | 28-29 | - | - |
| SetPmtToleranceOptionsOnCashFlowForecast | (var CashFlowForecast: Record "Cash Flow Forecast"; ConsiderPmtDiscTolDate: Boolean; ConsiderPmtTolAmount: Boolean) | - | public | 28-29 | - | - |
| SetupPmtDsctGracePeriod | (NewDscGracePeriodFormula: DateFormula) | - | public | 28-29 | - | - |
| SetupPmtTolPercentage | (NewPmtTolPercentage: Decimal) | - | public | 28-29 | - | - |
| SetupPmtTolAmount | (NewPmtTolAmount: Decimal) | - | public | 28-29 | - | - |
| SetupCustomerPmtTolAmtTestCase | (var CashFlowForecast: Record "Cash Flow Forecast"; var Customer: Record Customer; var Amount: Decimal; PmtTolAmtPercentMultiplier: Decimal; PmtTolPercentage: Decimal) | - | public | 28-29 | - | - |
| SetupVendorPmtTolAmtTestCase | (var CashFlowForecast: Record "Cash Flow Forecast"; var Vendor: Record Vendor; var Amount: Decimal; PmtTolAmtPercentMultiplier: Decimal; PmtTolPercentage: Decimal) | - | public | 28-29 | - | - |
| SetupPmtDsctTolCustLETest | (var CashFlowForecast: Record "Cash Flow Forecast"; var Customer: Record Customer; var PaymentTerms: Record "Payment Terms"; NewPmtDiscountGracePeriod: DateFormula; var Amount: Decimal; var DiscountedAmount: Decimal) | - | public | 28-29 | - | - |
| SetupPmtDsctTolVendorLETest | (var CashFlowForecast: Record "Cash Flow Forecast"; var Vendor: Record Vendor; var PaymentTerms: Record "Payment Terms"; NewPmtDiscountGracePeriod: DateFormula; var Amount: Decimal; var DiscountedAmount: Decimal) | - | public | 28-29 | - | - |
| SetupDsctPmtTermsCustLETest | (var CashFlowForecast: Record "Cash Flow Forecast"; var Customer: Record Customer; var PaymentTerms: Record "Payment Terms"; var Amount: Decimal; var DiscountedAmount: Decimal) | - | public | 28-29 | - | - |
| VerifyCFDateOnCFJnlLine | (CFWorksheetLine: Record "Cash Flow Worksheet Line"; ExpectedCFDate: Date) | - | public | 28-29 | - | - |
| VerifyExpectedCFAmount | (ExpectedAmount: Decimal; ActualAmount: Decimal) | - | public | 28-29 | - | - |
| VerifyExpectedCFAmtNearlyEqual | (ExpectedAmount: Decimal; ActualAmount: Decimal; Delta: Decimal) | - | public | 28-29 | - | - |
| VerifyCFDataOnSnglJnlLine | (var CFWorksheetLine: Record "Cash Flow Worksheet Line"; DocumentNo: Code[20]; SourceType: Enum "Cash Flow Source Type"; CFNo: Code[20]; ExpectedCFAmount: Decimal; ExpectedCFDate: Date) | - | public | 28-29 | - | - |
| VerifyCFDataOnSnglJnlLineWithDates | (var CFWorksheetLine: Record "Cash Flow Worksheet Line"; DocumentNo: Code[20]; SourceType: Enum "Cash Flow Source Type"; CFNo: Code[20]; DocumentDate: Date; ExpectedCFAmount: Decimal; ExpectedCFDate: Date) | - | public | 28-29 | - | - |
| UpdateDueDateOnCustomerLedgerEntry | (var CustLedgerEntry: Record "Cust. Ledger Entry") | - | public | 28-29 | - | - |
| UpdatePmtDiscountDateOnCustomerLedgerEntry | (var CustLedgerEntry: Record "Cust. Ledger Entry") | - | public | 28-29 | - | - |
| UpdateDueDateOnVendorLedgerEntry | (var VendorLedgerEntry: Record "Vendor Ledger Entry") | - | public | 28-29 | - | - |
| UpdatePmtDiscountDateOnVendorLedgerEntry | (var VendorLedgerEntry: Record "Vendor Ledger Entry") | - | public | 28-29 | - | - |

## Events

| Kind | Name | Parameters | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- |
| Integration event | OnBeforeCreatePurchaseLine | (PurchaseHeader: Record "Purchase Header"; GLAccount: Record "G/L Account"; var Handled: Boolean) | 28-29 | - | - |
| Integration event | OnAfterCreatePurchaseLine | (PurchaseHeader: Record "Purchase Header"; GLAccount: Record "G/L Account") | 28-29 | - | - |

## Source

Symbols: Microsoft.ApplicationTestLibrary.symbols.d852d5d2-a39d-4179-baeb-f99a19e32510, https://dynamicssmb2.pkgs.visualstudio.com/DynamicsBCPublicFeeds/_packaging/MSSymbols/nuget/v3/index.json, highest build per major on 2026-11-20.
AL source 29: https://github.com/microsoft/BCApps, MIT, releases/29.x at 4303e5e584d3aa5d9e98cbc615525a5396ad6ed7.

JOP-AL, 2026-11-20.
