Fakultas Ilmu Komputer UI

Commit 6e1eff1f authored by Azhar Difa Arnanda's avatar Azhar Difa Arnanda 💬
Browse files

Merge branch 'bungamaku/11/tambah-kode-bank' into 'dev'

PBI-9: Mengembalikan kode bank

Closes #11

See merge request !11
parents 0289117c da0c6878
Pipeline #76330 passed with stages
in 2 minutes and 24 seconds
# 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):
class BankAccountTransferDestination(db_models.Model):
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_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_name = db_models.CharField(max_length=200, verbose_name=_('bank account name'))
......@@ -63,7 +64,7 @@ class BankAccountTransferDestination(db_models.Model):
verbose_name_plural = _('bank account transfer destinations')
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):
......@@ -317,6 +318,12 @@ class Transaction(db_models.Model):
null=True,
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(
auto_now_add=True,
db_index=True,
......@@ -525,6 +532,12 @@ class ProgramDonation(db_models.Model):
max_length=100,
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(
blank=True,
null=True,
......
......@@ -18,7 +18,8 @@ USER_DATA = {
BANK_ACCOUNT_TRANSFER_DESTINATION = {
'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',
}
......
......@@ -223,7 +223,7 @@ class UserSerializer(serializers.ModelSerializer):
class BankAccountTransferDestinationSerializer(serializers.ModelSerializer):
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
read_only_fields = ['id']
......@@ -356,6 +356,7 @@ class TransactionSerializer(serializers.ModelSerializer):
'bank_account_transfer_destination',
'transfer_destination_bank_name',
'transfer_destination_bank_account_name',
'transfer_destination_bank_code_number',
'transfer_destination_bank_account_number',
'created_at',
'updated_at',
......@@ -387,6 +388,7 @@ class TransactionSerializer(serializers.ModelSerializer):
'bank_account_transfer_destination',
'transfer_destination_bank_name',
'transfer_destination_bank_account_name',
'transfer_destination_bank_code_number',
'transfer_destination_bank_account_number',
'created_at',
'updated_at',
......@@ -520,6 +522,7 @@ class ProgramDonationSerializer(serializers.ModelSerializer):
'bank_account_transfer_destination',
'transfer_destination_bank_name',
'transfer_destination_bank_account_name',
'transfer_destination_bank_code_number',
'transfer_destination_bank_account_number',
'goods_quantity',
'goods_description',
......@@ -545,6 +548,7 @@ class ProgramDonationSerializer(serializers.ModelSerializer):
'bank_account_transfer_destination',
'transfer_destination_bank_name',
'transfer_destination_bank_account_name',
'transfer_destination_bank_code_number',
'transfer_destination_bank_account_number',
'created_at',
'updated_at',
......
......@@ -856,8 +856,9 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
)
self.assertEqual(
str(bank_account_transfer_destination),
'{} - {}'.format(
'{}: {} - {}'.format(
bank_account_transfer_destination.bank_name,
bank_account_transfer_destination.bank_code_number,
bank_account_transfer_destination.bank_account_number
)
)
......@@ -892,6 +893,12 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
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(
models.BankAccountTransferDestination.objects.get(
id=response.data['id']
......@@ -913,6 +920,7 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
**seeds.BANK_ACCOUNT_TRANSFER_DESTINATION
)
data = {
'bank_code_number': '333',
'bank_account_number': 'Another Dummy Bank Account Number',
}
response = request(
......@@ -923,6 +931,12 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
url_args=[bank_account_transfer_destination.id]
)
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(
models.BankAccountTransferDestination.objects.get(
id=bank_account_transfer_destination.id
......@@ -938,6 +952,12 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
url_args=[bank_account_transfer_destination.id]
)
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(
models.BankAccountTransferDestination.objects.get(
id=bank_account_transfer_destination.id
......@@ -950,6 +970,7 @@ class BankAccountTransferDestinationTest(rest_framework_test.APITestCase):
**seeds.BANK_ACCOUNT_TRANSFER_DESTINATION
)
data = {
'bank_code_number': '',
'bank_account_number': '',
}
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