Fakultas Ilmu Komputer UI

Commit 592fd63a authored by addffa's avatar addffa
Browse files

[GREEN] implementasi model transaction

parent 9669fd1a
# Generated by Django 3.0.7 on 2020-08-05 04:58
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Muzakki',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('no_ktp', models.CharField(max_length=32, unique=True, validators=[django.core.validators.RegexValidator('^[0-9]*$', 'Numeric character only.')])),
('name', models.CharField(max_length=150)),
('phone', models.CharField(blank=True, max_length=32, null=True, validators=[django.core.validators.RegexValidator('^[0-9]*$', 'Numeric character only.')])),
],
),
migrations.CreateModel(
name='Transaction',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('payment_type', models.CharField(blank=True, choices=[('CASH', 'Tunai'), ('TRANSFER', 'Transfer')], max_length=32, null=True)),
('goods_delivery_type', models.CharField(blank=True, choices=[('PICKUP', 'Dijemput'), ('DELIVER', 'Diantar')], max_length=32, null=True)),
('pick_up_address', models.TextField(blank=True, null=True)),
('transfer_receipt', models.FileField(blank=True, null=True, upload_to='images/transaction')),
('payment_confirmation', models.BooleanField(default=False)),
('goods_confirmation', models.BooleanField(default=False)),
],
),
migrations.CreateModel(
name='ZakatType',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('item_type', models.CharField(choices=[('MONEY', 'Uang'), ('RICE', 'Beras'), ('GOLD', 'Emas'), ('CHECK', 'Cek')], max_length=32)),
],
),
migrations.CreateModel(
name='ZakatTransaction',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('value', models.DecimalField(decimal_places=2, max_digits=15)),
('muzakki', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='transaction.Muzakki')),
('transaction', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='transaction.Transaction')),
('zakat_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='transaction.ZakatType')),
],
),
]
import os
from django.db import models
# Create your models here.
from sizakat.validators import validate_numeric_character
class Muzakki(models.Model):
no_ktp = models.CharField(
max_length=32, unique=True,
validators=[validate_numeric_character]
)
name = models.CharField(max_length=150)
phone = models.CharField(
max_length=32, blank=True, null=True,
validators=[validate_numeric_character]
)
class ZakatType(models.Model):
class ItemType(models.TextChoices):
MONEY = ('MONEY', 'Uang')
RICE = ('RICE', 'Beras')
GOLD = ('GOLD', 'Emas')
CHECK = ('CHECK', 'Cek')
name = models.CharField(max_length=50)
item_type = models.CharField(max_length=32, choices=ItemType.choices)
class Transaction(models.Model):
class PaymentType(models.TextChoices):
CASH = ('CASH', 'Tunai')
TRANSFER = ('TRANSFER', 'Transfer')
class GoodsDeliveryType(models.TextChoices):
PICKUP = ('PICKUP', 'Dijemput')
DELIVER = ('DELIVER', 'Diantar')
payment_type = models.CharField(
max_length=32, choices=PaymentType.choices, blank=True, null=True
)
goods_delivery_type = models.CharField(
max_length=32, choices=GoodsDeliveryType.choices, blank=True, null=True
)
pick_up_address = models.TextField(blank=True, null=True)
transfer_receipt = models.FileField(
upload_to=os.path.join('images', 'transaction'), blank=True, null=True
)
payment_confirmation = models.BooleanField(default=False)
goods_confirmation = models.BooleanField(default=False)
# TODO: foreign key to user
class ZakatTransaction(models.Model):
value = models.DecimalField(max_digits=15, decimal_places=2)
zakat_type = models.ForeignKey(ZakatType, on_delete=models.CASCADE)
muzakki = models.ForeignKey(Muzakki, on_delete=models.CASCADE)
transaction = models.ForeignKey(Transaction, on_delete=models.CASCADE)
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