SmartPO
SmartPO, short for Smart Purchase Order, is the purchase order builder and predictive ordering flow within Smart Tools Hub. It is the largest piece of work we've delivered for Three Bears Alaska to date.
Overview
SmartPO is where a PIC builds and submits a purchase order. It replaces the Warehouse Order Guide and extends it with predictive ordering, suggesting quantities rather than leaving the orderer to guess.
It currently serves two vendors: the internal warehouse and Costco.
How It Works
Building an Order
A PIC creates a new order, chooses the vendor it is going to, and enters their own first and last name as the initiator. From there, items are added one at a time.
There are two ways to find an item:
- Scan - using the built-in scanner on the handheld. The same page also accepts a UPC typed or pasted in directly, which is mainly useful during development.
- Search - looking products up by UPC, item number, or name
Either path lands on the item, where the PIC can see its metrics, enter the quantity they want on the order, and add it.
Reviewing and Submitting
Before submitting, the PIC can view everything on the order and work through it - changing quantities, removing items, or swapping things out. Submitting hands the order off for delivery to the vendor.
Units vs Cases
Warehouse orders are placed in cases, while Costco orders are placed in units. The app accounts for this and shows the appropriate label wherever it applies.
Submission & Purchase Order Files
Submitting an order kicks off a chain of Azure resources rather than building the file in the app:
- SmartPO sends the order ID to a Logic App
- The Logic App pulls the order's information from the database and begins composing an email
- It calls the Function App responsible for purchase order files, which builds the Excel file and returns it as an attachment
- The Logic App passes that to the email sender Logic App, which sends the purchase order to the back office or directly to the vendor
The function app only needs an order ID. From there it assembles the file from the order's items in the database and produces it in whatever format the receiving vendor expects, since vendors differ in what they require. Getting the format right for the destination vendor is the function's job, not the app's.
This function sits alongside the tax exemption reporting function - see Tax Exemption - as two separate functions within the same Azure Function App, built from the tba-daily-excel repo. That repo has a wiki documenting how to call them, which is the place to start.
Costco Exclusives & New to Vendor Items
Costco sends over a list of their items, which means our dataset contains items that do not exist in BRData. These are the items referred to as Costco Exclusives or CEs - see CE / New to Vendor in the glossary.
There is connective tissue linking Costco's item list to our UPCs, but not every item has it yet. Most do.
These items have no UPC. They carry an item number instead, and for Costco items that item number
serves as the UPC equivalent. The OrderItemsCostco table exists to record which items on a purchase
order are Costco Exclusives.
This has consequences well beyond the Costco vendor itself:
Anything in the app that takes a UPC, or that pulls from the item table, will not work for these items. If you are writing or changing anything that touches a UPC, work out what it does with a Costco Exclusive before you ship it. These items will come back to bite you otherwise.
Data & Tables
Everything SmartPO reads and writes is catalogued in the Data Dictionary. The sections that matter most to this flow:
| Section | Covers |
|---|---|
| Ordering | Orders, OrderItems, OrderItemsCostco and order statuses |
| SmartPO Configuration | Lead times, days on hand goals, vendor groups and store zones |
| Costco | The Costco catalog and the bridge back to BRData vendors |
| Stored Procedures | The predictive query, search, and purchase order procedures |
| Functions | The PQ_ functions behind the suggestions |
Access & Permissions
Store accounts work the same across Smart Tools Hub - see Access & Permissions on the application page for how they are set up.
SmartPO identifies the store by reading the store number out of the email address text rather than the surname. Surnames are not reliably set when new accounts are created, so the email address is the dependable source of the store number.
Reached from the handhelds in each department, which are bookmarked directly to this flow.
Known Issues & Limitations
- Costco Exclusives have no UPC - anything UPC-based or item-table-based breaks for them; see above
- Two vendors only - the warehouse and Costco; every other vendor is still ordered outside the app
- Units vs cases differ by vendor - quantity means different things depending on who the order is going to, which is a recurring source of confusion