def get_titelzeile(kontakt, adresse):
    kontakt = frappe.get_doc("Contact", kontakt)
    adresse = frappe.get_doc("Address", adresse)
    titelzeile = '<b>'
    if kontakt.verstorben == 1:
        if kontakt.salutation:
            titelzeile += kontakt.salutation + " "
        titelzeile += kontakt.first_name + " "
        titelzeile += kontakt.last_name + " (verstorben"
        if kontakt.verstorben_am:
            titelzeile += " am " + formatdate(kontakt.verstorben_am) + "), "
        else:
            titelzeile += "), "
        if kontakt.geburtsdatum:
            titelzeile += "geboren am " + formatdate(
                kontakt.geburtsdatum) + ", "
        titelzeile += adresse.address_line1 + " "
        titelzeile += adresse.plz + " "
        titelzeile += adresse.city + "</b>"
        return titelzeile
    else:
        if kontakt.salutation:
            titelzeile += kontakt.salutation + " "
        titelzeile += kontakt.first_name + " "
        titelzeile += kontakt.last_name + ", "
        if kontakt.geburtsdatum:
            titelzeile += "geboren am " + formatdate(
                kontakt.geburtsdatum) + ", "
        titelzeile += adresse.address_line1 + " "
        titelzeile += adresse.plz + " "
        titelzeile += adresse.city + "</b>"
        return titelzeile
Example #2
0
    def test_make_schedule(self):
        ms = make_maintenance_schedule()
        ms.save()
        i = ms.items[0]
        expected_dates = []
        expected_end_date = add_days(i.start_date, i.no_of_visits * 7)
        self.assertEqual(i.end_date, expected_end_date)

        i.no_of_visits = 2
        ms.save()
        expected_end_date = add_days(i.start_date, i.no_of_visits * 7)
        self.assertEqual(i.end_date, expected_end_date)

        items = ms.get_pending_data(data_type="items")
        items = items.split('\n')
        items.pop(0)
        expected_items = ['_Test Item']
        self.assertTrue(items, expected_items)

        # "dates" contains all generated schedule dates
        dates = ms.get_pending_data(data_type="date", item_name=i.item_name)
        dates = dates.split('\n')
        dates.pop(0)
        expected_dates.append(
            formatdate(add_days(i.start_date, 7), "dd-MM-yyyy"))
        expected_dates.append(
            formatdate(add_days(i.start_date, 14), "dd-MM-yyyy"))

        # test for generated schedule dates
        self.assertEqual(dates, expected_dates)

        ms.submit()
        s_id = ms.get_pending_data(data_type="id",
                                   item_name=i.item_name,
                                   s_date=expected_dates[1])
        test = make_maintenance_visit(source_name=ms.name,
                                      item_name="_Test Item",
                                      s_id=s_id)
        visit = frappe.new_doc('Maintenance Visit')
        visit = test
        visit.maintenance_schedule = ms.name
        visit.maintenance_schedule_detail = s_id
        visit.completion_status = "Partially Completed"
        visit.set('purposes', [{
            'item_code': i.item_code,
            'description': "test",
            'work_done': "test",
            'service_person': "Sales Team",
        }])
        visit.save()
        visit.submit()
        ms = frappe.get_doc('Maintenance Schedule', ms.name)

        #checks if visit status is back updated in schedule
        self.assertTrue(ms.schedules[1].completion_status,
                        "Partially Completed")
Example #3
0
def _get_print_details_row(filters):
    from_date = formatdate(filters.get('from_date'), 'dd-mm-yyyy')
    to_date = formatdate(filters.get('to_date'), 'dd-mm-yyyy')
    printed_on = now_datetime().strftime('%d-%m-%Y %H:%M:%S')

    return [
        {},
        {'project': "'From Date: {}'".format(from_date)},
        {'project': "'To Date: {}'".format(to_date)},
        {'project': "'Printed On: {}'".format(printed_on)}
    ]
