Example #1
0
 def add_credit(id_client, id_offer, id_debet, sum):
     acc = Account.get(Account.ID_account == id_debet)
     acc.sum += sum
     acc.save()
     dateall = date.today()
     day = dateall.day
     month = dateall.month
     year = dateall.year
     period = (Offer.get(Offer.ID_offer == id_offer)).period
     percent = (Offer.get(Offer.ID_offer == id_offer)).percent
     year_period = period // 12
     if day == 31:
         day -= 1
     if year_period > 0:
         year += year_period
         period -= year_period * 12
     if month + period > 12:
         k = 12 - month
         period -= k
         year += 1
     month += period
     if month == 2 & day == 30:
         day = 28
     date_close = datetime(year, month, day)
     summonth = round(((sum * percent) / (100 * 12)) /
                      (1 - (1 / ((1 + (percent / (100 * 12)))**(period)))),
                      2)
     sumcred = summonth * period
     Account.create(sum=(sumcred * -1),
                    ID_offer=id_offer,
                    ID_client=id_client,
                    date_open=dateall,
                    date_close=date_close)
Example #2
0
 def add_deposit(id_client, id_offer, id_debet, sum):
     dateall = date.today()
     day = dateall.day
     month = dateall.month
     year = dateall.year
     period = (Offer.get(Offer.ID_offer == id_offer)).period
     year_period = period // 12
     if (day == 31):
         day -= 1
     if year_period > 0:
         year += year_period
         period -= year_period * 12
     if month + period > 12:
         k = 12 - month
         period -= k
         year += 1
     month += period
     if month == 2 & day == 30:
         day = 28
     date_close = datetime(year, month, day)
     if ((Account.get(Account.ID_account == id_debet)).sum > sum):
         Account.create(sum=sum,
                        ID_offer=id_offer,
                        ID_client=id_client,
                        date_open=dateall,
                        date_close=date_close)
         acc = Account.get(Account.ID_account == id_debet)
         acc.sum -= sum
         acc.save()
         s = 1
         return s
     else:
         s = 2
         return s
Example #3
0
 def registration_client(name, surname, patronymic, passport_id,
                         passport_seria, date_of_birth, login, password):
     dateall = date_of_birth.split('-')
     day = int(dateall[2])
     month = int(dateall[1])
     year = int(dateall[0])
     if ((passport_id > 1970) & (passport_id < 2030) &
         (passport_seria > 100000) & (passport_seria < 999999)):
         Client.create(name=name,
                       surname=surname,
                       patronymic=patronymic,
                       passport_id=passport_id,
                       passport_seria=passport_seria,
                       date_of_birth=date(year, month, day),
                       login=login,
                       password=password)
         sumR = random.randint(500, 5000)
         Account.create(
             sum=sumR,
             ID_offer=Offer.get(Offer.ID_offer == 1),
             ID_client=Client.get((Client.passport_seria == passport_seria)
                                  & (Client.passport_id == passport_id)),
             date_open=date.today())
         s = 1
         return s
     else:
         s = 2
         return s
Example #4
0
class Player(object):
    
    def __init__(self):
        self.act = Account('swimmi','52371314')
        self.act.create()

    def start_game(self):
        print(STR_WELCOME)

    def login_account(self):
        while True:
            self.act.username = input(STR_INPUT_USR)
            self.act.password = input(STR_INPUT_PWD)
            self.act.login()
            if self.act.status == 1:
                print(STR_LOGIN_SUCCESS % self.act.username)
                break
            else:
                print(STR_LOGIN_FAILED)

    def choose_role(self):
        roles = self.act.list_role()
        while 1:
            x = input(STR_CHOOSE % len(roles))
            try:
                i = int(x)
                if 0 <= i <= len(roles):
                    if i == 0:
                        name = input(STR_INPUT_NAME)
                        career = input(STR_INPUT_CAREER)
                        role = Role(name, career)
                        self.act.add_role(role)
                        self.choose_role()
                    else:
                        self.role = roles[i-1]
                    break
            except:
                pass

    def show_role(self):
        print(self.role)

    def wait_command(self):
        while 1:
            x = input(STR_MENU)
            i = int(x)
            if 0 <= i <= 9:
                if i == 0:
                    equip = Equip()
                    print(equip)
                    pass
                elif i == 1:
                    pass
                else:
                    pass
Example #5
0
 def add_debet(id_client):
     Account.create(sum=0,
                    ID_offer=Offer.get(Offer.ID_offer == 1),
                    ID_client=id_client,
                    date_open=date.today())