Changeset 4b34fed


Ignore:
Timestamp:
01/11/23 15:32:11 (23 months ago)
Author:
DarkoSasanski <darko.sasanski@…>
Branches:
main
Children:
0328cb0
Parents:
e341a60
Message:

Order status update fixed

Location:
FullyStocked/src/main/java/com/bazi/fullystocked/Services/Implementations
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • FullyStocked/src/main/java/com/bazi/fullystocked/Services/Implementations/OrderedArticlesServiceImpl.java

    re341a60 r4b34fed  
    22
    33import com.bazi.fullystocked.Models.Enumerations.ArticleStatus;
     4import com.bazi.fullystocked.Models.Enumerations.OrderStatus;
    45import com.bazi.fullystocked.Models.Exceptions.InvalidArgumentsException;
    56import com.bazi.fullystocked.Models.OrderedArticles;
     
    3334    public Optional<OrderedArticles> update(Integer oarticleid, int price, int quantity) {
    3435        OrderedArticles orderedArticles=orderedArticlesRepository.findById(oarticleid).orElseThrow(InvalidArgumentsException::new);
     36        if(!orderedArticles.getOrder().getStatus().equals(OrderStatus.SENT))
     37        {
     38            throw new InvalidArgumentsException();
     39        }
    3540        if(price<=0 || quantity<=0)
    3641        {
  • FullyStocked/src/main/java/com/bazi/fullystocked/Services/Implementations/OrdersServiceImpl.java

    re341a60 r4b34fed  
    174174            if(order.getArticlesList().stream().anyMatch(orderedArticles -> !orderedArticles.getArticlestatus().equals(ArticleStatus.PROCESSED)))
    175175            {
    176                 throw new InvalidArgumentsException();
     176                return Optional.of(order);
    177177            }
    178178        }
Note: See TracChangeset for help on using the changeset viewer.