コード例 #1
0
 def set_total_in_words(self):
     from frappe.utils import money_in_words
     if self.meta.get_field("base_in_words"):
         self.base_in_words = money_in_words(self.base_grand_total,
                                             self.company_currency)
     if self.meta.get_field("in_words"):
         self.in_words = money_in_words(self.grand_total, self.currency)
コード例 #2
0
	def set_total_in_words(self):
		from frappe.utils import money_in_words
		company_currency = get_company_currency(self.company)
		if self.meta.get_field("base_in_words"):
			self.base_in_words = money_in_words(self.base_grand_total, company_currency)
		if self.meta.get_field("in_words"):
			self.in_words = money_in_words(self.grand_total, self.currency)
コード例 #3
0
 def set_total_in_words(self):
     from frappe.utils import money_in_words
     company_currency = get_company_currency(self.company)
     if self.meta.get_field("in_words"):
         self.in_words = money_in_words(self.grand_total, company_currency)
     if self.meta.get_field("in_words_import"):
         self.in_words_import = money_in_words(self.grand_total_import,
                                               self.currency)
コード例 #4
0
	def set_total_in_words(self):
		from frappe.utils import money_in_words
		disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total"))

		if self.meta.get_field("base_in_words"):
			self.base_in_words = money_in_words(disable_rounded_total and
				abs(self.base_grand_total) or abs(self.base_rounded_total), self.company_currency)
		if self.meta.get_field("in_words"):
			self.in_words = money_in_words(disable_rounded_total and
				abs(self.grand_total) or abs(self.rounded_total), self.currency)
コード例 #5
0
	def set_total_in_words(self):
		from frappe.utils import money_in_words
		disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total"))

		if self.meta.get_field("base_in_words"):
			self.base_in_words = money_in_words(disable_rounded_total and
				abs(self.base_grand_total) or abs(self.base_rounded_total), self.company_currency)
		if self.meta.get_field("in_words"):
			self.in_words = money_in_words(disable_rounded_total and
				abs(self.grand_total) or abs(self.rounded_total), self.currency)
コード例 #6
0
	def set_total_in_words(self):
		from frappe.utils import money_in_words

		if self.meta.get_field("base_in_words"):
			base_amount = abs(self.base_grand_total
				if self.is_rounded_total_disabled() else self.base_rounded_total)
			self.base_in_words = money_in_words(base_amount, self.company_currency)

		if self.meta.get_field("in_words"):
			amount = abs(self.grand_total if self.is_rounded_total_disabled() else self.rounded_total)
			self.in_words = money_in_words(amount, self.currency)
コード例 #7
0
	def set_total_in_words(self):
		from frappe.utils import money_in_words

		if self.meta.get_field("base_in_words"):
			base_amount = abs(self.base_grand_total
				if self.is_rounded_total_disabled() else self.base_rounded_total)
			self.base_in_words = money_in_words(base_amount, self.company_currency)

		if self.meta.get_field("in_words"):
			amount = abs(self.grand_total if self.is_rounded_total_disabled() else self.rounded_total)
			self.in_words = money_in_words(amount, self.currency)
コード例 #8
0
	def validate(self):
		self.deposit_amount_in_words = money_in_words(self.deposit_amount)
		self.rent_amount_in_words = money_in_words(self.rent)
		self.final_rent_amount_in_words = money_in_words(self.final_rent_amount)
		if date_diff(self.contract_end_date, self.contract_start_date) < 0:
			frappe.throw(_("Rent Start Date cannot be before Rent End Date"))

		exist=frappe.db.sql("""select name,contract_start_date,contract_end_date from `tabRent Contract` where name<>'%s' and docstatus<> 2 and property='%s' and \
				(( contract_start_date<='%s' and contract_end_date>='%s') or ( contract_start_date>='%s' and contract_start_date<='%s') or 
				( contract_end_date>='%s' and contract_end_date<='%s'))
				"""%(self.name,self.property,self.contract_start_date,self.contract_end_date,self.contract_start_date,self.contract_end_date,self.contract_start_date,self.contract_end_date))
		if exist:
				frappe.throw(_("Rent Contract '{0}' with Contract Start Date '{1}' Contract End Date '{2}' Overlap with this contract for property '{3}'".format(exist[0][0],formatdate(exist[0][1]),formatdate(exist[0][2]),self.property)))
コード例 #9
0
	def set_total_in_words(self):
		from frappe.utils import money_in_words
		company_currency = get_company_currency(self.company)

		disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None,
			"disable_rounded_total"))

		if self.meta.get_field("in_words"):
			self.in_words = money_in_words(disable_rounded_total and
				self.grand_total or self.rounded_total, company_currency)
		if self.meta.get_field("in_words_export"):
			self.in_words_export = money_in_words(disable_rounded_total and
				self.grand_total_export or self.rounded_total_export, self.currency)
コード例 #10
0
ファイル: mrp_bank_transfer.py プロジェクト: kardmode/erpnext
	def set_total_in_words(self):
		from frappe.utils import money_in_words

		if self.meta.get_field("base_in_words"):
			base_amount = abs(self.base_grand_total)
			self.base_in_words = money_in_words(base_amount, self.company_currency)

		if self.meta.get_field("in_words"):
			if self.transfer_amount:
				amount = abs(self.transfer_amount)
			else:
				amount = 0
			self.in_words = money_in_words(amount, self.currency_of_transfer)
コード例 #11
0
	def set_total_in_words(self):
		from frappe.utils import money_in_words
		company_currency = get_company_currency(self.doc.company)
		
		disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, 
			"disable_rounded_total"))
			
		if self.meta.get_field("in_words"):
			self.doc.in_words = money_in_words(disable_rounded_total and 
				self.doc.grand_total or self.doc.rounded_total, company_currency)
		if self.meta.get_field("in_words_export"):
			self.doc.in_words_export = money_in_words(disable_rounded_total and 
				self.doc.grand_total_export or self.doc.rounded_total_export, self.doc.currency)
コード例 #12
0
ファイル: api.py プロジェクト: sugurujay/epochapp
def set_total_in_words(doc, method):
    from frappe.utils import money_in_words
    company_currency = get_company_currency(doc.company)
    
    disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total"))

    if doc.meta.get_field("base_in_words"):
        doc.base_in_words = money_in_words(disable_rounded_total and
            abs(doc.base_grand_total) or abs(doc.base_rounded_total), company_currency)
    if doc.meta.get_field("in_words"):
        doc.in_words = money_in_words(disable_rounded_total and
            abs(doc.grand_total) or abs(doc.rounded_total), doc.currency)
    if doc.meta.get_field("amount_of_duty_in_words"):
        doc.amount_of_duty_in_words = money_in_words(disable_rounded_total and
            abs(doc.excise_amount) or abs(doc.excise_amount), doc.currency)
