mrp_plan
Generates a read-only material requirements plan for a chosen timeframe and scope, netting sales, job, batch, and purchase data through the BOM to show what to buy or make, by when, and why.
Instructions
Material requirements plan for one company, read-only: nets open sales and job demand, open manufacturing batches and open purchase orders against stock, day by day, through the bill of materials, and returns what to buy and make, by when, and why. ALWAYS ask the user two things first and never assume either: the time frame (through, or days) — 'buy and make what is needed to cover everything due by this date' — and the scope: everything, particular vendors, or particular products. Lead times come from EBMS: the product's vendor record (INVENDOR.LEAD_DAYS), else the vendor's (APVENDOR.LEAD_DAYS); 0 means not set. A purchase with a lead time gets an order-by date; one without carries only its needed-by date. Pass leadTimes or leadTimeDays only for figures the user gives. Only stocked products and stocked lines are planned; drop-ship, associated and sync lines belong to their own orders. The planner's worksheet is an Excel workbook saved on this computer (worksheet.savedAt): give the user that path; they approve rows in it. A CSV copy of its rows is attached for reading only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Time frame as days from today. Give this or through. | |
| items | No | With scope 'products': the product IDs to report. | |
| scope | No | Required. ASK the user: everything, particular vendors, or particular products? Buyers often work one vendor at a time. The whole company is always planned; the scope decides what is reported. | |
| inChat | No | Default true: attach a CSV copy of the worksheet's rows to this result, for reading. | |
| saveTo | No | Folder for the worksheet. Default: KOBLE_OUTPUT_DIR, or 'Koble MRP' in the user's Documents. | |
| company | No | Company, by ID or name. May be omitted only when one company is available. | |
| maxRows | No | Rows per section in this result, default 25. The worksheet always has every row. | |
| through | No | Last date to cover, yyyy-mm-dd. Give this or days. | |
| vendors | No | With scope 'vendors': vendor IDs or names. A product belongs to its primary vendor. | |
| alsoMade | No | Product IDs to treat as manufactured although they have never been on a batch. | |
| leadTimes | No | Lead time in days per product ID, from the user; overrides EBMS's figure for that product. | |
| worksheet | No | Default true: write the planner's worksheet (an Excel workbook). | |
| buyInstead | No | Made products to plan as purchased for this run (not exploded into components). | |
| includeJobs | No | Count job transfers as demand. Default true. | |
| minimumRule | No | How an item that ends the time frame under its minimum is restored. when-crossed (default): the minimum is a reorder point, so the order is dated the day the item went under and can replace an expedite. by-end: the minimum is a level to be back at by the end of the time frame, so the order is dated its last day. It is a company policy; ask once. | |
| leadTimeDays | No | A lead time for items EBMS has none for (and for made items), only if the user states one. |