예제 #1
0
파일: eom.py 프로젝트: trustmub/OBS
 def serviceFeesEom():
     if Getters.getCobDates(Getters.getSysDate().date):
         if session.query(CobDates).filter_by(process='sf').filter_by(status=1):
             print("service process skipped")
             pass
         else:
             print("Effect the process table")
             pass
     else:
         charge = session.query(TransactionCharge).filter_by(tran_type='SF').first()
         all_accounts = session.query(Customer).all()
         for i in all_accounts:
             if i.contact_number == '09100000' or i.account_type == 'Student':
                 print("account {} passed. Account Type is {}".format(i.acc_number, i.account_type))
                 pass
             else:
                 account = i.acc_number
                 # record = session.query(Customer).filter_by(acc_number=account).first()
                 # update an EOM transaction update
                 TransactionUpdate.eomServfeeTransactionUpdate(account, Getters.getSysDate().date, charge.tran_charge)
                 print("Transaction updated " + str(account) + " " + str(charge.tran_charge) + " " + str(Getters.getSysDate().date) + " record effected")
                 # TransactionUpdate.accChargeUpdate('SF', account, Getters.getSysDate().date)
                 ChargeTransaction(Getters.getSysDate().date, account).charges(TransactionType.SERVICE_FEE)
                 print("Charge effected for account {}".format(account))
         new = CobDates(date=Getters.getSysDate().date,
                        process='sf',
                        status=1,
                        create_date=datetime.datetime.now())
         session.add(new)
         session.commit()
         print("Process table updated")
예제 #2
0
 def credit_transactions_report(self):
     # all deposits done for the day
     record = session.query(Transactions).filter_by(tran_date=Getters.getSysDate().date).filter_by(
         trantype='CR').all()
     if record is not None:
         print("The number of records are " + str(len(record)))
         with open(self.credit_transactions, mode="w", encoding="utf-8") as myFile:
             # skip_account = [33139793,
             #                 33139793,
             #                 33145826,
             #                 33145826,
             #                 33145826,
             #                 33145826,
             #                 33722073,
             #                 33202507,
             #                 33613681,
             #                 33407739]
             skip_account = [acc.acc_number for acc in
                             session.query(Customer).filter_by(email="*****@*****.**").all()]
             for i in record:
                 print("The record giving problems is" + str(i.cr_acc_number))
                 if i.cr_acc_number not in skip_account:
                     myFile.write(
                         str(i.trantype) + "," + i.tranref + "," + i.tranmethod + "," + str(i.tran_date) + "," + str(
                             i.cheque_num) + "," + str(i.acc_number) + "," + str(i.cr_acc_number) + "," + str(
                             i.amount) + "," + str(i.custid) + "\n")
예제 #3
0
파일: eom.py 프로젝트: trustmub/OBS
 def accountInterestEom():
     # Calculates the total interest for each account in the interest table
     # Credits the account with the interest credits the interests account
     # update the transaction table appropriately
     sys_date = datetime.datetime.strptime(Getters.getSysDate().date, '%Y-%m-%d')
     mo = sys_date.strftime('%m')
     all_accounts = session.query(Customer).all()
     if session.query(CobDates).filter_by(date=sys_date).filter_by(process='ai').first():
         print("Account interest has already run")
     else:
         for i in all_accounts:
             account = i.acc_number
             selector = session.query(Interest).filter_by(account=account).filter(
                 extract('month', Interest.date) == mo).all()
             total = 0
             for x in selector:
                 total += round(x.interest_earned, 2)
             tot = round(total, 2)
             i.working_bal += tot
             print("Account {} working balance upadated".format(i.working_bal))
             session.add(i)
             session.commit()
             TransactionUpdate.accInterestUpdate(account, tot, i.working_bal, i.custid)
             print("Account interest updated for Account {} Amount: ${} working balance now ${}".format(account, tot, i.working_bal))
         new = CobDates(date=sys_date,
                        process='ai',
                        status=1,
                        create_date=datetime.datetime.now())
         print("Cob Process for Account Interest done")
         session.add(new)
         session.commit()
     pass
