示例#1
0
def get_party_details(address_name):
	d = frappe.get_all('Address', filters={'name': address_name}, fields=['*'])[0]

	if (not d.gstin
		or not d.city
		or not d.pincode
		or not d.address_title
		or not d.address_line1
		or not d.gst_state_number):

		frappe.throw(
			msg=_('Address lines, city, pincode, gstin is mandatory for address {}. Please set them and try again.').format(
				get_link_to_form('Address', address_name)
			),
			title=_('Missing Address Fields')
		)

	if d.gst_state_number == 97:
		# according to einvoice standard
		pincode = 999999

	return frappe._dict(dict(
		gstin=d.gstin,
		legal_name=sanitize_for_json(d.address_title),
		location=sanitize_for_json(d.city),
		pincode=d.pincode,
		state_code=d.gst_state_number,
		address_line1=sanitize_for_json(d.address_line1),
		address_line2=sanitize_for_json(d.address_line2)
	))
def get_common_email_args(doc):
    doctype = doc.get('doctype')
    docname = doc.get('name')

    email_template = get_email_template(doc)
    if email_template:
        subject = frappe.render_template(email_template.subject, vars(doc))
        response = frappe.render_template(email_template.response, vars(doc))
    else:
        subject = _('Workflow Action') + f" on {doctype}: {docname}"
        response = get_link_to_form(doctype, docname, f"{doctype}: {docname}")

    common_args = {
        'template':
        'workflow_action',
        'header':
        'Workflow Action',
        'attachments':
        [frappe.attach_print(doctype, docname, file_name=docname, doc=doc)],
        'subject':
        subject,
        'message':
        response
    }
    return common_args
示例#3
0
	def validate_event_subscriber(self):
		if not frappe.db.get_value("User", self.user, "api_key"):
			frappe.throw(
				_("Please generate keys for the Event Subscriber User {0} first.").format(
					frappe.bold(get_link_to_form("User", self.user))
				)
			)
示例#4
0
def get_common_email_args(doc):
    doctype = doc.get("doctype")
    docname = doc.get("name")

    email_template = get_email_template(doc)
    if email_template:
        subject = frappe.render_template(email_template.subject, vars(doc))
        response = frappe.render_template(email_template.response, vars(doc))
    else:
        subject = _("Workflow Action") + f" on {doctype}: {docname}"
        response = get_link_to_form(doctype, docname, f"{doctype}: {docname}")

    common_args = {
        "template":
        "workflow_action",
        "header":
        "Workflow Action",
        "attachments":
        [frappe.attach_print(doctype, docname, file_name=docname, doc=doc)],
        "subject":
        subject,
        "message":
        response,
    }
    return common_args
示例#5
0
def show_link_to_error_log(invoice, einvoice):
	err_log = log_error(einvoice)
	link_to_error_log = get_link_to_form('Error Log', err_log.name, 'Error Log')
	frappe.throw(
		_('An error occurred while creating e-invoice for {}. Please check {} for more information.').format(
			invoice.name, link_to_error_log),
		title=_('E Invoice Creation Failed')
	)
示例#6
0
	def validate_vacancies(self):
		staffing_plan = get_staffing_plan_detail(self.designation, self.company, self.offer_date)
		check_vacancies = frappe.get_single("HR Settings").check_vacancies
		if staffing_plan and check_vacancies:
			job_offers = self.get_job_offer(staffing_plan.from_date, staffing_plan.to_date)
			if not staffing_plan.get("vacancies") or cint(staffing_plan.vacancies) - len(job_offers) <= 0:
				error_variable = "for " + frappe.bold(self.designation)
				if staffing_plan.get("parent"):
					error_variable = frappe.bold(get_link_to_form("Staffing Plan", staffing_plan.parent))

				frappe.throw(_("There are no vacancies under staffing plan {0}").format(error_variable))
示例#7
0
 def validate_vacancies(self):
     staffing_plan = get_staffing_plan_detail(self.designation,
                                              self.company, self.offer_date)
     check_vacancies = frappe.get_single("HR Settings").check_vacancies
     if staffing_plan and check_vacancies:
         job_offers = self.get_job_offer(staffing_plan.from_date,
                                         staffing_plan.to_date)
         if staffing_plan.vacancies - len(job_offers) <= 0:
             frappe.throw(
                 _("There are no vacancies under staffing plan {0}").format(
                     frappe.bold(
                         get_link_to_form("Staffing Plan",
                                          staffing_plan.parent))))
