Exemplo n.º 1
0
    def saveItem(valueCard, valueItem, price):
        tranId = 1 if len(
            ndb.dbTran) == 0 else ndb.dbTran[len(ndb.dbTran) - 1].tranId + 1
        tranData = TranData(tranId,
                            valueCard.cardId, valueCard.cardNo, valueCard.name,
                            UtilGp.now(), valueItem.itemId, price)
        DbTranData.addToTran(tranData)
        valueCard.creditUsed += price
        tranRewardPoint = price // 100 * (1 if valueCard.cardType == 'Gold'
                                          else 2)
        valueCard.creditUsed += price
        valueCard.rewardPoint += tranRewardPoint
        DbCardData.updateCards(ndb.dbCard, valueCard)

        print()
        print("Reward Points earned for this transaction : %d" %
              (tranRewardPoint, ))
        print()
        UtilGp.printCaptionData(
            ('Credit Limit Used', 'Credit Limit Available',
             'Total Reward Points'),
            (UtilGp.priceToStr(valueCard.creditUsed),
             UtilGp.priceToStr(valueCard.creditBal()), valueCard.rewardPoint),
            25)

        print("Loading..DB.2.\r", end="")
        ndb.loadCard(False)
        ndb.loadTran(valueCard, False)
        print("               \n", end="")

        Shop.showFailure()
Exemplo n.º 2
0
 def showFailure():
     ndb.IsLoggedIn = False
     ndb.logInCard = None
     choice = input("\n1-Exit App, 2-Main Menu\nYour Choice:")
     if not choice.isdigit(): return
     choice = int(choice)
     if not (choice == 2): return
     UtilGp.mainMenu()
Exemplo n.º 3
0
 def genCardNo(dbCard):
     noStart = 8000
     noEnd = 9000
     stepValue = 1
     cardNo = UtilGp.randNo(noStart, noEnd, stepValue, True)
     while DbCardData.checkCardNoExist(cardNo, dbCard):
         cardNo = UtilGp.randNo(noStart, noEnd, stepValue, True)
     cardNo = str(cardNo)
     return cardNo
Exemplo n.º 4
0
	def show():
		UtilGp.title('Main Menu')
		print("\n%s\n"%(UtilGp.centerText("SBI Credit Cards... Make Your Life Easy."),))
		print("Loading...\r",end="")
		UtilGp.sleep(2)
		print("1. Apply for Credit Card")
		print("2. Shopping")
		print("3. My Trasactions")
		choice = int(input("Please Enter Your Choice:"))
		return choice
Exemplo n.º 5
0
 def showCatTot():
     UtilGp.sleep(2)
     UtilGp.clear()
     UtilGp.title('Reports(%s)' % ('Total Amount Spent on a Category', ))
     for valueCat in ndb.dbCat:
         print("%d %s" % (valueCat.catId, valueCat.category))
     choiceCatId = int(input("Enter Catgory ID\nYour Choice:"))
     isExist = False
     resCat = None
     for valueCat in ndb.dbCat:
         if valueCat.catId == choiceCatId:
             isExist = True
             resCat = valueCat
             break
     if isExist:
         dbTran = DbTranData.queryByCategory(ndb.dbTran, choiceCatId)
         amount = sum(list(map(lambda x: x.price, dbTran)))
         UtilGp.printCaptionData(
             ('Category', 'Total Amount Spent is'),
             (valueCat.category, 'Rs.%.2f' % (amount, )), 45)
         #print("Total Amount Spent for category %s is Rs.%f"%(valueCat.category,amount))
         print("****End of Report****")
         print()
         Shop.showFailure()
     else:
         print("You Category Not Exist.")
         Shop.showFailure()
Exemplo n.º 6
0
 def showDateRange():
     UtilGp.sleep(2)
     UtilGp.clear()
     UtilGp.title('Reports(%s)' % ('Transactions between two dates', ))
     fromDate = input("From Date(dd-MM-YYYY):")
     toDate = input("To Date  (dd-MM-YYYY):")
     fromDate = UtilGp.strToDate(fromDate + ' 00:00:00')
     toDate = UtilGp.strToDate(toDate + ' 23:59:00')
     #print(fromDate,toDate)
     dbTran = DbTranData.queryByDateRange(ndb.dbTran, fromDate, toDate)
     DbTranData.printTran(dbTran)
     print("****End of Report****")
     print()
     from frmPageShop import Shop
     Shop.showFailure()
Exemplo n.º 7
0
 def showBySortedAmount():
     UtilGp.sleep(2)
     UtilGp.clear()
     UtilGp.title('Reports(%s)' % ('All Transactions sorted on amount', ))
     dbTran = DbTranData.queryAll(ndb.dbTran)
     dbTran.sort(key=lambda x: x.price)
     #print(dbTran)
     DbTranData.printTran(dbTran)
     print("****End of Report****")
     print()
     from frmPageShop import Shop
     Shop.showFailure()
