The problem: deposits that live outside the ERP

Many manufacturers pay suppliers in stages: a deposit when the order is placed, another before shipment, the balance on delivery. Engineered equipment, tooling and long-lead purchases almost always work this way. The commercial terms are clear, yet in most Epicor Kinetic sites the schedule lives in a spreadsheet beside the purchase order.

That gap costs money. AP clerks key advance bills by hand, deposits get paid twice or not at all, and nobody can say how much of a PO is already prepaid. Standard Epicor offers advance billing on AP invoices and payment terms on the PO, but nothing that ties a milestone schedule to each PO line and carries it through to the invoice.

This article walks through the solution we built and run: the schedule becomes data, it is split across PO lines, AP advance-bill lines are created automatically, and anything already processed is protected. It uses only standard Kinetic tools (user-defined tables, Epicor Functions, BPMs, an updatable BAQ and Application Studio), with no source changes and no third-party add-ons.

How it works, in one example

A buyer raises a PO for six lines and agrees two payment milestones with the supplier: 40% on order and 60% before shipment.

  1. Define the counters. On PO Entry the buyer adds two rows to the payment schedule grid (stored in UD01): counter 1 at 40% and counter 2 at 60%, each with a fixed pay date or a number of days before the line due date. Validations run on every save.
  2. Distribute. One click creates the line deposits in UD02: every PO line gets one row per counter. Six lines and two counters give twelve line deposits, and each line’s deposits add up to exactly 100% of that line.
  3. Bill. When a deposit falls due, AP selects it on the supplier invoice and the system creates the advance-bill line.
  4. Lock. Once a deposit is invoiced and processed, its Processed flag is set. From then on it cannot be edited, redistributed or deleted. Until then, buyers can distribute, change and delete freely, within the validations.
PO lineLine amountCounter 1 (40%)Counter 2 (60%)Total
1120.0048.0072.00120.00
224.009.6014.4024.00
399.9940.0059.99 (takes the remainder)99.99

Illustrative amounts. Line 3 shows why the last counter takes the remainder instead of its own rounded percentage: 40% of 99.99 rounds to 40.00, and 59.99 keeps the line exact to the cent.

PO deposit schedule lifecycle in Epicor KineticThe buyer defines payment counters on PO Entry, stored in UD01. Distribute creates one UD02 line deposit per PO line per counter. Amount-wise deposits are adjusted in an updatable BAQ grid. AP bills selected deposits as advance-bill lines on the supplier invoice. Processed rows are locked against edit and delete. Data directives and a BAQ update directive guard every save.1. DefinePO Entry, UD01Counters: %, date or days2. DistributeEpicor FunctionUD02: line x counter3. AdjustUpdatable BAQ gridAmount-wise splits4. BillAP Invoice EntryAdvance-bill lines5. ProcessedInvoiced and postedLocked: no edit or deleteGuards on every save, from any screen or importUD01 and UD02 data directives | BAQ Update pre-processing directive | AP line delete resets the link
Five steps from schedule to processed deposit, with server-side guards underneath every one of them.

The building blocks

The design rests on one idea: a payment schedule is data, stored in two user-defined tables and protected by rules on the server. Each piece sits in the layer it suits best:

  • UD01 holds the header schedule: one row per payment milestone, called a counter.
  • UD02 holds the line schedule: one row per PO line per counter, with the amount and pay date.
  • Epicor Functions run the business logic: add, distribute, delete, bill and reset.
  • BPMs (data directives and a BAQ method directive) guard the data whatever screen or process writes it.
  • Application Studio puts the grids and buttons on PO Entry and AP Invoice Entry and calls the functions.

The data model

Document the field map before writing a line of code. Every function, BPM and screen depends on it, and a single misread field causes most of the bugs you will chase later.

UD01: header payment schedule (one row per counter)

FieldMeaning
Key1PO number
Key5Unique row key
Number04Counter (milestone number 1, 2, 3 and so on)
Number02Percentage of the PO (0 means amount-wise)
Number01Days before the line due date
Date01Fixed pay date
CheckBox01Paid

UD02: line payment schedule (one row per PO line per counter)

FieldMeaning
Key1 / Key2 / Key3PO number / PO line / counter
Key5Distribution run ID
Number03Deposit amount
Number02Percentage (0 means typed by hand)
Number01 / Date01Days before due / pay date
Date03PO line due date
Number04 / Number05 / Number06Counter / PO / line (numeric copies for queries)
CheckBox02Selected for billing
CheckBox01Invoiced
ShortChar10 to ShortChar14AP group, vendor, invoice, invoice line, processed (posted) flag
Always filter by Company as well as the PO number. Function libraries are often shared across companies, and PO numbers repeat between them.

Step 1: Define the header schedule (UD01)

The buyer adds milestones to a grid on PO Entry, for example 40% on order and 60% before shipment. Each row gets a counter and either a fixed pay date or a number of days before the line due date. The schedule works in one of two modes, decided per PO:

  • Percent-wise: header percentages add up to 100% and the system calculates every line amount.
  • Amount-wise: percentages stay at 0 and buyers type a deposit per PO line, for suppliers who quote deposits line by line.

The “+” button calls a function that assigns the next counter as the highest existing counter plus one. Never derive it from a row count: after a delete, a count-based counter repeats an existing number, and everything that links by counter breaks.

An In-Transaction data directive on UD01 enforces the header rules on every save, from any source:

RuleResult
Both a pay date and days enteredError
Neither entered (on edit)Error
Negative days, or percentage outside 0 to 100Error
Total percentage above 100Error
Editing or deleting a paid rowError
Total percentage between 1 and 99Warning
Percentage changed after lines existWarning: redistribute

Two details matter. New rows from “+” start empty, so the date-or-days rule applies only on edit. And when only the Paid flag changes, the directive steps aside, so the billing functions are never blocked by an older row that predates a rule.

Step 2: Distribute to PO lines (UD02)

The Distribute button turns header percentages into line deposits. It is the heart of the solution, and the place where a first version usually goes wrong. Our first build rebuilt lines counter by counter; when a buyer deleted a header counter its line rows stayed behind, and the next distribution added fresh rows on top. A 24.00 line ended up scheduled at 38.40. The production version follows six rules:

  1. Validate before touching anything. Pay date or days on every row, percentages totalling exactly 100%, and a due date on every PO line when days are used. If any check fails, nothing changes.
  2. Rebuild, don’t patch. Distribution replaces every open line deposit on the PO, so stale rows cannot survive.
  3. Never touch what is paid or processed. Rows from a paid counter and any invoiced row are kept. Only the open percentage is redistributed: if 40% is paid, the remaining 60% is split, never 100%.
  4. Make the cents add up. Amounts are rounded to two decimals and the last open counter takes the remainder (line total minus kept amounts minus what is already allocated), so no line is ever over or under 100%.
  5. Create first, delete second. New rows are saved under a run ID in Key5, and old rows are removed only after the save succeeds. A failure midway leaves the previous schedule intact instead of an empty one.
  6. Each line uses its own due date. Pay date is the line due date minus the days, or the fixed date. The first version reused the first line’s date for every line.

The core of the calculation is short:

decimal remaining = lineTotal - keptAmount;   // paid or invoiced, already scheduled
decimal allocated = 0m;
for (int i = 0; i < openHeaders.Count; i++)
{
    bool isLast = i == openHeaders.Count - 1;
    decimal amount = isLast
        ? remaining - allocated
        : Math.Round(lineTotal * openHeaders[i].Number02 / 100m, 2);
    allocated += amount;
    // create UD02 row: Key2 = POLine, Number04 = counter, Number03 = amount
}

Before running, the button calls a small check function. If open line deposits exist, a Yes/No dialog explains how many will be replaced and how many paid rows will be kept, so users never lose work by accident.

Step 3: Amount-wise deposits and the updatable BAQ

When a supplier quotes deposits per line, the buyer adds line rows by hand. The add-line function refuses if any header row carries a percentage, because that PO belongs to Distribute. It also requires a pay date or days on the header and copies them onto the new line.

In amount-wise mode, line counters are simply splits of one PO line. A 120.00 line can be 60 + 40 + 20, or 64 + 36 + 10 + 10. They do not need to match header counters; tying them together was an early mistake that blocked perfectly valid splits.

The line grid is an updatable BAQ, and its total check belongs in the BAQ’s own Update pre-processing directive. That is the only place that sees every changed grid row in one batch: a data directive on UD02 sees rows one at a time, and a UI function sees saved values, not the user’s unsaved edits. The check groups changed rows by PO and line, then adds new grid amounts to the saved amounts of untouched counters:

SituationResult
Total above the line amountError, save blocked
Total equal to the line amountInformation: fully scheduled
Total below the line amountSaves silently, so buyers can work in stages
Amount 0 or negativeError
Change to an invoiced or processed rowError
Manual edit of a distributed rowError: change the percentage and redistribute