예제 #4
0
    def ttUpdate(t_type, amount, tran_date, tran_ref, acc_num):
        """
        when a withdrawal or a deposit is done this is how the till is affected

        :param t_type:
        :param amount:
        :param tran_date:
        :param tran_ref:
        :param acc_num:
        :return:
        """
        customer = session.query(Customer).filter_by(
            acc_number=acc_num).first()
        print("Till Details: {}".format(Getters.getTillDetails()))
        till_detail = session.query(Till).filter_by(
            till_account=Getters.getTillDetails().till_account).first()

        tt = TellerTransactions(
            tran_type=t_type.value,  # CR or DR
            tranref=Auto.reference_string_generator(),
            amount=amount,
            date=tran_date,
            remark=tran_ref,
            create_date=datetime.datetime.now(),
            teller_id=till_detail.id,
            customer_id=customer.custid,
            user_id=Profile().user_details().uid)
        session.add(tt)
        session.commit()
        pass
예제 #5
0
    def test_nominate_with_server(self):
        self.registered_user1 = self._create_user(tea_type='abc')
        self._create_server(self.registered_user.id)

        self.assertTrue(ServerManager.has_active_server())
        with patch('src.app.brew_countdown') as mock_brew_countdown:
            self.dispatcher.dispatch([{
                'channel':
                'tearoom',
                'text':
                '<@U123456> nominate <@%s>' % self.registered_user1.slack_id,
                'user':
                self.registered_user.slack_id
            }])
            self.mock_post_message.assert_any_call(
                'Someone else is already making tea, I\'ll save your nomination for later :smile:',
                'tearoom')
            self.assertEqual(
                session.query(Server).filter_by(
                    user_id=self.registered_user.id, completed=False).count(),
                1)
            self.assertEqual(
                session.query(Customer).filter_by(
                    user_id=self.registered_user1.id).count(), 0)
            mock_brew_countdown.apply_async.assert_not_called()
예제 #6
0
    def test_nominate_not_enough_points(self):
        self.registered_user1 = self._create_user(tea_type='abc')
        session.flush()
        session.commit()

        self.assertFalse(ServerManager.has_active_server())
        with patch('src.app.brew_countdown') as mock_brew_countdown:
            self.dispatcher.dispatch([{
                'channel':
                'tearoom',
                'text':
                '<@U123456> nominate <@%s>' % self.registered_user1.slack_id,
                'user':
                self.registered_user.slack_id
            }])
            self.mock_post_message.assert_any_call(
                'You can\'t nominate someone unless you brew tea %s times!' %
                NOMINATION_POINTS_REQUIRED, 'tearoom')
            self.assertEqual(
                session.query(Server).filter_by(
                    user_id=self.registered_user1.id, completed=False).count(),
                0)
            self.assertEqual(
                session.query(Customer).filter_by(
                    user_id=self.registered_user.id).count(), 0)
            mock_brew_countdown.apply_async.assert_not_called()
예제 #7
0
    def test_nominate(self):
        self.registered_user.nomination_points = NOMINATION_POINTS_REQUIRED
        self.registered_user1 = self._create_user(tea_type='abc')
        session.flush()
        session.commit()

        self.assertFalse(ServerManager.has_active_server())
        with patch('src.app.brew_countdown') as mock_brew_countdown:
            self.dispatcher.dispatch([{
                'channel':
                'tearoom',
                'text':
                '<@U123456> nominate <@%s>' % self.registered_user1.slack_id,
                'user':
                self.registered_user.slack_id
            }])
            self.mock_post_message.assert_any_call(
                '%s has nominated %s to make tea! Who wants in?' %
                (self.registered_user.first_name,
                 self.registered_user1.first_name), 'tearoom')
            self.assertEqual(
                session.query(Server).filter_by(
                    user_id=self.registered_user1.id, completed=False).count(),
                1)
            self.assertEqual(
                session.query(Customer).filter_by(
                    user_id=self.registered_user.id).count(), 1)
            mock_brew_countdown.apply_async.assert_called_with(
                countdown=BREW_COUNTDOWN, args=('tearoom', ))
