Late Payment prediction in Fabric instead of BC

Late Payment prediction in Fabric instead of BC

Maybe you knew it. But in the October release in 2018 Business Central already got his first AI feature called “Late Payment Prediction”.
With this feature you can predict open customer ledger entries when they get paid:

More if it you can learn here:
The Late Payment Prediction Extension – Release Notes | Microsoft Learn
Predict late payments for sales documents – Business Central | Microsoft Learn

But that was a long time ago. And since then we got Microsoft Fabric and AI stack is improved allot.
Inside Microsoft Fabric we got AutoML. So can we build this feature also inside Fabric with the data of Business Central?

What is AutoML

AutoML (Automated Machine Learning) automates the most complex and time-consuming parts of the machine learning workflow—such as model selection, hyperparameter tuning, and feature engineering—so you can focus on understanding your data and applying insights. It democratizes AI by making it accessible to analysts, developers, and business users, not just data scientists.

Microsoft Fabric takes this a step further by integrating AutoML directly into its unified analytics platform. Whether you prefer a no-code experience through the UI or a code-first approach using notebooks, Fabric provides the flexibility to build, evaluate, and deploy machine learning models at scale—all within the same environment where your data lives.
AutoML | AutoML

The experiment

But can we also build the late payment prediction feature inside Fabric with data from Business Central?
For that you can export the data through an API or bc2adls to MS Fabric.
The data would look like this (added the column DurationOpenDays manually):

And when it is there you can run autoML against it with the following notebook code (published on Github):
LatePaymentPrediction/LatePaymentPrediction.py at main · Bertverbeek4PS/LatePaymentPrediction

Step-by-step breakdown of the notebook script:

  1. Load the data
    • The script reads the table (BC_LatePaymentPrediction) from the lakehouse.
    • It makes sure all columns (dates, numbers, customer numbers) are in the right format.
  2. Create useful features
    • It calculates things like:
      • How many days the payment term is (term_days = due date minus posting date).
        (you can also use the Payment terms on the customer card)
      • The month and day of the week the invoice was posted.
    • These are all things are know when the invoice is created (so, no cheating with future info).
  3. Calculate customer payment history
    • For each customer, it calculates:
      • The average number of days they took to pay in the past.
      • How much their payment times vary.
      • How many invoices they’ve closed before.
    • This helps the model learn if some customers are always slow or fast payers.
  4. Prepare the training data
    • Only closed invoices (where you know exactly how long it took to pay) are used to train the model.
    • The script turns the customer number into a simple number (so the model can use it).
  5. Train the prediction model (AutoML)
    • The script uses AutoML to find the best way to predict “days to pay” based on all those features.
    • It splits the data into a training part and a test part, so it can check how well the model works on new data.
  6. Register the model
    • The trained model is saved and registered in MLflow (a model management system in Fabric), so you can reuse it later.
  7. Predict for open invoices
    • For all invoices that are still open, the script builds the same features as above.
    • It uses the trained model to predict how many days each invoice will probably stay open.
    • It also calculates a simple “baseline” prediction: the average payment time for that customer.
  8. Calculate expected close date
    • For each open invoice, it adds the predicted number of days to the posting date to get an “expected close date”.
  9. Write results back to the lakehouse
    • The predictions are saved in a new table (BC_LatePaymentPrediction_Scored), which you can use in Power BI or other tools.

If you are running this script (it can take up to 30 minutes to train the model) your data will be stored inside a lakehouse table:


And with this you can use it for your cashflow. Because you have trained also the “ML model”

Conclusion

This is just an experiment and maybe have some mistakes. But it shows you that with your Business Central data is inside Fabric it is very useful to do more advanced reporting and analyses.

Leave a Reply

Your email address will not be published. Required fields are marked *