Пример #1
0
 def lastmonthbal(self, mon):
     if not password.askpass():
         return
     d = dt.date.today()
     if mon == -1:
         d = d.replace(day=1) - dt.timedelta(days=1)
     dayreport.dayrep.print_monthreport(d)
Пример #2
0
 def purchasepay(self):
     if not password.askpass("admin"):
         tkMessageBox.showerror("wrong password", "try again")
         return
     con = cdb.Db().connection()
     cur = con.cursor()
     sql = "select * from seller order by name;"
     cur.execute(sql)
     stockists = cur.fetchall()
     items = ["   PURCHASE PAYMENT", " "]
     for stockist in stockists:
         sql="select count(amount), sum(amount) ,group_concat(amount) from purchase "\
          "where date < date_format(now(),'%Y-%m-01') and paid!=1 and seller="+str(stockist[0])+";"
         print sql
         cur.execute(sql)
         if cur.rowcount > 0:
             res = cur.fetchone()
             count = res[0]
             amount = res[1]
             bills = res[2]
             if count > 0:
                 item = " {:30s}{:10.2f} ::{}".format(
                     stockist[1] + " (" + str(count) + ")", amount, bills)
                 items.append(item)
                 sql = "update purchase set paid=1 where seller=" + str(
                     stockist[0]
                 ) + " and date<date_format(now(),'%Y-%m-01');"
                 cur.execute(sql)
     con.commit()
     printer.printinfo(items)
Пример #3
0
 def monthreport(self):
     if not password.askpass("admin"):
         tkMessageBox.showerror("error", "wrong password")
         return
     con = cdb.Db().connection()
     cur = con.cursor()
     sql = "select min(id), max(id) from bill where year(date)=year(current_date-interval 1 month) and month(date)=month(current_date-interval 1 month);"
     cur.execute(sql)
     row = cur.fetchone()
     (firstid, lastid) = (row[0], row[1])
     sql = "select date, sum(net) from bill where year(date)=year(current_date-interval 1 month) and month(date)=month(current_date-interval 1 month) group by date;"
     cur.execute(sql)
     rows = cur.fetchall()
     lines = []
     today = dt.date.today()
     first = today.replace(day=1)
     lastmonth = first - dt.timedelta(days=1)
     mony = lastmonth.strftime("%Y %B")
     lines.append("Sale Report " + mony)
     lines.append(" ")
     lines.append("from bill #" + str(firstid) + " to #" + str(lastid))
     lines.append(" ")
     for r in rows:
         item = ' {}   {:10.2f}'.format(r[0], r[1])
         lines.append(item)
     printbill.printinfo(lines)
Пример #4
0
 def print_day_bills_summery(self):
     if not password.askpass("admin"):
         return
     sh = shelve.open("data.db")
     lines = []
     myar = sh['bills-yesterday']
     for l in myar['sale']:
         lines.append(" {:7d} - {:8.2f}".format(l[0], l[1]))
     printbill.printinfo(lines)
     sh.close()
Пример #5
0
 def edit(self, id):
     self.editcan.delete(ALL)
     if id == 0:
         return
     if not password.askpass("admin"):
         return ()
     f = Frame(self.editcan)
     con = cdb.Db().connection()
     cur = con.cursor()
     sql="select products.name,stock.id,stock.ini_count, stock.cur_count,stock.batch,stock.mrp, stock.expiry "\
      "from products join stock on products.id=stock.product where stock.id=%s;"
     cur.execute(sql, (id))
     row = cur.fetchone()
     Label(f, text="product").grid(row=0,
                                   column=0,
                                   sticky=E,
                                   padx=10,
                                   pady=5)
     Label(f, text=row[0]).grid(row=0, column=1, sticky=W, padx=10, pady=5)
     Label(f, text="batch").grid(row=1, column=0, sticky=E, padx=10, pady=5)
     Label(f, text=row[4]).grid(row=1, column=1, sticky=W, padx=10, pady=5)
     Label(f, text="stock").grid(row=2, column=0, sticky=E, padx=10, pady=5)
     f.count = IntVar()
     f.count.set(row[3])
     Entry(f, textvariable=f.count, width=5).grid(row=2,
                                                  column=1,
                                                  sticky=W,
                                                  padx=10,
                                                  pady=5)
     Label(f, text="price").grid(row=3, column=0, sticky=E, padx=10, pady=5)
     f.price = DoubleVar()
     f.price.set(row[5])
     Entry(f, textvariable=f.price, width=5).grid(row=3,
                                                  column=1,
                                                  sticky=W,
                                                  padx=10,
                                                  pady=5)
     Label(f, text="expiry").grid(row=6,
                                  column=0,
                                  sticky=E,
                                  padx=10,
                                  pady=5)
     calpicker = cal.Calbutton(f, inidate=row[6])
     calpicker.grid(row=6, column=1, sticky=W)
     Button(f,
            text="save",
            command=lambda: self.savestock(row[1], f.count.get(
            ), f.price.get(), calpicker.get())).grid(row=7,
                                                     column=1,
                                                     sticky=W,
                                                     padx=10,
                                                     pady=5)
     self.editcan.create_window(1, 1, window=f, anchor=NW)
