Fakultas Ilmu Komputer UI

Commit da0c6878 authored by Bunga Amalia Kurniawati's avatar Bunga Amalia Kurniawati 🌺 Committed by Azhar Difa Arnanda
Browse files

PBI-9: Mengembalikan kode bank

parent 0289117c
# Generated by Django 3.0.7 on 2021-05-04 07:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0003_product_unit'),
]
operations = [
migrations.AddField(
model_name='bankaccounttransferdestination',
name='bank_code_number',
field=models.CharField(default='000', max_length=100, verbose_name='bank code number'),
),
]
# Generated by Django 3.0.7 on 2021-05-04 08:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0004_bankaccounttransferdestination_bank_code_number'),
]
operations = [
migrations.AddField(
model_name='programdonation',
name='transfer_destination_bank_code_number',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='transfer destination bank code number'),
),
migrations.AddField(
model_name='transaction',
name='transfer_destination_bank_code_number',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='transfer destination bank code number'),
),
]
...@@ -53,6 +53,7 @@ class User(auth_models.AbstractUser): ...@@ -53,6 +53,7 @@ class User(auth_models.AbstractUser):
class BankAccountTransferDestination(db_models.Model): class BankAccountTransferDestination(db_models.Model):
id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID')) id = db_models.UUIDField(default=uuid.uuid4, primary_key=True, verbose_name=_('ID'))
bank_name = db_models.CharField(max_length=100, verbose_name=_('bank name')) bank_name = db_models.CharField(max_length=100, verbose_name=_('bank name'))
bank_code_number = db_models.CharField(max_length=100, verbose_name=_('bank code number'), default='000')
bank_account_number = db_models.CharField(max_length=100, verbose_name=_('bank account number')) bank_account_number = db_models.CharField(max_length=100, verbose_name=_('bank account number'))
bank_account_name = db_models.CharField(max_length=200, verbose_name=_('bank account name')) bank_account_name = db_models.CharField(max_length=200, verbose_name=_('bank account name'))
...@@ -63,7 +64,7 @@ class BankAccountTransferDestination(db_models.Model): ...@@ -63,7 +64,7 @@ class BankAccountTransferDestination(db_models.Model):
verbose_name_plural = _('bank account transfer destinations') verbose_name_plural = _('bank account transfer destinations')
def __str__(self): def __str__(self):
return '{} - {}'.format(self.bank_name, self.bank_account_number) return '{}: {} - {}'.format(self.bank_name, self.bank_code_number, self.bank_account_number)
class Category(db_models.Model): class Category(db_models.Model):
...@@ -317,6 +318,12 @@ class Transaction(db_models.Model): ...@@ -317,6 +318,12 @@ class Transaction(db_models.Model):
null=True, null=True,
verbose_name=_('transfer destination bank account number') verbose_name=_('transfer destination bank account number')
) )
transfer_destination_bank_code_number = db_models.CharField(
blank=True,
max_length=100,
null=True,
verbose_name=_('transfer destination bank code number')
)
created_at = db_models.DateTimeField( created_at = db_models.DateTimeField(
auto_now_add=True, auto_now_add=True,
db_index=True, db_index=True,
...@@ -525,6 +532,12 @@ class ProgramDonation(db_models.Model): ...@@ -525,6 +532,12 @@ class ProgramDonation(db_models.Model):
max_length=100, max_length=100,
verbose_name=_('transfer destination bank account number') verbose_name=_('transfer destination bank account number')
) )
transfer_destination_bank_code_number = db_models.CharField(
blank=True,
null=True,
max_length=100,
verbose_name=_('transfer destination bank code number')
)
goods_quantity = db_models.DecimalField( goods_quantity = db_models.DecimalField(
blank=True, blank=True,
null=True, null=True,
......
...@@ -18,7 +18,8 @@ USER_DATA = { ...@@ -18,7 +18,8 @@ USER_DATA = {
BANK_ACCOUNT_TRANSFER_DESTINATION = { BANK_ACCOUNT_TRANSFER_DESTINATION = {
'bank_name': 'Dummy Bank Name', 'bank_name': 'Dummy Bank Name',
'bank_account_number': 'Dummy Bank Account Number', 'bank_code_number': '011',
'bank_account_number': '123456789',
'bank_account_name': 'Dummy Bank Account Name', 'bank_account_name': 'Dummy Bank Account Name',
} }
......
...@@ -223,7 +223,7 @@ class UserSerializer(serializers.ModelSerializer): ...@@ -223,7 +223,7 @@ class UserSerializer(serializers.ModelSerializer):
class BankAccountTransferDestinationSerializer(serializers.ModelSerializer): class BankAccountTransferDestinationSerializer(serializers.ModelSerializer):
class Meta: class Meta:
fields = ['id', 'bank_name', 'bank_account_number', 'bank_account_name'] fields = ['id', 'bank_name', 'bank_code_number', 'bank_account_number','bank_account_name']
model = models.BankAccountTransferDestination model = models.BankAccountTransferDestination
read_only_fields = ['id'] read_only_fields = ['id']
...@@ -356,6 +356,7 @@ class TransactionSerializer(serializers.ModelSerializer): ...@@ -356,6 +356,7 @@ class TransactionSerializer(serializers.ModelSerializer):
'bank_account_transfer_destination', 'bank_account_transfer_destination',
'transfer_destination_bank_name', 'transfer_destination_bank_name',
'transfer_destination_bank_account_name', 'transfer_destination_bank_account_name',
'transfer_destination_bank_code_number',
'transfer_destination_bank_account_number', 'transfer_destination_bank_account_number',
'created_at', 'created_at',
'updated_at', 'updated_at',
...@@ -387,6 +388,7 @@ class TransactionSerializer(serializers.ModelSerializer): ...@@ -387,6 +388,7 @@ class TransactionSerializer(serializers.ModelSerializer):
'bank_account_transfer_destination', 'bank_account_transfer_destination',
'transfer_destination_bank_name', 'transfer_destination_bank_name',
'transfer_destination_bank_account_name', 'transfer_destination_bank_account_name',
'transfer_destination_bank_code_number',
'transfer_destination_bank_account_number', 'transfer_destination_bank_account_number',
'created_at', 'created_at',
'updated_at', 'updated_at',
...@@ -520,6 +522,7 @@ class ProgramDonationSerializer(serializers.ModelSerializer): ...@@ -520,6 +522,7 @@ class ProgramDonationSerializer(serializers.ModelSerializer):
'bank_account_transfer_destination', 'bank_account_transfer_destination',
'transfer_destination_bank_name', 'transfer_destination_bank_name',
'transfer_destination_bank_account_name', 'transfer_destination_bank_account_name',
'transfer_destination_bank_code_number',
'transfer_destination_bank_account_number', 'transfer_destination_bank_account_number',
'goods_quantity', 'goods_quantity',
'goods_description', 'goods_description',
...@@ -545,6 +548,7 @@ class ProgramDonationSerializer(serializers.ModelSerializer): ...@@ -545,6 +548,7 @@ class ProgramDonationSerializer(serializers.ModelSerializer):
'bank_account_transfer_destination', 'bank_account_transfer_destination',
'transfer_destination_bank_name', 'transfer_destination_bank_name',
'transfer_destination_bank_account_name', 'transfer_destination_bank_account_name',
'transfer_destination_bank_code_number',
'transfer_destination_bank_account_number', 'transfer_destination_bank_account_number',
'created_at', 'created_at',
'updated_at', 'updated_at',
......
...@@ -856,8 +856,9 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase): ...@@ -856,8 +856,9 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
) )
self.assertEqual( self.assertEqual(
str(bank_account_transfer_destination), str(bank_account_transfer_destination),
'{} - {}'.format( '{}: {} - {}'.format(
bank_account_transfer_destination.bank_name, bank_account_transfer_destination.bank_name,
bank_account_transfer_destination.bank_code_number,
bank_account_transfer_destination.bank_account_number bank_account_transfer_destination.bank_account_number
) )
) )
...@@ -892,6 +893,12 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase): ...@@ -892,6 +893,12 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
) )
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(models.BankAccountTransferDestination.objects.count(), 1) self.assertEqual(models.BankAccountTransferDestination.objects.count(), 1)
self.assertEqual(
models.BankAccountTransferDestination.objects.get(
id=response.data['id']
).bank_code_number,
data['bank_code_number']
)
self.assertEqual( self.assertEqual(
models.BankAccountTransferDestination.objects.get( models.BankAccountTransferDestination.objects.get(
id=response.data['id'] id=response.data['id']
...@@ -913,6 +920,7 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase): ...@@ -913,6 +920,7 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
**seeds.BANK_ACCOUNT_TRANSFER_DESTINATION **seeds.BANK_ACCOUNT_TRANSFER_DESTINATION
) )
data = { data = {
'bank_code_number': '333',
'bank_account_number': 'Another Dummy Bank Account Number', 'bank_account_number': 'Another Dummy Bank Account Number',
} }
response = request( response = request(
...@@ -923,6 +931,12 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase): ...@@ -923,6 +931,12 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
url_args=[bank_account_transfer_destination.id] url_args=[bank_account_transfer_destination.id]
) )
self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
models.BankAccountTransferDestination.objects.get(
id=bank_account_transfer_destination.id
).bank_code_number,
data['bank_code_number']
)
self.assertEqual( self.assertEqual(
models.BankAccountTransferDestination.objects.get( models.BankAccountTransferDestination.objects.get(
id=bank_account_transfer_destination.id id=bank_account_transfer_destination.id
...@@ -938,6 +952,12 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase): ...@@ -938,6 +952,12 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
url_args=[bank_account_transfer_destination.id] url_args=[bank_account_transfer_destination.id]
) )
self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
models.BankAccountTransferDestination.objects.get(
id=bank_account_transfer_destination.id
).bank_code_number,
data['bank_code_number']
)
self.assertEqual( self.assertEqual(
models.BankAccountTransferDestination.objects.get( models.BankAccountTransferDestination.objects.get(
id=bank_account_transfer_destination.id id=bank_account_transfer_destination.id
...@@ -950,6 +970,7 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase): ...@@ -950,6 +970,7 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
**seeds.BANK_ACCOUNT_TRANSFER_DESTINATION **seeds.BANK_ACCOUNT_TRANSFER_DESTINATION
) )
data = { data = {
'bank_code_number': '',
'bank_account_number': '', 'bank_account_number': '',
} }
response = request( response = request(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment