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 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.º 3
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.º 4
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.º 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 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.º 7
0
 def loadTranByItem(self, valueCard, IsMsg=True):
     if (IsMsg): print("Loading T DataBase...")
     self.dbTran = DbTranData.readTrans(valueCard, True, self.dbItem)
     if (IsMsg): print("Loaded T DataBase%d!" % len(self.dbTran))