/
/
Turn a WooCommerce refund into a Business Central credit memo
For finance teams who want a WooCommerce refund credited against the right invoice in Dynamics 365 Business Central by their AI assistant.
On this page
Connector
Connect WooCommerce, pick your AI tool and paste the prompt.
The problem
Refund credits that get missed or doubled
Each WooCommerce refund needs a credit memo in Dynamics 365 Business Central against the right invoice. Working out which lines and prices to credit, and making sure it was not already credited, is fiddly, and a duplicate overstates the customer's account.
Without PopdockAI
- Read the refund and its lines in WooCommerce
- Search Business Central for an existing credit memo
- Find the posted invoice and its prices
- Key in the memo and hope it was not done already
With PopdockAI
- The refund is read and existing credit memos are checked first
- Each refunded quantity is credited at the invoiced price
- You approve the plan before anything is written
- The memo is created unposted, its total checked and the order noted
The prompt
Use this prompt
Copy it into any AI tool connected to PopdockAI. Swap the values in braces for your own.
**Objective:** Create an unposted Business Central sales credit memo for WooCommerce refund {refund-id}, applied to the posted invoice for its order, then note the credit memo number on the WooCommerce order. Use Business Central company {company} (if blank, leave `company` off).
**Step 1: Read the refund in WooCommerce**
Call `woocommerce-get-refund` with `refund-id` set to {refund-id}. If nothing comes back, report that and stop. Note order-id, order-number, amount (treat it as positive), reason and created-date. Call `woocommerce-get-refund-line` with the same `refund-id` for each line-item-sku, line-item-quantity and line-item-total. If there are no lines, it is an amount-only refund.
**Step 2: Check it has not already been credited**
Call `woocommerce-get-refund` with `order-number` set to the order-number to see all refunds on the order. Call `business-central-get-posted-sales-credit-memo` and `business-central-get-sales-transaction` (credit memo documents only), each with `external-document-number` set to the order-number. If the existing Business Central credit memos already cover this refund (as many credit memos as refunds, or a credit memo total matching this refund's amount), report them and stop.
**Step 3: Find the invoice being credited**
Call `business-central-get-posted-sales-invoice` with `external-document-number` set to the order-number. If nothing comes back, report that the order has not been invoiced in Business Central, so there is nothing to credit yet, and stop. If more than one comes back, list them and ask the user which to credit. Keep invoice-number, sell-to-customer-number and bill-to-customer-number.
**Step 4: Build the lines**
Call `business-central-get-posted-sales-invoice-line` with `invoice-number` set to the invoice. For each refund line, find the invoice line whose number equals the line-item-sku. Credit the refunded quantity at the invoice line's unit-price. If a refund line's SKU is not on the invoice, stop and list it.
For an amount-only refund, ask the user which G/L account to credit, and use one G/L account line for the refund amount.
**Step 5: Confirm**
Show the planned credit memo: customer, invoice it applies to, external document number, and a table of line type, number, description, quantity, unit price and amount, with the total next to the WooCommerce refund amount. Wait for the user to confirm.
**Step 6: Create**
Call `business-central-create-sales-credit-memo` once, with `customer-number`, `bill-to-customer-number`, `invoice-number` set to the invoice, and `external-document-number` set to the order-number. Then call `business-central-create-sales-credit-memo-line` once per line, with `document-number` set to the new credit memo's number, the line type, `number-on-line`, `quantity` and `unit-price`.
**Step 7: Record and confirm**
Call `woocommerce-add-order-note` with the refund's `order-id`, `customer-note` false (private), and a note giving the refund id and the new credit memo number. Then call `business-central-get-sales-transaction-line` with `document-number` set to the credit memo number and compare its total with the refund amount.
**Report:** the credit memo number, invoice credited, lines, Business Central total against the WooCommerce refund amount, and a reminder that the credit memo is unposted and needs review and posting in Business Central.
**Rules & Guidelines:**
* Tools whose names start with woocommerce- are on the woocommerce server; tools whose names start with business-central- are on the business-central server.
* The only writes allowed are `business-central-create-sales-credit-memo` (once), `business-central-create-sales-credit-memo-line` (once per line) and `woocommerce-add-order-note` (once, private), all after confirmation.
* Do not call `woocommerce-add-refund` (the refund already exists), `woocommerce-update-order`, or `business-central-update-sales-credit-memo`. Do not post the credit memo.
**Validation:**
* If a line create fails partway, stop and report the credit memo number and which lines were created. Do not create the credit memo header again.
* If the Business Central total differs from the refund amount by more than 0.01, report the difference (tax or shipping is the usual cause) rather than adjusting lines.Who it's for
One answer, three teams that use it
Accounts receivable
Credit refunds at the invoiced price
Each refunded line is credited at the price it was invoiced, ready to review and post.
Create a Business Central credit memo for WooCommerce refund 6140.
Finance controllers
Stop duplicate credits
It stops when a memo already covers the refund, so customer balances are not understated.
Has WooCommerce refund 5893 already been credited in Business Central? If not, credit it.
Ecommerce accountants
Link refunds back to the store
A private note on the web order records the credit memo, so anyone can trace it later.
Credit WooCommerce refund 7002 in Business Central and note it on the order.
How it works
What PopdockAI does when you ask
You give the refund ID, and your AI assistant builds the credit memo from the posted invoice. Nothing is written until you confirm, and the memo is left unposted.
01
Ask
You give the refund ID.
02
Check
It reads the refund and stops if Business Central already credits it.
03
Build
It finds the posted invoice and credits each refunded quantity at its price.
04
Confirm
You approve the plan, then the unposted memo is created and the order noted.
What PopdockAI provides
The tools behind the answer
Ready made tools for WooCommerce and one secure connection to your AI tool. No code, no exports.
woocommerce-get-refund
woocommerce-get-refund-line
woocommerce-add-order-note
This report is built from Get data tools only. PopdockAI applies the row, field and parameter rules your admin sets, and every query is written to the audit trail.
The outcome
Accurate draft credit memos, never twice
Related use cases
More ways to put this data to work
One prompt template with infinite possibilities.
Your AI assistant adapts its approach, tone, and capabilities to match each unique context while you maintain a single, manageable workflow.
Join forward-thinking companies that are transforming their operations with intelligent, secure AI automation.

.webp)