Exemplo n.º 8
0
 def showAmountRange():
     UtilGp.sleep(2)
     UtilGp.clear()
     UtilGp.title('Reports(%s)' % ('Transactions within amount range', ))
     fromAmount = float(input("From Amount:"))
     toAmount = float(input("To Amount:"))
     #print(fromDate,toDate)
     dbTran = DbTranData.queryByAmount(ndb.dbTran, fromAmount, toAmount)
     DbTranData.printTran(dbTran)
     print("****End of Report****")
     print()
     Shop.showFailure()
Exemplo n.º 9
0
 def printTran(dbTran):
     from UtilGp import UtilGp
     print()
     UtilGp.linePrint('*')
     print('%-12s%-14s %-16s%-20s%14s' %
           ('Date', 'Category', 'Sub Category', 'Item', 'Amount'))
     UtilGp.linePrint('*')
     print()
     for valueTran in dbTran:
         print('%-12s%-14s %-16s%-20s%14s ' %
               (UtilGp.dateToStr(valueTran.tranDate), valueTran.Category(),
                valueTran.SubCategory(), valueTran.ItemName(), 'Rs.%7.2f' %
                (valueTran.price, )))
     if len(dbTran) == 0:
         print("**No Data Found**")
     print()
     UtilGp.linePrint('*')
     print()
Exemplo n.º 10
0
    def savingItem(resItem):
        #amount validations against credit balance
        #confirming pin
        #success message
        res = UtilGp.parseItemMsg(resItem, ndb.logInCard.passCode,
                                  ndb.logInCard.creditBal())
        #end

        if res[0] == False:
            if res[1] == 1:
                print(
                    "No sufficient credit balance.\nYour transaction is cancelled.\n"
                )
            else:
                print(
                    "Incorrect PIN.\nFor security reason Your transaction is cancelled.\n"
                )
            Shop.showFailure()
        else:
            #print(ndb.logInCard,resItem,res[4])
            Shop.saveItem(ndb.logInCard, resItem, res[4])
Exemplo n.º 11
0
 def reportMenu():
     UtilGp.sleep(2)
     UtilGp.clear()
     UtilGp.title('Reports')
     print("1-All transactions done between two dates")
     print("2-All transactions that fall within a specified amount range")
     print("3-All transactions done on a category")
     print("4-Total amount spent on a category")
     print("5-Transactions sorted based on amount")
     choice = int(input("Your Choice:"))
     if choice == 1:
         Report.showDateRange()
     elif choice == 2:
         Report.showAmountRange()
     elif choice == 3:
         Report.showByCat()
     elif choice == 4:
         Report.showCatTot()
     elif choice == 5:
         Report.showBySortedAmount()
Exemplo n.º 12
0
 def showByCat():
     UtilGp.sleep(2)
     UtilGp.clear()
     UtilGp.title('Reports(%s)' % ('Transactions of a Category', ))
     for valueCat in ndb.dbCat:
         print("%d %s" % (valueCat.catId, valueCat.category))
     choiceCatId = int(input("Enter Catgory ID\nYour Choice:"))
     isExist = False
     resCat = None
     for valueCat in ndb.dbCat:
         if valueCat.catId == choiceCatId:
             isExist = True
             resCat = valueCat
             break
     if isExist:
         dbTran = DbTranData.queryByCategory(ndb.dbTran, choiceCatId)
         DbTranData.printTran(dbTran)
         print("****End of Report****")
         print()
         Shop.showFailure()
     else:
         print("You Category Not Exist.")
         Shop.showFailure()
Exemplo n.º 13
0
from UtilGp import UtilGp
UtilGp.startApp()
Exemplo n.º 14
0
 def showCat():
     UtilGp.sleep(2)
     UtilGp.clear()
     UtilGp.title('Shopping')
     UtilGp.creditLine()
     print("\n %-10s  %-16s" % ('ID', 'Category'))
     UtilGp.linePrint('-', 42)
     for valueCat in ndb.dbCat:
         print(" %-10d %-16s" % (valueCat.catId, valueCat.category))
     UtilGp.linePrint('-', 42)
     choiceCatId = int(input("Enter Catgory ID\nYour Choice:"))
     isExist = False
     resCat = None
     for valueCat in ndb.dbCat:
         if valueCat.catId == choiceCatId:
             isExist = True
             resCat = valueCat
             break
     if isExist:
         Shop.showSubCat(resCat)
     else:
         print("You Category Not Exist.")
         Shop.showFailure()
Exemplo n.º 15
0
 def show():
     UtilGp.Login(Report.reportMenu, ndb.loadTranByItem, 'Reports (Login)')