コード例 #13
0
	def set_total_in_words(self):
		from frappe.utils import money_in_words
		if self.meta.get_field("base_in_words"):
			if self.meta.get_field("base_rounded_total") and not self.is_rounded_total_disabled():
				amount = self.base_rounded_total
			else:
				amount = self.base_grand_total
			self.base_in_words = money_in_words(amount, self.company_currency)

		if self.meta.get_field("in_words"):
			if self.meta.get_field("rounded_total") and not self.is_rounded_total_disabled():
				amount = self.rounded_total
			else:
				amount = self.grand_total

			self.in_words = money_in_words(amount, self.currency)
コード例 #14
0
def kp_si_validate(self, method):
    self.kirat_total_excise_payable_in_words = money_in_words(
        self.kirat_excise_payable_total)

    #Check for duplicate items and items with zero rate for invoices other than type Sample/Challan.
    validate_repeating_items(self)
    validate_zero_amount_items(self)
コード例 #15
0
def _insert_invoice(invoice, mop,taxes_total, submit=False,allow_negative_stock=False):
    invoice.set_missing_values()
    invoice.insert()
    print(mop)
    invoice.append('payments', {
        'mode_of_payment': mop.mode_of_payment,
        'amount': invoice.outstanding_amount
    })
    invoice.save()

    check_stock_qty = _check_items_zero_qty(invoice.items)
    if check_stock_qty and allow_negative_stock:
        check_stock_qty = False

    if submit and not check_stock_qty:
        invoice.submit()
        from frappe.utils import money_in_words
        frappe.db.set_value("Sales Invoice", invoice.name, "total_taxes_and_charges", taxes_total)
        frappe.db.set_value("Sales Invoice", invoice.name, "total_taxes_and_charges", taxes_total)
        frappe.db.set_value("Sales Invoice", invoice.name, "grand_total", float(invoice.grand_total) + float(taxes_total))
        frappe.db.set_value("Sales Invoice", invoice.name, "rounded_total", round(float(invoice.grand_total) + float(taxes_total)))
        frappe.db.set_value("Sales Invoice", invoice.name, "outstanding_amount", round(float(invoice.grand_total) + float(taxes_total)))
        frappe.db.set_value("Sales Invoice", invoice.name, "paid_amount", round(float(invoice.grand_total) + float(taxes_total)))
        frappe.db.set_value("Sales Invoice", invoice.name, "in_words", money_in_words(round(float(invoice.grand_total) + float(taxes_total)), invoice.currency))
        frappe.db.commit()
コード例 #16
0
def get_amount_in_words(self, method):
    self.paid_amount_inwords_cf = ''
    self.total_allocated_amount_inwords_cf = ''
    self.unallocated_amount_inwords_cf = ''
    self.difference_amount_inword_cf = ''
    if self.paid_amount:
        self.paid_amount_inwords_cf = money_in_words(self.paid_amount)
    if self.total_allocated_amount:
        self.total_allocated_amount_inwords_cf = money_in_words(
            self.total_allocated_amount)
    if self.unallocated_amount:
        self.unallocated_amount_inwords_cf = money_in_words(
            self.unallocated_amount)
    if self.difference_amount:
        self.difference_amount_inword_cf = money_in_words(
            self.difference_amount)
コード例 #17
0
ファイル: purchase.py プロジェクト: reddymeghraj/beerbar
	def on_submit(self):
		ls=self.purchaseinfo
		for i in range(len(ls)):
			brand=ls[i].brand
			brandname=ls[i].brand_name
			btype=ls[i].brand_type
			btypename=ls[i].type_name
			qnty=ls[i].quantity
			q1=frappe.db.sql("""select stock_quantity from `tabStock` where brand=%s and brand_name=%s and brand_type=%s and type_name=%s""",(brand,brandname,btype,btypename))
			if q1:
				query=frappe.db.sql("""update `tabStock`
				set stock_quantity=stock_quantity+%s 
				where brand=%s and brand_type=%s""",(qnty,brand,btype))
				frappe.msgprint("Stock Updated")
			else:
				q3=frappe.db.sql("""select max(cast(name as int)) from `tabStock`""")[0][0]
				if q3:
					name=int(q3)+1;
				else:
					name=1	
				q2=frappe.db.sql("""insert into `tabStock` set name=%s, brand=%s, brand_name=%s, brand_type=%s,
				type_name=%s, stock_quantity=%s""",(name,brand,brandname,btype,btypename,qnty))
				frappe.msgprint("New Entry addede in Stock!")
		#-----------------------
		#Display Amount in words
		#-----------------------
		from frappe.utils import money_in_words
		self.net_pay_in_words = money_in_words(self.net_pay, 'INR')
コード例 #18
0
    def test_calculate_gratuity(self):
        gratuity_pay = 0
        gratuity_calculation = ''
        leave_encashment_amount = 0

        salary_per_day = 0
        struct = self.check_sal_struct(self.joining_date, self.relieving_date)
        if struct:
            salary_structure_doc = frappe.get_doc('Salary Structure', struct)

            salary_per_day = self.calculate_salary_per_day(
                salary_structure_doc.earnings)

            gratuity_pay, gratuity_calculation, leave_encashment_amount = calculate_gratuity(
                self.employee, salary_per_day, self.joining_date,
                self.relieving_date)

        loan_deduction, loan_deduction_summary = self.check_loan_deductions()

        gratuity_calculation = loan_deduction_summary + "<br>" + gratuity_calculation

        self.gratuity = gratuity_pay
        self.summary = gratuity_calculation
        self.leave_encashment_amount = leave_encashment_amount
        self.salary_per_day = salary_per_day
        self.total_deduction = loan_deduction
        self.grand_total = flt(gratuity_pay) + flt(
            leave_encashment_amount) - flt(loan_deduction)

        self.total_in_words = money_in_words(
            self.grand_total, get_company_currency(self.company))

        return gratuity_pay, gratuity_calculation, leave_encashment_amount, salary_per_day
コード例 #19
0
ファイル: multiorder.py プロジェクト: hrgadeha/multiorder
 def on_submit(doc):
     doc.in_words = money_in_words(doc.grand_total)
     for c in doc.multiorder_customer:
         items = []
         for d in doc.multiorder_item:
             item_li = {
                 "item_code": d.item_code,
                 "qty": d.qty,
                 "rate": d.rate,
                 "warehouse": d.warehouse
             }
             items.append(item_li)
         sales_order = frappe.get_doc({
             "doctype":
             "Sales Order",
             "customer":
             c.customer,
             "delivery_date":
             "2018-09-23",
             "apply_discount_on":
             doc.apply_discount_on,
             "additional_discount_percentage":
             doc.additional_discount_percentage,
             "total":
             doc.net_total,
             "tc_name":
             doc.terms,
             "items":
             items
         })
         sales_order.insert(ignore_permissions=True)
         sales_order.submit()
