Skip to main content

Contract margin guard

Audits your product-level price agreements against current cost and flags the ones selling below a margin floor, so input-cost creep does not quietly eat your margin. It runs automatically every week.

Runs: Outside Propeller · Trigger: Schedule · Difficulty: Medium

Scope: product discounts only

This workflow checks product-specific discount lines. Discounts set on a category or a price group are out of scope and are not audited. If your catalogue is priced mainly by category, most agreements will not be checked.

What you need​

  • An n8n account. See Set up n8n.
  • A Propeller API key that can read pricing and create tickets.
  • The Action Hub, where the tickets land.

How it works​

Every Monday at 06:00 the workflow reads all product-level price agreements of the types net price and list price discount. Other agreement types, such as cost price plus, are only checked if you add them to CHECK_TYPES in Settings. Expired agreements are skipped. Every quantity tier is checked.

For each agreement line, the workflow asks Propeller for the customer price and the cost at that line's quantity, for the customer on the price sheet. It flags lines with a margin below 15%, calculated as the price minus the cost, divided by the price. Lines without a cost price are never flagged.

It creates one ticket per price sheet in the Action Hub, worst margin first, listing the SKUs and prices of the thin lines. The ticket opens the company, contact or customer the price sheet belongs to. A price sheet that still has an open ticket from this workflow is skipped. At most 15 tickets per run.

Install it​

  1. In n8n, import the downloaded JSON as a new workflow.
  2. Create a header auth credential with your Propeller API key and select it on the eight GraphQL nodes.
  3. In the Settings node, set FLOOR to your margin floor and DEFAULT_ADMIN_USER_ID to the backoffice user who should get the tickets.
  4. Run the workflow once manually and check the Action Hub.
  5. Activate the workflow.
Filling in your API key

In n8n, create a credential of type Header Auth and fill in its two fields exactly like this:

FieldWhat to fill in
NameapiKey
ValueYour Propeller API key

Name is not a title you pick yourself. It has to say exactly apiKey, otherwise the workflow cannot sign in. See Set up n8n for the full steps.

Make it yours​

  • The floor: FLOOR in Settings (default 15).
  • Per-run cap: MAX_TICKETS_PER_RUN (default 15).
  • Which agreement types: CHECK_TYPES (default NET_PRICE and LIST_PRICE_MIN, the same as the earlier version).
  • When it runs: the Schedule Weekly Mon 6am node.

Limits​

A run reads at most 100,000 agreement lines. The tickets say when that limit was reached or when lines could not be priced. A price sheet with several customers is checked against the first company, contact or customer on it.

A run that takes longer than one hour is stopped and shows as canceled in the n8n executions list.

Good to know

The workflows and agents in the Agent Hub are free to use and adapt. They are examples, not supported product features, so test them in a staging environment and check the results before using them in production.