Skip to content

Commit

Permalink
Adding support to Comments in Taxpayer (#383)
Browse files Browse the repository at this point in the history
* Adding support to Comments in Taxpayer
  • Loading branch information
axelfernandez-eb authored Jun 18, 2020
1 parent 22d1647 commit ddf2ba9
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 6 deletions.
75 changes: 75 additions & 0 deletions supplier_app/migrations/0027_auto_20200618_1442.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2020-06-18 14:42
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('supplier_app', '0026_bankaccountunitedstates_historicalbankaccountunitedstates'),
]

operations = [
migrations.AddField(
model_name='historicaltaxpayer',
name='new_comment_from_ap',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='historicaltaxpayer',
name='new_comment_from_supplier',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='historicaltaxpayerargentina',
name='new_comment_from_ap',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='historicaltaxpayerargentina',
name='new_comment_from_supplier',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='historicaltaxpayerunitedstates',
name='new_comment_from_ap',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='historicaltaxpayerunitedstates',
name='new_comment_from_supplier',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='taxpayer',
name='new_comment_from_ap',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='taxpayer',
name='new_comment_from_supplier',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='bankaccount',
name='bank_transaction_type',
field=models.IntegerField(choices=[(1, 'Bank transfer')], verbose_name='Payment method'),
),
migrations.AlterField(
model_name='bankaccountunitedstates',
name='bank_transaction_type',
field=models.IntegerField(choices=[(1, 'Check'), (1, 'ACH'), (1, 'Wire')], verbose_name='Payment method'),
),
migrations.AlterField(
model_name='historicalbankaccount',
name='bank_transaction_type',
field=models.IntegerField(choices=[(1, 'Bank transfer')], verbose_name='Payment method'),
),
migrations.AlterField(
model_name='historicalbankaccountunitedstates',
name='bank_transaction_type',
field=models.IntegerField(choices=[(1, 'Check'), (1, 'ACH'), (1, 'Wire')], verbose_name='Payment method'),
),
]
3 changes: 2 additions & 1 deletion supplier_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class TaxPayer(models.Model):
)
company = models.ForeignKey(Company, on_delete=models.CASCADE)
taxpayer_date = models.DateField(auto_now_add=True, verbose_name=_("Creation date"))

new_comment_from_supplier = models.BooleanField(default=False)
new_comment_from_ap = models.BooleanField(default=False)
history = HistoricalRecords(inherit=True)

def __str__(self):
Expand Down
2 changes: 2 additions & 0 deletions supplier_app/tests/factory_boy.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class Meta:
taxpayer_state = "PENDING"
company = factory.SubFactory(CompanyFactory)
country = "AR"
new_comment_from_supplier = True
new_comment_from_ap = True


class TaxPayerEBEntityFactory(factory.django.DjangoModelFactory):
Expand Down
24 changes: 20 additions & 4 deletions supplier_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,16 @@ def handle_no_permission(self):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['taxpayer'] = get_object_or_404(TaxPayer, pk=self.kwargs['taxpayer_id']).get_taxpayer_child()
taxpayer = get_object_or_404(TaxPayer, pk=self.kwargs['taxpayer_id']).get_taxpayer_child()
if self.request.user.is_AP:
if taxpayer.new_comment_from_supplier is True:
taxpayer.new_comment_from_supplier = False
taxpayer.save()
if self.request.user.is_supplier:
if taxpayer.new_comment_from_ap is True:
taxpayer.new_comment_from_ap = False
taxpayer.save()
context['taxpayer'] = taxpayer
context['taxpayer_address'] = context['taxpayer'].address_set.get()
context['taxpayer_contact'] = context['taxpayer'].contactinformation_set.get()
context['taxpayer_bank_account'] = context['taxpayer'].bankaccount_set.get()
Expand Down Expand Up @@ -569,9 +578,16 @@ def handle_no_permission(self):
def form_valid(self, form):
form = self.set_required_fields(form)
action = self.request.POST['action']
if self.request.user.is_AP and action == TAXPAYER_STATUS_CHANGE_REQUIRED:
taxpayer = get_object_or_404(TaxPayer, pk=self.kwargs['taxpayer_id'])
run_strategy_taxpayer_status(action, taxpayer, self.request)
taxpayer = get_object_or_404(TaxPayer, pk=self.kwargs['taxpayer_id'])
if self.request.user.is_AP:
taxpayer.new_comment_from_ap = True
taxpayer.save()
if action == TAXPAYER_STATUS_CHANGE_REQUIRED:
run_strategy_taxpayer_status(action, taxpayer, self.request)
elif self.request.user.is_supplier:
taxpayer.new_comment_from_supplier = True
taxpayer.save()

return super().form_valid(form)

def form_invalid(self, forms):
Expand Down
5 changes: 5 additions & 0 deletions templates/supplier_app/ap-taxpayers.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ <h1>
<a class='btn btn-info' href="{% url 'supplier-details' taxpayer_id=taxpayer.id %}">
{% trans "More details" %}
</a>
{% if taxpayer.new_comment_from_supplier%}
<a data-toggle="tooltip" data-placement="right" title="{% trans 'New unread commments' %}">
<i class='far fa-comment-dots' style='font-size:24px'></i>
</a>
{% endif %}
</td>
</tr>
{% endfor %}
Expand Down
7 changes: 6 additions & 1 deletion templates/supplier_app/supplier-home.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@
{% trans "Invoices" %}
</a> -->
<a class='btn btn-info'
href="{% url 'supplier-details' taxpayer_id=taxpayer.id %}">
href="{% url 'supplier-details' taxpayer_id=taxpayer.id %}">
{% trans "Edit" %}
</a>
{% if taxpayer.new_comment_from_ap%}
<a data-toggle="tooltip" data-placement="right" title="{% trans 'New unread commments' %}">
<i class='far fa-comment-dots' style='font-size:24px'></i>
</a>
{% endif %}
</td>
</tr>
{% endfor %}
Expand Down

0 comments on commit ddf2ba9

Please sign in to comment.