Example #4
0
def get_usage_info():
    """Get data to show for Usage Info"""
    # imported here to prevent circular import
    from frappe.email.queue import get_emails_sent_this_month

    limits = get_limits()
    if not (limits and any([limits.users, limits.space, limits.emails, limits.expiry])):
        # no limits!
        return

    limits.space = (limits.space or 0) * 1024.0  # to MB
    if not limits.space_usage:
        # hack! to show some progress
        limits.space_usage = {"database_size": 26, "files_size": 1, "backup_size": 1, "total": 28}

    usage_info = frappe._dict(
        {
            "limits": limits,
            "enabled_users": len(get_enabled_system_users()),
            "emails_sent": get_emails_sent_this_month(),
            "space_usage": limits.space_usage["total"],
        }
    )

    if limits.expiry:
        usage_info["expires_on"] = formatdate(limits.expiry)
        usage_info["days_to_expiry"] = (getdate(limits.expiry) - getdate()).days

    if limits.upgrade_url:
        usage_info["upgrade_url"] = get_upgrade_url(limits.upgrade_url)

    return usage_info
Example #5
0
def get_expiry_message():
    if "System Manager" not in frappe.get_roles():
        return ""

    limits = get_limits()
    if not limits.expiry:
        return ""

    expires_on = getdate(get_limits().get("expiry"))
    today = now_datetime().date()

    message = ""
    if today > expires_on:
        message = _("Your subscription has expired.")
    else:
        days_to_expiry = (expires_on - today).days

        if days_to_expiry == 0:
            message = _("Your subscription will expire today.")

        elif days_to_expiry == 1:
            message = _("Your subscription will expire tomorrow.")

        elif days_to_expiry <= EXPIRY_WARNING_DAYS:
            message = _("Your subscription will expire on {0}.").format(formatdate(expires_on))

    if message and limits.upgrade_url:
        upgrade_link = get_upgrade_link(limits.upgrade_url)
        message += " " + _("To renew, {0}.").format(upgrade_link)

    return message
def get_usage_info():
	'''Get data to show for Usage Info'''
	# imported here to prevent circular import
	from frappe.email.queue import get_emails_sent_this_month

	limits = get_limits()
	if not (limits and any([limits.users, limits.space, limits.emails, limits.expiry])):
		# no limits!
		return

	limits.space = (limits.space or 0) * 1024.0 # to MB
	if not limits.space_usage:
		# hack! to show some progress
		limits.space_usage = {
			'database_size': 26,
			'files_size': 1,
			'backup_size': 1,
			'total': 28
		}

	usage_info = frappe._dict({
		'limits': limits,
		'enabled_users': len(get_enabled_system_users()),
		'emails_sent': get_emails_sent_this_month(),
		'space_usage': limits.space_usage['total'],
	})

	if limits.expiry:
		usage_info['expires_on'] = formatdate(limits.expiry)
		usage_info['days_to_expiry'] = (getdate(limits.expiry) - getdate()).days

	if limits.upgrade_url:
		usage_info['upgrade_url'] = get_upgrade_url(limits.upgrade_url)

	return usage_info
def get_expiry_message():
	if "System Manager" not in frappe.get_roles():
		return ""

	limits = get_limits()
	if not limits.expiry:
		return ""

	expires_on = getdate(get_limits().get("expiry"))
	today = now_datetime().date()

	message = ""
	if today > expires_on:
		message = _("Your subscription has expired.")
	else:
		days_to_expiry = (expires_on - today).days

		if days_to_expiry == 0:
			message = _("Your subscription will expire today.")

		elif days_to_expiry == 1:
			message = _("Your subscription will expire tomorrow.")

		elif days_to_expiry <= EXPIRY_WARNING_DAYS:
			message = _("Your subscription will expire on {0}.").format(formatdate(expires_on))

	if message and limits.upgrade_url:
		upgrade_link = get_upgrade_link(limits.upgrade_url)
		message += ' ' + _('To renew, {0}.').format(upgrade_link)

	return message
Example #8
0
def check_if_expired():
	"""check if account is expired. If expired, do not allow login"""
	if not has_expired():
		return

	limits = get_limits()
	expiry = limits.get("expiry")

	if not expiry:
		return

	expires_on = formatdate(limits.get("expiry"))
	support_email = limits.get("support_email")

	if limits.upgrade_url:
		message = _("""Your subscription expired on {0}. To renew, {1}.""").format(expires_on, get_upgrade_link(limits.upgrade_url))

	elif support_email:
		message = _("""Your subscription expired on {0}. To renew, please send an email to {1}.""").format(expires_on, support_email)

	else:
		# no recourse just quit
		return

	frappe.throw(message, SiteExpiredError)