Пример #6
0
 def liststockists(self):
     if not password.askpass("admin"):
         tkMessageBox.showerror("error", "wrong password")
         return
     sql = "select name from stockist order by name;"
     lines = ["STOCKISTS", " "]
     con = cdb.Db().connection()
     cur = con.cursor()
     cur.execute(sql)
     result = cur.fetchall()
     for r in result:
         lines.append(r[0])
     printbill.printinfo(lines)
Пример #7
0
 def dayreport(self):
     if not password.askpass():
         tkMessageBox.showerror("wrong password", "try again")
         return
     sh = shelve.open("data.db")
     lines = ["     DAY REPORT", "     " + str(dt.date.today())]
     try:
         lastbill = sh['lastbill']
     except:
         lastbill = 0
     try:
         lastprint = sh['lastprint']
     except:
         lastprint = 0
     lines.append("report from bill#" + str(lastprint + 1) + " to #" +
                  str(lastbill))
     lines.append("")
     lines.append('sale     :' + "{0:.2f}".format(sh['sale']))
     lines.append('ip sale  :' + "{0:.2f}".format(sh['ipsale']))
     lines.append('self sale:' + "{0:.2f}".format(sh['selfsale']))
     lines.append('return   :' + "{0:.2f}".format(sh['return']))
     lines.append('discharge:' + "{0:.2f}".format(sh['discharge']))
     lines.append('purchase :' + "{0:.2f}".format(sh['purchase']))
     lines.append("")
     csvstring = "{},{},{},{},{},{},{},{},{}\n".format(
         str(dt.date.today()), lastprint + 1, lastbill, sh['sale'],
         sh['ipsale'], sh['selfsale'], sh['return'], sh['discharge'],
         sh['purchase'])
     printbill.printinfo(lines)
     sh['sale'] = 0
     sh['purchase'] = 0
     sh['return'] = 0
     sh['ipsale'] = 0
     sh['selfsale'] = 0
     sh['discharge'] = 0
     sh['lastprint'] = lastbill
     self.statusSale.set(sh['sale'])
     self.statusIp.set(sh['ipsale'])
     sh['bills-yesterday'] = sh['bills']
     myar = {"sale": [], "ipsale": []}
     sh['bills'] = myar
     sh.close()
     try:
         fil = open("dayreports.csv", "a")
         fil.write(csvstring)
         fil.close()
     except:
         pass
     self.restatus()
Пример #8
0
 def monthreport(self):
     if not password.askpass("admin"):
         tkMessageBox.showerror("error", "wrong password")
         return
     cur = cdb.Db().connection().cursor()
     cur.execute("select count(id),sum(amount) from bill where date >= date_format(current_date-interval 1 month, '%Y/%m/01') and "\
       "date <date_format(current_date,'%Y/%m/01')")
     r = cur.fetchone()
     lines = [
         "Report of Month " + (dt.date.today().replace(day=1) -
                               dt.timedelta(days=1)).strftime("%b"), " "
     ]
     lines.append("Number of bills: " + str(r[0]))
     lines.append("Total Value: " + str(r[1]))
     cur.execute("select count(bill.amount), sum(bill.amount) from bill join sponsorship on sponsorship.bill=bill.id "\
       "where bill.date >= date_format(current_date-interval 1 month, '%Y/%m/01') and bill.date <date_format(current_date,'%Y/%m/01')")
     r = cur.fetchone()
     lines.append("Number of free bills: " + str(r[0]))
     lines.append("Total value of free: " + str(r[1]))
     printer.printinfo(lines)
Пример #9
0
 def noprinter(self):
     if not password.askpass("admin"):
         return
     sh = shelve.open("data.db")
     sh['noprinter'] = self.debug.get()
Пример #10
0
 def dbparams(self):
     if password.askpass("admin"):
         win = cdb.DbVariables()
Пример #11
0
 def reviewbills(self):
     if password.askpass("admin"):
         review.Review(status="admin")
     else:
         review.Review()
Пример #12
0
 def dayclose(self):
     if not password.askpass():
         tkMessageBox.showerror("wrong password", "try again")
         return
     dayreport.dayrep.day_close()
Пример #13
0
 def editstock(self):
     if not password.askpass():
         return
     editstock.EditStock()
Пример #14
0
 def printout(self):
     if len(self.lines) == 0:
         return
     if not password.askpass("admin"):
         return
     printbill.printinfo(self.lines)
Пример #15
0
 def print_day_bills(self):
     if not password.askpass("admin"):
         return
     d = dt.date.today() - dt.timedelta(days=1)
     print_daybills(d)