コード例 #20
0
    def validate(self):
        self.status = self.get_status()
        self.validate_dates()
        self.check_existing()
        if not self.salary_slip_based_on_timesheet:
            self.get_date_details()

        if not (len(self.get("earnings")) or len(self.get("deductions"))):
            # get details from salary structure
            self.get_emp_and_leave_details()
        else:
            self.get_leave_details(lwp=self.leave_without_pay)

        # if self.salary_slip_based_on_timesheet or not self.net_pay:
        self.calculate_net_pay()

        company_currency = erpnext.get_company_currency(self.company)
        self.total_in_words = money_in_words(self.rounded_total,
                                             company_currency)

        if frappe.db.get_single_value("HR Settings",
                                      "max_working_hours_against_timesheet"):
            max_working_hours = frappe.db.get_single_value(
                "HR Settings", "max_working_hours_against_timesheet")
            if self.salary_slip_based_on_timesheet and (
                    self.total_working_hours > int(max_working_hours)):
                frappe.msgprint(_(
                    "Total working hours should not be greater than max working hours {0}"
                ).format(max_working_hours),
                                alert=True)
コード例 #21
0
def get_total_in_words(amount,show_main_currency,line_one_max = 63):
	from frappe.utils import money_in_words,fmt_money
	
	if show_main_currency == 1:
		show_currency = True
	else:
		show_currency = False
	
	amount_in_words = money_in_words(float(amount),main_currency = "AED",fraction_currency="fils",show_main_currency = show_currency)
	amount_in_words = str(amount_in_words).strip()
	
	import textwrap
	lines = textwrap.wrap(amount_in_words, width=line_one_max)
	
	first_line = ""
	second_line =""
	if len(lines) > 0:
		first_line = lines[0]
		if len(lines) > 1:
			second_line_list = lines.pop(0)
			second_line = " ".join(lines)
	
	frappe.errprint(first_line)
	frappe.errprint(second_line)
	
	fmt_amount = fmt_money(amount)
	return fmt_amount,amount_in_words,first_line,second_line
コード例 #22
0
	def set_total_in_words(self):
		from frappe.utils import money_in_words
		if self.meta.get_field("base_in_words"):
			if self.meta.get_field("base_rounded_total") and not self.is_rounded_total_disabled():
				amount = self.base_rounded_total
			else:
				amount = self.base_grand_total
			self.base_in_words = money_in_words(amount, self.company_currency)

		if self.meta.get_field("in_words"):
			if self.meta.get_field("rounded_total") and not self.is_rounded_total_disabled():
				amount = self.rounded_total
			else:
				amount = self.grand_total

			self.in_words = money_in_words(amount, self.currency)
コード例 #23
0
def validate(self, method=None):

    page_break_idx = 8
    for row in self.items:
        if len(self.items) > 7:
            if row.idx == 8:
                row.page_break = 1
                page_break_idx = 8
                page_break_idx += 15
            elif row.idx >= page_break_idx:
                if row.idx == page_break_idx:
                    row.page_break = 1
                    page_break_idx += 15

    printformat_net_total = printformat_vat_tax = 0.0
    discount_amount = delivery_charge = 0.0
    for tax in self.taxes:
        if tax.account_head == "Stock Adjustment - E":
            delivery_charge = tax.tax_amount

    if self.discount_amount:
        discount_amount = self.discount_amount

    self.delivery_charge = delivery_charge
    printformat_net_total = (self.total - discount_amount) + delivery_charge
    printformat_vat_tax = (printformat_net_total * 5) / 100
    self.printformat_net_total_with_tax = printformat_net_total + printformat_vat_tax
    self.printformat_net_total = printformat_net_total
    self.printformat_vat_tax = printformat_vat_tax
    self.printformat_in_word = money_in_words(
        self.printformat_net_total_with_tax, self.currency)
コード例 #24
0
def invoice_item(start_date,end_date,company,client,site):
	salary_Slip = frappe.get_all('Salary Slip',{'company':company,'client_name':client,'site':site,'start_date':start_date,'end_date':end_date},['name','total_working_hours','hour_rate','start_date'])
	ot_hours = 0
	ot_amount = 0
	ctc_amount = 0
	ot_count = 0
	emp_count = len(salary_Slip)
	for ss in salary_Slip:
		date = ss.start_date
		month = date.strftime("%B-%Y")
		salary_detail = frappe.get_all('Salary Detail',{'parent':ss.name},['*'])		
		for sd in salary_detail:
			if sd.salary_component == "Cost to Company":
				ot_hours += ss.total_working_hours
				ctc_amount += sd.amount
			if sd.salary_component == "Over Time":
				ot_amount += sd.amount
				if sd.amount > 0:
					ot_count +=1
	gross = ot_amount + ctc_amount
	tax = gross * 0.09
	net_amount = round(gross + tax + tax)
	ot_hours = round(ot_hours)
	total_in_words = money_in_words(net_amount)
	return ot_hours,ot_amount,ctc_amount,emp_count,ot_count,gross,tax,net_amount,month,total_in_words
コード例 #25
0
 def before_save(self):
     if self.mode_of_payment != 'Cheque':
         self.cheque_no = None
         self.cheque_date = None
     currency = frappe.db.get_value('Company', self.company,
                                    'default_currency')
     self.in_words = money_in_words(self.rounded_total, currency)
コード例 #26
0
ファイル: fees.py プロジェクト: PawanMeh/erpnext
	def calculate_total(self):
		"""Calculates total amount."""
		self.grand_total = 0
		for d in self.components:
			self.grand_total += d.amount
		self.outstanding_amount = self.grand_total
		self.grand_total_in_words = money_in_words(self.grand_total)
コード例 #27
0
    def validate(self):
        #frappe.errprint("in validate")
        from datetime import datetime
        from frappe.utils import money_in_words
        d1 = datetime.strptime(self.from_date, "%Y-%m-%d")
        d2 = datetime.strptime(self.to_date, "%Y-%m-%d")
        diff = abs((d2 - d1).days)
        #frappe.errprint(diff)
        self.check_existing()
        self.validate_attendance()
        if not (len(self.get("earning_details"))
                or len(self.get("deduction_details"))):
            self.get_emp_and_leave_details(diff)
        else:
            self.get_leave_details(diff, self.leave_without_pay)

        if not self.net_pay:
            self.calculate_net_pay()

        company_currency = get_company_currency(self.company)
        #frappe.errprint(company_currency)
        self.total_in_words = money_in_words(self.rounded_total,
                                             company_currency)
        #frappe.errprint(self.total_in_words)
        set_employee_name(self)
コード例 #28
0
 def calculate_total(self):
     """Calculates total amount."""
     self.grand_total = 0
     for d in self.fee_components:
         self.grand_total += d.amount
     self.outstanding_amount = self.grand_total
     self.grand_total_in_words = money_in_words(self.grand_total)
