Hi guy, question…
Gat a crew code-price tracker implemented using Django and MySql
Job code change in a few weeks meaning certain task pay more while other pay less, what would be the easiest and best way to implement price history. Job codes are stored in a separate table from jobs.
Added code_price_history = FieldHistoryTracker(['code_price'])
back in the day when app developed but not sure how to use it ::
If I update the code price with new price it will effect the entire year of job and not just the jobs after certain date, need some advice please.
class Job(models.Model):
user = models.ForeignKey(
Tech, on_delete=models.DO_NOTHING)
JOB_TYPES = (
('wo', 'Work Order'),
('sc', 'Service Call')
)
work_order = models.CharField(max_length=64)
job_type = models.CharField(max_length=16, choices=JOB_TYPES)
address = models.CharField(max_length=256)
customer_name = models.CharField(max_length=256)
note = models.TextField(null=True, blank=True)
codes = models.ManyToManyField(JobCode, through='JobCode')
job_start = models.TimeField(null=True, blank=True)
job_end = models.TimeField(null=True, blank=True)
processed = models.BooleanField(null=True, blank=True)
created_at = CustomDateTimeField(auto_now_add=True)
updated_at = CustomDateTimeField(auto_now=True)
class JobCode(models.Model):
code = models.CharField(max_length=4)
code_type = models.CharField(max_length=32, default= '')
code_description = models.CharField(max_length=256, default='')
code_price = models.DecimalField(default=0, max_digits=6, decimal_places=2)
code_link = models.URLField(max_length=256, default='')
code_price_history = FieldHistoryTracker(['code_price'])