Example #9
0
def generate_so(so_date):
    frappe.errprint(so_date)
    closure_list = frappe.db.get_list(
        "Closure",
        filters={"sales_order_confirmed_date": formatdate(so_date)},
        fields=("name", "candidate", "name1", "candidate_sc", "client_sc"))
    return closure_list
Example #10
0
def check_if_expired():
	"""check if account is expired. If expired, do not allow login"""
	if not has_expired():
		return

	limits = get_limits()
	expiry = limits.get("expiry")

	if not expiry:
		return

	expires_on = formatdate(limits.get("expiry"))
	support_email = limits.get("support_email")

	if limits.upgrade_url:
		message = _("""Your subscription expired on {0}. To renew, {1}.""").format(expires_on, get_upgrade_link(limits.upgrade_url))

	elif support_email:
		message = _("""Your subscription expired on {0}. To renew, please send an email to {1}.""").format(expires_on, support_email)

	else:
		# no recourse just quit
		return

	frappe.throw(message, SiteExpiredError)
Example #11
0
def get_deckblat_data(mandat):
	data = {}
	if mandat:
		mandat = frappe.get_doc("Mandat", mandat)
		if mandat.kontakt:
			patienten_kontakt = frappe.get_doc("Contact", mandat.kontakt)
			data["name_klient"] = patienten_kontakt.first_name + " " + patienten_kontakt.last_name
			data["geburtsdatum_klient"] = formatdate(string_date=patienten_kontakt.geburtsdatum, format_string='dd.mm.yyyy')
		else:
			data["name_klient"] = ''
			data["geburtsdatum_klient"] = ''
		employee = frappe.db.sql("""SELECT `name` FROM `tabEmployee` WHERE `user_id` = '{owner}'""".format(owner=frappe.session.user), as_dict=True)
		if len(employee) > 0:
			data["beraterin"] = employee[0].name
		else:
			data["beraterin"] = ''
		if mandat.rsv:
			data["rsv"] = mandat.rsv
		else:
			data["rsv"] = ''
		if mandat.rsv_kontakt:
			data["rsv_kontakt"] = mandat.rsv_kontakt
		else:
			data["rsv_kontakt"] = ''
			
		return data
	else:
		return False
Example #12
0
def send_present_alert(employee, name, in_time,date,out_time):
    recipients = frappe.get_value("Employee", employee, "cell_number")
    if recipients:
        if not in_time:
            in_time ="NIL"
        if not out_time:
            out_time = "NIL"    
        message="""Attendance Alert for %s
        Dear %s,
        Info:
        In Time:%s 
        Out Time:%s
        ESE ERP""" % (formatdate(date),name, in_time,out_time)
        rcv = []
        rcv.append(recipients)
        sender = 'ESE ERP SYS'
        send_sms(rcv, message,sender_name=sender)