コード例 #29
0
ファイル: process_payroll.py プロジェクト: drukhil/erpnext
        def post_journal_entry(self, title, user_remark, accounts, bank_entry_req, tot_earnings, tot_deductions):
                from frappe.utils import money_in_words
                ss_list = []
                default_bank_account = frappe.db.get_value("Company", self.company,"default_bank_account")
                
                if bank_entry_req == 0:
                        ss = frappe.get_doc({
                                "doctype": "Journal Entry",
                                "voucher_type": 'Journal Entry',
                                "naming_series": 'Journal Voucher',
                                "title": title,
                                "fiscal_year": self.fiscal_year,
                                "user_remark": user_remark,
                                "posting_date": nowdate(),                     
                                "company": self.company,
                                "total_amount_in_words": money_in_words((tot_earnings-tot_deductions)),
                                "accounts": accounts
                        })

                        if (tot_deductions or tot_earnings):
                                ss.insert()
                                #ss.submit()
                        ss_list.append('Direct posting Journal Entry...')
                else:
                        accounts.append({"account": default_bank_account,
                                        "credit_in_account_currency": (tot_earnings-tot_deductions),
                                        "cost_center": 'CHQR-CEO - SMCL',
                                        "party_check": 0})                        
                        
                        ss = frappe.get_doc({
                                "doctype": "Journal Entry",
                                "voucher_type": 'Bank Entry',
                                "naming_series": 'Bank Payment Voucher',
                                "title": title,
                                "fiscal_year": self.fiscal_year,
                                "user_remark": user_remark,
                                "posting_date": nowdate(),                     
                                "company": self.company,
                                "total_amount_in_words": money_in_words((tot_earnings-tot_deductions)),
                                "accounts": accounts
                        })

                        if (tot_deductions or tot_earnings):
                                ss.insert()
                                #ss.submit()
                        ss_list.append('Direct posting Journal Entry...')
コード例 #30
0
ファイル: utils.py プロジェクト: beshoyAtefZaki/Last-mod
def validate_Percentage(input, min=0, max=100):
    try:
        input = float(input)
        if (input < min):
            frappe.throw(
                _("Sorry....Would you please enter a valid number bigger than "
                  + _(
                      money_in_words(min).replace("only", "").replace(
                          "SAR", "")) + ""))
        elif (input > float(max)):
            frappe.throw(
                _("Sorry....Would you please enter a valid number lower than "
                  + _(
                      money_in_words(max).replace("only", "").replace(
                          "SAR", "")) + ""))
    except ValueError as e:
        raise e
コード例 #31
0
ファイル: payment_request.py プロジェクト: kardmode/erpnext
 def validate(self):
     # self.validate_reference_document()
     # self.validate_payment_request()
     # self.validate_currency()
     # self.validate_subscription_details()
     self.grand_total_requested = flt(self.advance_required) + flt(
         self.vat) - flt(self.additional_discount_amount)
     self.request_in_words = money_in_words(self.grand_total_requested,
                                            self.currency)
コード例 #32
0
def calculate_customer_taxes_and_totals(self):
    total = 0
    for cdoc in self.items:
        if cdoc.consoleerp_customer_disc_percent:
            # taxes_and_totals controller updates rate based on rate_with_margin

            cdoc.margin_type = "Amount"
            cdoc.rate = flt(cdoc.consoleerp_customer_rate *
                            (1 -
                             (cdoc.consoleerp_customer_disc_percent / 100)))
            cdoc.margin_rate_or_amount = cdoc.rate - cdoc.price_list_rate
            cdoc.rate_with_margin = cdoc.rate

            total += cdoc.consoleerp_customer_rate * cdoc.qty
            cdoc.consoleerp_original_amt = cdoc.consoleerp_customer_rate * cdoc.qty
        else:
            total += cdoc.rate * cdoc.qty

    self.consoleerp_customer_total = total
    self.consoleerp_customer_discount_total = self.consoleerp_customer_total - self.total
    self.consoleerp_order_total = self.total

    # get tax
    for tax in self.taxes:
        if cstr(tax.charge_type) != "On Net Total" and not (cstr(
                tax.charge_type) == "Actual" and tax.vat_madness):
            continue

        if tax.rate:
            tax.vat_madness = "On Net Total : " + tax.rate

        #this rate will be handled by calculate_taxes_and_totals
        tax.rate = flt(tax.vat_madness.split(" : ")[1])

        from erpnext.controllers.taxes_and_totals import calculate_taxes_and_totals
        import json

        amount = 0
        for item in self.items:
            # from taxes_and_totals.py
            item_tax_map = json.loads(
                item.item_tax_rate) if item.item_tax_rate else {}
            item_tax_rate = _get_tax_rate(self, tax, item_tax_map)
            item_tax_amount = item.consoleerp_original_amt * item_tax_rate / 100
            item.consoleerp_item_tax_amount = item_tax_amount
            item.consoleerp_item_grand_total = item.consoleerp_original_amt + item_tax_amount
            amount += item_tax_amount

        tax.charge_type = "Actual"
        tax.tax_amount = amount
    self.calculate_taxes_and_totals()
    self.consoleerp_customer_grand_total = self.consoleerp_customer_total + (
        self.total_taxes_and_charges or 0) - (self.discount_amount or 0)

    from frappe.utils import money_in_words
    self.consoleerp_customer_grand_total_in_words = money_in_words(
        self.consoleerp_customer_grand_total)
コード例 #33
0
def calculate_excise_amount(doc):
    from frappe.utils import money_in_words

    doc.excise_amount = sum([
        flt(d.base_tax_amount) for d in doc.get("taxes")
        if cint(d.is_excise_account) == 1
    ])
    doc.excise_amount_in_words = money_in_words(
        doc.excise_amount, erpnext.get_company_currency(doc.company))
コード例 #34
0
ファイル: test_utils.py プロジェクト: ektai/frappe3
    def test_money_in_words(self):
        nums_bhd = [(5000, "BHD Five Thousand"), (5000.0, "BHD Five Thousand"),
                    (0.1, "One Hundred Fils"), (0, "BHD Zero"), ("Fail", "")]

        nums_ngn = [(5000, "NGN Five Thousand"), (5000.0, "NGN Five Thousand"),
                    (0.1, "Ten Kobo"), (0, "NGN Zero"), ("Fail", "")]

        for num in nums_bhd:
            self.assertEqual(
                money_in_words(num[0], "BHD"), num[1],
                "{0} is not the same as {1}".format(
                    money_in_words(num[0], "BHD"), num[1]))

        for num in nums_ngn:
            self.assertEqual(
                money_in_words(num[0], "NGN"), num[1],
                "{0} is not the same as {1}".format(
                    money_in_words(num[0], "NGN"), num[1]))