예제 #8
0
    def depositTransactionUpdate(tran_date, acc_number, amount, tranref):
        customer = session.query(Customer).filter_by(
            acc_number=acc_number).one()
        current_balance = float(amount) + float(customer.working_bal)

        till_detail = session.query(Till).filter_by(
            till_account=Getters.getTillDetails().till_account).first()
        trans = Transactions(trantype='CR',
                             tranref=Auto.reference_string_generator(),
                             tranmethod='Cash',
                             tran_date=tran_date,
                             cheque_num='None',
                             acc_number=int(till_detail.till_account),
                             cr_acc_number=int(acc_number),
                             amount=amount,
                             current_balance=round(current_balance, 2),
                             remark='Deposit ' + tranref,
                             custid=customer.custid)
        session.add(trans)
        session.commit()
        # Update customer working balance
        customer.working_bal = round(current_balance, 2)
        session.add(customer)
        session.commit()
        # -------------------------------

        # Update Till Opening/Closing   Balance
        till_detail.c_balance -= round(float(amount), 2)
        session.add(till_detail)
        session.commit()
        # ---------------------------
        pass
예제 #9
0
    def accCreationCash(date, amount, acc_num):
        # establish the account for account creation
        acc_creation_sus_acc = session.query(Customer).filter_by(
            account_type='acccreate').first()

        cus = session.query(Customer).filter_by(acc_number=acc_num).one()
        # Update transactions Table
        trans = Transactions(trantype='CR',
                             tranref=Auto.reference_string_generator(),
                             tranmethod='Cash',
                             tran_date=date,
                             cheque_num='None',
                             acc_number=acc_creation_sus_acc.acc_number,
                             cr_acc_number=acc_num,
                             amount=amount,
                             current_balance=round(amount, 2),
                             remark='Account Creation',
                             custid=cus.custid)
        session.add(trans)
        session.commit()

        # update the Account creation Suspanse Account
        acc_creation_sus_acc.working_bal -= amount
        session.add(acc_creation_sus_acc)
        session.commit()
        # ---------------------------------------------

        pass
예제 #10
0
    def withdrawal(self, transaction_reference):
        """
        this methods takes in transaction reference generated at the point of withdrawal and save
        the record in the Transaction table. in a withdrawal, two transaction record are created,
        one for the debited account and the other for the credited account.

            - A withdrawal affects the Tellers till balance, this means the Teller account will be
            credited and customer account debited """
        customer = session.query(Customer).filter_by(acc_number=self.cr_account).one()

        current_balance = float(customer.working_bal) - float(self.amount)
        main_withdrawal_transaction \
            = Transactions(trantype='DR',
                           tranref=transaction_reference,
                           tranmethod='Cash',
                           tran_date=self.date,
                           cheque_num='None',
                           acc_number=int(self.cr_account),
                           cr_acc_number=int(self.suspense_account_teller.till_account),
                           amount=self.amount,
                           current_balance=round(current_balance, 2),
                           remark='Withdrawal ' + transaction_reference,
                           custid=customer.custid)
        session.add(main_withdrawal_transaction)
        session.commit()
        # update customer working balance
        customer.working_bal = round(current_balance, 2)
        session.add(customer)
        session.commit()
        # -------------------------------
        # Update Till Opening/Closing balance
        self.suspense_account_teller.c_balance += round(self.amount, 2)
        session.add(self.suspense_account_teller)
        session.commit()
        # -------------------------------

        # 2. charge details between customer and charge account
        # charge_account = session.query(Customer).filter_by(account_type='charges').first()
        get_charge = session.query(TransactionCharge).filter_by(tran_type=TransactionType.DEBIT).first()
        current_balance_after_charge = float(customer.working_bal) - float(get_charge.tran_charge)
        charge_withdrawal_transaction \
            = Transactions(trantype='DR',
                           tranref=Auto.reference_string_generator(),
                           tranmethod='Charge Transfer',
                           tran_date=transaction_reference,
                           cheque_num='None',
                           acc_number=int(self.cr_account),
                           cr_acc_number=int(self.suspense_account_charges.acc_number),
                           amount=float(get_charge.tran_charge),
                           current_balance=round(current_balance_after_charge, 2),
                           remark='Debit Charge',
                           custid=customer.custid)
        session.add(charge_withdrawal_transaction)
        session.commit()

        # Update Working balance on charge
        customer.working_bal = round(current_balance_after_charge, 2)
        session.add(customer)
        session.commit()
