Repository: RAF-SI-2024/Banka-3-Backend
Pull request #248: profit za stock i bank
Author: login: DavidRRN
Labels: name: size/L
description: Denotes a PR that changes 100-499 lines, ignoring generated files.
name: lgtm
description: Indicates that a PR is ready to be merged.
name: approved
description: Indicates a PR has been approved by an approver from all required OWNERS files.
Created: 2025-04-12T12:14:41Z | Merged: 2025-04-13T01:41:31Z

## Opis
kreiranje vracanje profita za stock i bank

## Lista taskova pri pravljenju PR-a
-kreirani servisi, kontrolleri, dodati/izmenjeni neki fajlovi
-odradjene izmene koje su bile potrebne

## Screenshot-ovi (ako je primenjivo)
![Screenshot 2025-04-12 161453](https://github.com/user-attachments/assets/088ec02e-32b2-445e-8ada-50f5bef8ce75)
![Screenshot 2025-04-12 161703](https://github.com/user-attachments/assets/b8ac57f8-e415-4a80-9548-cb8d1e08d30a)


## Objašnjenje korisničkog toka (ako je primenjivo)
//

## Dodatne napomene
feedback samo



Diff:
diff --git a/bank-service/src/main/java/rs/raf/bank_service/controller/ProfitController.java b/bank-service/src/main/java/rs/raf/bank_service/controller/ProfitController.java
new file mode 100644
index 00000000..7d97af15
--- /dev/null
+++ b/bank-service/src/main/java/rs/raf/bank_service/controller/ProfitController.java
@@ -0,0 +1,29 @@
+package rs.raf.bank_service.controller;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import rs.raf.bank_service.domain.dto.BankProfitResponseDto;
+import rs.raf.bank_service.repository.PaymentRepository;
+import rs.raf.bank_service.service.PaymentService;
+
+import java.math.BigDecimal;
+
+@RestController
+@RequestMapping("/api/profit")
+@RequiredArgsConstructor
+public class ProfitController {
+
+    private final PaymentService paymentService;
+
+    @GetMapping
+    public ResponseEntity<BankProfitResponseDto> getProfit() {
+        BigDecimal exchangeProfit = paymentService.getExchangeProfit();
+
+        return ResponseEntity.ok(new BankProfitResponseDto(exchangeProfit));
+    }
+}
+
+
diff --git a/bank-service/src/main/java/rs/raf/bank_service/domain/dto/BankProfitResponseDto.java b/bank-service/src/main/java/rs/raf/bank_service/domain/dto/BankProfitResponseDto.java
new file mode 100644
index 00000000..fa53ef57
--- /dev/null
+++ b/bank-service/src/main/java/rs/raf/bank_service/domain/dto/BankProfitResponseDto.java
@@ -0,0 +1,12 @@
+package rs.raf.bank_service.domain.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@AllArgsConstructor
+public class BankProfitResponseDto {
+    private BigDecimal exchangeProfit;
+}
diff --git a/bank-service/src/main/java/rs/raf/bank_service/domain/entity/ExchangeRate.java b/bank-service/src/main/java/rs/raf/bank_service/domain/entity/ExchangeRate.java
index 419597a6..f05007f1 100644
--- a/bank-service/src/main/java/rs/raf/bank_service/domain/entity/ExchangeRate.java
+++ b/bank-service/src/main/java/rs/raf/bank_service/domain/entity/ExchangeRate.java
@@ -37,4 +37,5 @@ public class ExchangeRate {
     @Column(precision = 10, scale = 6)
     private BigDecimal sellRate;
 
+
 }
diff --git a/bank-service/src/main/java/rs/raf/bank_service/domain/entity/Payment.java b/bank-service/src/main/java/rs/raf/bank_service/domain/entity/Payment.java
index c6da4577..c19707e8 100644
--- a/bank-service/src/main/java/rs/raf/bank_service/domain/entity/Payment.java
+++ b/bank-service/src/main/java/rs/raf/bank_service/domain/entity/Payment.java
@@ -65,6 +65,10 @@ public class Payment {
     @Column()
     private Long receiverClientId;
 
+    @Column
+    private BigDecimal exchangeProfit;
+
+
     @Override
     public String toString() {
         return "Payment{" +
diff --git a/bank-service/src/main/java/rs/raf/bank_service/repository/PaymentRepository.java b/bank-service/src/main/java/rs/raf/bank_service/repository/PaymentRepository.java
index bb0b4e43..630e5c31 100644
--- a/bank-service/src/main/java/rs/raf/bank_service/repository/PaymentRepository.java
+++ b/bank-service/src/main/java/rs/raf/bank_service/repository/PaymentRepository.java
@@ -2,10 +2,16 @@
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
 import rs.raf.bank_service.domain.entity.Payment;
 
+import java.math.BigDecimal;
 import java.util.Optional;
 
 public interface PaymentRepository extends JpaRepository<Payment, Long>, JpaSpecificationExecutor<Payment> {
     Optional<Payment> findByIdAndClientId(Long id, Long clientId);
+
+    @Query("SELECT SUM(p.exchangeProfit) FROM payments p WHERE p.exchangeProfit IS NOT NULL")
+    BigDecimal getBankProfitFromExchange();
+
 }
\ No newline at end of file
diff --git a/bank-service/src/main/java/rs/raf/bank_service/repository/ProfitRepository.java b/bank-service/src/main/java/rs/raf/bank_service/repository/ProfitRepository.java
new file mode 100644
index 00000000..2c165645
--- /dev/null
+++ b/bank-service/src/main/java/rs/raf/bank_service/repository/ProfitRepository.java
@@ -0,0 +1,4 @@
+package rs.raf.bank_service.repository;
+
+public interface ProfitRepository {
+}
diff --git a/bank-service/src/main/java/rs/raf/bank_service/service/ExchangeRateService.java b/bank-service/src/main/java/rs/raf/bank_service/service/ExchangeRateService.java
index 0fa9eded..094c1384 100644
--- a/bank-service/src/main/java/rs/raf/bank_service/service/ExchangeRateService.java
+++ b/bank-service/src/main/java/rs/raf/bank_service/service/ExchangeRateService.java
@@ -17,6 +17,7 @@
 import rs.raf.bank_service.repository.ExchangeRateRepository;
 
 import java.math.BigDecimal;
+import java.math.MathContext;
 import java.math.RoundingMode;
 import java.util.List;
 import java.util.Map;
@@ -88,6 +89,8 @@ public void updateExchangeRates() {
 
             exchangeRateRepository.save(mirrored);
         }
+
+
     }
 
     @Scheduled(cron = "0 0 8 * * ?")
diff --git a/bank-service/src/main/java/rs/raf/bank_service/service/PaymentService.java b/bank-service/src/main/java/rs/raf/bank_service/service/PaymentService.java
index 9c3192e7..16b6b03d 100644
--- a/bank-service/src/main/java/rs/raf/bank_service/service/PaymentService.java
+++ b/bank-service/src/main/java/rs/raf/bank_service/service/PaymentService.java
@@ -211,11 +211,15 @@ public PaymentDto createPaymentBeforeConfirmation(CreatePaymentDto paymentDto, L
         BigDecimal amount = paymentDto.getAmount();
         BigDecimal convertedAmount = amount;
         BigDecimal exchangeRateValue = BigDecimal.ONE;
+        BigDecimal exchangeProfit = BigDecimal.ZERO;
         // Provera da li su valute različite
         if (!sender.getCurrency().equals(receiver.getCurrency())) {
             ExchangeRateDto exchangeRateDto = exchangeRateService.getExchangeRate(sender.getCurrency().getCode(), receiver.getCurrency().getCode());
             exchangeRateValue = exchangeRateDto.getSellRate();
             convertedAmount = amount.multiply(exchangeRateValue);
+
+            exchangeProfit = exchangeRateDto.getSellRate().multiply(amount)
+                    .subtract(exchangeRateDto.getExchangeRate().multiply(amount));
         }
 
         // Kreiranje Payment entiteta
@@ -231,6 +235,7 @@ public PaymentDto createPaymentBeforeConfirmation(CreatePaymentDto paymentDto, L
         payment.setDate(LocalDateTime.now());
         payment.setStatus(PaymentStatus.PENDING_CONFIRMATION);
         payment.setOutAmount(convertedAmount);
+        payment.setExchangeProfit(exchangeProfit);
 
         // Postavi receiverClientId samo ako je receiver u našoj banci (za sad uvek postoji)
         payment.setReceiverClientId(receiver.getClientId());
@@ -367,4 +372,9 @@ public void rejectPayment(Long paymentId) {
         payment.setStatus(PaymentStatus.CANCELED);
         paymentRepository.save(payment);
     }
+
+    public BigDecimal getExchangeProfit() {
+        return paymentRepository.getBankProfitFromExchange();
+    }
+
 }
diff --git a/bank-service/src/main/java/rs/raf/bank_service/service/ProfitService.java b/bank-service/src/main/java/rs/raf/bank_service/service/ProfitService.java
new file mode 100644
index 00000000..c2f6a760
--- /dev/null
+++ b/bank-service/src/main/java/rs/raf/bank_service/service/ProfitService.java
@@ -0,0 +1,4 @@
+package rs.raf.bank_service.service;
+
+public class ProfitService {
+}
diff --git a/stock-service/src/main/java/rs/raf/stock_service/controller/ProfitController.java b/stock-service/src/main/java/rs/raf/stock_service/controller/ProfitController.java
new file mode 100644
index 00000000..de228b22
--- /dev/null
+++ b/stock-service/src/main/java/rs/raf/stock_service/controller/ProfitController.java
@@ -0,0 +1,31 @@
+package rs.raf.stock_service.controller;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import rs.raf.stock_service.domain.dto.ActuaryProfitDto;
+import rs.raf.stock_service.domain.dto.StockProfitResponseDto;
+import rs.raf.stock_service.repository.OrderRepository;
+import rs.raf.stock_service.service.OrderService;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/profit")
+@RequiredArgsConstructor
+public class ProfitController {
+
+    private final OrderService orderService;
+
+    @GetMapping
+    public ResponseEntity<StockProfitResponseDto> getProfit() {
+            BigDecimal stockCommissionProfit = orderService.getCommissionProfit();
+            return ResponseEntity.ok(new StockProfitResponseDto(stockCommissionProfit));
+
+    }
+}
+
+
diff --git a/stock-service/src/main/java/rs/raf/stock_service/domain/dto/ActuaryProfitDto.java b/stock-service/src/main/java/rs/raf/stock_service/domain/dto/ActuaryProfitDto.java
new file mode 100644
index 00000000..4f9ad7aa
--- /dev/null
+++ b/stock-service/src/main/java/rs/raf/stock_service/domain/dto/ActuaryProfitDto.java
@@ -0,0 +1,16 @@
+package rs.raf.stock_service.domain.dto;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ActuaryProfitDto {
+    private Long userId;
+    private BigDecimal profit;
+}
diff --git a/stock-service/src/main/java/rs/raf/stock_service/domain/dto/StockProfitResponseDto.java b/stock-service/src/main/java/rs/raf/stock_service/domain/dto/StockProfitResponseDto.java
new file mode 100644
index 00000000..5e9ed40d
--- /dev/null
+++ b/stock-service/src/main/java/rs/raf/stock_service/domain/dto/StockProfitResponseDto.java
@@ -0,0 +1,14 @@
+package rs.raf.stock_service.domain.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+@AllArgsConstructor
+public class StockProfitResponseDto {
+    private BigDecimal stockCommissionProfit;
+
+}
diff --git a/stock-service/src/main/java/rs/raf/stock_service/domain/entity/Order.java b/stock-service/src/main/java/rs/raf/stock_service/domain/entity/Order.java
index 954e90cf..b296c1f3 100644
--- a/stock-service/src/main/java/rs/raf/stock_service/domain/entity/Order.java
+++ b/stock-service/src/main/java/rs/raf/stock_service/domain/entity/Order.java
@@ -79,6 +79,10 @@ public class Order {
     @Column(nullable = false, updatable = false)
     private boolean allOrNone;
 
+    @Column
+    private BigDecimal commission;
+
+
     private BigDecimal reservedAmount;
 
     @OneToMany(mappedBy = "order", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
diff --git a/stock-service/src/main/java/rs/raf/stock_service/repository/OrderRepository.java b/stock-service/src/main/java/rs/raf/stock_service/repository/OrderRepository.java
index 3822c8cf..8c87eb68 100644
--- a/stock-service/src/main/java/rs/raf/stock_service/repository/OrderRepository.java
+++ b/stock-service/src/main/java/rs/raf/stock_service/repository/OrderRepository.java
@@ -3,11 +3,14 @@
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import rs.raf.stock_service.domain.dto.ActuaryProfitDto;
 import rs.raf.stock_service.domain.entity.Order;
 import rs.raf.stock_service.domain.enums.OrderDirection;
 import rs.raf.stock_service.domain.enums.OrderStatus;
 import rs.raf.stock_service.domain.enums.OrderType;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 public interface OrderRepository extends JpaRepository<Order, Long> {
@@ -16,5 +19,13 @@ public interface OrderRepository extends JpaRepository<Order, Long> {
     List<Order> findAllByUserId(Long userId);
     List<Order> findAllByDirection(OrderDirection orderDirection);
 
+    @Query("SELECT SUM(o.commission) FROM Order o WHERE o.commission IS NOT NULL")
+    BigDecimal getBankProfitFromOrders();
+
+    @Query("SELECT new rs.raf.stock_service.domain.dto.ActuaryProfitDto(o.userId, SUM(o.profit)) " +
+            "FROM Order o WHERE o.role = 'ACTUAR' GROUP BY o.userId")
+    List<ActuaryProfitDto> getActuaryProfits();
+
+
 }
 
diff --git a/stock-service/src/main/java/rs/raf/stock_service/repository/ProfitRepository.java b/stock-service/src/main/java/rs/raf/stock_service/repository/ProfitRepository.java
new file mode 100644
index 00000000..e22736aa
--- /dev/null
+++ b/stock-service/src/main/java/rs/raf/stock_service/repository/ProfitRepository.java
@@ -0,0 +1,4 @@
+package rs.raf.stock_service.repository;
+
+public interface ProfitRepository {
+}
diff --git a/stock-service/src/main/java/rs/raf/stock_service/service/OrderService.java b/stock-service/src/main/java/rs/raf/stock_service/service/OrderService.java
index e8f8e069..dc188fcd 100644
--- a/stock-service/src/main/java/rs/raf/stock_service/service/OrderService.java
+++ b/stock-service/src/main/java/rs/raf/stock_service/service/OrderService.java
@@ -180,9 +180,22 @@ public OrderDto createOrder(CreateOrderDto createOrderDto, String authHeader) {
 
         Order order = OrderMapper.toOrder(createOrderDto, userId, listing, role);
 
-        BigDecimal price = BigDecimal.valueOf(order.getContractSize()).multiply(BigDecimal.valueOf(order.getQuantity()))
+        BigDecimal price = BigDecimal.valueOf(order.getContractSize())
+                .multiply(BigDecimal.valueOf(order.getQuantity()))
                 .multiply(order.getPricePerUnit());
 
+
+        if (role.equals("CLIENT")) {
+            BigDecimal priceWithCommission = priceWithCommission(order.getOrderType(), price); //@todo uzeti commission iz ordera kad se doda
+            BigDecimal commission = priceWithCommission.subtract(price);
+
+            order.setCommission(commission);
+        } else {
+            order.setCommission(BigDecimal.ZERO);
+        }
+
+
+
         boolean checksPassed = false;
         if(role.equals("AGENT")) {
             ActuaryLimitDto actuaryLimitDto = userClient.getActuaryByEmployeeId(userId);
@@ -418,5 +431,9 @@ private void checkLimitOrder(Order order){
         }
     }
 
+    public BigDecimal getCommissionProfit() {
+        return orderRepository.getBankProfitFromOrders();
+    }
+
 
 }
diff --git a/stock-service/src/main/java/rs/raf/stock_service/service/ProfitService.java b/stock-service/src/main/java/rs/raf/stock_service/service/ProfitService.java
new file mode 100644
index 00000000..dfe94cb9
--- /dev/null
+++ b/stock-service/src/main/java/rs/raf/stock_service/service/ProfitService.java
@@ -0,0 +1,4 @@
+package rs.raf.stock_service.service;
+
+public class ProfitService {
+}
diff --git a/stock-service/src/main/resources/application.properties b/stock-service/src/main/resources/application.properties
index 1763a250..4e4a3c2d 100644
--- a/stock-service/src/main/resources/application.properties
+++ b/stock-service/src/main/resources/application.properties
@@ -27,4 +27,4 @@ spring.datasource.hikari.minimum-idle=5
 bootstrap.thread.pool.size=10
 refresh.thread.pool.size=10
 logging.level.org.hibernate.SQL=OFF
-logging.level.org.hibernate.type.descriptor.sql.BasicBinder=OFF
\ No newline at end of file
+logging.level.org.hibernate.type.descriptor.sql.BasicBinder=OFF


Reviews:
user: login: copilot-pull-request-reviewer[bot]
body: 

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.




state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-12T12:17:00Z
user: login: djzivkovic
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-12T12:57:35Z
user: login: djzivkovic
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-13T01:36:32Z

Review comments:
diff_hunk: @@ -183,6 +183,15 @@ public OrderDto createOrder(CreateOrderDto createOrderDto, String authHeader) {
         BigDecimal price = BigDecimal.valueOf(order.getContractSize()).multiply(BigDecimal.valueOf(order.getQuantity()))
                 .multiply(order.getPricePerUnit());
 
+        // commission
+        if (role.equals("CLIENT")) {
+            BigDecimal commission = price.multiply(BigDecimal.valueOf(0.01)); // lupio sam 1%
path: stock-service/src/main/java/rs/raf/stock_service/service/OrderService.java
user: login: Copilot
body: [nitpick] Consider revising the informal comment 'lupio sam 1%' to a more professional phrasing, e.g., '// applied 1% commission'.
```suggestion
            BigDecimal commission = price.multiply(BigDecimal.valueOf(0.01)); // applied 1% commission
```
created_at: 2025-04-12T12:17:00Z
author_association: CONTRIBUTOR
diff_hunk: @@ -2,10 +2,16 @@
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
 import rs.raf.bank_service.domain.entity.Payment;
 
+import java.math.BigDecimal;
 import java.util.Optional;
 
 public interface PaymentRepository extends JpaRepository<Payment, Long>, JpaSpecificationExecutor<Payment> {
     Optional<Payment> findByIdAndClientId(Long id, Long clientId);
+
+    @Query("SELECT SUM(p.exchangeProfit) FROM payments p WHERE p.exchangeProfit IS NOT NULL")
path: bank-service/src/main/java/rs/raf/bank_service/repository/PaymentRepository.java
user: login: Copilot
body: The query references 'payments' as the entity name, but it should likely be 'Payment' to match the entity class name.
```suggestion
    @Query("SELECT SUM(p.exchangeProfit) FROM Payment p WHERE p.exchangeProfit IS NOT NULL")
```
created_at: 2025-04-12T12:17:00Z
author_association: CONTRIBUTOR
diff_hunk: @@ -37,4 +37,7 @@ public class ExchangeRate {
     @Column(precision = 10, scale = 6)
     private BigDecimal sellRate;
 
+    @Column(precision = 10, scale = 6)
+    private BigDecimal middleRate;
+
path: bank-service/src/main/java/rs/raf/bank_service/domain/entity/ExchangeRate.java
user: login: djzivkovic
body: exchangerate je srednji kurs
created_at: 2025-04-12T12:35:06Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,27 @@
+package rs.raf.bank_service.controller;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import rs.raf.bank_service.domain.dto.BankProfitResponseDto;
+import rs.raf.bank_service.repository.PaymentRepository;
+
+import java.math.BigDecimal;
+
+@RestController
+@RequestMapping("/api/profit")
+@RequiredArgsConstructor
+public class ProfitController {
+
+    private final PaymentRepository paymentRepository;
+
+    @GetMapping
+    public ResponseEntity<BankProfitResponseDto> getProfit() {
+        BigDecimal exchangeProfit = paymentRepository.getBankProfitFromExchange();
path: bank-service/src/main/java/rs/raf/bank_service/controller/ProfitController.java
user: login: djzivkovic
body: napraviti u servisu metodu za ovo da se ne zove direktno repository, iako je prosta metoda
created_at: 2025-04-12T12:45:23Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,30 @@
+package rs.raf.stock_service.controller;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import rs.raf.stock_service.domain.dto.ActuaryProfitDto;
+import rs.raf.stock_service.domain.dto.StockProfitResponseDto;
+import rs.raf.stock_service.repository.OrderRepository;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/profit")
+@RequiredArgsConstructor
+public class ProfitController {
+
+    private final OrderRepository orderRepository;
+
+    @GetMapping
+    public ResponseEntity<StockProfitResponseDto> getProfit() {
+        BigDecimal stockCommissionProfit = orderRepository.getBankProfitFromOrders();
+        List<ActuaryProfitDto> actuaryProfits = orderRepository.getActuaryProfits();
+        return ResponseEntity.ok(new StockProfitResponseDto(stockCommissionProfit, actuaryProfits));
path: stock-service/src/main/java/rs/raf/stock_service/controller/ProfitController.java
user: login: djzivkovic
body: imamo poseban endpoint koji vraca profite po aktuarima tako da nam to ne treba, ovde nam trebaju samo profiti od komisije
created_at: 2025-04-12T12:56:46Z
author_association: CONTRIBUTOR
diff_hunk: @@ -183,6 +183,15 @@ public OrderDto createOrder(CreateOrderDto createOrderDto, String authHeader) {
         BigDecimal price = BigDecimal.valueOf(order.getContractSize()).multiply(BigDecimal.valueOf(order.getQuantity()))
                 .multiply(order.getPricePerUnit());
 
+        // commission
+        if (role.equals("CLIENT")) {
+            BigDecimal commission = price.multiply(BigDecimal.valueOf(0.01)); // lupio sam 1%
+            order.setCommission(commission);
+        } else {
+            order.setCommission(null); // aktuar nema proviziju
+        }
path: stock-service/src/main/java/rs/raf/stock_service/service/OrderService.java
user: login: djzivkovic
body: trebalo bi da commision postoji negde u orderima valjda, nisam siguran
created_at: 2025-04-12T12:57:25Z
author_association: CONTRIBUTOR
diff_hunk: @@ -183,6 +183,15 @@ public OrderDto createOrder(CreateOrderDto createOrderDto, String authHeader) {
         BigDecimal price = BigDecimal.valueOf(order.getContractSize()).multiply(BigDecimal.valueOf(order.getQuantity()))
                 .multiply(order.getPricePerUnit());
 
+        // commission
+        if (role.equals("CLIENT")) {
+            BigDecimal commission = price.multiply(BigDecimal.valueOf(0.01)); // lupio sam 1%
+            order.setCommission(commission);
+        } else {
+            order.setCommission(null); // aktuar nema proviziju
+        }
path: stock-service/src/main/java/rs/raf/stock_service/service/OrderService.java
user: login: djzivkovic
body: msm kao gde se racuna
created_at: 2025-04-12T12:57:31Z
author_association: CONTRIBUTOR

PR comments:
user: login: raf-si-2024-prow[bot]
created_at: 2025-04-13T01:36:37Z
body: LGTM label has been added.  <details>Git tree hash: 547f0ba69dc1a25d6aebf4317846df9dea5d8905</details>
author_association: CONTRIBUTOR
user: login: djzivkovic
created_at: 2025-04-13T01:41:19Z
body: /approve
author_association: CONTRIBUTOR
user: login: raf-si-2024-prow[bot]
created_at: 2025-04-13T01:41:26Z
body: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/RAF-SI-2024/Banka-3-Backend/pull/248#" title="Author self-approved">DavidRRN</a>*, *<a href="https://github.com/RAF-SI-2024/Banka-3-Backend/pull/248#issuecomment-2799540788" title="Approved">djzivkovic</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=RAF-SI-2024%2FBanka-3-Backend).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/RAF-SI-2024/Banka-3-Backend/blob/main/OWNERS)~~ [djzivkovic]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
author_association: CONTRIBUTOR