kishan-1721 commited on
Commit
38bb81e
·
1 Parent(s): c1fb6b5

update place-order

Browse files
backend/__pycache__/main.cpython-310.pyc CHANGED
Binary files a/backend/__pycache__/main.cpython-310.pyc and b/backend/__pycache__/main.cpython-310.pyc differ
 
backend/main.py CHANGED
@@ -46,7 +46,7 @@ if IS_PRODUCTION and SPACE_HOST:
46
  else:
47
  # In development, allow all origins
48
  allowed_origins = ["*"]
49
- print("🔧 Development mode detected. Allowing all origins.")
50
 
51
  # Add CORS middleware
52
  app.add_middleware(
 
46
  else:
47
  # In development, allow all origins
48
  allowed_origins = ["*"]
49
+ print("Development mode detected. Allowing all origins.")
50
 
51
  # Add CORS middleware
52
  app.add_middleware(
frontend/place-order.html CHANGED
@@ -235,8 +235,8 @@
235
  <th style="padding: 8px;">Qty/Lots</th>
236
  <th style="padding: 8px;">Total Trade Value (₹)</th>
237
  <th style="padding: 8px;">Fund (₹)</th>
238
- <th style="padding: 8px;">MY INVESTMENT (₹)</th>
239
- <th style="padding: 8px;">% USED OF CURRENT BALANCE</th>
240
  </tr>
241
  </thead>
242
  <tbody id="client-qty-tbody">
@@ -248,8 +248,8 @@
248
  <td style="padding: 8px;" id="total-qty">0</td>
249
  <td style="padding: 8px;" id="total-trade-value">₹0.00</td>
250
  <td style="padding: 8px;">-</td>
251
- <td style="padding: 8px;" id="total-my-investment">₹0.00</td>
252
- <td style="padding: 8px;">-</td>
253
  </tr>
254
  </tfoot>
255
  </table>
 
235
  <th style="padding: 8px;">Qty/Lots</th>
236
  <th style="padding: 8px;">Total Trade Value (₹)</th>
237
  <th style="padding: 8px;">Fund (₹)</th>
238
+ <th style="padding: 8px;" class="mtf-only-col">MY INVESTMENT (₹)</th>
239
+ <th style="padding: 8px;" class="mtf-only-col">% USED OF CURRENT BALANCE</th>
240
  </tr>
241
  </thead>
242
  <tbody id="client-qty-tbody">
 
248
  <td style="padding: 8px;" id="total-qty">0</td>
249
  <td style="padding: 8px;" id="total-trade-value">₹0.00</td>
250
  <td style="padding: 8px;">-</td>
251
+ <td style="padding: 8px;" id="total-my-investment" class="mtf-only-col">₹0.00</td>
252
+ <td style="padding: 8px;" class="mtf-only-col">-</td>
253
  </tr>
254
  </tfoot>
255
  </table>
frontend/static/js/place-order.js CHANGED
@@ -390,26 +390,26 @@ function updateProductTypeOptions(exchange) {
390
  if (exchange === 'NSE_FNO') {
391
  container.innerHTML = `
392
  <div class="radio">
393
- <input type="radio" name="productType" id="pt-intra" value="INTRA" checked>
394
  <label for="pt-intra">Intraday</label>
395
  </div>
396
  <div class="radio">
397
- <input type="radio" name="productType" id="pt-normal" value="NORMAL">
398
  <label for="pt-normal">Normal</label>
399
  </div>
400
  `;
401
  } else {
402
  container.innerHTML = `
403
  <div class="radio">
404
- <input type="radio" name="productType" id="pt-intra" value="INTRA" checked>
405
  <label for="pt-intra">Intraday</label>
406
  </div>
407
  <div class="radio">
408
- <input type="radio" name="productType" id="pt-delivery" value="DELIVERY">
409
  <label for="pt-delivery">Delivery</label>
410
  </div>
411
  <div class="radio">
412
- <input type="radio" name="productType" id="pt-mtf" value="MTF">
413
  <label for="pt-mtf">MTF</label>
414
  </div>
415
  `;
@@ -632,6 +632,14 @@ function updateClientAllocations() {
632
  existingInputs[input.dataset.client] = input.value;
633
  });
634
 
 
 
 
 
 
 
 
 
635
  tbody.innerHTML = '';
636
 
637
  selectedCheckboxes.forEach(cb => {
@@ -643,16 +651,24 @@ function updateClientAllocations() {
643
  const qtyVal = existingInputs[clientName] || mainQty;
644
 
645
  const row = document.createElement('tr');
646
- row.innerHTML = `
 
647
  <td style="padding: 8px;">${clientName}</td>
648
  <td style="padding: 8px;">
649
  <input type="number" class="form-input client-qty-input" data-client="${clientName}" value="${qtyVal}" min="1" style="width: 80px; padding: 4px;" oninput="calculateRowInvestment(this)">
650
  </td>
651
  <td style="padding: 8px;" class="total-val">--</td>
652
  <td style="padding: 8px;">₹${(fund || 0).toLocaleString('en-IN')}</td>
653
- <td style="padding: 8px;" class="my-invest-val">--</td>
654
- <td style="padding: 8px;" class="percent-used-val">--</td>
655
  `;
 
 
 
 
 
 
 
 
 
656
  tbody.appendChild(row);
657
 
658
  // Initial calc
@@ -680,22 +696,27 @@ function calculateRowInvestment(input) {
680
  // Avoid division by zero
681
  const leverage = currentMTFLeverage > 0 ? currentMTFLeverage : 1;
682
  const myInvestment = totalTradeValue / leverage;
683
- myInvestCell.textContent = '₹' + myInvestment.toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
 
 
 
684
 
685
  // 3. % Used = My Investment * 100 / Fund
686
- const fundText = fundCell.textContent.replace(/[^\d.]/g, ''); // Remove ₹ and commas
687
- const fund = parseFloat(fundText) || 0;
688
-
689
- if (fund > 0) {
690
- const percentUsed = (myInvestment * 100) / fund;
691
- // Format 00.00 %
692
- percentUsedCell.textContent = percentUsed.toFixed(2) + ' %';
693
-
694
- // Highlight if used > 100%?
695
- if (percentUsed > 100) percentUsedCell.style.color = 'red';
696
- else percentUsedCell.style.color = 'var(--text-primary)';
697
- } else {
698
- percentUsedCell.textContent = '0.00 %';
 
 
699
  }
700
 
701
  updateTableTotals();
 
390
  if (exchange === 'NSE_FNO') {
391
  container.innerHTML = `
392
  <div class="radio">
393
+ <input type="radio" name="productType" id="pt-intra" value="INTRA" checked onchange="updateClientAllocations()">
394
  <label for="pt-intra">Intraday</label>
395
  </div>
396
  <div class="radio">
397
+ <input type="radio" name="productType" id="pt-normal" value="NORMAL" onchange="updateClientAllocations()">
398
  <label for="pt-normal">Normal</label>
399
  </div>
400
  `;
401
  } else {
402
  container.innerHTML = `
403
  <div class="radio">
404
+ <input type="radio" name="productType" id="pt-intra" value="INTRA" checked onchange="updateClientAllocations()">
405
  <label for="pt-intra">Intraday</label>
406
  </div>
407
  <div class="radio">
408
+ <input type="radio" name="productType" id="pt-delivery" value="DELIVERY" onchange="updateClientAllocations()">
409
  <label for="pt-delivery">Delivery</label>
410
  </div>
411
  <div class="radio">
412
+ <input type="radio" name="productType" id="pt-mtf" value="MTF" onchange="updateClientAllocations()">
413
  <label for="pt-mtf">MTF</label>
414
  </div>
415
  `;
 
632
  existingInputs[input.dataset.client] = input.value;
633
  });
634
 
635
+ const productType = document.querySelector('input[name="productType"]:checked');
636
+ const isMTF = productType && productType.value === 'MTF';
637
+
638
+ // Toggle header and footer visibility
639
+ document.querySelectorAll('.mtf-only-col').forEach(el => {
640
+ el.style.display = isMTF ? 'table-cell' : 'none';
641
+ });
642
+
643
  tbody.innerHTML = '';
644
 
645
  selectedCheckboxes.forEach(cb => {
 
651
  const qtyVal = existingInputs[clientName] || mainQty;
652
 
653
  const row = document.createElement('tr');
654
+
655
+ let rowHtml = `
656
  <td style="padding: 8px;">${clientName}</td>
657
  <td style="padding: 8px;">
658
  <input type="number" class="form-input client-qty-input" data-client="${clientName}" value="${qtyVal}" min="1" style="width: 80px; padding: 4px;" oninput="calculateRowInvestment(this)">
659
  </td>
660
  <td style="padding: 8px;" class="total-val">--</td>
661
  <td style="padding: 8px;">₹${(fund || 0).toLocaleString('en-IN')}</td>
 
 
662
  `;
663
+
664
+ if (isMTF) {
665
+ rowHtml += `
666
+ <td style="padding: 8px;" class="my-invest-val">--</td>
667
+ <td style="padding: 8px;" class="percent-used-val">--</td>
668
+ `;
669
+ }
670
+
671
+ row.innerHTML = rowHtml;
672
  tbody.appendChild(row);
673
 
674
  // Initial calc
 
696
  // Avoid division by zero
697
  const leverage = currentMTFLeverage > 0 ? currentMTFLeverage : 1;
698
  const myInvestment = totalTradeValue / leverage;
699
+
700
+ if (myInvestCell) {
701
+ myInvestCell.textContent = '₹' + myInvestment.toLocaleString('en-IN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
702
+ }
703
 
704
  // 3. % Used = My Investment * 100 / Fund
705
+ if (percentUsedCell) {
706
+ const fundText = fundCell.textContent.replace(/[^\d.]/g, ''); // Remove ₹ and commas
707
+ const fund = parseFloat(fundText) || 0;
708
+
709
+ if (fund > 0) {
710
+ const percentUsed = (myInvestment * 100) / fund;
711
+ // Format 00.00 %
712
+ percentUsedCell.textContent = percentUsed.toFixed(2) + ' %';
713
+
714
+ // Highlight if used > 100%?
715
+ if (percentUsed > 100) percentUsedCell.style.color = 'red';
716
+ else percentUsedCell.style.color = 'var(--text-primary)';
717
+ } else {
718
+ percentUsedCell.textContent = '0.00 %';
719
+ }
720
  }
721
 
722
  updateTableTotals();