Skip to content

Commit

Permalink
Error for not being able to add IO lines to IS
Browse files Browse the repository at this point in the history
  • Loading branch information
roxy-dao committed Feb 2, 2025
1 parent a059995 commit 7e66c53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fn map_error(error: ServiceError) -> Result<InsertFromInternalOrderResponse> {
| NotAnInboundShipment
| RequisitionLineDoesNotExist
| RequisitionNotLinkedToInvoice
| CannotAddLineFromInternalOrder
| ItemDoesNotExist => StandardGraphqlError::BadUserInput(formatted_error),
NewlyCreatedLineDoesNotExist | DatabaseError(_) => {
StandardGraphqlError::InternalError(formatted_error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub enum InsertFromInternalOrderLineError {
RequisitionLineDoesNotExist,
ItemDoesNotExist,
RequisitionNotLinkedToInvoice,
CannotAddLineFromInternalOrder,
NewlyCreatedLineDoesNotExist,
DatabaseError(RepositoryError),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
invoice::{check_invoice_exists, check_invoice_is_editable, check_store},
invoice_line::validate::check_item_exists,
requisition_line::common::check_requisition_line_exists,
store_preference::get_store_preferences,
};

use super::{InsertFromInternalOrderLine, InsertFromInternalOrderLineError};
Expand All @@ -21,8 +22,15 @@ pub fn validate(
) -> Result<ValidateResults, InsertFromInternalOrderLineError> {
use InsertFromInternalOrderLineError::*;

let store_preference = get_store_preferences(connection, store_id)?;

let invoice =
check_invoice_exists(&input.invoice_id, connection)?.ok_or(InvoiceDoesNotExist)?;
if !store_preference.manually_link_internal_order_to_inbound_shipment
|| invoice.linked_invoice_id.is_some()
{
return Err(CannotAddLineFromInternalOrder);
}

if !check_store(&invoice, store_id) {
return Err(NotThisStoreInvoice);
Expand Down

0 comments on commit 7e66c53

Please sign in to comment.