コード例 #1
0
	def _create_fiscal_years(self):
		try:
			# Assumes that exactly one fiscal year has been created so far
			# Creates fiscal years till oldest ledger entry date is covered
			from frappe.utils.data import add_years, getdate
			from itertools import chain
			smallest_ledger_entry_date = getdate(min(entry["date"] for entry in chain(*self.gl_entries.values()) if entry["date"]))
			oldest_fiscal_year = frappe.get_all("Fiscal Year",
				fields=["year_start_date", "year_end_date"],
				order_by="year_start_date"
			)[0]
			# Keep on creating fiscal years
			# until smallest_ledger_entry_date is no longer smaller than the oldest fiscal year's start date
			while smallest_ledger_entry_date < oldest_fiscal_year.year_start_date:
				new_fiscal_year = frappe.get_doc({"doctype": "Fiscal Year"})
				new_fiscal_year.year_start_date = add_years(oldest_fiscal_year.year_start_date, -1)
				new_fiscal_year.year_end_date = add_years(oldest_fiscal_year.year_end_date, -1)
				if new_fiscal_year.year_start_date.year == new_fiscal_year.year_end_date.year:
					new_fiscal_year.year = new_fiscal_year.year_start_date.year
				else:
					new_fiscal_year.year = "{}-{}".format(new_fiscal_year.year_start_date.year, new_fiscal_year.year_end_date.year)
				new_fiscal_year.save()
				oldest_fiscal_year = new_fiscal_year

			frappe.db.commit()
		except Exception as e:
			self._log_error(e)
コード例 #2
0
	def _create_fiscal_years(self):
		try:
			# Assumes that exactly one fiscal year has been created so far
			# Creates fiscal years till oldest ledger entry date is covered
			from frappe.utils.data import add_years, getdate
			from itertools import chain
			smallest_ledger_entry_date = getdate(min(entry["date"] for entry in chain(*self.gl_entries.values()) if entry["date"]))
			oldest_fiscal_year = frappe.get_all("Fiscal Year",
				fields=["year_start_date", "year_end_date"],
				order_by="year_start_date"
			)[0]
			# Keep on creating fiscal years
			# until smallest_ledger_entry_date is no longer smaller than the oldest fiscal year's start date
			while smallest_ledger_entry_date < oldest_fiscal_year.year_start_date:
				new_fiscal_year = frappe.get_doc({"doctype": "Fiscal Year"})
				new_fiscal_year.year_start_date = add_years(oldest_fiscal_year.year_start_date, -1)
				new_fiscal_year.year_end_date = add_years(oldest_fiscal_year.year_end_date, -1)
				if new_fiscal_year.year_start_date.year == new_fiscal_year.year_end_date.year:
					new_fiscal_year.year = new_fiscal_year.year_start_date.year
				else:
					new_fiscal_year.year = "{}-{}".format(new_fiscal_year.year_start_date.year, new_fiscal_year.year_end_date.year)
				new_fiscal_year.save()
				oldest_fiscal_year = new_fiscal_year

			frappe.db.commit()
		except Exception as e:
			self._log_error(e)
コード例 #3
0
ファイル: tally_migration.py プロジェクト: Anju-P/moms-bench
		def create_fiscal_years(vouchers):
			from frappe.utils.data import add_years, getdate
			earliest_date = getdate(min(voucher["posting_date"] for voucher in vouchers))
			oldest_year = frappe.get_all("Fiscal Year", fields=["year_start_date", "year_end_date"], order_by="year_start_date")[0]
			while earliest_date < oldest_year.year_start_date:
				new_year = frappe.get_doc({"doctype": "Fiscal Year"})
				new_year.year_start_date = add_years(oldest_year.year_start_date, -1)
				new_year.year_end_date = add_years(oldest_year.year_end_date, -1)
				if new_year.year_start_date.year == new_year.year_end_date.year:
					new_year.year = new_year.year_start_date.year
				else:
					new_year.year = "{}-{}".format(new_year.year_start_date.year, new_year.year_end_date.year)
				new_year.save()
				oldest_year = new_year
コード例 #4
0
def vorschau(von='Kein von',
             fuer='Kein für',
             widmung='Keine Widmung',
             betrag=0,
             motiv=''):
    gutschein = frappe.get_doc("Gutschein", 'Gutschein-000001')
    gutschein.text_from = von
    gutschein.text_to = fuer
    gutschein.inscription = widmung.replace("\n", "<br>")
    gutschein.amount = betrag
    gutschein.selling_date = nowdate()
    gutschein.valid_date = add_years(nowdate(), 5)
    if motiv == 'Herz':
        motiv = 'Wintergruss'
    if motiv == 'Blumen':
        motiv = 'Herbstblüte'
    if motiv == 'Blumen2':
        motiv = 'Glücksbringer'
    if motiv == 'Hortensien':
        motiv = 'Sommergarten'
    if motiv == 'Tulpenstrauss':
        motiv = 'Frühlingsstrauss'
    gutschein.motiv = motiv

    gutschein.save(ignore_permissions=True)

    return