예제 #11
0
 def __init__(self, date, dr_account):
     self.date = date
     self.dr_account = dr_account
     self.suspense_account_charges = session.query(Customer) \
         .filter_by(account_type=AccountTypes.CHARGES.value) \
         .first()
     self.suspense_account_service_fees = session.query(Customer) \
         .filter_by(account_type=AccountTypes.SERVICE_FEES.value) \
         .first()
예제 #12
0
    def link_banking_service(self, service_id):
        api_user = session.query(ApiUser).filter_by(account_number=self.account_number).first()
        service = session.query(BankingServices).filter_by(id=int(service_id))

        record = CustomerBankingService(api_user_id=api_user.user_id,
                                        service_id=service_id,
                                        status="active")
        session.add(record)
        session.commit()
예제 #13
0
 def customer_banking_services(self) -> list:
     try:
         api_user_id = session.query(ApiUser).filter_by(account_number=self.account_number).first()
         if api_user_id is not None:
             service_list = session.query(CustomerBankingService).filter_by(api_user_id=api_user_id.user_id).all()
             return [service.serialize for service in service_list]
         return []
     except ArgumentError as e:
         print(e)
         return []
예제 #14
0
    def withdrawalTransactionUpdate(tran_date, acc_number, amount, tranref):
        #   1. withdrawal detail between customer and till
        customer = session.query(Customer).filter_by(
            acc_number=acc_number).one()
        till_detail = session.query(Till).filter_by(
            till_account=Getters.getTillDetails().till_account).first()
        cb = float(customer.working_bal) - float(amount)
        trans = Transactions(trantype='DR',
                             tranref=tranref,
                             tranmethod='Cash',
                             tran_date=tran_date,
                             cheque_num='None',
                             acc_number=int(acc_number),
                             cr_acc_number=int(till_detail.till_account),
                             amount=amount,
                             current_balance=round(cb, 2),
                             remark='Withdrawal ' + tranref,
                             custid=customer.custid)
        session.add(trans)
        session.commit()
        # update customer working balance
        customer.working_bal = round(cb, 2)
        session.add(customer)
        session.commit()
        # -------------------------------
        # Update Till Opening/Closing balance
        till_detail.c_balance += round(amount, 2)
        session.add(till_detail)
        session.commit()
        # -------------------------------

        # 2. charge details between customer and charge account
        charge_account = session.query(Customer).filter_by(
            account_type='charges').first()
        get_charge = session.query(TransactionCharge).filter_by(
            tran_type='DR').first()
        cb2 = float(customer.working_bal) - float(get_charge.tran_charge)
        trans2 = Transactions(trantype='DR',
                              tranref=Auto.reference_string_generator(),
                              tranmethod='Charge Transfer',
                              tran_date=tran_date,
                              cheque_num='None',
                              acc_number=int(acc_number),
                              cr_acc_number=int(charge_account.acc_number),
                              amount=float(get_charge.tran_charge),
                              current_balance=round(cb2, 2),
                              remark='Debit Charge',
                              custid=customer.custid)
        session.add(trans2)
        session.commit()

        # Update Working balance on charge
        customer.working_bal = round(cb2, 2)
        session.add(customer)
        session.commit()
예제 #15
0
    def eomServfeeTransactionUpdate(acc_number, tran_date, amount):
        charged_customer = session.query(Customer).filter_by(
            acc_number=acc_number).first()
        current_balance = charged_customer.working_bal - amount

        servfee = session.query(Customer).filter_by(
            account_type='servfee').first()
        # same transactiion reference for customer and suspense account
        tranref = Auto.reference_string_generator()
        # transaction for Charged Customer
        trans = Transactions(trantype='SF',
                             tranref=tranref,
                             tranmethod='COB',
                             tran_date=tran_date,
                             cheque_num='None',
                             acc_number=acc_number,
                             cr_acc_number=servfee.acc_number,
                             amount=amount,
                             current_balance=round(current_balance, 2),
                             remark='SERVFEES',
                             custid=charged_customer.custid)
        session.add(trans)
        session.commit()

        # update customer working balance
        charged_customer.working_bal = round(current_balance, 2)
        session.add(charged_customer)
        session.commit()
        # -------------------------------

        # transaction for Suspense account
        cb = servfee.working_bal + amount
        trans_sus = Transactions(trantype='SF',
                                 tranref=tranref,
                                 tranmethod='COB',
                                 tran_date=tran_date,
                                 cheque_num='None',
                                 acc_number=acc_number,
                                 cr_acc_number=servfee.acc_number,
                                 amount=amount,
                                 current_balance=round(cb, 2),
                                 remark='SERVFEES',
                                 custid=servfee.custid)

        session.add(trans_sus)
        session.commit()

        # update Suspence account Working balance
        servfee.working_bal = cb
        session.add(servfee)
        session.commit()
        # ---------------------------------------

        pass
