Service - Stock Location Standard: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
(Created page with "= Overview = Handler service for basic stock locations that hold a quantity remaining per stock location and can reserve stock when building orders. One Stock Location can service many SellOffers, so each Stock Location keeps per SellOfferId list of quantities remaining = Repository = https://bitbucket.org/izara-market-products/izara-market-products-stock-location-standard = DynamoDB tables = == Standard Config Table Per Service == === Configuration tags === <...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
= Overview =
= Overview =


Handler service for basic stock locations that hold a quantity remaining per stock location and can reserve stock when building orders. One Stock Location can service many SellOffers, so each Stock Location keeps per SellOfferId list of quantities remaining
Handler service for basic stock locations that hold a quantity remaining per stock location and can reserve stock when building orders. One Stock Location can service many SellOffers, so each Stock Location keeps per SellOfferId list of quantities remaining.


= Repository =
= Repository =
Line 37: Line 37:
</syntaxhighlight>
</syntaxhighlight>


= Graph database =  
== SellOfferStock ==


== [[Service - Products Graph]]==
Remaining stock for one SellOffer.
 
=== Nodes ===


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
nodeLabel: "{stockLocationSharedLib.consts.STOCKLOCATION_GRAPH_NODE_LABEL}",
sellofferId
stockRemaining
stockReserved
stockAvailable
updateUuid: xxx // random number, used in conditional when updating count to protect against race conditions
}
}
</syntaxhighlight>
</syntaxhighlight>


=== Relationships ===
* partition key: sellofferId
* sort key: (none)
 
== SellOfferReservedStock ==
 
Reserve stock when begin processing an order, one record per usage, once the order is successful we adjust SellOfferStock to reflect the change and change status of reserved stock.


<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
{
{
relationshipType: "{stockLocationSharedLib.atStockLocationGraphRelationshipType()}", // "at_StockLocation"
sellofferId
schema: {
reservedTimestampId
immutable: true,
quantity
restrictProperties: true,
reservedStockStatus: reserved|confirmed|cancelled
properties: {
originTimestamp: //timestamp the request to create/change this relationship was sent
},
}
}
}
</syntaxhighlight>
</syntaxhighlight>
* connects sellOffer to stockLocation


== Translate Ids - stockLocation to sellOffer ==
* partition key: sellofferId
* sortKey: reservedTimestampId
* reservedTimestampId: {timestamp sent with request}_{uniqueRequestId}, this allows us to check idempotence and not reserve same request multiple times
* records are not deleted once they are confirmed or cancelled, so a record is kept of changes
 
= Notes =


* from stockLocationId to sellOfferIds
* When finding or reserving stock for a SellOffer, query graph to find the StockLocation for the sellOffer (or have it saved in the SellOffer object), then query dynamoDB for stock levels
* A SellOffer's link to StockLocation is immutable, cannot be changed


= Working documents =
= Working documents =

Latest revision as of 09:47, 4 May 2023

Overview

Handler service for basic stock locations that hold a quantity remaining per stock location and can reserve stock when building orders. One Stock Location can service many SellOffers, so each Stock Location keeps per SellOfferId list of quantities remaining.

Repository

https://bitbucket.org/izara-market-products/izara-market-products-stock-location-standard

DynamoDB tables

Standard Config Table Per Service

Configuration tags

{
	configTag: "StockLocationHandlerServiceNameTag"
	configKey: "StockLocationHandlerServiceNameTag"
	configValue: xxx // this own services ServiceNameTag, eg "StockLocationStandard"
}
{
	configTag: "ProductGraphServiceName"
	configKey: "ProductGraphServiceName"
	configValue: xxx // eg: "ProductGraph"
}
{
	configTag: "StockLocationManagerServiceName"
	configKey: "StockLocationManagerServiceName"
	configValue: xxx // eg: "StockLocationManager"
}

SellOfferStock

Remaining stock for one SellOffer.

{
	sellofferId
	stockRemaining
	stockReserved
	stockAvailable
	updateUuid: xxx // random number, used in conditional when updating count to protect against race conditions
}
  • partition key: sellofferId
  • sort key: (none)

SellOfferReservedStock

Reserve stock when begin processing an order, one record per usage, once the order is successful we adjust SellOfferStock to reflect the change and change status of reserved stock.

{
	sellofferId
	reservedTimestampId
	quantity
	reservedStockStatus: reserved|confirmed|cancelled
}
  • partition key: sellofferId
  • sortKey: reservedTimestampId
  • reservedTimestampId: {timestamp sent with request}_{uniqueRequestId}, this allows us to check idempotence and not reserve same request multiple times
  • records are not deleted once they are confirmed or cancelled, so a record is kept of changes

Notes

  • When finding or reserving stock for a SellOffer, query graph to find the StockLocation for the sellOffer (or have it saved in the SellOffer object), then query dynamoDB for stock levels
  • A SellOffer's link to StockLocation is immutable, cannot be changed

Working documents

Stock Location Standard