Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
// Major draft's line items since they share the same server draft id.
if ($stateParams.physicalInventoryType === 'Cyclic') {
if (!$stateParams.program || !$stateParams.facility) {
// On refresh, program and facility are lost from stateParams.
// Cyclic has no id in the URL so we cannot look up by id.
// The cache key is cyclic-{programId}-{facilityId} but we
// don't know either value here. Return an empty draft —
// the program and facility resolves below will recover what
// they can, and the page will render in its blank start state.
return {
programId: undefined,
facilityId: undefined,
Expand All @@ -82,6 +88,15 @@
});
}

// On refresh for Major: program and facility are lost from stateParams
// but id is always in the URL. Load directly from the cache which
// holds the full draft object including programId and facilityId.
// physicalInventoryFactory.getPhysicalInventory needs both program
// and facility to load stock summaries — the cache avoids that call.
if (!$stateParams.program || !$stateParams.facility) {
return physicalInventoryDraftCacheService.getDraft($stateParams.id);
}

// noReload=true after Add Product or Save for Major — load from cache.
if (offlineService.isOffline() || $stateParams.noReload) {
return physicalInventoryDraftCacheService.getDraft($stateParams.id);
Expand Down