コード例 #35
0
	def validate(self):
		#if self.start_date:
		#	self.month = calendar.month_name[getdate(self.start_date).month]
		#	self.year  = getdate(self.start_date).year
		self.status = self.get_status()
		self.validate_dates()
		self.check_existing()
		if not self.salary_slip_based_on_timesheet:
			self.get_date_details()

		if not (len(self.get("earnings")) or len(self.get("deductions"))):
			# get details from salary structure
			self.get_emp_and_leave_details()
		else:
			self.get_leave_details(lwp = self.leave_without_pay)

		# if self.salary_slip_based_on_timesheet or not self.net_pay:
		self.calculate_net_pay()


		company_currency = erpnext.get_company_currency(self.company)
		self.total_in_words = money_in_words(self.rounded_total, company_currency)

		if frappe.db.get_single_value("HR Settings", "max_working_hours_against_timesheet"):
			max_working_hours = frappe.db.get_single_value("HR Settings", "max_working_hours_against_timesheet")
			if self.salary_slip_based_on_timesheet and (self.total_working_hour > float(max_working_hours)):
				pass #frappe.msgprint(_("Total working hours should not be greater than max working hours {0}").
					#			format(max_working_hours), alert=True)
		self.fill_attendance()
		dep=frappe.get_all("Employee Dependent",['name'],filters={"employee":self.employee})
		
		self.no_of_children=len(dep) if dep else 0
		emp_edu=frappe.get_all("Employee Education",['specialization'],filters={"employee":self.employee})
		if emp_edu:
			#frappe.msgprint(ed[0].employee)
			self.specialization=emp_edu[0].specialization
		emp_pers=frappe.get_all("Employee",['identity_no','marital_status'],filters={"employee":self.employee})
		if emp_pers:
			self.identity= emp_pers[0].identity_no
			self.marital_status= emp_pers[0].marital_status 

		emp_det=frappe.get_all("Employee",['department','branch','circle','designation','employment_type','date_of_joining'],filters={"employee":self.employee})
		if emp_det:
			self.circle=emp_det[0].circle
			self.branch=emp_det[0].branch
			self.designation=emp_det[0].designation
			self.department=emp_det[0].department
			self.employment_type=emp_det[0].employment_type
			self.date_of_joining=emp_det[0].date_of_joining


		emp_sal=frappe.get_all("Employee",['grade','grade_category','experience_years'],filters={"employee":self.employee})
		if emp_sal:
			self.grade=emp_sal[0].grade
			self.grade_category=emp_sal[0].grade_category
			self.experience_years=emp_sal[0].experience_year
コード例 #36
0
def update_totals(gst_tax, base_gst_tax, doc):
	doc.base_grand_total -= base_gst_tax
	doc.grand_total -= gst_tax

	if doc.meta.get_field("rounded_total"):
		if doc.is_rounded_total_disabled():
			doc.outstanding_amount = doc.grand_total
		else:
			doc.rounded_total = round_based_on_smallest_currency_fraction(doc.grand_total,
				doc.currency, doc.precision("rounded_total"))

			doc.rounding_adjustment += flt(doc.rounded_total - doc.grand_total,
				doc.precision("rounding_adjustment"))

			doc.outstanding_amount = doc.rounded_total or doc.grand_total

	doc.in_words = money_in_words(doc.grand_total, doc.currency)
	doc.base_in_words = money_in_words(doc.base_grand_total, erpnext.get_company_currency(doc.company))
	doc.set_payment_schedule()
コード例 #37
0
def validate(doc, method):

    print "VALOR POR EXTENSO"

    company_currency = erpnext.get_company_currency(doc.company)
    print company_currency
    if (company_currency == 'KZ'):
        doc.in_words = num2words(doc.grand_total,
                                 lang='pt_BR').title() + ' Kwanzas.'
    else:
        doc.in_words = money_in_words(doc.grand_total, company_currency)
コード例 #38
0
def merge_tailoring_items(doc,method):
	doc.set('entries', [])
	amt = amount = 0.0
	for d in doc.get('sales_invoice_items_one'):
		e = doc.append('entries', {})
		e.barcode=d.tailoring_barcode
		e.item_code=d.tailoring_item_code
		e.item_name=d.tailoring_item_name
		e.item_group = frappe.db.get_value('Item', d.tailoring_item_code, 'item_group')
		e.work_order=d.tailoring_work_order
		e.description=d.tailoring_description
		e.sales_invoice_branch = d.tailoring_branch
		e.warehouse= frappe.db.get_value('Branch', d.tailoring_branch, 'warehouse')
		e.income_account=d.tailoring_income_account
		e.cost_center=d.tailoring_cost_center
		e.batch_no=d.tailoring_batch_no
		e.item_tax_rate=d.tailoring_item_tax_rate
		e.stock_uom=d.tailoring_stock_uom 
		e.price_list_rate=d.tailoring_price_list_rate
		e.trial_date = d.tailoring_trial_date
		e.discount_percentage=d.tailoring_discount_percentage
		e.amount= d.tailoring_amount
		e.base_amount= cstr(flt(e.amount)*flt(doc.conversion_rate))
		e.base_rate=  cstr(flt(d.tailoring_rate)*flt(doc.conversion_rate))
		e.rate=d.tailoring_rate
		e.base_price_list_rate=d.tailoring_base_price_list_rate
		e.qty=d.tailoring_qty
		e.base_price_list_rate=d.tailoring_base_price_list_rate
		e.delivery_date  =  d.tailoring_delivery_date
		amt += flt(e.amount)
	amount = merge_merchandise_items(doc)
	doc.net_total_export = cstr(flt(amount) + flt(amt))
	doc.grand_total_export = cstr(flt(amount) + flt(amt) + flt(doc.other_charges_total_export))
	doc.rounded_total_export = cstr(rounded(flt(amount) + flt(amt) + flt(doc.other_charges_total_export)))
	doc.in_words_export = cstr(money_in_words(flt(amount) + flt(amt) + flt(doc.other_charges_total_export),doc.currency))
	doc.net_total = cstr(flt(doc.net_total_export) * flt(doc.conversion_rate))
	doc.grand_total = cstr(flt(doc.net_total) + flt(doc.other_charges_total))
	doc.rounded_total = cstr(rounded(flt(doc.net_total) + flt(doc.other_charges_total)))
	doc.in_words = cstr(money_in_words(flt(doc.net_total) + flt(doc.other_charges_total)))
	doc.outstanding_amount = cstr(flt(doc.net_total) + flt(doc.other_charges_total) - flt(doc.total_advance))
	return "Done"
コード例 #39
0
ファイル: test_utils.py プロジェクト: britlog/frappe
	def test_money_in_words(self):
		nums_bhd = [
			(5000, "BHD Five Thousand only."), (5000.0, "BHD Five Thousand only."),
			(0.1, "One Hundred Fils only."), (0, "BHD Zero only."), ("Fail", "")
		]

		nums_ngn = [
			(5000, "NGN Five Thousand only."), (5000.0, "NGN Five Thousand only."),
			(0.1, "Ten Kobo only."), (0, "NGN Zero only."), ("Fail", "")
		]

		for num in nums_bhd:
			self.assertEqual(
				money_in_words(num[0], "BHD"), num[1], "{0} is not the same as {1}".
					format(money_in_words(num[0], "BHD"), num[1])
			)

		for num in nums_ngn:
			self.assertEqual(
				money_in_words(num[0], "NGN"), num[1], "{0} is not the same as {1}".
					format(money_in_words(num[0], "NGN"), num[1])
			)
コード例 #40
0
ファイル: fee_schedule.py プロジェクト: Aptronics/erpnext
	def calculate_total_and_program(self):
		no_of_students = 0
		for d in self.student_groups:
			# if not d.total_students:
			d.total_students = get_total_students(d.student_group, self.academic_year,
				self.academic_term, self.student_category)
			no_of_students += cint(d.total_students)

			# validate the program of fee structure and student groups
			student_group_program = frappe.db.get_value("Student Group", d.student_group, "program")
			if self.program and student_group_program and self.program != student_group_program:
				frappe.msgprint(_("Program in the Fee Structure and Student Group {0} are different.")
					.format(d.student_group))
		self.grand_total = no_of_students*self.total_amount
		self.grand_total_in_words = money_in_words(self.grand_total)
コード例 #41
0
ファイル: salary_slip.py プロジェクト: RicardoJohann/erpnext
	def validate(self):
		self.check_existing()

		if not (len(self.get("earnings")) or len(self.get("deductions"))):
			self.get_emp_and_leave_details()
		else:
			self.get_leave_details(lwp = self.leave_without_pay)

		if not self.net_pay:
			self.calculate_net_pay()

		company_currency = get_company_currency(self.company)
		self.total_in_words = money_in_words(self.rounded_total, company_currency)

		set_employee_name(self)
コード例 #42
0
	def validate(self):
		from frappe.utils import money_in_words
		self.check_existing()

		if not (len(self.get("earning_details")) or
			len(self.get("deduction_details"))):
				self.get_emp_and_leave_details()
		else:
			self.get_leave_details(self.leave_without_pay)

		if not self.net_pay:
			self.calculate_net_pay()

		company_currency = get_company_currency(self.company)
		self.total_in_words = money_in_words(self.rounded_total, company_currency)
コード例 #43
0
ファイル: api.py プロジェクト: jompha/siyar_erpnext
def load_customer_item_name(self, method):
	""" Loads the Cutomer Item Name in to the calling doc from the Item"""
	if self.doctype == "Sales Invoice" and self.consoleerp_customer_total != None:
		from frappe.utils import money_in_words
		self.consoleerp_customer_total_in_words = money_in_words(self.consoleerp_customer_total, self.currency)
	
	for item in self.items:
		item_doc = frappe.get_doc("Item", item.item_code)
		customer_row = item_doc.get("customer_items", {"customer_name" : self.customer})
		
		item.consoleerp_customer_item_name = None
		
		if not customer_row or not customer_row[0]:
			continue
		
		item.consoleerp_customer_item_name = customer_row[0].consoleerp_ref_name
コード例 #44
0
ファイル: journal_voucher.py プロジェクト: BIGGANI/erpnext
	def set_print_format_fields(self):
		for d in self.get('entries'):
			account_type, master_type = frappe.db.get_value("Account", d.account,
				["account_type", "master_type"])

			if master_type in ['Supplier', 'Customer']:
				if not self.pay_to_recd_from:
					self.pay_to_recd_from = frappe.db.get_value(master_type,
						' - '.join(d.account.split(' - ')[:-1]),
						master_type == 'Customer' and 'customer_name' or 'supplier_name')

			if account_type in ['Bank', 'Cash']:
				company_currency = get_company_currency(self.company)
				amt = flt(d.debit) and d.debit or d.credit
				self.total_amount = company_currency + ' ' + cstr(amt)
				from frappe.utils import money_in_words
				self.total_amount_in_words = money_in_words(amt, company_currency)
コード例 #45
0
def execute():
	company_currency = dict(frappe.db.sql("select name, default_currency from `tabCompany`"))
	bank_or_cash_accounts = frappe.db.sql_list("""select name from `tabAccount`
		where account_type in ('Bank', 'Cash') and docstatus < 2""")

	for je in frappe.db.sql_list("""select name from `tabJournal Entry` where docstatus < 2"""):
		total_amount = 0
		total_amount_in_words = ""

		je_doc = frappe.get_doc('Journal Entry', je)
		for d in je_doc.get("accounts"):
			if (d.party_type and d.party) or d.account in bank_or_cash_accounts:
				total_amount = d.debit or d.credit
				if total_amount:
					total_amount_in_words = money_in_words(total_amount, company_currency.get(je_doc.company))

		if total_amount:
			frappe.db.sql("""update `tabJournal Entry` set total_amount=%s, total_amount_in_words=%s
				where name = %s""", (total_amount, total_amount_in_words, je))
コード例 #46
0
ファイル: salary_slip.py プロジェクト: dstechnology/erpnext
	def validate(self):
		self.status = self.get_status()
		self.validate_dates()
		self.check_existing()
		self.get_date_details()
		if not (len(self.get("earnings")) or len(self.get("deductions"))):
			# get details from salary structure
			self.get_emp_and_leave_details()
		else:
			self.get_leave_details(lwp = self.leave_without_pay)

		# if self.salary_slip_based_on_timesheet or not self.net_pay:
		self.calculate_net_pay()

		company_currency = get_company_currency(self.company)
		self.total_in_words = money_in_words(self.rounded_total, company_currency)

		if frappe.db.get_single_value("HR Settings", "max_working_hours_against_timesheet"):
			max_working_hours = frappe.db.get_single_value("HR Settings", "max_working_hours_against_timesheet")
			if self.salary_slip_based_on_timesheet and (self.total_working_hours > int(max_working_hours)):
				frappe.msgprint(_("Total working hours should not be greater than max working hours {0}").
								format(max_working_hours), alert=True)
コード例 #47
0
    def set_print_format_fields(self):
        for d in self.get("entries"):
            result = frappe.db.get_value("Account", d.account, ["account_type", "master_type"])

            if not result:
                continue

            account_type, master_type = result

            if master_type in ["Supplier", "Customer"]:
                if not self.pay_to_recd_from:
                    self.pay_to_recd_from = frappe.db.get_value(
                        master_type,
                        " - ".join(d.account.split(" - ")[:-1]),
                        master_type == "Customer" and "customer_name" or "supplier_name",
                    )

            if account_type in ["Bank", "Cash"]:
                company_currency = get_company_currency(self.company)
                amt = flt(d.debit) and d.debit or d.credit
                self.total_amount = fmt_money(amt, currency=company_currency)
                from frappe.utils import money_in_words

                self.total_amount_in_words = money_in_words(amt, company_currency)
