Ver 14.06 overtime still on progress
This commit is contained in:
parent
75d2e669b3
commit
bb49956693
Binary file not shown.
Binary file not shown.
@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 5.2.7 on 2026-02-10 10:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0013_worklog_overtime_worklog_overtime_priced'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='worklog',
|
||||||
|
name='overtime_priced',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='worklog',
|
||||||
|
name='overtime_paid_to',
|
||||||
|
field=models.ManyToManyField(blank=True, related_name='overtime_paid_logs', to='core.worker'),
|
||||||
|
),
|
||||||
|
]
|
||||||
Binary file not shown.
@ -90,7 +90,7 @@ class WorkLog(models.Model):
|
|||||||
notes = models.TextField(blank=True)
|
notes = models.TextField(blank=True)
|
||||||
|
|
||||||
overtime = models.DecimalField(max_digits=3, decimal_places=2, default=0, choices=OT_CHOICES)
|
overtime = models.DecimalField(max_digits=3, decimal_places=2, default=0, choices=OT_CHOICES)
|
||||||
overtime_priced = models.BooleanField(default=False)
|
overtime_paid_to = models.ManyToManyField(Worker, blank=True, related_name='overtime_paid_logs')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Work Log / Attendance"
|
verbose_name = "Work Log / Attendance"
|
||||||
|
|||||||
@ -662,8 +662,8 @@ def payroll_dashboard(request):
|
|||||||
log_count = unpaid_logs.count()
|
log_count = unpaid_logs.count()
|
||||||
log_amount = log_count * worker.day_rate
|
log_amount = log_count * worker.day_rate
|
||||||
|
|
||||||
# Overtime Logic (Step 5)
|
# Overtime Logic (Updated: Check M2M field)
|
||||||
ot_logs = worker.work_logs.filter(overtime__gt=0, overtime_priced=False).exclude(paid_in__worker=worker).select_related('project')
|
ot_logs = worker.work_logs.filter(overtime__gt=0).exclude(overtime_paid_to=worker).exclude(paid_in__worker=worker).select_related('project')
|
||||||
ot_data_worker = []
|
ot_data_worker = []
|
||||||
ot_hours_unpriced = Decimal('0.0')
|
ot_hours_unpriced = Decimal('0.0')
|
||||||
|
|
||||||
@ -986,8 +986,8 @@ def price_overtime(request):
|
|||||||
)
|
)
|
||||||
created += 1
|
created += 1
|
||||||
|
|
||||||
worklog.overtime_priced = True
|
# Updated: Use M2M field
|
||||||
worklog.save()
|
worklog.overtime_paid_to.add(worker)
|
||||||
|
|
||||||
except (WorkLog.DoesNotExist, Worker.DoesNotExist, Exception):
|
except (WorkLog.DoesNotExist, Worker.DoesNotExist, Exception):
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user