Two settings make or break this. Tick Allow Multiple Row Update in the BAQ’s Update Settings, or the directive receives one row per call and can never total a line. And keep the Counter column read-only, while Amount, Pay Date and Days stay editable.

Step 4: Bill the deposits on an AP invoice

When a deposit falls due, AP opens the supplier invoice, ticks the line deposits to bill and runs the billing function. For each selected row it creates an advance-bill line through the standard APInvoice business object:

var ds = svc.GetByID(vendorNum, invoiceNum);
svc.GetNewAPInvDtlAdvance(ref ds, vendorNum, invoiceNum);
svc.ChangePONum(poNum, ref ds);
svc.ChangePOLine(poLine, ref ds);
svc.ChangeExtCost(amount, ref ds);
svc.UpdateMaster(ref ds, groupID, "APInvDtl", true, false, true, false,
    out od1, out ob1, out os1, out os2, out os3, out ob2, out ob3, out os4);

Going through the business object rather than writing tables directly keeps every standard AP validation, tax calculation and audit trail intact. Three safeguards make this step trustworthy:

  • Vendor check first. The invoice vendor must equal the PO vendor, or nothing is billed.
  • Mark only on success. A row is flagged invoiced, and its header counter marked paid, only after the AP line saves. A failed row keeps its error text and can be retried. The first version marked rows invoiced even when creation failed.
  • Store the real link. Each row records the AP group, vendor, invoice number and the invoice line actually created, read back from the invoice after the save.

The link also heals when AP deletes an invoice line. A Standard data directive on the AP invoice detail table calls a reset function for the deleted line; it clears the invoiced flag on UD02 only where the AP line no longer exists, and un-pays the header counter when no invoiced line remains.

Step 5: Processed means locked

A deposit moves through four states, and what users may do narrows at each one:

StateSet byDistribute or redistributeEdit amount or dateDelete
OpenDistribute or manual addYesYes, within the validationsYes
Selected for billingAP ticks the rowYes, until billedYesYes
InvoicedBilling function, after the AP line savesKept as isNoOnly if the AP line no longer exists
ProcessedInvoice processed and postedKept as isNoNo

The lock is enforced on the server, not just hidden in the screen. The In-Transaction data directive on UD02 and the BAQ Update directive both reject any change or delete of an invoiced or processed row, so a toolbar delete, an import or a service call cannot bypass it.

Step 6: Delete safely

Deletes are where financial data is most easily corrupted, so every delete goes through a function that checks the real state first:

DeleteAllowed whenBlocked when
A line depositIt is not on an AP invoice and not processedThe AP invoice line still exists, or the row is processed
All line deposits of a POAlways, for open rowsInvoiced and processed rows are kept and reported
A header counterIt is unpaid and has no distributed linesIt is paid, or lines were distributed from it
The last header counterNo amount-wise lines depend on its datesAmount-wise lines still use it

“On an AP invoice” is checked against the AP invoice itself, not only the flag on UD02. If AP has deleted the invoice or its line, the row is free to delete. If the link cannot be verified, the function treats the row as invoiced: when in doubt, block.

The first header-delete function compared the counter with UD02.Key2, which holds the PO line. It let a counter be deleted while its line deposits survived, which is exactly how the orphaned 14.40 in step 2 appeared. One wrong field in one check: read the field map twice.

Where each validation lives

Put every rule in the one layer that sees all the data it needs and cannot be bypassed. Duplicate rules across layers and you get double pop-ups, contradictory messages and rules that drift apart.

LayerSeesUse it for
In-Transaction data directive (UD01, UD02)Each row saved, from any sourceHard guards: paid, invoiced and processed data, date and percentage rules
BAQ Update pre-processing directiveAll changed grid rows togetherTotals across the counters of a PO line
Epicor FunctionThe whole PO, plus other business objectsMulti-step actions: distribute, bill, delete with checks
Application Studio eventThe screenRow selected, confirmation dialogs, messages, refresh
  • Errors block, warnings inform. In a BPM only a raised exception stops a save; Show Message lets it through. If an “error” saves anyway, check which widget it is wired to.
  • One message channel per action. A function sets an output and the screen shows it as a toast. Mixing that with a message raised inside the function produces two pop-ups, and messages raised in a function called through the task agent are never seen at all.
  • Retire old directives. A legacy UD02 directive that warned about totals fired during distribution, while new and old rows briefly coexisted, and blocked the save. Disabling it fixed a bug that looked like a fault in the new code.

Application Studio: lessons from the event trace

Custom data views are not bound to a business object, so a grid’s built-in Delete removes the row on screen only. The fix is to hook the system’s delete chain, not rebuild it. The chain runs: toolbar Delete, confirmation dialog, SysDelete, BeforeDelete, Delete, row-delete, AfterDelete. Turn on browser console tracing; every lesson below came from reading it.

  1. Hook Before BeforeDelete to call the server delete. An After hook fires once the whole chain has finished, when the selected row is gone and the event reads its neighbour. Selecting row 3 deleted row 2 until the hook was moved.
  2. Check the data view first. Every delete in every grid fires the hook, so start with a condition on the current data view and leave its False path empty.
  3. Never use a return action in these hooks. Return ends the entire system chain, not just your event. A return on the “not my grid” path silently broke deletes in every other grid.
  4. Refresh in AfterDelete. Reloading the grid from the server after the chain ends means the screen always shows the database, even when the server refused the delete.
  5. Check a row is selected. An empty or undefined key means no row; show a message instead of calling the function.

The Distribute button follows the same spirit: a check function, a Yes/No dialog when existing lines will be replaced, then one shared event that runs the function, shows the toast and refreshes the line grid. Call the function directly, not through a task agent submission, or users never see its messages.

Testing and go-live

Run every scenario in Pilot with real PO structures before promoting anything. These cases caught real defects:

ScenarioExpected result
40% + 60% on a 120.00 line48.00 + 72.00 = 120.00
60% + 40% on a 24.00 line14.40 + 9.60 = 24.00
33.33% + 33.33% + 33.34% on 100.0033.33 + 33.33 + 33.34 = 100.00
Distribute twice in a rowConfirmation shown; same totals, no duplicates
Delete a header counter, change percentages, redistributeOld rows removed; line total exact
Counter 1 (40%) paid, then redistribute40% kept, only the open 60% rebuilt
Header total 80%Blocked; existing lines unchanged
Amount-wise 60 + 40 + 30 on a 120.00 lineBlocked: over by 10.00
Edit or delete a processed depositBlocked
Delete an invoiced depositBlocked, with the invoice number
Delete the AP invoice line, then the depositLink cleared; delete allowed
Bill with a different vendor’s invoiceBlocked before any line is created
  • Promote, then hard-refresh. Most “the fix did not work” reports were an unpublished function library or a cached layer.
  • Read the trace before changing code. The browser console shows each event, condition and value; it pinpointed the timing and return-action bugs in minutes.
  • Clean legacy data once. Rows created by earlier versions are replaced on the first redistribution; check a sample of open POs after go-live.
  • Inventory old BPMs. Search directive bodies for message text you do not recognise, and disable what the new design replaces.

Frequently asked questions

Can Epicor Kinetic split a purchase order into deposit payments?

Standard Kinetic supports advance billing on AP invoices and payment terms on the PO, but not a milestone schedule per PO line. A schedule stored in UD01 and UD02, driven by Epicor Functions and BPMs, adds it without changing Epicor source code.

How do you stop deposit amounts exceeding the PO line value?

Round each counter to two decimals and let the last open counter take the remainder, so distributed amounts always equal the line total. For amount-wise lines, total all counters in the updatable BAQ's Update pre-processing directive and block the save when they exceed the line amount.

How do you prevent changes to a deposit that has already been billed?

Flag the row when its AP advance-bill line saves successfully, then reject any edit or delete of a flagged or processed row in an In-Transaction data directive on the UD table, so the guard applies to every screen, import and service call.

What happens if AP deletes the advance-bill line?

A Standard data directive on the AP invoice detail table calls a reset function that clears the invoiced flag only where the AP line no longer exists, and un-pays the header counter when no invoiced line remains.

The takeaway

A deposit schedule stops being a spreadsheet problem once it lives in the ERP as data, with rules that protect it. Two UD tables, a handful of Epicor Functions, a few well-placed BPMs and two Application Studio screens carry a purchase order from milestone plan to processed advance bill, exact to the cent.

The pieces are standard Kinetic. What makes the solution hold up is the discipline around them: validate before changing anything, rebuild instead of patching, never touch paid or processed data, and put each rule in the one layer that cannot be bypassed. The same pattern carries over to retention payments, progress billing on the sales side, or any schedule that splits one document into dated instalments.

Related: a one-click Miscellaneous Pack Slip report in Epicor Kinetic and provisioning Epicor users across companies.