示例#8
0
 def get_credentials(self):
     if self.invoice:
         gstin = self.get_seller_gstin()
         if not self.e_invoice_settings.enable:
             frappe.throw(
                 _("E-Invoicing is disabled. Please enable it from {} to generate e-invoices."
                   ).format(
                       get_link_to_form("E Invoice Settings",
                                        "E Invoice Settings")))
         credentials = next(d for d in self.e_invoice_settings.credentials
                            if d.gstin == gstin)
     else:
         credentials = self.e_invoice_settings.credentials[
             0] if self.e_invoice_settings.credentials else None
     return credentials
示例#9
0
 def validate_vacancies(self):
     staffing_plan = get_staffing_plan_detail(self.designation,
                                              self.company, self.offer_date)
     check_vacancies = frappe.get_single("HR Settings").check_vacancies
     if staffing_plan and check_vacancies:
         vacancies = frappe.db.get_value(
             "Staffing Plan Detail",
             filters={"name": staffing_plan.name},
             fieldname=['vacancies'])
         job_offers = len(
             self.get_job_offer(staffing_plan.from_date,
                                staffing_plan.to_date))
         if vacancies - job_offers <= 0:
             frappe.throw(
                 _("There are no vacancies under staffing plan {0}").format(
                     get_link_to_form("Staffing Plan",
                                      staffing_plan.parent)))
示例#10
0
文件: utils.py 项目: vallantis/ejango
def get_overseas_address_details(address_name):
	address_title, address_line1, address_line2, city = frappe.db.get_value(
		'Address', address_name, ['address_title', 'address_line1', 'address_line2', 'city']
	)

	if not address_title or not address_line1 or not city:
		frappe.throw(
			msg=_('Address lines and city is mandatory for address {}. Please set them and try again.').format(
				get_link_to_form('Address', address_name)
			),
			title=_('Missing Address Fields')
		)

	return frappe._dict(dict(
		gstin='URP', legal_name=address_title, location=city,
		address_line1=address_line1, address_line2=address_line2,
		pincode=999999, state_code=96, place_of_supply=96
	))
示例#11
0
def validate_information(obj, attr, max_size):
	''' Checks if the information is not set in the system and is within the size '''

	if getattr(obj, attr, None):
		val = getattr(obj, attr)
		if type(val).__name__ in ('int', 'float'):
			return validate_amount(val, max_size)
		else:
			return validate_field_size(val, frappe.unscrub(attr), max_size)

	elif not attr:
		if type(obj).__name__ in ('int', 'float'):
			return validate_amount(obj, max_size)
		return cstr(obj)

	else:
		if obj.doctype:
			link = obj.doctype +' '+ get_link_to_form(obj.doctype, obj.name)
		else:
			link = str(obj.name)
		frappe.throw(_("{0} in {1} is mandatory for generating file, set the field and try again").format(frappe.unscrub(attr), link))
示例#12
0
 def validate_event_subscriber(self):
     if not frappe.db.get_value('User', self.user, 'api_key'):
         frappe.throw(
             _('Please generate keys for the Event Subscriber User {0} first.'
               ).format(frappe.bold(get_link_to_form('User', self.user))))
示例#13
0
	def set_credentials(self):
		self.e_invoice_settings = frappe.get_cached_doc('E Invoice Settings')

		if not self.e_invoice_settings.enable:
			frappe.throw(_("E-Invoicing is disabled. Please enable it from {} to generate e-invoices.").format(get_link_to_form("E Invoice Settings", "E Invoice Settings")))

		if self.invoice:
			gstin = self.get_seller_gstin()
			credentials_for_gstin = [d for d in self.e_invoice_settings.credentials if d.gstin == gstin]
			if credentials_for_gstin:
				self.credentials = credentials_for_gstin[0]
			else:
				frappe.throw(_('Cannot find e-invoicing credentials for selected Company GSTIN. Please check E-Invoice Settings'))
		else:
			self.credentials = self.e_invoice_settings.credentials[0] if self.e_invoice_settings.credentials else None