コード例 #5
0
def background_rechnungslauf(self):
    sinv_to_print = []
    for mitgliedschaft in self.auslaufende_mitgliedschaften:
        mitgliedschaft = frappe.get_doc("Mitgliedschaft",
                                        mitgliedschaft.mitgliedschaft)
        neue_mitgliedschaft = frappe.get_doc({
            "doctype":
            "Mitgliedschaft",
            "mitglied":
            mitgliedschaft.mitglied,
            "mitgliedschafts_typ":
            mitgliedschaft.mitgliedschafts_typ,
            "start":
            mitgliedschaft.ende,
            "ende":
            add_years(mitgliedschaft.ende, 1),
            "customer":
            mitgliedschaft.customer,
            "rechnung_an_dritte":
            mitgliedschaft.rechnung_an_dritte,
            "rechnungsempfaenger":
            mitgliedschaft.rechnungsempfaenger
        })
        neue_mitgliedschaft.insert()

        rechnung = create_invoice(neue_mitgliedschaft.name)

        neue_mitgliedschaft.rechnung = rechnung
        neue_mitgliedschaft.save()

        mitgliedschaft.neue_mitgliedschaft = neue_mitgliedschaft.name
        mitgliedschaft.save()

        if self.asap_print == 1:
            rechnung = frappe.get_doc("Sales Invoice", rechnung)
            rechnung.submit()
            sinv_to_print.append(rechnung.name)

    if self.asap_print == 1:
        qty = 0
        sales_invoices = []
        for sinv in sinv_to_print:
            qty += 1
            sales_invoices.append(sinv)
        if qty > 0:
            bind_source = "/assets/spo/sinvs_for_print/{rechnungslauf}/Rechnungslauf_{rechnungslauf}.pdf".format(
                rechnungslauf=self.name)
            physical_path = "/home/frappe/frappe-bench/sites" + bind_source
            pdf_batch(sales_invoices,
                      format="Mitgliederrechnung",
                      dest=str(physical_path),
                      name=self.name)

        frappe.db.sql(
            """UPDATE `tabMitglieder Rechnungslauf` SET `rechnungen_erstellt` = 1 WHERE `name` = '{name}'"""
            .format(name=self.name),
            as_list=True)
コード例 #6
0
	def make_membership(self):
		doc = frappe.new_doc("Library Membership")

		doc.set('library_member', self.name)
		doc.set('member_first_name', self.first_name)
		doc.set('member_last_name', self.last_name)
		doc.set('from_date', nowdate())
		doc.set('to_date', add_years(nowdate(), 1))
		doc.save()
コード例 #7
0
	def make_meebership(self):
		doc=frappe.new_doc("Membership")

		doc.set('member_name',self.name)
		doc.set('member_frist_name',self.frist_name)
		doc.set('member_last_name',self.last_name)
		doc.set('status','Active')
		doc.set('email',self.email)
		doc.set('phone',self.phone)
		doc.set('form_date',nowdate())
		doc.set('to_date',add_years(nowdate(),1))
		doc.save()
		
		
		doc.submit()
		frappe.msgprint("Libray Membership Are Generate For 1 Year")
コード例 #8
0
ファイル: custom_patch.py プロジェクト: drukhil/erpnext
def post_earned_leaves():
	date = add_years(frappe.utils.nowdate(), 1)
	start = get_first_day(date);
	end = get_last_day(date);
	
	employees = frappe.db.sql("select name, employee_name from `tabEmployee` where status = 'Active' and employment_type in (\'Regular employees\', \'Contract\')", as_dict=True)
	for e in employees:
		la = frappe.new_doc("Leave Allocation")
		la.employee = e.name
		la.employee_name = e.employee_name
		la.leave_type = "Casual Leave"
		la.from_date = str(start)
		la.to_date = str(end)
		la.carry_forward = cint(0)
		la.new_leaves_allocated = flt(10)
		la.submit()
