Repository: dcapal/dcapal (language: rust)

Issue:
[Bug]: Missing suggested quantities to BUY/SELL when fractional shares are enabled
# **🐞 Bug Report**

## **Description**
<!-- A clear and concise description of what the bug is. -->

When running the allocation step with fractional shares, the quantities to buy/sell in the last step are not present

---

### **To Reproduce**

<!-- Steps to reproduce the error:
(e.g.:)


<!-- Write the steps here (add or remove as many steps as needed)-->

1. Go to the allocation step
2. Deselect the option "Don't split whole shares"
3. Run Allocation
4. Quantities are not present

---

### **Expected behaviour**
<!-- A clear and concise description of what you expected to happen. -->

Quantities must be shown in the last step

---

<!--📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛

Oh, hi there! 😄

To expedite issue processing, please search open and closed issues before submitting a new one.

📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛📛-->


Discussion / hints:

Fix patch:
diff --git a/dcapal-frontend/package-lock.json b/dcapal-frontend/package-lock.json
index ce2eabf9..0ef77a73 100644
--- a/dcapal-frontend/package-lock.json
+++ b/dcapal-frontend/package-lock.json
@@ -60,7 +60,7 @@
     },
     "../dcapal-optimizer-wasm/pkg": {
       "name": "dcapal-optimizer-wasm",
-      "version": "0.0.1"
+      "version": "0.4.0"
     },
     "node_modules/@alloc/quick-lru": {
       "version": "5.2.0",
diff --git a/dcapal-frontend/src/components/allocationFlow/endStep/index.js b/dcapal-frontend/src/components/allocationFlow/endStep/index.js
index fa9f6b73..ccf80605 100644
--- a/dcapal-frontend/src/components/allocationFlow/endStep/index.js
+++ b/dcapal-frontend/src/components/allocationFlow/endStep/index.js
@@ -15,6 +15,8 @@ import { useTranslation } from "react-i18next";
 
 export const UNALLOCATED_CASH = "Unallocated cash";
 
+const USE_ADVANCED_ALGORITHM = true;
+
 const buildCards = (assets, solution, pfolioCcy, pfolioFees) => {
   const cards = Object.values(assets).map((a) => ({
     symbol: a.symbol,
@@ -109,46 +111,23 @@ const buildFeesInput = (fees) => {
   return input;
 };
 
-const buildProblemInput = (
-  budget,
-  pfolioAmount,
-  assets,
-  fees,
-  useWholeShares
-) => {
-  if (!useWholeShares) {
-    const problemBudget = budget + pfolioAmount;
-    const as = Object.values(assets).reduce(
-      (as, a) => ({
-        ...as,
-        [a.symbol]: {
-          symbol: a.symbol,
-          target_weight: a.targetWeight / 100,
-          current_amount: a.amount,
-        },
-      }),
-      {}
-    );
-
-    return [problemBudget, as, buildFeesInput(fees)];
-  } else {
-    const as = Object.values(assets).reduce(
-      (as, a) => ({
-        ...as,
-        [a.symbol]: {
-          symbol: a.symbol,
-          shares: a.qty,
-          price: a.price,
-          target_weight: a.targetWeight / 100,
-          is_whole_shares: isWholeShares(a.aclass),
-          fees: buildFeesInput(a.fees),
-        },
-      }),
-      {}
-    );
-
-    return [budget, as, buildFeesInput(fees)];
-  }
+const buildProblemInput = (budget, assets, fees, useWholeShares) => {
+  const as = Object.values(assets).reduce(
+    (as, a) => ({
+      ...as,
+      [a.symbol]: {
+        symbol: a.symbol,
+        shares: a.qty,
+        price: a.price,
+        target_weight: a.targetWeight / 100,
+        is_whole_shares: useWholeShares ? isWholeShares(a.aclass) : false,
+        fees: buildFeesInput(a.fees),
+      },
+    }),
+    {}
+  );
+
+  return [budget, as, buildFeesInput(fees)];
 };
 
 export const EndStep = ({ useTaxEfficient, useWholeShares }) => {
@@ -158,7 +137,6 @@ export const EndStep = ({ useTaxEfficient, useWholeShares }) => {
 
   const { t } = useTranslation();
   const budget = useSelector((state) => state.pfolio.budget);
-  const pfolioAmount = useSelector((state) => state.pfolio.totalAmount);
   const assets = useSelector((state) => state.pfolio.assets);
   const quoteCcy = useSelector((state) => state.pfolio.quoteCcy);
   const fees = useSelector((state) => state.pfolio.fees);
@@ -175,7 +153,6 @@ export const EndStep = ({ useTaxEfficient, useWholeShares }) => {
 
       const [inputBudget, as, inputFees] = buildProblemInput(
         budget,
-        pfolioAmount,
         assets,
         fees,
         useWholeShares
@@ -195,7 +172,7 @@ export const EndStep = ({ useTaxEfficient, useWholeShares }) => {
           as,
           quoteCcy,
           useTaxEfficient,
-          useWholeShares,
+          USE_ADVANCED_ALGORITHM,
           inputFees
         );
 


Test patch: