diff --git a/supplier_app/migrations/0027_auto_20200618_1442.py b/supplier_app/migrations/0027_auto_20200618_1442.py new file mode 100644 index 0000000..fa39210 --- /dev/null +++ b/supplier_app/migrations/0027_auto_20200618_1442.py @@ -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'), + ), + ] diff --git a/supplier_app/models.py b/supplier_app/models.py index 30704a4..d39dbe3 100644 --- a/supplier_app/models.py +++ b/supplier_app/models.py @@ -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): diff --git a/supplier_app/tests/factory_boy.py b/supplier_app/tests/factory_boy.py index 67daafc..a8e8416 100644 --- a/supplier_app/tests/factory_boy.py +++ b/supplier_app/tests/factory_boy.py @@ -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): diff --git a/supplier_app/views.py b/supplier_app/views.py index d206eec..3e7083f 100644 --- a/supplier_app/views.py +++ b/supplier_app/views.py @@ -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() @@ -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): diff --git a/templates/supplier_app/ap-taxpayers.html b/templates/supplier_app/ap-taxpayers.html index ff04c34..c4ef9c2 100644 --- a/templates/supplier_app/ap-taxpayers.html +++ b/templates/supplier_app/ap-taxpayers.html @@ -55,6 +55,11 @@