예제 #16
0
 def __init__(self,
              date,
              acc_number,
              amount,
              suspence_account_type=AccountTypes.ACCOUNT_CREATION):
     self.date = date
     self.acc_number = acc_number
     self.amount = amount
     self._suspence_account_type = suspence_account_type
     self._suspence_account = session.query(Customer).filter_by(
         account_type=self.suspence_account_type.value).first()
     self._customer_account = session.query(Customer).filter_by(
         acc_number=self.acc_number).one()
예제 #17
0
    def __init__(self, date, amount, cr_account):
        Transaction.__init__(self, date, amount, cr_account)
        self.suspense_account_new_account = session.query(Customer).filter_by(
            account_type=AccountTypes.ACCOUNT_CREATION.value).first()
        if Getters.getTillDetails() is not None:
            self.suspense_account_teller = session.query(Till).filter_by(
                till_account=Getters.getTillDetails().till_account).first()
        else:
            SystemOBS.start_logging("there are no till details")

        self.suspense_account_charges = session \
            .query(Customer) \
            .filter_by(account_type=AccountTypes.CHARGES.value).first()
예제 #18
0
 def test_remove_product(self):
     user_id = int(input('user id: '))
     carts = session.query(Cart).filter(Cart.user_id.like(user_id)).all()
     if carts:
         for item in carts:
             prod_id = item.product_id
             product = session.query(Product).filter(
                 Product.id.like(prod_id)).one()
             print(product.name)
         product_name = input("Select product from above")
         status = self.activity.remove_product(product_name=product_name)
         self.assertTrue(status, True)
     else:
         print("Cart is empty")
예제 #19
0
 def test_me_without_server(self):
     self.assertEqual(
         session.query(Customer).filter_by(
             user_id=self.registered_user.id).count(), 0)
     self.dispatcher.dispatch([{
         'channel': 'tearoom',
         'text': '<@U123456> me',
         'user': self.registered_user.slack_id
     }])
     self.mock_post_message.assert_called_with(
         'No one has volunteered to make tea, why dont you make it %s?' %
         self.registered_user.first_name, 'tearoom')
     self.assertEqual(
         session.query(Customer).filter_by(
             user_id=self.registered_user.id).count(), 0)
예제 #20
0
    def accountInterestEod():
        print("Account Interest")
        interest_per_annam = 0.05
        debit_interest = 0.15
        all_accounts = session.query(Customer).all()
        for i in all_accounts:
            date = Getters.getSysDate().date  # time.strftime('%Y-%m-%d')
            print("Interest for date: " + date)
            acc = i.acc_number
            print("Account picked is: " + str(acc))
            eod_bal = float(i.working_bal)
            print("Working balance is: " + str(eod_bal))
            if i.working_bal > 0:
                # interest charges on credit balances
                interest = (interest_per_annam / 365) * eod_bal
            else:
                # interest charged on negative balances
                interest = (debit_interest / 365) * eod_bal
            print("Interest Charges: " + str(interest))
            table_update = Interest(date=date,
                                    account=acc,
                                    eod_bal=round(eod_bal, 2),
                                    interest_earned=round(interest, 4))
            session.add(table_update)
            print("Record Account " + date + " || " + str(acc) + " || " + str(
                eod_bal) + " ==== daily interest ----" + str(interest) + " Updated on date : ----" + date)

        session.commit()
        print("Account interest Calculation complete")
