I need to calculate the commission a doctor must have for the laboratory tests he sends his patients. In other words, the laboratory pays you for each order sent.
Here I have the commission parameterization table:
class Comisiones(models.Model):
precio_inicial = models.IntegerField()
precio_final = models.IntegerField()
porcentaje_comision = models.IntegerField()
doctor = models.ForeignKey(Doctores, on_delete=models.CASCADE)
def full_name(self):
return u'{} []'.format(self.precio_inicial, self.precio_final, self.porcentaje_comision)
Here I have the table where the order is registered:
class OrdenPaciente(models.Model):
paciente = models.ForeignKey(Pacientes, on_delete=models.CASCADE)
doctor = models.ForeignKey(Doctores, on_delete=models.CASCADE)
estado_paciente = models.CharField(max_length=50)
status = models.BooleanField(default=True)
fecha_solicitud = models.DateField(blank=True, null=True)
dias = models.CharField(max_length=3)
precio = models.IntegerField()
Here the table where the Commissions are registered
class ComisionesCalculo(models.Model):
orden = models.ForeignKey(OrdenPaciente, on_delete=models.CASCADE)
comision = models.ForeignKey(Comisiones, on_delete=models.CASCADE)
calculo = models.DecimalField(default=0, max_digits=5, decimal_places=2)
def full_name(self):
return u'{} []'.format(self.orden, self.comision, self.calculo)
Someone helps me how I could calculate the commission based on the price and commission percentage parameterized in the Commissions model