How to Build a Weekly Food-Cost Trend Report from MarketMan

Each week, pull MarketMan catalog item costs, compare them against last week's prices, calculate the week-over-week movement per ingredient, write a trend CSV, and upload it to an FTP reporting folder, all on a fixed schedule in Spojit.

What This Integration Does

Ingredient prices drift constantly, and by the time a kitchen notices margin slipping it is usually too late to renegotiate or swap a vendor. This workflow gives you a standing weekly snapshot of every catalog item's cost and how much it moved since the previous run, so a chef or purchasing manager opens one file and sees exactly which ingredients went up, by how much, and which ones to act on. The output is a plain CSV that any spreadsheet, BI tool, or finance system can read straight from your FTP server.

The workflow runs on a Schedule trigger (for example every Monday morning). On each run it reads the current MarketMan catalog, looks up the prices it stored on the previous run, computes per-item percentage and absolute movement with the math connector, builds a CSV with the csv connector, and uploads it to a dated path on your ftp connection. Because the comparison depends on last week's figures, the very first run has no baseline and produces a report with zero movement; every run after that compares against the run before it. Re-running for the same week simply overwrites that week's file at the FTP destination, so reruns are safe.

Prerequisites

  • A MarketMan connection in Spojit (Connections - Add connection - MarketMan) with access to the buyer account whose catalog you want to track. Note the buyerGuid if you manage more than one buyer.
  • An ftp connection to the server and folder where the report should land, with write permission to the target directory.
  • A way to persist last week's prices between runs. The simplest is a small file on the same FTP server (for example /reports/food-cost/_state/last-week.json) that this workflow reads at the start and rewrites at the end. The ftp connector's download-file and upload-file tools handle both.
  • The csv and math connectors are built in and need no setup.

Step 1: Add the Schedule trigger

Start a new workflow and set the Trigger node type to Schedule. Enter a 5-field cron expression and an IANA timezone so the run fires at a predictable local time. For example, every Monday at 6am Sydney time:

Cron:     0 6 * * 1
Timezone: Australia/Sydney

The trigger output is { scheduledAt }, which you can reference later as {{ trigger.scheduledAt }} to stamp the report. A single Schedule trigger can hold multiple schedules if you later want, say, a mid-week check as well.

Step 2: Load last week's prices from FTP

Add a Connector node in Direct mode, pick the ftp connector, and choose the download-file tool. Point path at your state file:

path: /reports/food-cost/_state/last-week.json

This returns the JSON you wrote on the previous run (a map of catalog item code to price). On the first ever run this file will not exist. To keep the workflow from halting, follow this node with a Condition node that checks whether the download succeeded; on the "missing" branch, treat the baseline as empty so every item simply reports zero movement. You can also see the retry and error handling guide for how to make a single failing step non-fatal.

Step 3: Pull the current MarketMan catalog

Add a Connector node in Direct mode, choose the marketman connector, and select the get-catalog-items tool. This returns every vendor catalog item available for ordering, including each item's code and current cost. Fill in only what you need:

buyerGuid:  {{ your buyer GUID, or leave blank for the default }}
vendorGuid: {{ optional - set to track a single vendor's catalog }}

Bind the result to a variable such as catalog so later steps can read {{ catalog }}. If your account has a large multi-vendor catalog, set vendorGuid to keep each report focused and the file readable.

Step 4: Calculate week-over-week movement per ingredient

You now have this week's catalog and last week's prices. Add a Loop node in ForEach mode over the catalog items so you process one ingredient at a time. Inside the loop, add a Connector node in Direct mode using the math connector with the percentage tool to compute the percentage change, and a second math node with the round tool to keep the figure clean:

percentage  -> change vs base price for the current item
round       -> round that percentage to 2 decimal places

For each item build a small object with the fields you want in the report: item code, item name, last week's price, this week's price, the absolute difference, and the rounded percentage change. Use a Transform node to assemble that object, looking up the prior price for the item code from the Step 2 result and defaulting to this week's price when the item is new (so a brand-new item shows zero movement rather than a misleading spike). Collect the per-item objects into an array, for example trendRows.

Step 5: Build the trend CSV

Add a Connector node in Direct mode, choose the csv connector, and select the from-json tool to turn your trendRows array into a CSV string. Pass the rows as data and pin the column order with columns so the file is stable week to week:

data:    {{ trendRows }}
columns: ["itemCode","itemName","lastPrice","thisPrice","priceDiff","pctChange"]
header:  true

The tool returns { csv, rows, encoding }. Reference the generated text later as {{ csv_result.csv }}. If you want the steepest increases at the top, add a csv node with the sort tool on the pctChange column in descending order before uploading.

Step 6: Upload the report to the FTP reporting folder

Add a Connector node in Direct mode, choose the ftp connector, and select the upload-file tool. Use a dated path so each week keeps its own file, and pass the CSV string as content:

path:     /reports/food-cost/food-cost-trend-{{ trigger.scheduledAt }}.csv
content:  {{ csv_result.csv }}
encoding: utf8

Because upload-file overwrites an existing file at the same path, re-running for the same week safely replaces that week's report rather than duplicating it.

Step 7: Save this week's prices as next week's baseline

Finish with a second Connector node using the ftp connector and the upload-file tool, this time writing the current price map back to your state file so the next run has a baseline to compare against. Build the map of item code to this week's price with a Transform node, then upload it:

path:     /reports/food-cost/_state/last-week.json
content:  {{ priceMapJson }}
encoding: utf8

This must run after the report is written, so that a failure during reporting does not advance the baseline and skip a week of comparison. Optionally add a Send Email node to notify the purchasing team that the new report is available, with the file path in the body.

Tips

  • Keep the state file and the report in separate folders (a _state subfolder) so anyone browsing the reports directory only sees clean CSVs.
  • Need a one-sentence build to start from? Ask Miraxa, the intelligent layer across your automation, something like: "Add a Schedule trigger that runs every Monday at 6am Australia/Sydney, then a Direct-mode MarketMan node calling get-catalog-items." Miraxa scaffolds the nodes on the canvas and you fine-tune the fields in the properties panel.
  • If you track several vendors, run one workflow per vendorGuid writing to its own dated path, or add a Loop over vendors so a single workflow produces one file each.
  • Use the math round tool on the percentage so the CSV stays readable; long floating point values make the report hard to scan.

Common Pitfalls

  • No baseline on the first run. The state file does not exist yet, so guard the download with a Condition node and treat a missing baseline as empty. Without that guard the workflow can halt on a file-not-found error.
  • New or removed items. Items that appear this week but were absent last week have no prior price. Default their baseline to this week's price so they report zero movement instead of an infinite or misleading percentage.
  • Advancing the baseline too early. Always write the new state file after the report upload succeeds. If you write it first and the upload then fails, you lose a week of comparison.
  • Timezone drift. The Schedule trigger uses the IANA timezone you set, not the server's. Confirm the timezone so the weekly run fires on the day you expect, especially across daylight-saving changes.

Testing

Before relying on the schedule, validate the logic on a small scope. Temporarily point vendorGuid at one vendor with a handful of catalog items, then run the workflow twice using the Run button: the first run seeds the state file and shows zero movement; nudge a price in MarketMan (or hand-edit the state file) and run again to confirm the second report shows the expected week-over-week change. Open the uploaded CSV from the FTP folder to check the column order and rounding. Once the figures look right, widen the scope back to the full catalog and let the Schedule trigger take over. The execution logs show each step's input and output so you can confirm the math and the file path on every run.

Learn More

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.