def register_user(email,password,username): user_data = Database.find_one("users", {"email": email}) # Password in sha512 -> pbkdf if user_data is not None: raise UserErrors.UserAlreadyRegistered("The e-mail you registered already exists") if not Utils.email_is_valid(email): raise UserErrors.InvalidEmailError("The email does not have right format") User(email, Utils.hash_password(password), username).save_to_db() return True
def backup(): """try: os.mkdir("C:\\Users\\kunjm\\Desktop\\Drives\Projects\\Invoices\\backup"+self.date) except: print("Directory Ecist") """ z = datetime.datetime.strftime(Utils.current_time(), "%d-%m-%Y") if os.path.exists( "C:\\Users\\kunjm\\Desktop\\Drives\Projects\\Invoices\\backup\\" + z): shutil.rmtree( "C:\\Users\\kunjm\\Desktop\\Drives\Projects\\Invoices\\backup\\" + z) print("ok") f = open("C:\\Users\\kunjm\\Desktop\\second.bat", 'w') f.write( "mongodump --db fullstack --out C:\\Users\\kunjm\\Desktop\\Drives\Projects\\Invoices\\backup\\" + z) f.close() subprocess.call([r'C:\Users\kunjm\Desktop\second.bat']) x = open("C:\\Users\\kunjm\\Desktop\\third.bat", 'w') # old = x.read() x.write( "mongorestore --db fullstack --drop C:\\Users\\kunjm\\Desktop\\Drives\\Projects\\Invoices\\backup\\" + z + "\\fullstack") x.close()
def is_login_valid(email, password): user_data = Database.find_one(UserConstants.COLLECTION,{"email":email}) #Password in sha512 -> pbkdf print(email) if user_data is None: raise UserErrors.UserNotExistsError("Your user does not exist") #print(user_data) if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Your password was wrong") return True
def __init__(self, no, party_id, total_amount, date=None, narration=None, e_way=None,_id=None): self.no = no self.party_id = party_id if type(date) is not datetime.datetime: print("inside") self.date = Utils.current_time() if date is None else datetime.datetime.strptime(date,"%d-%m-%Y") else: print("outside") self.date =date self._id = uuid.uuid4().hex if _id is None else _id self.narration = narration self.total_amount = total_amount self.e_way = e_way
def backup(): try: os.mkdir("C:\\Users\\Dell\\Desktop\\Projects\\Invoices\\backup") except: print("Directory Exist") z = datetime.datetime.strftime(Utils.current_time(), "%d-%m-%Y") if os.path.exists("C:\\Users\\Dell\\Desktop\\Projects\\Invoices\\backup\\" + z): shutil.rmtree("C:\\Users\\Dell\\Desktop\\Projects\\Invoices\\backup\\" + z) print("ok") f = open("C:\\Users\\Dell\\Desktop\\second.bat", 'w') f.write("mongodump --db office_test_1 --out C:\\Users\\Dell\\Desktop\\Projects\\Invoices\\backup\\" + z) f.close() subprocess.call([r'C:\Users\Dell\Desktop\second.bat']) x = open("C:\\Users\\Dell\\Desktop\\third.bat", 'w') # old = x.read() x.write("mongorestore --db office_test_1 --drop C:\\Users\\Dell\\Desktop\\Projects\\Invoices\\backup\\" + z + "\\office_test_1") x.close()
def make_workbook(self, gst, igst): len_gst = len(gst) len_igst = len(igst) wb = Workbook() x = datetime.datetime.strftime(self.start, '%d-%m-%Y') y = datetime.datetime.strftime(self.end, '%d-%m-%Y') c = Utils.current_time() c = datetime.datetime.strftime(c, '%d-%m-%Y') dest_filename = c + '_' + x + '_' + y + '_' + str(len_igst + len_gst) + '.xlsx' ws1 = wb.active ws1.title = "GST" for row in range(len_gst): ws1.append(gst[row]) ws1['M' + str(row + 1)].alignment = styles.Alignment(wrap_text=True) wb["GST"].freeze_panes = "A2" ws2 = wb.create_sheet('IGST') for row in range(len_igst): ws2.append(igst[row]) ws2['L' + str(row + 1)].alignment = styles.Alignment(wrap_text=True) wb["IGST"].freeze_panes = "A2" wb.save("C:\\Users\\Dell\\Desktop\\" + dest_filename) #Database.initialize() #start = datetime.datetime.strptime('27-01-2019','%d-%m-%Y') #end = datetime.datetime.strptime('27-08-2019','%d-%m-%Y') #x = Excel_export(start,end).make_sheet() #print(x.gst) #print(x.igst)
def __init__(self, date=None, _id=None): self.date = date if date is not None else datetime.datetime.strftime( Utils.current_time(), "%d-%m-%Y") self._id = uuid.uuid4().hex if _id is None else _id
def print_invoice(invoice_id): print(invoice_id) company = Company.get_company() company[0].address = format(company[0].address) company[0].address = Utils.format_address(company[0].address) invoice = Invoice.get_by_id(invoice_id) if (invoice is None): invoice = Invoice.get_by_no(invoice_id) invoice_id = invoice._id invoice.date = datetime.datetime.strftime(invoice.date, "%d-%m-%Y") invoice_items = Invoice_item.get_by_invoice_id(invoice_id) invoice_package = {} invoice_package['invoice'] = invoice #invoice_package.append(invoice) party = Party.get_by_id(invoice.party_id) party.address = Utils.format_address(party.address) invoice_package['party'] = party tax_type = party.tax_type() tax, igst, round_off, total_amount, hsn_taxable_tot, total_quantity = 0.0, 0.0, 0.0, 0.0, 0.0, 0 hsn_list = {} invoice_package['invoice_items'] = [] sr = 0 for invoice_item in invoice_items: sr += 1 serial_no = Serial_no.get_by_invoice_item_id(invoice_item._id) total_quantity += invoice_item.quantity #invoice_package.append([invoice_item,serial_no]) item = Item.get_by_id(invoice_item.item_id) print(item.type_id) amount_item = int(invoice_item.quantity) * float(invoice_item.rate_per) if item.hsn not in hsn_list: hsn_list[item.hsn] = [0, invoice_item.rate_per, 0, 0, item.tax] if tax_type == "gst": tax1 = amount_item * float(item.tax) / 200 total_amount += (tax1 * 2) else: tax1 = amount_item * float(item.tax) / 100 total_amount += tax1 hsn_list[item.hsn][2] += tax1 hsn_list[item.hsn][0] += amount_item if tax_type == "gst": hsn_list[item.hsn][3] += tax1 * 2 else: hsn_list[item.hsn][3] += tax1 hsn_taxable_tot += amount_item tax += tax1 print('Type_obj', item.type_id) item.type_id = Type.get_by_id(item.type_id) print(item.type_id) print() invoice_package['invoice_items'].append({ "invoice_item": invoice_item, "item": item, "serial_no": serial_no, "amount": amount_item, "sr_no": sr }) if tax_type == "gst": x = tax * 2 else: x = tax invoice_package['total_tax_amount'] = x total = hsn_taxable_tot + x round_off = abs(round(total) - total) invoice_package['hsn_taxable_total'] = hsn_taxable_tot invoice_package['tax'] = tax invoice_package['total_items'] = len(invoice_items) invoice_package['round_off'] = round_off invoice_package['total'] = total invoice_package['tax_type'] = tax_type invoice_package['company'] = company[0] invoice_package['total_words'] = Utils.get_currency_words(total) if tax_type == "gst": invoice_package['tax_words'] = Utils.get_currency_words(tax * 2) else: invoice_package['tax_words'] = Utils.get_currency_words(tax) invoice_package['hsn_list'] = hsn_list invoice_package['total_quantity'] = total_quantity #for i in invoice_package: # print(i,invoice_package[i]) #print() #for i in invoice_package['invoice_items']: # print(i) print(invoice_package['hsn_list']) #print(company[0].address) #print(party.address) return render_template('invoices/invoice_print.jinja2', invoice_package=invoice_package)