예제 #21
0
def create_transaction_charge_type():
    charge_types = [{
        "tran_type": "CR",
        "tran_charge": 0
    }, {
        "tran_type": "DR",
        "tran_charge": 1.50
    }, {
        "tran_type": "TR",
        "tran_charge": 1.0
    }, {
        "tran_type": "RTGS",
        "tran_charge": 5.0
    }, {
        "tran_type": "SF",
        "tran_charge": 3.0
    }]

    for charge in charge_types:
        trans_type = charge.get("tran_type")
        trans_charge = charge.get("tran_charge")
        if trans_type not in [
                chg.tran_type
                for chg in session.query(TransactionCharge).all()
        ]:
            new_charge = TransactionCharge(tran_type=trans_type,
                                           tran_charge=trans_charge)
            session.add(new_charge)
            session.commit()
            print("Charge Type created")
        else:
            continue
예제 #22
0
def create_banking_services():
    service_dictionary = [{
        "service_name": "Pay",
        "service_description": "for payments"
    }, {
        "service_name":
        "Transfer",
        "service_description":
        "Transfer funds to local banks"
    }, {
        "service_name": "CashSend",
        "service_description": "E-wallet services"
    }, {
        "service_name": "Bill Payments",
        "service_description": "Bill Payments"
    }]
    for service in service_dictionary:

        service_n = service.get("service_name")
        service_d = service.get("service_description")

        if service_n not in [
                s.service_name
                for s in session.query(BankingServices).filter_by(
                    service_name=service_n).all()
        ]:
            service_record = BankingServices(service_name=service_n,
                                             service_description=service_d)
            print("Banking service: {} create".format(service_n))
            session.add(service_record)
            session.commit()
        else:
            continue
예제 #23
0
def create_system_currencies():
    currencies = [{
        "currency_code": "USD",
        "description": "United States Dollar"
    }, {
        "currency_code": "ZAR",
        "description": "South African Rand"
    }, {
        "currency_code": "GBP",
        "description": "Great Britain Pound"
    }]

    for currency in currencies:
        code = currency.get("currency_code")
        description = currency.get("description")
        if code not in [
                c.currency_code for c in session.query(Currency).all()
        ]:
            new_currency = Currency(currency_code=code,
                                    description=description,
                                    create_date=datetime.datetime.now())
            session.add(new_currency)
            session.commit()
        else:
            continue
예제 #24
0
 def till_details(self):
     _teller_id_list = [i.id for i in self.teller_list]
     _profile_id = Profile().user_details().uid
     if _profile_id in _teller_id_list:
         return session.query(Till).filter_by(user_id=_profile_id).first()
     else:
         return []
예제 #25
0
    def deposit(self, transaction_reference):
        """
        This method takes an additional parameter @transaction_reference for a deposit transaction
        to be saved in the database.
            - A deposit affects the Teller Till account, this means theTeller Account is debited
            and Customer account credited.
        """
        customer = session.query(Customer).filter_by(acc_number=self.cr_account).one()
        current_balance = float(self.amount) + float(customer.working_bal)
        trans_ref = References().get_transaction_reference

        CommitTransaction(trans_type=TransactionType.CREDIT.value,
                          trans_ref=trans_ref,
                          trans_method=TransactionMethod.CASH.value,
                          trans_date=self.date,
                          cheque_number='None',
                          dr_account_number=self.suspense_account_teller.till_account,
                          cr_account_number=self.cr_account,
                          amount=self.amount,
                          current_balance=round(current_balance, 2),
                          remark='Deposit_' + transaction_reference,
                          customer_id=customer.custid).commit_to_database()

        # Update customers working balance
        customer.working_bal = round(current_balance, 2)
        session.add(customer)
        session.commit()
        # -------------------------------

        # Update Till Opening/Closing   Balance
        self.suspense_account_teller.c_balance -= round(float(self.amount), 2)
        session.add(self.suspense_account_teller)
        session.commit()
예제 #26
0
    def create_account(self):

        """
        this method does not take any parameter. it create a new account and associates it to the
        customer ID for the new customer created
        :return: 0 for exception, 1 for account created
        """
        # suspense_account = session.query(Customer).filter_by(account_type='acccreate').first()
        try:
            customer = session.query(Customer).filter_by(acc_number=self.cr_account).one()
        except ValueError as value_error:
            print(value_error)
            SystemOBS().start_logging(value_error)
            return 0
        # Update transactions Table
        CommitTransaction(trans_type=TransactionType.CREDIT.value,
                          trans_ref=References().get_transaction_reference,
                          trans_method=TransactionMethod.CASH.value,
                          cheque_number='None',
                          dr_account_number=self.suspense_account_new_account.acc_number,
                          cr_account_number=self.cr_account,
                          amount=self.amount,
                          current_balance=round(self.amount, 2),
                          remark='Account Creation',
                          customer_id=customer.custid) \
            .commit_to_database()

        # update the Account creation Suspense Account
        self.suspense_account_new_account.working_bal -= self.amount
        session.add(self.suspense_account_new_account)
        session.commit()
        SystemOBS.start_logging("Account Created: " + str(customer.acc_number))
        return 1
예제 #27
0
파일: banking.py 프로젝트: trustmub/OBS
def external_transfer():
    if request.method == 'POST':
        from_acc = request.form['from_acc']
        to_bank = request.form['to_bank']
        swift = session.query(Banks).filter_by(name=to_bank).first()
        swift_code = swift.swift_code
        to_ext_acc = request.form['to_ext_acc']
        remark = request.form['remark']
        remark += " " + str(swift_code)
        amount = float(request.form['amount'])
        if amount > Getters.getCustomerAccountDetails(from_acc).working_bal:
            flash('Account Balance is Less than Required')
            return redirect(url_for('banking.external_transfer'))
        else:
            TransactionUpdate.externalTransferTransactionUpdate(
                from_acc, to_ext_acc, amount, remark,
                Getters.getSysDate().date)

            # TransactionUpdate.accChargeUpdate('RTGS', from_acc, Getters.getSysDate().date)
            ChargeTransaction(Getters.getSysDate().date,
                              from_acc).charges(TransactionType.RTGS)
            flash('RTGS Successful')
            return redirect(url_for('banking.external_transfer'))
    else:
        record = []
        # fad = From Account Details
        # tad = To Account Details
        fad = None
        tad = None
        return render_template('banking/external_transfer.html',
                               fad=fad,
                               tad=tad,
                               record=record,
                               user=Profile().user_details(),
                               banks=Getters.getBanks())
예제 #28
0
 def getCobDates(date):
     cob_dates = session.query(CobDates).all()
     my_list = []
     for i in cob_dates:
         my_list += [i.date]
     if date in my_list:
         return True
예제 #29
0
파일: customer.py 프로젝트: trustmub/OBS
def amend_cus():
    record = None
    if request.method == 'POST':
        acc_num = int(request.form['acc_number'])
        if Verify.account_exists(acc_num):

            a_record = session.query(Customer).filter_by(
                acc_number=acc_num).one()
            if request.form['first_name'] == a_record.first_name:
                pass
            else:
                a_record.first_name = request.form['first_name']
            if request.form['last_name'] == a_record.last_name:
                pass
            else:
                a_record.last_name = request.form['last_name']
            if request.form['dob'] == a_record.dob:
                pass
            else:
                a_record.dob = request.form['dob']
            if request.form['gender'] == a_record.gender:
                pass
            else:
                a_record.gender = request.form['gender']
            if request.form['contact_number'] == a_record.contact_number:
                pass
            else:
                a_record.contact_number = int(request.form['contact_number'])
            if request.form['email'] == a_record.email:
                pass
            else:
                a_record.email = request.form['email']
            if request.form['address'] == a_record.address:
                pass
            else:
                a_record.address = request.form['address']
            if request.form['country'] == a_record.country:
                pass
            else:
                a_record.country = request.form['country']
            if request.form['account_type'] == a_record.account_type:
                pass
            else:
                a_record.account_type = request.form['account_type']
            a_record.create_date = a_record.create_date

            session.add(a_record)
            session.commit()
            return redirect(
                url_for('customer.my_cus', user=Profile().user_details()))
        else:
            flash('Account Cannot be modified, Search Again')
            record = None
            return redirect(url_for('customer.amend_cus'))
    else:
        return render_template('customer/amend_cus.html',
                               record=record,
                               user=Profile().user_details(),
                               account=Getters.getAccountType())
예제 #30
0
 def rollover_system_date():
     date_change = session.query(SysDate).first()
     mydate = datetime.datetime.strptime(Getters.getSysDate().date, '%Y-%m-%d')
     add_day = datetime.timedelta(days=1)
     new_date = mydate + add_day
     date_change.date = new_date.strftime('%Y-%m-%d')
     session.add(date_change)
     session.commit()