Exemple #1
0
def run_accounts(current_date):
	if can_make("Sales Invoice"):
		from selling.doctype.sales_order.sales_order import make_sales_invoice
		report = "Ordered Items to be Billed"
		for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Sales Invoice")]:
			si = webnotes.bean(make_sales_invoice(so))
			si.doc.posting_date = current_date
			for d in si.doclist.get({"parentfield": "entries"}):
				if not d.income_account:
					d.income_account = "Sales - {}".format(company_abbr)
			
			si.insert()
			si.submit()
			webnotes.conn.commit()

	if can_make("Purchase Invoice"):
		from stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
		report = "Received Items to be Billed"
		for pr in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Invoice")]:
			pi = webnotes.bean(make_purchase_invoice(pr))
			pi.doc.posting_date = current_date
			pi.doc.bill_no = random_string(6)
			pi.insert()
			pi.submit()
			webnotes.conn.commit()
			
	if can_make("Payment Received"):
		from accounts.doctype.journal_voucher.journal_voucher import get_payment_entry_from_sales_invoice
		report = "Accounts Receivable"
		for si in list(set([r[4] for r in query_report.run(report, {"report_date": current_date })["result"] if r[3]=="Sales Invoice"]))[:how_many("Payment Received")]:
			jv = webnotes.bean(get_payment_entry_from_sales_invoice(si))
			jv.doc.posting_date = current_date
			jv.doc.cheque_no = random_string(6)
			jv.doc.cheque_date = current_date
			jv.insert()
			jv.submit()
			webnotes.conn.commit()
			
	if can_make("Payment Made"):
		from accounts.doctype.journal_voucher.journal_voucher import get_payment_entry_from_purchase_invoice
		report = "Accounts Payable"
		for pi in list(set([r[4] for r in query_report.run(report, {"report_date": current_date })["result"] if r[3]=="Purchase Invoice"]))[:how_many("Payment Made")]:
			jv = webnotes.bean(get_payment_entry_from_purchase_invoice(pi))
			jv.doc.posting_date = current_date
			jv.doc.cheque_no = random_string(6)
			jv.doc.cheque_date = current_date
			jv.insert()
			jv.submit()
			webnotes.conn.commit()
Exemple #2
0
	def send_welcome_mail(self):
		"""send welcome mail to user with password and login url"""

		from webnotes.utils import random_string, get_url

		self.doc.reset_password_key = random_string(32)
		link = get_url("/update-password?key=" + self.doc.reset_password_key)
		
		txt = """
%(company)s

Dear %(first_name)s,

A new account has been created for you. 

Your login id is: %(user)s

To complete your registration, please click on the link below:

<a href="%(link)s">%(link)s</a>

Thank you,<br>
%(user_fullname)s
		"""
		self.send_login_mail("Welcome to MedSynaptic" , txt, 
			{ "link": link })
Exemple #3
0
	def send_welcome_mail(self):
		from webnotes.utils import random_string, get_url

		self.doc.reset_password_key = random_string(32)
		link = get_url("/update-password?key=" + self.doc.reset_password_key)

		self.send_login_mail("Verify Your Account", "templates/emails/new_user.html", {"link": link})
Exemple #4
0
def sign_up(email, full_name):
    profile = webnotes.conn.get("Profile", {"email": email})
    if profile:
        if profile.disabled:
            return _("Registered but disabled.")
        else:
            return _("Already Registered")
    else:
        if webnotes.conn.sql(
                """select count(*) from tabProfile where 
			TIMEDIFF(%s, modified) > '1:00:00' """, now())[0][0] > 200:
            raise Exception, "Too Many New Profiles"
        from webnotes.utils import random_string
        profile = webnotes.bean({
            "doctype": "Profile",
            "email": email,
            "first_name": full_name,
            "enabled": 1,
            "new_password": random_string(10),
            "user_type": "Website User",
            "send_invite_email": 1
        })
        profile.ignore_permissions = True
        profile.insert()
        return _("Registration Details Emailed.")
Exemple #5
0
def sign_up(email, full_name):
    profile = webnotes.conn.get("Profile", {"email": email})
    if profile:
        if profile.disabled:
            return _("Registered but disabled.")
        else:
            return _("Already Registered")
    else:
        if (
            webnotes.conn.sql(
                """select count(*) from tabProfile where 
			TIMEDIFF(%s, modified) > '1:00:00' """,
                now(),
            )[0][0]
            > 200
        ):
            raise Exception, "Too Many New Profiles"
        from webnotes.utils import random_string

        profile = webnotes.bean(
            {
                "doctype": "Profile",
                "email": email,
                "first_name": full_name,
                "enabled": 1,
                "new_password": random_string(10),
                "user_type": "Website User",
            }
        )
        profile.ignore_permissions = True
        profile.insert()
        return _("Registration Details Emailed.")
Exemple #6
0
    def reset_password(self):
        from webnotes.utils import random_string, get_url

        key = random_string(32)
        webnotes.conn.set_value("Profile", self.doc.name, "reset_password_key",
                                key)
        self.password_reset_mail(get_url("/update-password?key=" + key))