コード例 #9
0
ファイル: custom_patch.py プロジェクト: myolderp/erpnext
def post_earned_leaves():
    date = add_years(frappe.utils.nowdate(), 1)
    start = get_first_day(date)
    end = get_last_day(date)

    employees = frappe.db.sql(
        "select name, employee_name from `tabEmployee` where status = 'Active' and employment_type in (\'Regular employees\', \'Contract\')",
        as_dict=True)
    for e in employees:
        la = frappe.new_doc("Leave Allocation")
        la.employee = e.name
        la.employee_name = e.employee_name
        la.leave_type = "Casual Leave"
        la.from_date = str(start)
        la.to_date = str(end)
        la.carry_forward = cint(0)
        la.new_leaves_allocated = flt(10)
        la.submit()
コード例 #10
0
def create_gutschein(type='Klassisch',
                     amount=0,
                     valid_date='',
                     barcode='',
                     salutation='',
                     company='',
                     first_name='',
                     last_name='',
                     street='',
                     plz='',
                     city='',
                     email='',
                     phone='',
                     text_from='',
                     text_to='',
                     inscription='',
                     informationen='',
                     motiv='',
                     edge=0):
    barcode = barcode.replace("&lt;", "<")
    barcode = barcode.replace("&gt;", ">")
    barcode = barcode.replace("<svg-x", "<svg")
    barcode = barcode.replace("<g-x", "<g")
    barcode = barcode.replace("<rect-x>", "</rect>")
    barcode = barcode.replace("<rect-x ", "<rect ")
    barcode = barcode.replace("svg-x>", "svg>")
    barcode = barcode.replace("g-x>", "g>")
    barcode = barcode.replace("x-y=", "y=")
    barcode = barcode.replace("x-x=", "x=")
    barcode = barcode.replace("</rect-x>", "")
    barcode = barcode.replace(
        '<text style="font: 20px monospace;">',
        '<text style="font: 20px monospace;" ' + barcode.split("!*!")[6] +
        ' text-anchor="middle">')
    barcode = barcode.replace(
        '<text style="font: 20px monospace;" ' + barcode.split("!*!")[6] +
        ' text-anchor="middle">', '<text style="font: 20px monospace;" ' +
        barcode.split("!*!")[5] + ' text-anchor="middle">', 5)
    barcode = barcode.replace(
        '<text style="font: 20px monospace;" ' + barcode.split("!*!")[5] +
        ' text-anchor="middle">', '<text style="font: 20px monospace;" ' +
        barcode.split("!*!")[4] + ' text-anchor="middle">', 4)
    barcode = barcode.replace(
        '<text style="font: 20px monospace;" ' + barcode.split("!*!")[4] +
        ' text-anchor="middle">', '<text style="font: 20px monospace;" ' +
        barcode.split("!*!")[3] + ' text-anchor="middle">', 3)
    barcode = barcode.replace(
        '<text style="font: 20px monospace;" ' + barcode.split("!*!")[3] +
        ' text-anchor="middle">', '<text style="font: 20px monospace;" ' +
        barcode.split("!*!")[2] + ' text-anchor="middle">', 2)
    barcode = barcode.replace(
        '<text style="font: 20px monospace;" ' + barcode.split("!*!")[2] +
        ' text-anchor="middle">', '<text style="font: 20px monospace;" ' +
        barcode.split("!*!")[1] + ' text-anchor="start">', 1)
    barcode = barcode.split("!*!")[0]
    #frappe.throw(str(barcode))
    if motiv == 'Herz':
        motiv = 'Wintergruss'
    if motiv == 'Blumen':
        motiv = 'Herbstblüte'
    if motiv == 'Blumen2':
        motiv = 'Glücksbringer'
    if motiv == 'Hortensien':
        motiv = 'Sommergarten'
    if motiv == 'Tulpenstrauss':
        motiv = 'Frühlingsstrauss'

    if type != "print@home":
        mail = "Bestellbestätigung (Klassisch, EC)"
    else:
        if int(edge) == 1:
            mail = 'Bestellbestätigung ohne PDF (P@H Edge)'
        else:
            if int(amount) < 250:
                mail = 'Bestellbestätigung mit PDF (P@H)'
            else:
                mail = 'Bestellbestätigung ohne PDF (P@H Bonitätsprüfung)'

    gutschein = frappe.get_doc({
        "doctype": "Gutschein",
        "type": type,
        "amount": amount,
        "selling_date": nowdate(),
        "valid_date": add_years(nowdate(), 5),
        "barcode": barcode,
        "salutation": salutation,
        "company": company,
        "first_name": first_name,
        "last_name": last_name,
        "street": street,
        "plz": plz,
        "city": city,
        "email": email,
        "phone": phone,
        "text_from": text_from,
        "text_to": text_to,
        "inscription": inscription,
        "informationen": informationen,
        "motiv": motiv,
        "edge": edge,
        "mail_spezifikation": mail
    })
    gutschein.insert(ignore_permissions=True)

    return gutschein.name