コード例 #48
0
ファイル: leave_encashment.py プロジェクト: drukhil/erpnext
        def post_accounts_entry(self):
                employee = frappe.get_doc("Employee", self.employee)
                default_bank_cash_account = get_default_bank_cash_account(employee.company, "Bank")
                sal_struc_name = self.get_salary_structure()
                #le = get_le_settings(["expense_account", "tax_account"])
                le = get_le_settings()
                if sal_struc_name:
                        sal_struc= frappe.get_doc("Salary Structure",sal_struc_name)
                        for d in sal_struc.earnings:
                                if d.salary_component == 'Basic Pay':
                                        basic_pay = flt(d.amount)
                else:
                        frappe.throw(_("No Active salary structure found."))
                        
                if basic_pay:
                        salary_tax = get_salary_tax(basic_pay)

                salary_tax = flt(salary_tax) if salary_tax else 0.00                
                
                je = frappe.new_doc("Journal Entry")
		je.flags.ignore_permissions = 1 
		je.title = 'Leave Encashment - '+str(employee.employee_name)
                je.voucher_type = 'Bank Entry'
                je.naming_series = 'Bank Payment Voucher'
                je.company = employee.company
                je.remark = 'Payment against Leave Encashment: ' + self.name;
                je.posting_date = self.application_date
                je.total_amount_in_words =  money_in_words(flt(basic_pay)-flt(salary_tax))

                je.append("accounts", {
                        "account": le.expense_account,
                        "debit_in_account_currency": flt(basic_pay),
                        "reference_type": "Leave Encashment",
                        "reference_name": self.name,
                        #"party_type": "Employee",
                        #"party": self.employee,
                        "cost_center": self.cost_center,
                        "party_check": 0
                })

                je.append("accounts", {
                        "account": le.tax_account,
                        "credit_in_account_currency": flt(salary_tax),
                        "reference_type": "Leave Encashment",
                        "reference_name": self.name,
                        #"party_type": "Employee",
                        #"party": self.employee,
                        "cost_center": self.cost_center,
                        "party_check": 0
                })

                je.append("accounts", {
                        "account": "Sundry Creditors - Employee - SMCL",
                        "debit_in_account_currency": flt(basic_pay),
                        "reference_type": "Leave Encashment",
                        "reference_name": self.name,
                        "party_type": "Employee",
                        "party": self.employee,
                        "cost_center": self.cost_center,
                        "party_check": 0
                })

                je.append("accounts", {
                        "account": "Sundry Creditors - Employee - SMCL",
                        "credit_in_account_currency": flt(basic_pay),
                        "reference_type": "Leave Encashment",
                        "reference_name": self.name,
                        "party_type": "Employee",
                        "party": self.employee,
                        "cost_center": self.cost_center,
                        "party_check": 0
                })

                je.append("accounts", {
                        "account": default_bank_cash_account.account,
                        "credit_in_account_currency": (flt(basic_pay)-flt(salary_tax)),
                        "reference_type": "Leave Encashment",
                        "reference_name": self.name,
                        "balance": default_bank_cash_account.balance,
                        "account_currency": default_bank_cash_account.account_currency,
                        "account_type": default_bank_cash_account.account_type,
                        "cost_center": self.cost_center
                })
                je.insert()

		self.db_set("encash_journal", je.name)
		self.db_set("encashment_amount", flt(basic_pay))
		self.db_set("tax_amount", flt(salary_tax))
コード例 #49
0
ファイル: journal_entry.py プロジェクト: akshay83/erpnext
	def set_total_amount(self, amt, currency):
		self.total_amount = amt
		from frappe.utils import money_in_words
		self.total_amount_in_words = money_in_words(amt, currency)
コード例 #50
0
ファイル: expense_claim.py プロジェクト: drukhil/erpnext
def make_bank_entry(docname):
	from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account

	expense_claim = frappe.get_doc("Expense Claim", docname)
	default_bank_cash_account = get_default_bank_cash_account(expense_claim.company, "Bank")

        # Ver 1.0 by SSK on 10/08/2016, fetching cost_center for the employee
        #msgprint(expense_claim.employee)
        cost_center = frappe.db.sql("""
                        select t2.cost_center
                        from `tabEmployee` t1, `tabDivision` t2
                        where t2.name = t1.division
                        and t2.dpt_name = t1.department
                        and t2.branch = t1.branch
                        and t1.name = '%s'
                """ % (expense_claim.employee))

        # Ver 1.0 Ends, by SSK on 10/08/2016

	je = frappe.new_doc("Journal Entry")
	je.title = 'Travel Claims - '+str(expense_claim.employee)+' '+str(expense_claim.employee_name)
	je.voucher_type = 'Bank Entry'
	je.naming_series = 'Bank Payment Voucher'
	je.company = expense_claim.company
	je.remark = 'Payment against Expense Claim: ' + docname;
        #je.posting_date = nowdate()
	je.posting_date = expense_claim.expense_date
        je.total_amount_in_words =  money_in_words(expense_claim.total_sanctioned_amount)

        # Ver 1.0 Begins, added by SSK on 09/09/2016
        # Following code is commented and the equivalet is passed
        '''
	for expense in expense_claim.expenses:
		je.append("accounts", {
			"account": expense.default_account,
			"debit_in_account_currency": expense.sanctioned_amount,
			"reference_type": "Expense Claim",
			"reference_name": expense_claim.name,
                        "party_type": "Employee",
                        "party": expense_claim.employee,
                        "cost_center": cost_center[0][0],
                        "party_check": 0
		})
        '''

        default_accounts = frappe.db.sql("""
                                select default_account, sum(ifnull(sanctioned_amount,0)) sanctioned_amount,
                                sum(ifnull(advance_total_amount,0)) advance_amount
                                from `tabExpense Claim Detail`
                                where parent = '%s'
                                group by default_account
                                """ % (expense_claim.name), as_dict=True)

        for da in default_accounts:
                if flt(da.sanctioned_amount if da.sanctioned_amount else 0.00) > 0.00:
                        je.append("accounts", {
                                "account": da.default_account,
                                "debit_in_account_currency": da.sanctioned_amount,
                                "reference_type": "Expense Claim",
                                "reference_name": expense_claim.name,
                                "cost_center": cost_center[0][0],
                                "party_check": 0
                        })
                
        # Ver 1.0 Ends

        if flt(expense_claim.total_advance_amount if expense_claim.total_advance_amount else 0.00) > 0.00:
                je.append("accounts", {
                        "account": "Advance to Employee-Travel - SMCL",
                        "credit_in_account_currency": flt(expense_claim.total_advance_amount),
                        "reference_type": "Expense Claim",
                        "reference_name": expense_claim.name,
                        "party_type": "Employee",
                        "party": expense_claim.employee,
                        "cost_center": cost_center[0][0],
                        "party_check": 0
                })

        if flt(expense_claim.total_sanctioned_amount if expense_claim.total_sanctioned_amount else 0.00) > 0.00:
                je.append("accounts", {
                        "account": "Sundry Creditors - Employee - SMCL",
                        "debit_in_account_currency": expense_claim.total_sanctioned_amount,
                        "reference_type": "Expense Claim",
                        "reference_name": expense_claim.name,
                        "party_type": "Employee",
                        "party": expense_claim.employee,
                        "cost_center": cost_center[0][0],
                        "party_check": 0
                })

                je.append("accounts", {
                        "account": "Sundry Creditors - Employee - SMCL",
                        "credit_in_account_currency": expense_claim.total_sanctioned_amount,
                        "reference_type": "Expense Claim",
                        "reference_name": expense_claim.name,
                        "party_type": "Employee",
                        "party": expense_claim.employee,
                        "cost_center": cost_center[0][0],
                        "party_check": 0
                })
                
                je.append("accounts", {
                        "account": default_bank_cash_account.account,
                        "credit_in_account_currency": expense_claim.total_sanctioned_amount,
                        "reference_type": "Expense Claim",
                        "reference_name": expense_claim.name,
                        "balance": default_bank_cash_account.balance,
                        "account_currency": default_bank_cash_account.account_currency,
                        "account_type": default_bank_cash_account.account_type,
                        "cost_center": "Corporate Head Office - SMCL"
                })

                je.insert()
                
        msgprint(_("Posting to Accounts Successful..."))
