Skip to content

Commit

Permalink
Resolves #497 - Add support for multi-location inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-r-west committed Feb 18, 2025
1 parent 50d5fa2 commit 74c4753
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docs/runbook-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,6 @@ actions:



### Output JQ

You will need to escape \ when using the `--output-jq` argument.
11 changes: 8 additions & 3 deletions external/resources/yaml/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ cart-product-items:
type: STRING
tax[n].rate:
type: FLOAT
location:
type: RESOURCE_ID:mli-inventory-locations
alias_attribute: slug
cart-custom-items:
singular-name: "cart-custom-item"
json-api-type: "custom_item"
Expand Down Expand Up @@ -2833,19 +2836,21 @@ mli-inventory-stocks:
json-api-format: compliant
json-api-type: "stock"
singular-name: "mli-inventory-stock"
alternate-json-type-for-aliases:
- pcm-products
docs: "https://elasticpath.dev/docs/api/pxm/inventory_mli/inventory"
get-collection:
docs: "https://elasticpath.dev/docs/api/pxm/inventory_mli/list-stock"
url: "/v2/inventories/"
get-entity:
docs: "https://elasticpath.dev/docs/api/pxm/inventory_mli/get-stock"
url: "/v2/inventories/{pcm_products}"
url: "/v2/inventories/{mli_inventory_stocks}"
update-entity:
docs: "https://elasticpath.dev/docs/api/pxm/inventory_mli/update-stock"
url: "/v2/inventories/{pcm_products}"
url: "/v2/inventories/{mli_inventory_stocks}"
delete-entity:
docs: "https://elasticpath.dev/docs/api/pxm/inventory_mli/delete-stock"
url: "/v2/inventories/{pcm_products}"
url: "/v2/inventories/{mli_inventory_stocks}"
create-entity:
docs: "https://elasticpath.dev/docs/api/pxm/inventory_mli/create-stock"
url: "/v2/inventories"
Expand Down
34 changes: 32 additions & 2 deletions external/runbooks/multi-location-inventory.epcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: "multi-location-inventory"
description:
long: "Sample commands for working with Multi Location Inventory (https://elasticpath.dev/docs/api/pxm/inventory_mli/inventories-introduction)"
short: "Multi Location Inventory"
actions:
create-prerequisites:
description:
short: "Create necessary prerequisites"
Expand Down Expand Up @@ -30,17 +31,46 @@ description:
description:
short: "Setup inventory"
commands:
- epcc create mli-inventory-location name "Milton Keynes Warehouse" slug "milton-keynes-warehouse" description "Southern dispatch location for all inventory" geolocation.lat '51.477928' geolocation.l
- |
epcc get -s mli-inventory-stocks
epcc get -s mli-inventory-locations
- |
epcc create mli-inventory-location --if-alias-does-not-exist slug=milton-keynes-warehouse name "Milton Keynes Warehouse" slug "milton-keynes-warehouse" description "Southern dispatch location for all inventory" address[0] "Troughton Supplies" address[1] "38 Pipernel Grove" address[2] "Walnut Tree" address[3] "MK7 4UL" geolocation.lat '51.477928' geolocation.lon -- '-0.001545'
epcc create mli-inventory-location --if-alias-does-not-exist slug=manchester-warehouse name "Manchester Warehouse" slug "manchester-warehouse" description "Northern dispatch location for all inventory" address[0] "Tonge Supplies" address[1] "10 Lower Darcy St" address[2] "Bolton" address[3] "BL2 1PP" geolocation.lat '53.5707004' geolocation.lon -- '-2.4071741'
- |
epcc create mli-inventory-stock --if-alias-does-not-exist BestEverRangeStock --save-as-alias BestEverRangeStock id name=BestEver_Electric_Range locations.milton-keynes-warehouse.available 1 locations.manchester-warehouse.available 2
epcc create mli-inventory-stock --if-alias-does-not-exist GasRangeStock --save-as-alias GasRangeStock id name=BestEver_Gas_Range locations.milton-keynes-warehouse.available 0 locations.manchester-warehouse.available 1
reset-inventory:
description:
short: "Reset inventory"
commands:
- |
epcc get -s mli-inventory-stocks
epcc get -s mli-inventory-locations
- |
epcc delete mli-inventory-stock BestEverRangeStock --if-alias-exists BestEverRangeStock
epcc delete mli-inventory-stock GasRangeStock --if-alias-exists GasRangeStock
- |
epcc delete mli-inventory-location slug=milton-keynes-warehouse --if-alias-exists slug=milton-keynes-warehouse
epcc delete mli-inventory-location slug=manchester-warehouse --if-alias-exists slug=manchester-warehouse
create-order:
description:
short: "Create an order"
commands:
- epcc delete cart sample_cart
- epcc create cart name sample_cart id sample_cart description sample_cart
- epcc create cart-product-item id=sample_cart quantity 1 id sku=BE-Gas-Range-2b2b
- epcc create cart-product-item id=sample_cart quantity 1 id sku=BE-Gas-Range-2b2b location manchester-warehouse
- epcc create cart-checkout sample_cart customer.name Billy customer.email "[email protected]" billing_address.first_name Jack billing_address.last_name Macdowall billing_address.company_name Macdowalls billing_address.line_1 "1225 Invention Avenue" billing_address.line_2 Birmingham billing_address.postcode "B21 9AF" billing_address.county "West midlands" billing_address.country "UK" shipping_address.first_name Otis shipping_address.last_name Sedmak shipping_address.company_name "Sedmak & Co." shipping_address.line_1 "1251, Rexmere Ave" shipping_address.line_2 "Farmingville, Suffolk" shipping_address.postcode '"11738"' shipping_address.county "New York" shipping_address.country US shipping_address.instructions "Leave in porch"
- epcc get order last_read=entity
check-inventory:
description:
short: "Friendly printout of inventory"
commands:
- |
epcc get mli-inventory-stocks --output-jq '.data[] | . as $root | "ID: \\\($root.id), Global: \\\($root.attributes.available), " + ($root.attributes.locations | to_entries | map("\\\(.key): \\\(.value.available)") | join(", "))'
authorize-payment:
description:
short: "Authorize a payment"
Expand Down
15 changes: 15 additions & 0 deletions external/runbooks/run-all-runbooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ set -x
#Let's test that epcc command works after an embarrassing bug that caused it to panic :(
epcc

echo "Starting Multi Location Inventory Runbook"
epcc reset-store .+
epcc headers set ep-inventories-multi-location true
epcc runbooks run multi-location-inventory create-prerequisites
epcc runbooks run multi-location-inventory setup-inventory
epcc runbooks run multi-location-inventory check-inventory
epcc runbooks run multi-location-inventory create-order
epcc runbooks run multi-location-inventory check-inventory
epcc runbooks run multi-location-inventory authorize-payment
epcc runbooks run multi-location-inventory capture-payment
epcc runbooks run multi-location-inventory reset-inventory
epcc runbooks run multi-location-inventory reset-cart
epcc runbooks run multi-location-inventory reset
epcc headers delete ep-inventories-multi-location

echo "Starting Commerce Extensions Runbook"
epcc reset-store .+

Expand Down

0 comments on commit 74c4753

Please sign in to comment.