updated draw issue
This commit is contained in:
parent
38400a8d1a
commit
233ee692bd
|
|
@ -2732,10 +2732,34 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
|
||||||
final nextMonthName = _getMonthName(nextMonth);
|
final nextMonthName = _getMonthName(nextMonth);
|
||||||
final nextMonthNumber = currentMonthNumber + 1;
|
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(
|
final currentDraw = _service.monthlyDraws.firstWhereOrNull(
|
||||||
(draw) => draw.month == currentMonth && draw.year == currentYear,
|
(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
|
// Get financial data for current month
|
||||||
final financialData = _service.financialData;
|
final financialData = _service.financialData;
|
||||||
|
|
@ -2794,12 +2818,30 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.calendar_today, color: Colors.green.shade600, size: 20.w),
|
Icon(Icons.calendar_today, color: Colors.green.shade600, size: 20.w),
|
||||||
SizedBox(width: 8.w),
|
SizedBox(width: 8.w),
|
||||||
Text(
|
Expanded(
|
||||||
'Current Month',
|
child: Column(
|
||||||
style: TextStyle(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
fontSize: 16.sp,
|
children: [
|
||||||
fontWeight: FontWeight.w600,
|
Text(
|
||||||
color: Colors.green.shade800,
|
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,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'$currentMonthName $currentYear',
|
'$displayCurrentMonth $displayCurrentYear',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18.sp,
|
fontSize: 18.sp,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
|
@ -2820,7 +2862,7 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Month $currentMonthNumber of ${group.durationMonths}',
|
'Month $displayCurrentMonthNum of ${group.durationMonths}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14.sp,
|
fontSize: 14.sp,
|
||||||
color: Colors.green.shade600,
|
color: Colors.green.shade600,
|
||||||
|
|
@ -2901,7 +2943,7 @@ class _GroupDetailsPageState extends State<GroupDetailsPage> with SingleTickerPr
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'K Thirupathi Reddy', // September 2025 winner from the image
|
'', // September 2025 winner from the image
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16.sp,
|
fontSize: 16.sp,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue