A simple Django app that provides Indonesian Bank models and fields.
Project description
A Django application that provides Indonesian bank choices for use with forms and a country field for models.
Installation
Run pip install p1-bank
Add 'bank' to INSTALLED_APPS in settings.py
Run python manage.py migrate to create banks models
Bank Model
A model of bank that holds all banks in Indonesia.
Supports long name, short name, bank code, and branch code.
>>> from django.apps import apps
>>> Bank = apps.get_model('bank', 'Bank')
>>> bank = Bank.objects.get(short_name='BANK BCA')
>>> bank.long_name
u'PT. BANK CENTRAL ASIA TBK.'
>>> bank.short_name
u'BANK BCA'
>>> bank.bank_code
u'014'
>>> bank.branch_code
u'0397'
>>> bank.bi_code
u'0140397'
It is possible to get a bank object from bi code:
>>> Bank.objects.get_by_bi_code('0140397')
<Bank: BANK BCA>
or upsert (update or create) from list with header:
>>> Bank.objects.get(bank_code='200')
<Bank: BANK BTN>
>>> bank_list = [
['bank_code', 'short_name'],
['200', 'BTN']
]
>>> Bank.objects.upsert_from_list_with_header(bank_list)
>>> Bank.objects.get(bank_code='200')
<Bank: BTN>
Bank Field
BankField is based on Django’s ForeignKey, a relationship to Bank model.
Consider an Account model using a BankField:
from django.db import models
from p1_bank.fields import BankField
class Account(models.Model):
name = models.CharField(max_length=100)
bank = BankField(related_name='accounts')
Any Account instance will have a bank attribute that you can use to identify account’s bank:
>>> bank = Bank.objects.get(short_name='BANK BCA')
>>> account = Account.objects.create(name='Kania', bank=bank)
>>> account.bank
'BANK BCA'
>>> account.bank.code
'014'
Bank Factories
You may use bank factories to support your test (requires factory_boy)
>>> from bank.factories import BankFactory
>>> BankFactory()
<Bank: Bank X00>
>>> BankFactory()
<Bank: Bank X01>
>>> bank301 = BankFactory(bank_code='301')
>>> bank301.bank_code
'301'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file p1-bank-0.2.45508391.tar.gz
.
File metadata
- Download URL: p1-bank-0.2.45508391.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e19a354ab8bab81c5aa9113bf4510831289c66c5e6dff275a53f251c0918693 |
|
MD5 | 27596b3d5a0af20379d68e152858addf |
|
BLAKE2b-256 | 66fe1bd4711981502edc702fd77e8a7fb9bda8a49d756ae17427c26abb07ec40 |
File details
Details for the file p1_bank-0.2.45508391-py2-none-any.whl
.
File metadata
- Download URL: p1_bank-0.2.45508391-py2-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 914b7739439f656606c19c956a268fc2c9d3d9e308e3af7ce99d231a6591322b |
|
MD5 | e557abe32b59c8578580b2a6d094d080 |
|
BLAKE2b-256 | 743c76dc5b1b56511c9aac7663230518f02ca4539279c746e700b3e943a93bb9 |