Exemplo n.º 16
0
    def showSubCat(valueCat):
        UtilGp.sleep(2)
        UtilGp.clear()
        UtilGp.title('Shopping(%s)' % (valueCat.category, ))
        UtilGp.creditLine()
        subCat = list(filter(lambda x: x.catId == valueCat.catId,
                             ndb.dbSubCat))
        print("\n %-10s  %-16s" % ('ID', 'Sub Category'))
        UtilGp.linePrint('-', 42)
        for valueSubCat in subCat:
            print(" %-10d %-16s" %
                  (valueSubCat.subCatId, valueSubCat.subCategory))
        UtilGp.linePrint('-', 42)
        choiceSubCatId = int(input("Enter Sub Category ID\nYour Choice:"))

        #print(choiceSubCatId)
        isExist = False
        resSubCat = None
        for valueSubCat in subCat:
            if valueSubCat.subCatId == choiceSubCatId:
                isExist = True
                resSubCat = valueSubCat
                break
        if isExist:
            Shop.showItem(resSubCat)
        else:
            print("You Sub Category Not Exist.")
            Shop.showFailure()
Exemplo n.º 17
0
 def showItem(valueSubCat):
     UtilGp.sleep(2)
     UtilGp.clear()
     UtilGp.title('Shopping(%s)' % (valueSubCat.subCategory, ))
     UtilGp.creditLine()
     its = list(
         filter(lambda x: x.itemId // 100 == valueSubCat.subCatId,
                ndb.dbItem))
     if len(its) == 1:
         if its[0].itemType == 1:
             Shop.savingItem(its[0])
     else:
         print("\n %-10s  %-22s %12s" % ('ID', 'Item', 'Price')
               if valueSubCat.subCatId != 21 else "\n %-10s  %-16s" %
               ('ID', 'Item'))
         UtilGp.linePrint('-', 48)
         for valueItem in its:
             print(" %-10d  %-22s %12s" %
                   (valueItem.itemId, valueItem.itemName, 'Rs.%7.2f' %
                    (valueItem.price, )) if valueSubCat.subCatId != 21 else
                   "%-10d  %-16s" % (valueItem.itemId, valueItem.itemName))
         UtilGp.linePrint('-', 48)
         choidItemId = int(input("Enter Item ID\nYour Choice:"))
         #print(choidItemId)
         isExist = False
         resItem = None
         for valueItem in its:
             if valueItem.itemId == choidItemId:
                 isExist = True
                 resItem = valueItem
                 break
         if isExist:
             Shop.savingItem(resItem)
         else:
             print("Your Item Not Exist.")
             Shop.showFailure()
Exemplo n.º 18
0
 def show():
     UtilGp.Login(Shop.showCat, ndb.loadTran, 'Shopping (Login)')
Exemplo n.º 19
0
    def show():
        UtilGp.clear()
        UtilGp.title('Applying Card')
        print("Loading...\r",end="")
        UtilGp.sleep(2)		
        name=input("%-30s:"%"Enter Name")
        mobileNo=input("%-30s:"%"Enter Mobile Number")
        if not UtilGp.isValidDigit(mobileNo):
            print("Invalid Mobile Number")
            Shop.showFailure()
            return
        dob=input("%s\n%-30s:"%("Enter Date of Birth","(DD-MM-YYYY)"))
        if not UtilGp.isValidDate(dob):
            print("Invalid Date Format")
            Shop.showFailure()
            return
        dob = dob + ' 00:00:00'
        dobDate = UtilGp.strToDate(dob)
        if UtilGp.age(dobDate)<18:
            print("Minimum age to apply should be 18 years")
            Shop.showFailure()
            return
        netSalary=input("%-30s:"%"Enter Net Annual Salary")
        if not UtilGp.isValidDigit(netSalary,False):
            print("Invalid Salary Input")
            Shop.showFailure()
            return
        netSalary =float(netSalary)
        if netSalary < 300000:
            print("Minimum Salary to apply for Credit Card is Rs.300000.00")
            Shop.showFailure()
            return
        adharNo = input("%-30s:" % "ADHAAR Number")
        if not UtilGp.isValidDigit(adharNo,True,12):
            print("Invalid ADHAAR number")
            Shop.showFailure()
            return
        adharCount = DbCardData.countCardByAdhaar(ndb.dbCard,adharNo)
        if adharCount>0:
            print("Only one credit card per user is allowed")
            Shop.showFailure()
            return
        card = CardData(name,mobileNo,dobDate,netSalary,adharNo)
        card.preCardRegister()
        passCode=input("%-30s:" % "Select Your PIN (4-Digit)")
        if not UtilGp.isValidDigit(passCode,True,4):
            print("Invalid PIN format")
            Shop.showFailure()
            return
        card.passCode = passCode


        DbCardData.addToCard(card)
        print();print("Congratulation!\nYour SBI Credit Card is Approved.");print();
        UtilGp.printCaptionData(('Card No', 'Credit Limit', 'Card Type'),
                                (card.cardNo, UtilGp.priceToStr(card.creditLimit), card.cardType), 20)
        Shop.showFailure()