Skip to main content

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

  1. Run pip install p1-bank

  2. Add 'bank' to INSTALLED_APPS in settings.py

  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

p1-bank-0.2.36216664.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

p1_bank-0.2.36216664-py2-none-any.whl (14.0 kB view details)

Uploaded Python 2

File details

Details for the file p1-bank-0.2.36216664.tar.gz.

File metadata

  • Download URL: p1-bank-0.2.36216664.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.15

File hashes

Hashes for p1-bank-0.2.36216664.tar.gz
Algorithm Hash digest
SHA256 7c1da3826b963c8e427bd9e8ebe6b3c05bbc0e4cb33431ef6eb51b6d38383700
MD5 12dfc62c6959cae9aea07f63467ca267
BLAKE2b-256 f92e661bc1463afc4d6a8b99d0f5539e5e70bfe7ab63dbd70492cf45c0f612e9

See more details on using hashes here.

File details

Details for the file p1_bank-0.2.36216664-py2-none-any.whl.

File metadata

  • Download URL: p1_bank-0.2.36216664-py2-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.15

File hashes

Hashes for p1_bank-0.2.36216664-py2-none-any.whl
Algorithm Hash digest
SHA256 976278eb4bd37ab5c907f82df4c1a1f9e9e9130a42216f0facb1aaf9f78fdb43
MD5 4675f76c2cb5cadfab3cb446c9646505
BLAKE2b-256 a2d84e0fef5d6db1b6311c95c977f8d9fe25c45f50d10a33934da47e2cafa204

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page