mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-30 01:43:59 +00:00
Fix: last updated rate
This commit is contained in:
@@ -145,24 +145,34 @@ export default {
|
||||
|
||||
// Get rates for date range
|
||||
const ratesForRange = {};
|
||||
let currentRate = 0;
|
||||
Object.keys(ratesByType).forEach(type => {
|
||||
ratesForRange[type] = [];
|
||||
for (let i = start.getDate(); i <= end.getDate(); i++) {
|
||||
const dateStr = `${i.toString().padStart(2, '0')}-${startMonth.toString().padStart(2, '0')}-${startYear}`;
|
||||
if (i === end.getDate() && startMonth !== endMonth) {
|
||||
// Handle end month
|
||||
const endMonthDays = new Date(endYear, endMonth, 0).getDate();
|
||||
for (let j = 1; j <= end.getDate(); j++) {
|
||||
const dateStr = `${j.toString().padStart(2, '0')}-${endMonth.toString().padStart(2, '0')}-${endYear}`;
|
||||
const rate = ratesByType[type].find(r => r.created_at === dateStr);
|
||||
ratesForRange[type].push(rate ? rate.rate : '');
|
||||
|
||||
ratesForRange[type] = [];
|
||||
|
||||
for (let i = start.getDate(); i <= end.getDate(); i++) {
|
||||
|
||||
const dateStr = `${i.toString().padStart(2, '0')}-${startMonth.toString().padStart(2, '0')}-${startYear}`;
|
||||
if (i === end.getDate() && startMonth !== endMonth) {
|
||||
// Handle end month
|
||||
const endMonthDays = new Date(endYear, endMonth, 0).getDate();
|
||||
for (let j = 1; j <= end.getDate(); j++) {
|
||||
const dateStr = `${j.toString().padStart(2, '0')}-${endMonth.toString().padStart(2, '0')}-${endYear}`;
|
||||
const rate = ratesByType[type].find(r => r.created_at === dateStr);
|
||||
if(rate){
|
||||
currentRate = rate;
|
||||
}
|
||||
ratesForRange[type].push(rate ? rate.rate : currentRate.rate);
|
||||
}
|
||||
} else {
|
||||
// Handle start month and other months in range
|
||||
const rate = ratesByType[type].find(r => r.created_at === dateStr);
|
||||
if(rate){
|
||||
currentRate = rate;
|
||||
}
|
||||
ratesForRange[type].push(rate ? rate.rate : currentRate.rate);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Handle start month and other months in range
|
||||
const rate = ratesByType[type].find(r => r.created_at === dateStr);
|
||||
ratesForRange[type].push(rate ? rate.rate : '');
|
||||
}
|
||||
}
|
||||
});
|
||||
// Generate labels for chart
|
||||
const labels = [];
|
||||
|
||||
Reference in New Issue
Block a user