Resolves (and creates if missing) the PhoenixKit Storage folder for a warehouse document.
Consolidates what were 5 near-identical *_storage_folders.ex modules in
Andi (goods_issue_storage_folders.ex, goods_receipt_storage_folders.ex,
inventory_storage_folders.ex, supplier_order_storage_folders.ex,
internal_order_storage_folders.ex) into one module with 5 ensure_for_*/2
functions.
Layout: a single, non-hierarchical folder at storage root, named
<prefix>-<number> (falling back to <prefix>-<uuid> when the document
has no number yet).
Four of the five resources (goods issue, goods receipt, inventory, supplier
order) cache the resolved folder's uuid on a storage_folder_uuid column
and take a fast path once cached. The fifth — internal orders — has no
storage_folder_uuid column at all (confirmed: internal_order_storage_folders.ex
is a genuine smaller variant with a single function clause and no
write-back) and resolves by name on every call instead.
Summary
Functions
Returns {:ok, %Folder{}} for the given goods issue, creating the folder
if needed. Persists storage_folder_uuid on the issue record after first
creation. Pass admin_user_uuid as the folder owner.
Returns {:ok, %Folder{}} for the given goods receipt, creating the folder
if needed. Persists storage_folder_uuid on the receipt record after first
creation. Pass admin_user_uuid as the folder owner.
Returns {:ok, %Folder{}} for the given internal order, creating the
folder if needed. Resolves the folder by name on every call — internal
orders have no storage_folder_uuid column to cache against (dropped
along with sub_order_uuid; nothing in Plan 1's migration created either
column on phoenix_kit_warehouse_internal_orders). Pass admin_user_uuid
as the folder owner.
Returns {:ok, %Folder{}} for the given inventory document, creating the
folder if needed. Persists storage_folder_uuid on the document record
after first creation. Pass admin_user_uuid as the folder owner.
Returns {:ok, %Folder{}} for the given supplier order, creating the folder
if needed. Persists storage_folder_uuid on the order record after first
creation. Pass admin_user_uuid as the folder owner.
Functions
Returns {:ok, %Folder{}} for the given goods issue, creating the folder
if needed. Persists storage_folder_uuid on the issue record after first
creation. Pass admin_user_uuid as the folder owner.
Returns {:ok, %Folder{}} for the given goods receipt, creating the folder
if needed. Persists storage_folder_uuid on the receipt record after first
creation. Pass admin_user_uuid as the folder owner.
Returns {:ok, %Folder{}} for the given internal order, creating the
folder if needed. Resolves the folder by name on every call — internal
orders have no storage_folder_uuid column to cache against (dropped
along with sub_order_uuid; nothing in Plan 1's migration created either
column on phoenix_kit_warehouse_internal_orders). Pass admin_user_uuid
as the folder owner.
Returns {:ok, %Folder{}} for the given inventory document, creating the
folder if needed. Persists storage_folder_uuid on the document record
after first creation. Pass admin_user_uuid as the folder owner.
Returns {:ok, %Folder{}} for the given supplier order, creating the folder
if needed. Persists storage_folder_uuid on the order record after first
creation. Pass admin_user_uuid as the folder owner.