Skip to content

Commit

Permalink
Merge pull request harunurkst#133 from rahidulislam/dev
Browse files Browse the repository at this point in the history
CIH Calculation
  • Loading branch information
harunurkst authored Aug 3, 2023
2 parents 97ac6aa + b25818a commit ec8bb80
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 44 deletions.
5 changes: 2 additions & 3 deletions backend/organization/management/commands/prepare_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from organization.models import (
Organization,
Staff,
User,
Branch,
Division,
Expand All @@ -12,7 +11,7 @@
Team,
)
from transaction.models import TransactionCategory

from peoples.models import Staff

class Command(BaseCommand):
help = "Create a new user, category, and post"
Expand Down Expand Up @@ -42,7 +41,7 @@ def handle(self, *args, **options):
name="Test Branch",
code=111,
organization=org,
thana=thana,
# thana=thana,
)

# Create new user
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 4.2.3 on 2023-07-29 08:05

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("auth", "0012_alter_user_first_name_max_length"),
("organization", "0002_remove_branch_thana"),
]

operations = [
migrations.AlterField(
model_name="user",
name="groups",
field=models.ManyToManyField(
blank=True,
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
related_name="user_set",
related_query_name="user",
to="auth.group",
verbose_name="groups",
),
),
migrations.AlterField(
model_name="user",
name="is_superuser",
field=models.BooleanField(
default=False,
help_text="Designates that this user has all permissions without explicitly assigning them.",
verbose_name="superuser status",
),
),
]
3 changes: 1 addition & 2 deletions backend/organization/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ def get_token(cls, user):
# Add custom claims
user_data = {
"username": user.username,
"branch": user.branch.id,
"branch": user.branch.id if user.branch else None,
"role": user.role,
}
token["user"] = user_data

return token


Expand Down
12 changes: 12 additions & 0 deletions backend/transaction/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Iterable, Optional
from django.db import models
from organization.models import BaseModel
from report.models import CIHCalculation
Expand Down Expand Up @@ -27,6 +28,17 @@ class GeneralTransaction(BaseModel):
category = models.ForeignKey(TransactionCategory, models.PROTECT)
summary = models.TextField(blank=True, max_length=150)

def save(self, *args, **kwargs):
super().save(*args, **kwargs)
if self.transaction_type == "income":
CIHCalculation.objects.add_cash_in_hand(
branch=self.branch, date=self.date, amount=self.amount
)
else:
CIHCalculation.objects.deduct_cash_in_hand(
branch=self.branch, date=self.date, amount=self.amount
)


class Savings(BaseModel):
amount = models.IntegerField()
Expand Down
3 changes: 2 additions & 1 deletion backend/transaction/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
from .utils import format_savings_date, format_loan_data
from korjo_soft.permissions import IsBranchOwner

from report.models import CIHCalculation

class DepositView(CreateAPIView):
serializer_class = SavingsSerializer
Expand Down Expand Up @@ -232,6 +232,7 @@ def perform_create(self, serializer):
branch=user.branch,
organization=user.branch.organization,
)


def get_queryset(self):
return GeneralTransaction.objects.filter(
Expand Down
74 changes: 37 additions & 37 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"react-paginate": "^8.1.5",
"recharts": "^2.5.0",
"sass": "^1.60.0",
"sweetalert2": "^11.7.9",
"sweetalert2": "^11.6.13",
"tiny-invariant": "^1.3.1",
"typescript": "^5.0.3",
"yarn": "^1.22.19",
Expand Down

0 comments on commit ec8bb80

Please sign in to comment.