Mobiusi commited on
Commit
a14938a
·
verified ·
1 Parent(s): d448869

sync sample package

Browse files
record_6b5b0b8f-a477-4a3d-9995-d1af491eaa87.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "code_prefix": "from datetime import date\nfrom collections.abc import Iterable\n\ndef allocate_fefo(\n batches: Iterable[dict],\n requested_units: int,\n today: date,\n) -> tuple[list[dict], int]:\n if requested_units < 0:\n raise ValueError(\"requested_units must be non-negative\")\n\n remaining = requested_units\n allocations = []\n eligible = sorted(\n (\n batch\n for batch in batches\n if batch[\"on_hand\"] > 0 and batch[\"expires_on\"] >= today\n ),\n key=lambda batch: (batch[\"expires_on\"], batch[\"batch_id\"]),\n )\n for batch in eligible:\n",
3
+ "completed_code": "from datetime import date\nfrom collections.abc import Iterable\n\ndef allocate_fefo(\n batches: Iterable[dict],\n requested_units: int,\n today: date,\n) -> tuple[list[dict], int]:\n if requested_units < 0:\n raise ValueError(\"requested_units must be non-negative\")\n\n remaining = requested_units\n allocations = []\n eligible = sorted(\n (\n batch\n for batch in batches\n if batch[\"on_hand\"] > 0 and batch[\"expires_on\"] >= today\n ),\n key=lambda batch: (batch[\"expires_on\"], batch[\"batch_id\"]),\n )\n for batch in eligible:\n if remaining == 0:\n break\n\n picked = min(batch[\"on_hand\"], remaining)\n allocations.append(\n {\n \"batch_id\": batch[\"batch_id\"],\n \"quantity\": picked,\n \"expires_on\": batch[\"expires_on\"],\n }\n )\n remaining -= picked\n\n return allocations, remaining\n",
4
+ "reference_completion": " if remaining == 0:\n break\n\n picked = min(batch[\"on_hand\"], remaining)\n allocations.append(\n {\n \"batch_id\": batch[\"batch_id\"],\n \"quantity\": picked,\n \"expires_on\": batch[\"expires_on\"],\n }\n )\n remaining -= picked\n\n return allocations, remaining\n"
5
+ }
record_d9d9ecc3-f4c4-458b-841a-b295ce97b395.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "reference_completion": " write_offs.append(\n {\n \"batch_id\": batch[\"batch_id\"],\n \"quantity\": quantity,\n \"expires_on\": expires_on,\n \"reason\": \"expired\",\n }\n )\n else:\n sellable.append(dict(batch))\n\n return sellable, write_offs\n",
3
+ "code_prefix": "from datetime import date\nfrom collections.abc import Iterable\n\ndef reconcile_expired_batches(\n batches: Iterable[dict],\n as_of: date,\n) -> tuple[list[dict], list[dict]]:\n sellable = []\n write_offs = []\n for batch in batches:\n quantity = batch[\"on_hand\"]\n expires_on = batch[\"expires_on\"]\n if quantity < 0:\n raise ValueError(\"on_hand must be non-negative\")\n if quantity == 0:\n continue\n if expires_on < as_of:\n",
4
+ "completed_code": "from datetime import date\nfrom collections.abc import Iterable\n\ndef reconcile_expired_batches(\n batches: Iterable[dict],\n as_of: date,\n) -> tuple[list[dict], list[dict]]:\n sellable = []\n write_offs = []\n for batch in batches:\n quantity = batch[\"on_hand\"]\n expires_on = batch[\"expires_on\"]\n if quantity < 0:\n raise ValueError(\"on_hand must be non-negative\")\n if quantity == 0:\n continue\n if expires_on < as_of:\n write_offs.append(\n {\n \"batch_id\": batch[\"batch_id\"],\n \"quantity\": quantity,\n \"expires_on\": expires_on,\n \"reason\": \"expired\",\n }\n )\n else:\n sellable.append(dict(batch))\n\n return sellable, write_offs\n"
5
+ }
record_ea69b778-1ec0-4a98-ad93-133007139805.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "code_prefix": "from datetime import date, timedelta\nfrom collections.abc import Iterable\n\ndef summarize_expiry_status(\n batches: Iterable[dict],\n today: date,\n warning_window_days: int = 3,\n) -> dict[str, list[dict]]:\n if warning_window_days < 0:\n raise ValueError(\"warning_window_days must be non-negative\")\n\n cutoff = today + timedelta(days=warning_window_days)\n status = {\"expired\": [], \"due_soon\": [], \"available\": []}\n for batch in batches:\n",
3
+ "completed_code": "from datetime import date, timedelta\nfrom collections.abc import Iterable\n\ndef summarize_expiry_status(\n batches: Iterable[dict],\n today: date,\n warning_window_days: int = 3,\n) -> dict[str, list[dict]]:\n if warning_window_days < 0:\n raise ValueError(\"warning_window_days must be non-negative\")\n\n cutoff = today + timedelta(days=warning_window_days)\n status = {\"expired\": [], \"due_soon\": [], \"available\": []}\n for batch in batches:\n quantity = batch[\"on_hand\"]\n if quantity <= 0:\n continue\n\n expires_on = batch[\"expires_on\"]\n record = {\n \"batch_id\": batch[\"batch_id\"],\n \"quantity\": quantity,\n \"expires_on\": expires_on,\n }\n if expires_on < today:\n status[\"expired\"].append(record)\n elif expires_on <= cutoff:\n status[\"due_soon\"].append(record)\n else:\n status[\"available\"].append(record)\n\n return status\n",
4
+ "reference_completion": " quantity = batch[\"on_hand\"]\n if quantity <= 0:\n continue\n\n expires_on = batch[\"expires_on\"]\n record = {\n \"batch_id\": batch[\"batch_id\"],\n \"quantity\": quantity,\n \"expires_on\": expires_on,\n }\n if expires_on < today:\n status[\"expired\"].append(record)\n elif expires_on <= cutoff:\n status[\"due_soon\"].append(record)\n else:\n status[\"available\"].append(record)\n\n return status\n"
5
+ }