updated draw issue

This commit is contained in:
Deep Koluguri 2025-11-06 16:12:21 -05:00
parent 38400a8d1a
commit 233ee692bd
1 changed files with 53 additions and 11 deletions

View File

@ -2732,10 +2732,34 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
final nextMonthName = _getMonthName(nextMonth);
final nextMonthNumber = currentMonthNumber + 1;
// Get current month draw data
// Get draw data - show LATEST AVAILABLE draw (most recent conducted draw)
// Sort draws by year and month to get the most recent one
final sortedDraws = _service.monthlyDraws.toList()
..sort((a, b) {
if (a.year != b.year) return b.year.compareTo(a.year);
return b.month.compareTo(a.month);
});
// Try to find current month's draw first, otherwise show latest available
final currentDraw = _service.monthlyDraws.firstWhereOrNull(
(draw) => draw.month == currentMonth && draw.year == currentYear,
);
) ?? (sortedDraws.isNotEmpty ? sortedDraws.first : null);
// If we're showing latest draw (not current month), update display names
String displayCurrentMonth = currentMonthName;
int displayCurrentYear = currentYear;
int displayCurrentMonthNum = currentMonthNumber;
if (currentDraw != null && (currentDraw.month != currentMonth || currentDraw.year != currentYear)) {
// We're showing a past draw as "latest"
displayCurrentMonth = _getMonthName(currentDraw.month);
displayCurrentYear = currentDraw.year;
// Calculate what cycle month this was
if (startDate != null) {
final monthsSinceStart = (currentDraw.year - startDate.year) * 12 + (currentDraw.month - startDate.month);
displayCurrentMonthNum = monthsSinceStart + 1;
}
}
// Get financial data for current month
final financialData = _service.financialData;
@ -2794,12 +2818,30 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
children: [
Icon(Icons.calendar_today, color: Colors.green.shade600, size: 20.w),
SizedBox(width: 8.w),
Text(
'Current Month',
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w600,
color: Colors.green.shade800,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
currentDraw != null && (currentDraw.month != currentMonth || currentDraw.year != currentYear)
? 'Latest Draw'
: 'Current Month',
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w600,
color: Colors.green.shade800,
),
),
if (currentDraw != null && (currentDraw.month != currentMonth || currentDraw.year != currentYear))
Text(
'No draw for current month yet',
style: TextStyle(
fontSize: 12.sp,
color: Colors.orange.shade700,
fontStyle: FontStyle.italic,
),
),
],
),
),
],
@ -2812,7 +2854,7 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'$currentMonthName $currentYear',
'$displayCurrentMonth $displayCurrentYear',
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.bold,
@ -2820,7 +2862,7 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
),
),
Text(
'Month $currentMonthNumber of ${group.durationMonths}',
'Month $displayCurrentMonthNum of ${group.durationMonths}',
style: TextStyle(
fontSize: 14.sp,
color: Colors.green.shade600,
@ -2901,7 +2943,7 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
),
),
Text(
'K Thirupathi Reddy', // September 2025 winner from the image
'', // September 2025 winner from the image
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,