From 97426fb27ca8c2e368e2d0e47774ffc55c631e09 Mon Sep 17 00:00:00 2001 From: Fergus Roache Date: Wed, 8 Jan 2025 17:26:13 +1300 Subject: [PATCH 1/4] Add generating with customer_name_id --- .../requisition/request_requisition/insert_program.rs | 9 +++++++-- .../requisition/response_requisition/insert_program.rs | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/service/src/requisition/request_requisition/insert_program.rs b/server/service/src/requisition/request_requisition/insert_program.rs index bd5cf16817..b1bd9cdf67 100644 --- a/server/service/src/requisition/request_requisition/insert_program.rs +++ b/server/service/src/requisition/request_requisition/insert_program.rs @@ -19,7 +19,7 @@ use repository::{ IndicatorValueType, MasterListLineFilter, MasterListLineRepository, NameFilter, NameRepository, NumberRowType, Pagination, ProgramIndicatorFilter, ProgramRequisitionOrderTypeRow, ProgramRow, RepositoryError, Requisition, RequisitionLineRowRepository, RequisitionRowRepository, - StorageConnection, + StorageConnection, StoreRowRepository, }; use util::uuid::uuid; @@ -204,12 +204,17 @@ fn generate( Some(ProgramIndicatorFilter::new().program_id(EqualFilter::equal_to(&program.id))), )?; + let customer_name_id = StoreRowRepository::new(connection) + .find_one_by_id(&ctx.user_id.clone())? + .ok_or(RepositoryError::NotFound)? + .name_link_id; + let indicator_values = generate_program_indicator_values( connection, &ctx.store_id, &period_id, program_indicators, - &other_party_id, + &customer_name_id, )?; Ok(GenerateResult { diff --git a/server/service/src/requisition/response_requisition/insert_program.rs b/server/service/src/requisition/response_requisition/insert_program.rs index b71ad7587c..9ceea164ea 100644 --- a/server/service/src/requisition/response_requisition/insert_program.rs +++ b/server/service/src/requisition/response_requisition/insert_program.rs @@ -218,10 +218,10 @@ fn generate( .query_one(StoreFilter::new().name_id(EqualFilter::equal_to(&other_party_id)))?; let indicator_values = match customer_store { - Some(_) => generate_program_indicator_values( + Some(customer_store) => generate_program_indicator_values( &ctx.store_id, &period_id, - &other_party_id, + &customer_store.name_row.id, program_indicators, ), None => vec![], From 70fab193a393d9257418cb9bf23af63af30dcb8b Mon Sep 17 00:00:00 2001 From: Fergus Roache Date: Fri, 10 Jan 2025 10:22:15 +1300 Subject: [PATCH 2/4] Update insert program logic Search for name id rather thank link id and search for store correctly --- .../src/requisition/request_requisition/insert_program.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/service/src/requisition/request_requisition/insert_program.rs b/server/service/src/requisition/request_requisition/insert_program.rs index b1bd9cdf67..50309cf224 100644 --- a/server/service/src/requisition/request_requisition/insert_program.rs +++ b/server/service/src/requisition/request_requisition/insert_program.rs @@ -204,10 +204,12 @@ fn generate( Some(ProgramIndicatorFilter::new().program_id(EqualFilter::equal_to(&program.id))), )?; - let customer_name_id = StoreRowRepository::new(connection) - .find_one_by_id(&ctx.user_id.clone())? + let customer_name_id = StoreRepository::new(connection) + .query_by_filter(StoreFilter::new().id(EqualFilter::equal_to(&ctx.store_id)))? + .pop() .ok_or(RepositoryError::NotFound)? - .name_link_id; + .name_row + .id; let indicator_values = generate_program_indicator_values( connection, From 38dbeda40067d2f0ecc61216b33e338c27333ac9 Mon Sep 17 00:00:00 2001 From: Fergus Roache Date: Fri, 10 Jan 2025 10:32:49 +1300 Subject: [PATCH 3/4] amend imports --- .../src/requisition/request_requisition/insert_program.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/service/src/requisition/request_requisition/insert_program.rs b/server/service/src/requisition/request_requisition/insert_program.rs index 50309cf224..1aa52d6d91 100644 --- a/server/service/src/requisition/request_requisition/insert_program.rs +++ b/server/service/src/requisition/request_requisition/insert_program.rs @@ -19,7 +19,7 @@ use repository::{ IndicatorValueType, MasterListLineFilter, MasterListLineRepository, NameFilter, NameRepository, NumberRowType, Pagination, ProgramIndicatorFilter, ProgramRequisitionOrderTypeRow, ProgramRow, RepositoryError, Requisition, RequisitionLineRowRepository, RequisitionRowRepository, - StorageConnection, StoreRowRepository, + StorageConnection, StoreFilter, StoreRepository, }; use util::uuid::uuid; From 68df7fdc7c3772a8ef79f608b9536e7125fc4e45 Mon Sep 17 00:00:00 2001 From: Fergus Roache Date: Fri, 10 Jan 2025 10:33:33 +1300 Subject: [PATCH 4/4] Revert unnecessary name_id changes --- .../src/requisition/response_requisition/insert_program.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/service/src/requisition/response_requisition/insert_program.rs b/server/service/src/requisition/response_requisition/insert_program.rs index 9ceea164ea..b71ad7587c 100644 --- a/server/service/src/requisition/response_requisition/insert_program.rs +++ b/server/service/src/requisition/response_requisition/insert_program.rs @@ -218,10 +218,10 @@ fn generate( .query_one(StoreFilter::new().name_id(EqualFilter::equal_to(&other_party_id)))?; let indicator_values = match customer_store { - Some(customer_store) => generate_program_indicator_values( + Some(_) => generate_program_indicator_values( &ctx.store_id, &period_id, - &customer_store.name_row.id, + &other_party_id, program_indicators, ), None => vec![],