Example #13
0
    def make_gl_entries_for_rebate(self, si_list):

        default_currency = frappe.get_value('Company', self.company,
                                            'default_currency')
        cost_center = self.cost_center or frappe.get_cached_value(
            'Company', self.company, "cost_center")
        date_format = frappe.db.get_single_value('System Settings',
                                                 'date_format')
        jv_main = {
            "company":
            self.company,
            "voucher_type":
            "Journal Entry",
            "is_opening":
            "No",
            "remark":
            " Customer rebate paid against period {from_date} to {to_date}.".
            format(from_date=formatdate(self.from_date, date_format),
                   to_date=formatdate(self.to_date, date_format)) +
            "\n List of updated sales invoices are:\n" + si_list,
            "title":
            "Rebate from {from_date} to {to_date}".format(
                from_date=formatdate(self.from_date, date_format),
                to_date=formatdate(self.to_date, date_format)),
            "total_debit":
            self.total_discount,
            "total_credit":
            self.total_discount,
            "posting_date":
            getdate(nowdate()),
            "account_currency":
            default_currency,
        }

        credit_account = self.default_receivable_account or frappe.get_cached_value(
            'Company', self.company, "default_receivable_account")
        debit_account = self.expense_account
        try:
            je = frappe.new_doc("Journal Entry")
            je.update(jv_main)
            for row in self.customer_rebate_detail:
                credit_party_balance = get_balance_on(party=row.customer,
                                                      party_type="Customer")
                credit_account_balance = get_balance_on(
                    account=credit_account, cost_center=cost_center)
                jv_credit_row = {
                    "account": credit_account,
                    "account_type": 'Receivable',
                    "account_balance": credit_account_balance,
                    "is_advance": "No",
                    "party_type": "Customer",
                    "party": row.customer,
                    "against_account": self.expense_account,
                    "credit": row.rebate_amount,
                    "credit_in_account_currency": row.rebate_amount,
                    "party_balance": credit_party_balance,
                }
                debit_account_balance = get_balance_on(
                    account=debit_account, cost_center=self.cost_center)
                jv_debit_row = {
                    "account": debit_account,
                    "account_type": 'Expense Account',
                    "account_balance": debit_account_balance,
                    "is_advance": "No",
                    "party": "",
                    "party_type": "",
                    "debit": row.rebate_amount,
                    "debit_in_account_currency": row.rebate_amount,
                    "cost_center": cost_center,
                }
                je.append("accounts", jv_credit_row)
                je.append("accounts", jv_debit_row)
            je.save()
            je.submit()
            frappe.db.commit()
            return je.name
        except:
            frappe.db.rollback()
            title = _("Error while processing customer rebate for {0}").format(
                self.name)
            traceback = frappe.get_traceback()
            frappe.log_error(message=traceback, title=title)
            sendmail_to_system_managers(title, traceback)
            return False
Example #14
0
    def test_make_schedule(self):
        ms = make_maintenance_schedule()
        ms.save()
        i = ms.items[0]
        expected_dates = []
        expected_end_date = add_days(i.start_date, i.no_of_visits * 7)
        self.assertEqual(i.end_date, expected_end_date)

        i.no_of_visits = 2
        ms.save()
        expected_end_date = add_days(i.start_date, i.no_of_visits * 7)
        self.assertEqual(i.end_date, expected_end_date)

        items = ms.get_pending_data(data_type="items")
        items = items.split("\n")
        items.pop(0)
        expected_items = ["_Test Item"]
        self.assertTrue(items, expected_items)

        # "dates" contains all generated schedule dates
        dates = ms.get_pending_data(data_type="date", item_name=i.item_name)
        dates = dates.split("\n")
        dates.pop(0)
        expected_dates.append(
            formatdate(add_days(i.start_date, 7), "dd-MM-yyyy"))
        expected_dates.append(
            formatdate(add_days(i.start_date, 14), "dd-MM-yyyy"))

        # test for generated schedule dates
        self.assertEqual(dates, expected_dates)

        ms.submit()
        s_id = ms.get_pending_data(data_type="id",
                                   item_name=i.item_name,
                                   s_date=expected_dates[1])

        # Check if item is mapped in visit.
        test_map_visit = make_maintenance_visit(source_name=ms.name,
                                                item_name="_Test Item",
                                                s_id=s_id)
        self.assertEqual(len(test_map_visit.purposes), 1)
        self.assertEqual(test_map_visit.purposes[0].item_name, "_Test Item")

        visit = frappe.new_doc("Maintenance Visit")
        visit = test_map_visit
        visit.maintenance_schedule = ms.name
        visit.maintenance_schedule_detail = s_id
        visit.completion_status = "Partially Completed"
        visit.set(
            "purposes",
            [{
                "item_code": i.item_code,
                "description": "test",
                "work_done": "test",
                "service_person": "Sales Team",
            }],
        )
        visit.save()
        visit.submit()
        ms = frappe.get_doc("Maintenance Schedule", ms.name)

        # checks if visit status is back updated in schedule
        self.assertTrue(ms.schedules[1].completion_status,
                        "Partially Completed")
        self.assertEqual(format_date(visit.mntc_date),
                         format_date(ms.schedules[1].actual_date))

        # checks if visit status is updated on cancel
        visit.cancel()
        ms.reload()
        self.assertTrue(ms.schedules[1].completion_status, "Pending")
        self.assertEqual(ms.schedules[1].actual_date, None)