Account and tracking category rules
Rules let you choose which account or tracking category a line goes to, based on a combination of the product and the customer. For example, distributor orders of kegs can post to one account, while every other order uses the account set on the product.
Accounts set on products, customers, customer types, parent companies and drink types are the main way to set accounts, as explained in Chart of accounts. Rules are there for the combinations those fields can't express, so you only need to add conditions where something different is needed.
What the rules decide
Each accountancy integration has its own set of rules:
| Rules | What they decide | Available on |
|---|---|---|
| Sales account rules | Which sales account each invoice and credit note line posts to | Every accountancy integration |
| COGS account rules | Which cost of goods sold account each delivered line posts to | Accounting platforms that support balance sheet syncing |
| Tracking category rules | Which tracking category each invoice and credit note line uses | Accounting platforms that have tracking categories |
Rules are used for the product lines on invoices, and for credit note lines with or without a product. The following keep their own accounts and aren't affected by your rules:
- Additional charges, such as delivery charges and discounts, along with their tracking categories
- Container deposit return lines on credit notes
- Rounding adjustments
- Finished goods, WIP, WIP losses and stock adjustment accounts
Opening your rules
You'll need the Manage integrations permission to view, test or change these rules.
- Go to Integrations -> Accountancy -> Actions -> Configuration.
- Press Accounts & tracking categories (shown as Accounts if your accounting platform doesn't have tracking categories).
- On the Defaults tab, find the How Breww chooses accounts card and press the edit button on the row for the rules you'd like to change.

The Set up column shows the starting rule until you change anything, and after that it shows how many conditions and outputs you have.
How your rules work
Every line starts at Start and follows the lines between the blocks. At each condition Breww answers yes or no and carries on down that path until it reaches an output, which gives the answer for that line. Only one output is ever used for a line.

These rules use the same editor as Breww's other rules, so Using the rules editor explains how to add blocks, draw lines between them and spot unfinished paths. The panel on the canvas offers Condition, plus one block named after what these rules decide: Sales account, COGS account or Tracking category.
Your rules apply as soon as they're saved. There are no drafts, so the next document Breww uploads will use whatever is on the canvas. Documents that have already been uploaded aren't changed.
Only the path a line actually takes needs to be finished. If one path is unfinished, the lines that take a different path carry on as normal, and the lines that reach the unfinished path are held back. See When Breww is unable to choose an account below.
Your starting rules
Each set of rules starts with a single output called Everything else, which uses the accounts you've set on products and customers:
- Sales account rules start with Product, then customer, then your default sales account, or with the customer first.
- Tracking category rules start with Product, then customer, then your default tracking category, or none, or with the customer first.
- COGS account rules start with Product, then customer, then your default COGS account.
To change the order, press the pencil button on the Everything else output and choose a different option under Look on.
Adding a condition
- Drag Condition from the panel and drop it onto the canvas.
- Enter a Name. This is shown on the block, so choose something you'll recognise, such as "Distributors".
- Under Conditions, choose what to check, then in or not in, then the values to compare against.
- Press Save, then draw lines from its green check mark and red cross to the blocks that should come next.

Use Add rule and Add group to combine several checks in one condition with AND and OR. These are the checks you can use:
| Check | What it looks at |
|---|---|
| Customer | The customer on the order |
| Customer type | That customer's type |
| Customer tag | The tags on that customer |
| Parent company | That customer's parent company |
| Product | The product on the line |
| Product tag | The tags on that product |
| Product type | The type of product |
| Beer | The drink in that product |
| Drink type | The drink type of that product |
| Container type | The container type of that product |
| Keg, cask or smallpack | Whether the product is a keg, a cask or a smallpack. Mixed packs count as smallpack. |
| Guest beer | Whether the product is a guest beer. This check uses equal or not equal with a yes or no value. |
Beer and Guest beer are named after your own drink name, so you may see a different word here.
Conditions always look at the customer on the order, even when the invoice is uploaded to their parent company. Alias products are checked as their parent product, apart from the Product and Product tag checks, which use the alias itself.
When a check has nothing to compare
A check counts as false when there's nothing for it to look at, whether you've chosen in or not in:
- Lines with no product: some credit note lines don't have a product, so every product check is false for them.
- Customers with no customer type or parent company: the Customer type or Parent company check is false for them.
- Mixed packs: the Beer check only matches when the pack has one beer or an associated beer. Otherwise in and not in are both false. Drink type and Container type work the same way, so they need every item in the pack to share one drink type or one container type.
Customer tag and Product tag are the exception, as a customer or product with no tags still counts as not in any tag. A line with no product is still false for Product tag.
Adding an output
Drag Sales account, COGS account or Tracking category from the panel and drop it onto the canvas. The optional Label is shown on the block and in sync messages, but has no effect on how your rules work.
Under Output, choose what should happen:
- Use the account set on a product or customer (or Use the tracking category set on a product or customer) looks up what you've already set, using the options described below.
- Post to a specific account (or Use a specific tracking category) always uses the one you choose, whatever is set on the product or customer.
- No tracking category is only offered on tracking category rules, and leaves the line without one.

Where Breww looks
Look on decides where Breww looks and in what order, and it stops at the first one that has something set:
| Option | What it means |
|---|---|
| Product, then customer | The product first, and the customer if the product has nothing set |
| Customer, then product | The customer first, and the product if the customer has nothing set |
| Product only | Only the product |
| Customer only | Only the customer |
| Neither | Doesn't look at either, and goes straight to If none is set |
Product means the product, then the product it's an alias of, then the product's drink type.
Customer means the customer, then their parent company, then their customer type. When the invoice is being uploaded to the parent company, Breww uses the parent company's own account instead.
You can set a COGS account on customers, parent companies and customer types as well as on products and drink types. The Cost of goods sold account column is on the Customers, Parent companies and Customer types tabs of the same page as your rules.
If none is set
If none is set decides what happens when Breww finds nothing in the places it looked:
| Option | Offered on | What it means |
|---|---|---|
| Use your default sales account | Sales account rules | Uses the default set on the Defaults tab. The document is held back if you haven't set one. |
| Use your default COGS account | COGS account rules | Uses the default set on the Defaults tab. If you haven't set one, Breww raises a balance sheet sync message. |
| Use your default tracking category (held if it isn't set) | Tracking category rules | Uses your default, and the document is held back if you haven't set one |
| Use your default tracking category, or none if it isn't set | Tracking category rules | Uses your default if you have one, otherwise leaves the line without a tracking category |
| Use no tracking category | Tracking category rules | Leaves the line without a tracking category |
| Hold the document | Sales account rules and tracking category rules | Holds the document back until the product or customer has something set |

Neither needs a default to fall back on, so it can't be combined with Hold the document. On tracking category rules it can't be combined with Use no tracking category either: use the No tracking category output for that.
An account or tracking category that's used by a rule can't be deleted until you've changed that rule.
Testing your rules
You can check how Breww would treat any line before relying on your rules. Testing doesn't change anything and doesn't upload anything.
- Press Test these rules at the top of the rules editor.
- Choose a Customer and a Product. Leave Product blank to test a credit note line without a product.
- Press Test this line.

The bar shows the result, such as Posts to Beer sales - 4000, along with where the answer came from. On the canvas, the path the line takes is highlighted and everything else fades, and notes appear inside the blocks it passed through:
- Conditions say why the line went that way, such as "No, because this line has Customer type: Pub/Bar".
- Outputs show each place Breww looked, marked Used or Not set, or the Result when they use a specific account or tracking category.

Use Change test to try another customer or product, and Clear test to return to the normal view. If you add, remove or reconnect blocks while a test is showing, Breww runs it again so that the result stays up to date.
When Breww is unable to choose an account
Breww holds a line back rather than guessing. This happens when:
- The line reaches an unfinished path, in which case the message says "Your account rules are incomplete, so Breww can't choose an account for this line" (or the equivalent for tracking categories). Finish the path in the rules editor to fix it.
- An output set to Hold the document finds nothing on the product or customer. Set an account or tracking category on one of them, or change the rule.
- An output needs a default that you haven't set. Set the default on the Defaults tab.
Testing the same line shows you the same message:

Invoices and credit notes
If Breww can't choose a sales account or tracking category for any line on an invoice or credit note, the whole document is held back. Other documents carry on uploading as normal.
You'll see why on the Sync messages tab of your accountancy integration, and on the invoice or credit note itself. The message names the line, the product and the customer, says what to set, and links to Edit the product, Edit the customer and Test the rules, which opens your rules with that line already tested.
Once you've fixed the problem, you don't need to do anything else. Breww tries held documents again shortly after you change your rules, your default accounts, or the accounts set on a product, drink type, customer or customer type, and the sync message clears when the upload succeeds.
COGS accounts
If Breww can't choose a COGS account, you'll see a message on the Balance sheet sync part of the Sync messages tab, and that balance sheet sync stops at that point until it's fixed. The invoice itself stays uploaded. Breww tries again at the next scheduled balance sheet sync and clears the message once it succeeds.
Sage 50 CSV exports
Held documents stay out of your export file. They remain pending with their sync message, and return in your next export once they're fixed. See Manual accountancy integrations.