コード例 #51
0
def kp_si_validate(self, method):
	self.kirat_total_excise_payable_in_words = money_in_words(self.kirat_excise_payable_total)

	#Check for duplicate items and items with zero rate for invoices other than type Sample/Challan.
	validate_repeating_items(self)
	validate_zero_amount_items(self)
コード例 #52
0
ファイル: purchase_item.py プロジェクト: umapulkurte/hotel
def get_money_in_words(n):
	from frappe.utils import money_in_words
	from frappe.utils import in_words
	x=money_in_words(n)
	return (x)
コード例 #53
0
def calculate_net_salary(doc, msd, med):
	gross_pay = 0
	net_pay = 0
	tot_ded = 0
	tot_cont = 0
	tot_books = 0
	emp = frappe.get_doc("Employee", doc.employee)
	tdim, twd = get_total_days(doc, emp, msd, med)
	holidays = get_holidays(doc, msd, med, emp)
	lwp, plw = get_leaves(doc, msd, med, emp)
	doc.leave_without_pay = lwp
	doc.posting_date = med
	wd = twd - holidays #total working days
	doc.total_days_in_month = tdim
	att = frappe.db.sql("""SELECT sum(overtime), count(name) FROM `tabAttendance` 
		WHERE employee = '%s' AND attendance_date >= '%s' AND attendance_date <= '%s' 
		AND status = 'Present' AND docstatus=1""" \
		%(doc.employee, msd, med),as_list=1)

	half_day = frappe.db.sql("""SELECT count(name) FROM `tabAttendance` 
		WHERE employee = '%s' AND attendance_date >= '%s' AND attendance_date <= '%s' 
		AND status = 'Half Day' AND docstatus=1""" \
		%(doc.employee, msd, med),as_list=1)
	
	t_hd = flt(half_day[0][0])
	t_ot = flt(att[0][0])
	doc.total_overtime = t_ot
	tpres = flt(att[0][1])

	ual = twd - tpres - lwp - holidays - plw - (t_hd/2)
	
	if ual < 0:
		frappe.throw(("Unauthorized Leave cannot be Negative for Employee {0}").\
			format(doc.employee_name))
	
	paydays = tpres + (t_hd/2) + plw + math.ceil((tpres+(t_hd/2))/wd * holidays)
	pd_ded = flt(doc.payment_days_for_deductions)
	doc.payment_days = paydays
	
	if doc.change_deductions == 0:
		doc.payment_days_for_deductions = doc.payment_days
		
	if doc.payment_days_for_deductions == doc.payment_days:
		doc.change_deductions = 0
	
	doc.unauthorized_leaves = ual 
	
	ot_ded = round(8*ual,1)
	if ot_ded > t_ot:
		ot_ded = (int(t_ot/8))*8
	doc.overtime_deducted = ot_ded
	d_ual = int(ot_ded/8)

	#Calculate Earnings
	chk_ot = 0 #Check if there is an Overtime Rate
	for d in doc.earnings:
		if d.salary_component == "Overtime Rate":
			chk_ot = 1
	
	for d in doc.earnings:
		earn = frappe.get_doc("Salary Component", d.salary_component)
		if earn.depends_on_lwp == 1:
			d.depends_on_lwp = 1
		else:
			d.depends_on_lwp = 0

		if earn.based_on_earning:
			for d2 in doc.earnings:
				#Calculate Overtime Value
				if earn.earning == d2.salary_component:
					d.default_amount = flt(d2.amount) * t_ot
					d.amount = flt(d2.amount) * (t_ot - ot_ded)
		else:
			if d.depends_on_lwp == 1 and earn.books == 0:
				if chk_ot == 1:
					d.amount = round(flt(d.default_amount) * (paydays+d_ual)/tdim,0)
				else:
					d.amount = round(flt(d.default_amount) * (paydays)/tdim,0)
			elif d.depends_on_lwp == 1 and earn.books == 1:
				d.amount = round(flt(d.default_amount) * flt(doc.payment_days_for_deductions)/ tdim,0)
			elif earn.manual == 1:
				d.default_amount = d.amount
			else:
				d.amount = d.default_amount
		if earn.books == 1:
			tot_books += flt(d.amount)
		
		if earn.only_for_deductions != 1:
			gross_pay += flt(d.amount)

	if gross_pay < 0:
		frappe.throw(("Gross Pay Cannot be Less than Zero for Employee: {0}").format(emp.employee_name))
	
	#Calculate Deductions
	for d in doc.deductions:
		if d.salary_component != 'Loan Deduction':
			sal_comp_doc = frappe.get_doc("Salary Component", d.salary_component)
			if sal_comp_doc.depends_on_lwp == 1:
				if sal_comp_doc.round_up == 1:
					d.amount = int(flt(d.default_amount) * flt(doc.payment_days_for_deductions)/tdim)+1
				else:
					d.amount = round(flt(d.default_amount) * flt(doc.payment_days_for_deductions)/tdim,0)
		tot_ded += flt(d.amount)
	
	#Calculate Contributions
	for c in doc.contributions:
		c.amount = round((flt(c.default_amount) * flt(doc.payment_days_for_deductions)/tdim),0)
		tot_cont += c.amount

	doc.gross_pay = gross_pay
	doc.total_deduction = tot_ded
	doc.net_pay = doc.gross_pay - doc.total_deduction
	doc.rounded_cash = myround(flt(doc.net_pay) - flt(doc.actual_bank_salary))
	doc.rounded_total = flt(doc.actual_bank_salary) + flt(doc.rounded_cash)
	doc.net_pay_books = tot_books - doc.total_deduction
		
	company_currency = erpnext.get_company_currency(doc.company)
	doc.total_in_words = money_in_words(doc.rounded_total, company_currency)
	doc.total_ctc = doc.gross_pay + tot_cont
コード例 #54
0
def calculate_excise_amount(doc):
	from frappe.utils import money_in_words

	doc.excise_amount = sum([flt(d.base_tax_amount) for d in doc.get("taxes")
			if cint(d.is_excise_account) == 1])
	doc.excise_amount_in_words = money_in_words(doc.excise_amount, erpnext.get_company_currency(doc.company))
コード例 #55
0
	def validate(self):
		if (self.payment_amount <= 0):
			frappe.throw("Check Payment Amount");

		from frappe.utils import money_in_words
		self.in_words = money_in_words(self.payment_amount);
コード例 #56
0
	def set_total_amount(self, amt):
		company_currency = get_company_currency(self.company)
		self.total_amount = amt
		from frappe.utils import money_in_words
		self.total_amount_in_words = money_in_words(amt, company_currency)