-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
566 lines (507 loc) · 22 KB
/
Copy pathtest.html
File metadata and controls
566 lines (507 loc) · 22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>SadiCoin Investment & ETF Platform Prototype</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.1/xlsx.full.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/qrcode@1.4.4/build/qrcode.min.js"></script>
<style>
/* General CSS */
body {
font-family: Arial, sans-serif;
background-color: #121212;
color: #ffffff;
margin: 0;
padding: 0;
}
header {
background-color: #1c1c1c;
padding: 20px;
display: flex;
justify-content: space-between;
align-items: center;
}
header h3 {
font-size: 24px;
color: #f1f1f1;
}
header img {
width: 100px;
height: auto;
}
.app {
padding: 20px;
}
.cards {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20px;
}
.card {
background-color: #333333;
padding: 15px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}
h1, h3 {
color: #f1f1f1;
}
label {
color: #f1f1f1;
margin-top: 10px;
}
input, select, button {
width: 100%;
padding: 10px;
margin-top: 5px;
border-radius: 5px;
border: 1px solid #555555;
background-color: #222222;
color: #f1f1f1;
}
button {
cursor: pointer;
background-color: #007BFF;
color: white;
border: none;
}
button:hover {
background-color: #0056b3;
}
.out {
background-color: #444444;
padding: 10px;
margin-top: 10px;
border-radius: 5px;
color: #f1f1f1;
font-size: 14px;
}
footer {
text-align: center;
padding: 20px;
background-color: #1c1c1c;
color: #f1f1f1;
}
.muted {
color: #888888;
}
.row {
margin-bottom: 15px;
}
.actions {
display: flex;
justify-content: space-between;
}
.actions button {
width: 48%;
}
.dark-theme {
background-color: #121212;
color: #ffffff;
}
.security-seal {
position: absolute;
bottom: 10px;
right: 10px;
background-color: rgba(0, 0, 0, 0.7);
padding: 10px;
color: #fff;
font-size: 12px;
border-radius: 5px;
}
</style>
</head>
<body class="dark-theme">
<header>
<img src="sadicoin_logo.png" alt="SadiCoin Tech Logo" class="logo">
<h3>SADC Wallet</h3>
</header>
<div class="app">
<header>
<h1>SadiCoin Investment & ETF Platform</h1>
<p class="muted" style="text-align:center;margin:6px 0 0">Deposit • FX-Aware Yield • Auto Certificate • ETF Trading (Paper)</p>
</header>
<!-- Investor's Personal Details -->
<section class="cards">
<div class="card">
<h3>Investor Details</h3>
<div class="row">
<label>Investor Name</label>
<input id="investor-name" type="text" placeholder="Full Name">
</div>
<div class="row">
<label>ID/Passport Number</label>
<input id="investor-id" type="text" placeholder="ID/Passport Number">
</div>
<div class="row">
<label>Contact Information</label>
<input id="investor-contact" type="text" placeholder="Email or Phone">
</div>
</div>
</section>
<!-- Bond Generation and Certificate Download -->
<section class="cards">
<div class="card">
<h3>Bond Investment</h3>
<div class="row">
<label>Bond Face Value (FV)</label>
<input id="bond-fv" type="number" step="0.01" value="1000">
</div>
<div class="row">
<label>Annual Yield (%)</label>
<input id="bond-rate" type="number" step="0.01" value="8.25">
</div>
<div class="row">
<label>Years (n)</label>
<input id="bond-years" type="number" step="0.01" value="5">
</div>
<div class="row">
<label>Compounding</label>
<select id="bond-cmp">
<option value="1">Annual</option>
<option value="2">Semiannual</option>
<option value="4">Quarterly</option>
<option value="12">Monthly</option>
<option value="365">Daily</option>
<option value="cont">Continuous</option>
</select>
</div>
<div class="row">
<button id="btnBondCalc">Calculate Bond Yield</button>
<button id="btnDownloadBondCert">Download Bond Certificate</button>
</div>
<div id="bond-result" class="out">Enter bond details and press Calculate.</div>
</div>
<!-- Bond Certificate Download -->
<div class="card" id="bond-cert-card" style="display:none;">
<h3>Download Bond Certificate</h3>
<div id="bond-cert-details">
<p>Certificate Number: <span id="cert-num"></span></p>
<p>Investor Name: <span id="investor-name-display"></span></p>
<p>Bond Face Value: <span id="bond-fv-display"></span></p>
<p>Annual Rate: <span id="bond-rate-display"></span>%</p>
<p>Years: <span id="bond-years-display"></span></p>
<p>Compounding: <span id="bond-cmp-display"></span></p>
<p>Purchase Date: <span id="purchase-date"></span></p>
<p>Maturity Date: <span id="maturity-date"></span></p>
<p>Yield: <span id="yield"></span></p>
<p>Ask Price: <span id="ask-price"></span></p>
<p>Bid Price: <span id="bid-price"></span></p>
<p>Discount Rate: <span id="discount-rate"></span></p>
<p>Repo Rate: <span id="repo-rate"></span></p>
<p>Price: <span id="price"></span></p>
</div>
<button id="download-pdf-btn">Download PDF</button>
<div id="qrcode" style="margin-top: 10px;"></div>
</div>
</section>
<footer>
Bond Investment + Crypto Token
</footer>
<div class="security-seal">Security Seal</div>
</div>
<script>
// Bond Yield Calculation and Certificate Generation
document.getElementById('btnBondCalc').addEventListener('click', function() {
const fv = +document.getElementById('bond-fv').value;
const rate = +document.getElementById('bond-rate').value / 100;
const years = +document.getElementById('bond-years').value;
const cmp = document.getElementById('bond-cmp').value;
let futureValue = fv * Math.pow(1 + rate, years); // Compound Interest formula
// Populate bond results
document.getElementById('bond-result').textContent = `Future Value of Bond after ${years} years: ZAR ${futureValue.toFixed(2)}`;
// Save bond data to localStorage
localStorage.setItem('bondFV', fv);
localStorage.setItem('bondRate', rate);
localStorage.setItem('bondYears', years);
localStorage.setItem('bondCmp', cmp);
localStorage.setItem('bondFutureValue', futureValue.toFixed(2));
// Display bond details for certificate
document.getElementById('bond-fv-display').textContent = fv.toFixed(2);
document.getElementById('bond-rate-display').textContent = rate * 100;
document.getElementById('bond-years-display').textContent = years;
document.getElementById('bond-cmp-display').textContent = cmp;
// Display investor details for certificate
document.getElementById('investor-name-display').textContent = document.getElementById('investor-name').value;
// Generate certificate number, purchase date, maturity date, and other details
const certNum = Math.floor(Math.random() * 1000000); // Random certificate number
document.getElementById('cert-num').textContent = certNum;
document.getElementById('purchase-date').textContent = new Date().toLocaleDateString();
document.getElementById('maturity-date').textContent = new Date(new Date().setFullYear(new Date().getFullYear() + years)).toLocaleDateString();
document.getElementById('yield').textContent = rate * 100;
document.getElementById('ask-price').textContent = (fv * 1.05).toFixed(2); // Example calculation for ask price
document.getElementById('bid-price').textContent = (fv * 0.95).toFixed(2); // Example calculation for bid price
document.getElementById('discount-rate').textContent = "5"; // Example discount rate
document.getElementById('repo-rate').textContent = "3"; // Example repo rate
document.getElementById('price').textContent = futureValue.toFixed(2);
// Generate a QR Code for the certificate
const certificateData = {
certNum,
fv,
rate: rate * 100,
years,
purchaseDate: new Date().toLocaleDateString(),
maturityDate: new Date(new Date().setFullYear(new Date().getFullYear() + years)).toLocaleDateString(),
};
const qrCodeData = JSON.stringify(certificateData);
QRCode.toCanvas(document.getElementById('qrcode'), qrCodeData, function (error) {
if (error) console.error(error);
});
document.getElementById('bond-cert-card').style.display = 'block';
});
// Download Bond Certificate as PDF
document.getElementById('download-pdf-btn').addEventListener('click', function() {
const doc = new jsPDF();
// Add content to PDF
doc.text('Bond Investment Certificate', 20, 20);
doc.text(`Certificate Number: ${document.getElementById('cert-num').textContent}`, 20, 30);
doc.text(`Investor Name: ${document.getElementById('investor-name-display').textContent}`, 20, 40);
doc.text(`Bond Face Value: ZAR ${document.getElementById('bond-fv-display').textContent}`, 20, 50);
doc.text(`Annual Rate: ${document.getElementById('bond-rate-display').textContent}%`, 20, 60);
doc.text(`Years: ${document.getElementById('bond-years-display').textContent}`, 20, 70);
doc.text(`Compounding: ${document.getElementById('bond-cmp-display').textContent}`, 20, 80);
doc.text(`Purchase Date: ${document.getElementById('purchase-date').textContent}`, 20, 90);
doc.text(`Maturity Date: ${document.getElementById('maturity-date').textContent}`, 20, 100);
doc.text(`Yield: ${document.getElementById('yield').textContent}%`, 20, 110);
doc.text(`Ask Price: ZAR ${document.getElementById('ask-price').textContent}`, 20, 120);
doc.text(`Bid Price: ZAR ${document.getElementById('bid-price').textContent}`, 20, 130);
doc.text(`Discount Rate: ${document.getElementById('discount-rate').textContent}%`, 20, 140);
doc.text(`Repo Rate: ${document.getElementById('repo-rate').textContent}%`, 20, 150);
doc.text(`Price: ZAR ${document.getElementById('price').textContent}`, 20, 160);
// Download the PDF
doc.save('Bond_Investment_Certificate.pdf');
// Auto download the receipt
const receiptData = [
['Certificate Number', document.getElementById('cert-num').textContent],
['Investor Name', document.getElementById('investor-name-display').textContent],
['Bond Face Value', document.getElementById('bond-fv-display').textContent],
['Annual Rate', document.getElementById('bond-rate-display').textContent],
['Years', document.getElementById('bond-years-display').textContent],
['Compounding', document.getElementById('bond-cmp-display').textContent],
['Purchase Date', document.getElementById('purchase-date').textContent],
['Maturity Date', document.getElementById('maturity-date').textContent],
['Yield', document.getElementById('yield').textContent],
['Ask Price', document.getElementById('ask-price').textContent],
['Bid Price', document.getElementById('bid-price').textContent],
['Discount Rate', document.getElementById('discount-rate').textContent],
['Repo Rate', document.getElementById('repo-rate').textContent],
['Price', document.getElementById('price').textContent]
];
const ws = XLSX.utils.aoa_to_sheet(receiptData);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Investment Receipt');
// Auto download the receipt as an Excel file
XLSX.writeFile(wb, 'Investment_Receipt.xlsx');
});
// Bond Yield Calculation Export to Excel
document.getElementById('btnDownloadBondCert').addEventListener('click', function() {
const bondData = [
['Certificate Number', document.getElementById('cert-num').textContent],
['Investor Name', document.getElementById('investor-name-display').textContent],
['Bond Face Value', document.getElementById('bond-fv-display').textContent],
['Annual Rate', document.getElementById('bond-rate-display').textContent],
['Years', document.getElementById('bond-years-display').textContent],
['Compounding', document.getElementById('bond-cmp-display').textContent],
['Purchase Date', document.getElementById('purchase-date').textContent],
['Maturity Date', document.getElementById('maturity-date').textContent],
['Yield', document.getElementById('yield').textContent],
['Ask Price', document.getElementById('ask-price').textContent],
['Bid Price', document.getElementById('bid-price').textContent],
['Discount Rate', document.getElementById('discount-rate').textContent],
['Repo Rate', document.getElementById('repo-rate').textContent],
['Price', document.getElementById('price').textContent]
];
const ws = XLSX.utils.aoa_to_sheet(bondData);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Bond Investment');
XLSX.writeFile(wb, 'Bond_Investment_Details.xlsx');
});
</script>
</body>
</html>
add the above file to the file below ,that the page can instance aid cbdc buy cash over the counter ,and send cbdc to mobile wallet /bank account ( cbdc yield according to the maturity date . Make sure that the formulas are correct .
auto download Cbdc Certificate with invester details
both cbdc value must reflect in the wallet 1 ( SDC 1000 +100Rand )2(securities purchased yield
value)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SDC SDG GRANT PROTOTYPE Platform</title>
<style>
</style>
</head>
<body>
<header>
<nav>
<h1>SADC CBDC Platform</h1>
<a href="token.html">SDC Digital Coin</a>
<a href="statsdata.html">Stats</a>
</nav>
</header>
<!-- Balance Section -->
<section id="balance-section">
<h3>Your CBDC Balance</h3>
<p><strong>Balance (SDC):</strong> <span id="balance-sdc">1000</span> SDC</p>
<p><strong>Balance (ZAR):</strong> <span id="balance-zar">1000</span> ZAR</p>
<p><strong>Digital Bank Account Number:</strong> <span id="account-number">+27 123 456 789</span></p> ( here it must add the connected number)
<p><strong>Digital Card Number:</strong> <span id="card-number">XXXXXXXXXXXX1234</span></p> ( auto generate and save)
<button onclick="checkBalance()">Check Balance</button>
</section>
<!-- Phone Number Input Section -->
<section id="phone-number-section">
<h3>Enter Your Phone Number</h3>
<form id="phone-number-form">
<label for="user-phone-number">Phone Number:</label>
<input type="text" id="user-phone-number" placeholder="Enter phone number for authentication" required>
<button type="submit">Submit</button>
</form>
</section>
<!-- MoMo Payment Section -->
<section id="momo-payment-section" class="card" style="display:none;">
<h2>Make MoMo Payment</h2>
<form id="momo-form">
<label for="momo-phone">Phone Number:</label>
<input type="text" id="momo-phone" placeholder="Enter phone number for wallet" required>
<label for="momo-amount">Amount (ZAR):</label>
<input type="number" id="momo-amount" min="0.01" step="0.01" required>
<button type="submit">Make MoMo Payment</button>
</form>
</section>
<!-- Transaction History Section -->
<section id="transactions-section">
<h3>Transaction History</h3>
<div id="transaction-history">
<!-- Transactions will be listed here -->
</div>
<button onclick="downloadCSV()">Download CSV</button>
<button onclick="downloadPDF()">Download PDF</button>
</section>
<footer>
<p>© 2025 SADC CBDC Platform | All Rights Reserved</p>
</footer>
<script>
// MoMo API Keys (For local or testing purposes only)
const PRIMARY_KEY = '73d9d1541cf94eb19690103ad2ee810a'; // Replace with your actual Primary API Key
const SECONDARY_KEY = 'b2430aa3386d4c57bde8844dec78ad73'; // Replace with your actual Secondary API Key
// MoMo API URL
const MOMO_API_URL = 'https://api.mtn.com/momo/payment';
// Simulated Initial CBDC Balances and Account Information
let balanceSDC = 1000; // 1000 SDC
let balanceZAR = 1000; // 1000 ZAR
let accountNumber = '+27 123 456 789'; // Simulated account number
let cardNumber = 'XXXXXXXXXXXX1234'; // Simulated digital card number
let transactions = []; // Transaction history array
let userPhoneNumber = ''; // Store user's phone number after input
// Display balance (SDC and ZAR)
function checkBalance() {
document.getElementById('balance-sdc').innerText = balanceSDC;
document.getElementById('balance-zar').innerText = balanceZAR;
}
// Handle Phone Number Form Submission
document.getElementById('phone-number-form').addEventListener('submit', function(e) {
e.preventDefault();
// Get the phone number from the form
userPhoneNumber = document.getElementById('user-phone-number').value;
// For demonstration, we simulate storing the phone number
alert('Phone Number Registered: ' + userPhoneNumber);
// Show the MoMo payment section after phone number is entered
document.getElementById('phone-number-section').style.display = 'none';
document.getElementById('momo-payment-section').style.display = 'block';
});
// Handle MoMo Payment Form Submission
document.getElementById('momo-form').addEventListener('submit', function(e) {
e.preventDefault();
let phoneNumber = document.getElementById('momo-phone').value;
let momoAmount = parseFloat(document.getElementById('momo-amount').value);
if (momoAmount <= 0 || momoAmount > balanceZAR) { // Ensure the amount does not exceed the balance
alert("Invalid amount for MoMo payment!");
return;
}
let paymentDetails = {
phoneNumber: phoneNumber,
amount: momoAmount,
currency: 'ZAR'
};
// Send payment request to MoMo API directly from frontend
fetch(MOMO_API_URL, {
method: 'POST',
headers: {
'Authorization': `Bearer ${PRIMARY_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(paymentDetails)
})
.then(response => response.json())
.then(data => {
if (data.status === 'SUCCESS') {
alert('Payment successful! MoMo transaction ID: ' + data.transactionId);
// Deduct the payment amount from the balance
balanceZAR -= momoAmount;
balanceSDC -= momoAmount * 0.1; // Assuming 1 ZAR = 0.1 SDC for demo purposes
let transaction = {
id: data.transactionId,
amount: momoAmount,
phone: phoneNumber,
date: new Date().toLocaleString(),
type: 'Payment'
};
transactions.push(transaction);
addTransactionToHistory(transaction);
checkBalance(); // Update the displayed balance
} else {
alert('Payment failed: ' + data.message);
}
})
.catch(error => {
console.error('Error:', error);
alert('Error processing MoMo payment.');
});
});
// Add transaction to the transaction history section
function addTransactionToHistory(transaction) {
const transactionHistory = document.getElementById('transaction-history');
const transactionElement = document.createElement('div');
transactionElement.classList.add('transaction-item');
transactionElement.innerHTML = `
<p><strong>Transaction ID:</strong> ${transaction.id}</p>
<p><strong>Amount:</strong> ${transaction.amount} ZAR</p>
<p><strong>Phone:</strong> ${transaction.phone}</p>
<p><strong>Date:</strong> ${transaction.date}</p>
<p><strong>Type:</strong> ${transaction.type}</p>
`;
transactionHistory.appendChild(transactionElement);
}
// Function to download transaction history as CSV
function downloadCSV() {
let csvContent = "Transaction ID,Amount,Phone,Date,Type\n";
transactions.forEach(function(transaction) {
csvContent += `${transaction.id},${transaction.amount},${transaction.phone},${transaction.date},${transaction.type}\n`;
});
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'transaction_history.csv';
link.click();
}
// Function to download transaction history as PDF
function downloadPDF() {
const doc = new jsPDF();
doc.text('Transaction History', 10, 10);
transactions.forEach((transaction, index) => {
doc.text(`Transaction ID: ${transaction.id}`, 10, 20 + (index * 30));
doc.text(`Amount: ${transaction.amount} ZAR`, 10, 30 + (index * 30));
doc.text(`Phone: ${transaction.phone}`, 10, 40 + (index * 30));
doc.text(`Date: ${transaction.date}`, 10, 50 + (index * 30));
doc.text(`Type: ${transaction.type}`, 10, 60 + (index * 30));
});
doc.save('transaction_history.pdf');
}
// Initialize the balance on page load
checkBalance();
</script>
</body>
</html>