eos: stock balance logic Notes: 4th Nov 24 , 18th nov 24
Get link
Facebook
X
Pinterest
Email
Other Apps
-
18th nov 24 Logic
working:
-----------------
file 2
DHLN2024-03-24T00:00:00UTC+00A46130602030-01-01T00:00:00UTC+00R4630626722030-02-2025T00:00:00UTC+00Product key,Site key,Current date year,Current date month,Current date day,Expiry date year,Expiry date month,Expiry date day,Quantity
,,,,,,,,
Product key,Site key,Current date year,Current date month,Current date day,Expiry date year,Expiry date month,Expiry date day,Quantity
A461,DHLN,2024,,11-18T11:41:56.245+01:00,2030,01,01,3060
R463062,DHLN,2024,,11-18T11:41:56.245+01:00,2030,02,20,672
file 3
DHLN2024-03-24T00:00:00UTC+00A46130602030-01-01T00:00:00UTC+00R4630626722030-02-2025T00:00:00UTC+00Product key,Site key,Current date year,Current date month,Current date day,Expiry date year,Expiry date month,Expiry date day,Quantity
,,,,,,,,
Product key,Site key,Current date year,Current date month,Current date day,Expiry date year,Expiry date month,Expiry date day,Quantity
A461,DHLN,2024,,11-18T11:53:26.25+01:00,2030,01,01,3060
R463062,DHLN,2024,,11-18T11:53:26.25+01:00,2030,02,20,672
--------------
input
DHLN2024-03-24T00:00:00UTC+00A46130602030-01-01T00:00:00UTC+00R4630626722025-02-20T00:00:00UTC+00
----------------------
Product key,Site key,Current date year,Current date month,Current date day,Expiry date year,Expiry date month,Expiry date day,Quantity
,,,,,,,,
--------------
Product key,Site key,Current date year,Current date month,Current date day,Expiry date year,Expiry date month,Expiry date day,Quantity
A461,DHLN,2024,,11-04T15:26:20.58+01:00,2030,01,01,3060
R463062,DHLN,2024,,11-04T15:26:20.58+01:00,2025,02,20,672
--------------------------------------------------
file 2
DHLN2024-03-24T00:00:00UTC+00A46130602030-01-01T00:00:00UTC+00R4630626722030-02-2025T00:00:00UTC+00Product key,Site key,Current date year,Current date month,Current date day,Expiry date year,Expiry date month,Expiry date day,Quantity
,DHLN,,,,,,,
Product key,Site key,Current date year,Current date month,Current date day,Expiry date year,Expiry date month,Expiry date day,Quantity
A461,DHLN,,,,2030,01,01,3060
R463062,DHLN,,,,2030,02,20,672
-----------
file 3
DHLN2024-03-24T00:00:00UTC+00A46130602030-01-03T00:00:00UTC+00R4630626722030-01-02T00:00:00UTC+00
-----------
DHLN2024-03-24T00:00:00UTC+00A46130602030-01-03T00:00:00UTC+00R4630626722030-01-02T00:00:00UTC+00Product key,Site key,Current date year,Current date month,Current date day,Expiry date year,Expiry date month,Expiry date day,Quantity
,DHLN,,,,,,,
Product key,Site key,Current date year,Current date month,Current date day,Expiry date year,Expiry date month,Expiry date day,Quantity
A461,DHLN,2030,01,01,3060
R463062,DHLN,2030,01,01,672
-------------------------------
Logic 3
stockBalance->companyCode Company code string yes skip
stockBalance->sourceType
stockBalance->source Location (plant code, shipping point...) where the goods are supplied from structure yes skip
stockBalance->source->location Identification of the partner string yes Access the reference table of the given transformation to find the value Site key
stockBalance->source->name1 Name of the partner string yes skip
stockBalance->source->name2 Name of the partner string yes skip
stockBalance->source->houseNumber House number string yes skip
stockBalance->source->street1 Street string yes skip
stockBalance->source->street2 skip
stockBalance->source->postalCode ZIP code, Postal code string skip
stockBalance->source->poBox PO Box string yes skip
stockBalance->source->city City string yes skip
stockBalance->source->state State string skip
stockBalance->source->country Country string yes skip
stockBalance->source->phone Phone number string yes skip
stockBalance->source->globalLocationNumber Global location number string yes skip
stockBalance->stockBalanceDate Date when the stock balance was issued in the WMS side (in the local timezone) string yes Add one day to the provided stock balance date and extract year from the result Current date year
Add one day to the provided stock balance date and extract month from the result Current date month
Add one day to the provided stock balance date and extract day from the result Current date day
stockBalance->stockBalanceName Identification of the stock balance run string yes skip
stockBalance->items List of Items structure yes skip
stockBalance->items->item An item record array [1 to N] yes skip
stockBalance->items->itemPosition Position of the item string yes skip
stockBalance->items->stockBalanceItemtype category of the location for a stock balance item line string yes skip
stockBalance->items->vendorLocation Vendor when stock is located at a vendor location string yes skip
stockBalance->items->storageLocation Storage location string yes skip
stockBalance->items->ssccNumber Serial Shipping Container Code (handling unit) string yes skip
stockBalance->items->wmsQualityStatus Quality status of the pallet from a WMS perspective string yes skip
stockBalance->items->qualityStatus Quality status of the pallet from a QFS perspetive (tbc)? string yes skip
stockBalance->items->positiveRelease PHR Status of the pallet string yes skip
stockBalance->items->positiveReleaseDate Modification date of PHR Status string yes skip
stockBalance->items->materialReference Reference identifying the product string yes passthrough Product key
stockBalance->items->batch Batch number in the Mars GBC format string yes skip
stockBalance->items->quantityInAuom Quantity in an alternative unit of measure (base or not) string yes skip
stockBalance->items->uomCode Sales unit of measure string yes skip
stockBalance->items->quantityInBuom Quantity in base unit of measure string yes Sum quantityInBuom for all item records having identical materialReference and bestBeforeDate Quantity
stockBalance->items->baseUom Base unit of measure string yes skip
stockBalance->items->conversionFactorToBuom Conversion factor to convert quantity in sales UOM to base UOM string yes skip
stockBalance->items->stockType Type of stock string yes skip
stockBalance->items->batchAvailabilityDate Date when the batch should be ready in the warehouse to be picked string yes skip
stockBalance->items->bestBeforeDate Shelf Life Expiration or Best-Before Date string yes Extract year from the provided Best-Before date Expiry date year
Extract month from the provided Best-Before date Expiry date month
Extract day from the provided Best-Before date Expiry date day
skip
stockBalance->items->productionDate Production Date of the batch string yes skip
stockBalance->items->materialType Material Type string yes skip
stockBalance->items->itemDescription Description of the item string yes skip
stockBalance->items->localPalletId local pallet number - License Plate Number (LPN) or reference number used to identify the pallet instead of or in addition to SSCC - this field is only relevant for Agnostic site - it is available in the Experience API but not the core API string yes skip
stockBalance->items->localReferenceNumber Local Lot Number or reference number used at the factory, if any - this field is only relevant for Agnostic site - it is available in the Experience API but not the core API string yes skip
stockBalance->items->startProductionDate date when the production started (production goods receipt of the SSCC) string yes skip
stockBalance->items->lastUpdateDate Timestamp when the quantity of product in the pallet was last updated in the WMS - this field is only relevant for Agnostic site - it is available in the Experience API but not the core API string yes skip
----------------------
routing logic: ai
To handle the splitting of data from a single JSON structure into three separate output files based on specific criteria, we can outline a process involving conditional checks. The primary steps revolve around parsing the JSON, applying filtering conditions to segregate data, and finally generating the respective CSV files.
Overview of the Process
Input Parsing: Read the incoming JSON payload.
Define Criteria: Set the criteria for determining whether items belong to the "Available Stock ON HAND", "Blocked Stock ON HAND", or "Non-Available Stock ON HAND" categories based on the required fields.
Item Filtering: Iterate through the items, applying the criteria to filter them into the relevant categories.
Prepare CSV Files: Create separate lists for each category and convert them into CSV format.
File Naming: Generate filenames based on the given naming conventions with the appropriate date format and 3PL Prefix.
Example Splitting Logic
Below is a pseudo-code representation of how the logic might look:
Input JSON Structure
Assuming the input JSON structure is similar to what you provided:
CopyReplit
{
"stockBalance": {
"companyCode": " ",
"items": {
"item": [
{
"itemPosition": " ",
"stockBalanceItemtype": "storage location",
"wmsQualityStatus": "", // Add some sample values
"qualityStatus": "Available", // or Blocked, or Non-Available
"positiveRelease": "Yes", // or No
// ... other attributes...
},
// ... potentially more items ...
]
}
}
}
Pseudo-code for File Splitting Logic
CopyReplit
import json
import csv
from datetime import datetime
# Example input
input_data = '''
{...
}
''' # Your full JSON data here
data = json.loads(input_data)
current_date = datetime.now().strftime('%d%m%y')
prefix = "3PL_Prefix" # Replace with actual 3PL Prefix logic
# Initialize lists for each stock category
available_stock = []
blocked_stock = []
non_available_stock = []
# Define your filtering criteria
for item in data['stockBalance']['items']['item']:
if item['stockBalanceItemtype'] == "storage location":
if item['wmsQualityStatus'] == "Available" and item['qualityStatus'] == "Available" and item['positiveRelease'] == "Yes":
available_stock.append(item)
elif item['wmsQualityStatus'] == "Blocked" or item['qualityStatus'] == "Blocked":
blocked_stock.append(item)
else:
non_available_stock.append(item)
# Function to write to CSV
def write_to_csv(items, filename):
with open(filename, mode='w', newline='') as file:
writer = csv.DictWriter(file, fieldnames=items[0].keys())
writer.writeheader()
writer.writerows(items)
# Generate CSV files based on the conditions
if available_stock:
write_to_csv(available_stock, f"rc_{prefix}_{current_date}_asoh.csv")
if blocked_stock:
write_to_csv(blocked_stock, f"rc_{prefix}_{current_date}_bs.csv")
if non_available_stock:
write_to_csv(non_available_stock, f"rc_{prefix}_{current_date}_nasoh.csv")
Notes on the Code Logic
Filtering: The logic checks the value of stockBalanceItemtype, wmsQualityStatus, qualityStatus, and positiveRelease to categorize each item.
CSV Writing: A simple function write_to_csv is defined to handle writing items to CSV files. The field names are dynamically gathered from the item’s keys.
File Naming: The naming convention for the files is strictly followed as per your specifications.
Error Handling: In a production environment, ensure you handle errors such as empty lists or file writing issues gracefully.
--------------------------------------------------
https://deepai.org/chat
శ్రీకృష్ణుడు దేవుడా, భగవంతుడా. నేటి ప్రజలందరికి తెలిసిన ప్రకారము దేవుడనినా, భగవంతుడనినా రెండు ఒకటే అను భావముతో ఉన్నారు. చాలామంది స్వామీజీలు కూడ తమ తమ ఉపన్యాసములలో సృష్టికర్త అయిన పరమాత్మను గురించి తెలుపునపుడు ఒకప్పుడు దేవుడని, మరొకప్పుడు భగవంతుడని పలుకుచు చెప్పుచుందురు. దీనినిబట్టి ఇటు ప్రజల దృష్టిలోను, అటు బోధకులైన స్వామీజీల దృష్టిలోను దేవునికీ, భగవంతునికీ ఏమీ తేడా లేదనీ, అందువలన వారు ఇలా ఆ పదములను వాడుచున్నారని తెలియుచున్నది. ఆధ్యాత్మిక రంగములో ఇది చాలా ముఖ్యమైన విషయం అందరికి అవసరమైన విషయము. కావున దేవుడు మరియు భగవంతుడు అను పదములకు శాస్త్రీయత ఉందా? లేదా? అని యోచించవలసిన అవసరమున్నది. అంతేకాక ఒక పనిని చేయుటకు ఒక కారణముంటుంది. అలాగే ఒక పదమును పలుకుటకు కూడ కారణముంటుంది. అటువంటి కారణమునే హేతువు అంటాము. ఇక్కడ 'దేవుడు అనుటకు, భగవంతుడు అనుటకు హేతువును చూపకపోతే అది హేతుబద్దము కాదు. హేతువాదులు ఒప్పుకోరు. నాస్తికవాదులు ఒప్పుకోక పోయినా ఫరవాలేదు. కానీ హేతువాదులు తప్పక ఒప్పుకోవలసియున్నది. ఎక్కడైతే శాస్త్రీయత ఉంటుందో అక్కడ హేతువాదమునకు జవాబు ఉన్నట్లే. ఎక్కడైతే శాస్త్రీయత లేదో అక్కడ హేతువాదమున...
విషయ సూచిక. 1. గురు ప్రార్థనామంజరి 2. గురువు అంటే ఏవరు? 3. గురువును గురించి పెద్దలు ఏమి చెప్పారు? 4. గురువు యొక్క జ్ఞానమును ప్రజలు గుర్తించగలరా? 5. గురువును మనుషులు గౌరవిస్తారా? 6. గురువును దూషించిన వారిని గురువేమి చేయును? 7. గురువు అడవిలో ఉంటాడా లేక ఊరిలో ఉంటాడా? 8. గురువుకు శిష్యులుంటారా? 9. గురువుకు మహత్యములుండునా? 10. గురువుకు రోగాలు వస్తాయా? 11. గురువును ఎవరూ గుర్తించలేరా? 12. గురువు అందరివలె చనిపోవునా? 13. గురుపౌర్ణమి 14. గురువు-పౌర్ణమి 15. గురు 16. గురువులేని విద్య గ్రుడ్డివిద్య 17. గురుప్రార్థన శ్లోకములు -- గురు ప్రార్థనామంజరి. నేటి మానవులను మరియు కేవలము యాభైసంవత్సరముల వెనుకటి కాలపు మానవులను గమనిస్తే, ఇటు ప్రపంచపద్ధతిలోగానీ, అటు పరమాత్మ పద్ధతిలో గానీ ఎంతో గణనీయమైన తేడా కనిపిస్తున్నది. ప్రపంచ పద్ధతిలో చూస్తే ఒక నాగరికతే కాక, మానవుని జీవితములో ఎన్నో పరికరములూ, యంత్రములూ చోటు చేసుకొని మానవుని జీవితము సుఖవంతమైనట్లు కనిపిస్తున్నది. ఉన్నతమైన చదువులూ, అధునాతన యంత్రములూ, వేగవంతమైన వాహనములూ, సరిక్రొత్త పరిశోధనలు, ఖండాతర మారణా యుధములూ మనిషి జీవితములో ఎంతో ఉన...
దయ్యాల కోన అది ఒక భయంకరమైన అడవి. ఎత్తయిన చెట్లు, చిక్కుగ అల్లుకొనిన తీగలు, గుడ్లగూబలకు నిలయమైన మర్రిమాన్లు, భయంకర సర్పములకు నిలయమైన పొదలుకల్గి ఎటువైపు నరసంచారములేని అడవి మధ్యభాగములో పురాతన దేవాలయము ఒకటి కలదు. అది ఈశ్వర దేవాలయమైనప్పటికి అక్కడ పూజారిలేడు, పూజలు జరుగవు. కాని శివరాత్రి రోజు మాత్రము అక్కడికి జనముచేరి పూజలు చేయుట ఆనవాయితీగ కలదు. ఆ ఒక్క దినము తప్ప మానవ సంచారము ఆ అడవిలో ఉండెడిది కాదు. సంవత్సరమునకు ఒక రోజు పూజ జరుగు ఆ దేవాలయమునకు ఆ ఒక దినము లక్షల సంఖ్యలో మనుషులు వస్తారు కావున అందరి సౌకర్యార్థము దేవాలయము వరకు అడవిలో తారు రోడ్డును ప్రభుత్వమువారు నిర్మించారు. సంవత్సరమునకు ఒకమారు ఆ రోడ్డు వెంట మనుషులు ప్రయాణించెడివారు. అడవి ప్రారంభ మొదటి భాగమునుండి మధ్యలోగల దేవాలయమునకు అరవైమైళ్ల దూరము ఉండెడిది. అడవి మొదటి భాగములో రోడ్డు మీద పోలీస్ చెకో పోస్టు కూడ ఉండెడిది. శివరాత్రి రోజు కాకుండ విడి దినములలో ఆ రోడ్డు మీద ఎవరు ప్రయాణించకుండ పోలీస్ వారు చూచుకొనెడివారు. అడవిలో కౄరమృగములు సహితము విచ్చలవిడిగ ఉండుట వలన వాటి రక్షణ నిమిత్తము కూడ పోలీస్ వారుండెడివారు. శివరాత్రి రోజు తప్ప రోడ్డు వెంబడి...