Exemple #7
0
	def send_welcome_mail(self):
		"""send welcome mail to user with password and login url"""

		from webnotes.utils import random_string, get_url

		self.doc.reset_password_key = random_string(32)
		link = get_url("/update-password?key=" + self.doc.reset_password_key)
		
		txt = """
## %(company)s

Dear %(first_name)s,

A new account has been created for you. 

Your login id is: %(user)s

To complete your registration, please click on the link below:

<a href="%(link)s">%(link)s</a>

Thank you,<br>
%(user_fullname)s
		"""
		self.send_login_mail("Welcome to " + webnotes.get_config().get("app_name"), txt, 
			{ "link": link })
Exemple #8
0
def run_accounts(current_date):
	if can_make("Sales Invoice"):
		from selling.doctype.sales_order.sales_order import make_sales_invoice
		report = "Ordered Items to be Billed"
		for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Sales Invoice")]:
			si = webnotes.bean(make_sales_invoice(so))
			si.doc.posting_date = current_date
			si.insert()
			si.submit()
			webnotes.conn.commit()

	if can_make("Purchase Invoice"):
		from stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
		report = "Received Items to be Billed"
		for pr in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Invoice")]:
			pi = webnotes.bean(make_purchase_invoice(pr))
			pi.doc.posting_date = current_date
			pi.doc.bill_no = random_string(6)
			pi.insert()
			pi.submit()
			webnotes.conn.commit()
			
	if can_make("Payment Received"):
		from accounts.doctype.journal_voucher.journal_voucher import get_payment_entry_from_sales_invoice
		report = "Accounts Receivable"
		for si in list(set([r[4] for r in query_report.run(report, {"report_date": current_date })["result"] if r[3]=="Sales Invoice"]))[:how_many("Payment Received")]:
			jv = webnotes.bean(get_payment_entry_from_sales_invoice(si))
			jv.doc.posting_date = current_date
			jv.doc.cheque_no = random_string(6)
			jv.doc.cheque_date = current_date
			jv.insert()
			jv.submit()
			webnotes.conn.commit()
			
	if can_make("Payment Made"):
		from accounts.doctype.journal_voucher.journal_voucher import get_payment_entry_from_purchase_invoice
		report = "Accounts Payable"
		for pi in list(set([r[4] for r in query_report.run(report, {"report_date": current_date })["result"] if r[3]=="Purchase Invoice"]))[:how_many("Payment Made")]:
			jv = webnotes.bean(get_payment_entry_from_purchase_invoice(pi))
			jv.doc.posting_date = current_date
			jv.doc.cheque_no = random_string(6)
			jv.doc.cheque_date = current_date
			jv.insert()
			jv.submit()
			webnotes.conn.commit()
Exemple #9
0
	def reset_password(self):
		"""reset password"""
		from webnotes.utils import random_string, now
		pwd = random_string(8)
		
		# update tab Profile
		webnotes.conn.sql("""UPDATE tabProfile SET password=password(%s), modified=%s 
			WHERE name=%s""", (pwd, now(), self.name))

		return pwd
Exemple #10
0
def get_conf_params(db_name=None, db_password=None):
	if not db_name:
		db_name = raw_input("Database Name: ")
		if not db_name:
			raise Exception("Database Name Required")
	
	if not db_password:
		from webnotes.utils import random_string
		db_password = random_string(16)
	
	return {"db_name": db_name, "db_password": db_password}
Exemple #11
0
def get_conf_params(db_name=None, db_password=None):
    if not db_name:
        db_name = raw_input("Database Name: ")
        if not db_name:
            raise Exception("Database Name Required")

    if not db_password:
        from webnotes.utils import random_string
        db_password = random_string(16)

    return {"db_name": db_name, "db_password": db_password}
Exemple #12
0
def reset_password():
    from webnotes.model.code import get_obj
    from webnotes.utils import random_string

    user = webnotes.form_dict.get('user', '')
    if webnotes.conn.sql("""select name from tabProfile where name=%s""",
                         user):
        new_password = random_string(8)
        webnotes.conn.sql(
            """update `__Auth` set password=password(%s)
			where `user`=%s""", (new_password, user))

        # Hack!
        webnotes.session["user"] = "******"
        profile = get_obj("Profile", user)
        profile.password_reset_mail(new_password)
        webnotes.msgprint("Password has been reset and sent to your email id.")
    else:
        webnotes.msgprint("No such user (%s)" % user)
Exemple #13
0
def reset_password():
	from webnotes.model.code import get_obj
	from webnotes.utils import random_string
	
	user = webnotes.form_dict.get('user', '')
	if user in ["*****@*****.**", "Administrator"]:
		webnotes.msgprint("Not allowed", raise_exception=1)
		
	if webnotes.conn.sql("""select name from tabProfile where name=%s""", user):
		new_password = random_string(8)
		webnotes.conn.sql("""update `__Auth` set password=password(%s)
			where `user`=%s""", (new_password, user))

		# Hack!
		webnotes.session["user"] = "******"
		profile = get_obj("Profile", user)
		profile.password_reset_mail(new_password)
		webnotes.msgprint("Password has been reset and sent to your email id.")
	else:
		webnotes.msgprint("No such user (%s)" % user)
Exemple #14
0
	def reset_password(self):
		from webnotes.utils import random_string, get_url

		key = random_string(32)
		webnotes.conn.set_value("Profile", self.doc.name, "reset_password_key", key)
		self.password_reset_mail(get_url("/update-password?key=" + key))