Skip to content

Commit

Permalink
Inserting back-end code for new attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
BeatrizFerreira committed Jun 23, 2015
1 parent ea9e9d1 commit 276bae5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
10 changes: 9 additions & 1 deletion gestorpsi/client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
(13, _('Others')),
)

COMPANY_SIZE = (
PAYMENT_CONDITION = (
(1, _('Payer')),
(2, _('Exempted')),
(3, _('Temporarily exempted')),
Expand Down Expand Up @@ -87,6 +87,13 @@ class Family(models.Model):
def __unicode__(self):
return u"%s" % self.get_relation_level_display()


class PaymentCondition(models.Model):
payment_condition = models.CharField(choices=PAYMENT_CONDITION,
max_length=25)
value_for_payment = models.DecimalField(max_digits=7, decimal_places=2, default=0.00)


''' class not in use! moved to parents relations to class Family.
removing soon '''

Expand Down Expand Up @@ -267,6 +274,7 @@ class Client(models.Model):
active = models.BooleanField(default=True)
comments = models.TextField(blank=True)
objects = ClientManager()
payment_condition = models.ForeignKey('PaymentCondition')

def __unicode__(self):
return (u"%s" % (self.person.name.title(), )) \
Expand Down
13 changes: 12 additions & 1 deletion gestorpsi/client/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from gestorpsi.service.models import Service, ServiceGroup, GroupMembers
from gestorpsi.careprofessional.models import CareProfessional
from gestorpsi.careprofessional.views import Profession
from gestorpsi.client.models import Client, Relation
from gestorpsi.client.models import Client, Relation, PAYMENT_CONDITION, PaymentCondition
from gestorpsi.client.forms import FamilyForm
from gestorpsi.document.models import TypeDocument, Issuer
from gestorpsi.internet.models import EmailType, IMNetwork
Expand Down Expand Up @@ -194,6 +194,7 @@ def add(request):
'ReferralChoices': ReferralChoice.objects.all(),
'Relations': Relation.objects.all(),
'cnae': Cnae.objects.all(),
'payment_conditions': PAYMENT_CONDITION,
},
context_instance=RequestContext(request))

Expand Down Expand Up @@ -389,6 +390,7 @@ def form(request, object_id=''):
'clss': request.GET.get('clss'),
'company_form': company_form,
'cnae': cnae,
'payment_conditions': PAYMENT_CONDITION,
},
context_instance=RequestContext(request)
)
Expand Down Expand Up @@ -778,10 +780,18 @@ def save(request, object_id=None, is_company = False):
org.last_id_record = org.last_id_record + 1
org.save()

payment_condition = PaymentCondition()
payment_condition.payment_condition = request.POST["payment_condition"]
payment_condition.value_for_payment = request.POST["value_for_payment"]
payment_condition.save()
object.payment_condition = payment_condition

# Admission date
object.idRecord = org.last_id_record + 1
object.admission_date = datetime.now()
object.person = person_save(request, person)
object.person.salary = request.POST["salary"]
object.person.save()
object.save()

if is_company:
Expand All @@ -799,6 +809,7 @@ def save(request, object_id=None, is_company = False):

a.referral_choice_id = AdmissionChoice.objects.all().order_by('weight')[0].id
object.admissionreferral_set.add(a)

object.save()

messages.success(request, _('Client saved successfully'))
Expand Down
2 changes: 2 additions & 0 deletions gestorpsi/person/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@
(3, _('Big')),
)


class MaritalStatus(models.Model):
description = models.CharField(max_length=20)
def __unicode__(self):
return u"%s" % self.description
class Meta:
ordering = ['description']


class Person(models.Model):
id = UuidField(primary_key=True)
user = models.ForeignKey(User, editable=False, default=threadlocals.get_current_user) # the register owner
Expand Down
13 changes: 6 additions & 7 deletions gestorpsi/templates/tags/payment_condition.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@
<div>

<label>{% trans "Salary" %}<br />
<input type="text" maxlength="8" class="medium" name="salary" value="{{ person.salary }}" mask="?9?9999.99" />
<input type="text" maxlength="8" class="medium" name="salary" id="salary" value="{{ object.person.salary }}" mask="?9?9999.99" />
</label>

<label>{% trans "Value for payment" %}<br />
<input type="text" maxlength="6" class="medium" name="value_for_payment" value="{{ client.value_for_payment }}" mask="?9?9?9.99" />
<input type="text" maxlength="6" class="medium" name="value_for_payment" id="value_payment" value="{{ object.payment_condition.value_for_payment }}" mask="?9?9?9.99" />
</label>

<label>{% trans "Type" %}<br />
<select name="payment_condition" class="medium">
<option value="1">Payer</option>
<option value="2">Exempted</option>
<option value="3">Temporarily exempted</option>
{% for payment_condition in payment_conditions %}
<option value="{{payment_condition.0}}">{{payment_condition.1}}</option>
{%endfor%}
</select>
</label>

</div>
</div>

0 comments on commit 276bae5

Please sign in to comment.