Esempio n. 1
0
	def set_total_in_words(self):
		from webnotes.utils import money_in_words
		company_currency = get_company_currency(self.doc.company)
		if self.meta.get_field("in_words"):
			self.doc.in_words = money_in_words(self.doc.grand_total, company_currency)
		if self.meta.get_field("in_words_import"):
			self.doc.in_words_import = money_in_words(self.doc.grand_total_import,
		 		self.doc.currency)
Esempio n. 2
0
 def set_total_in_words(self):
     from webnotes.utils import money_in_words
     company_currency = get_company_currency(self.doc.company)
     if self.meta.get_field("in_words"):
         self.doc.in_words = money_in_words(self.doc.grand_total,
                                            company_currency)
     if self.meta.get_field("in_words_import"):
         self.doc.in_words_import = money_in_words(
             self.doc.grand_total_import, self.doc.currency)
Esempio n. 3
0
	def set_total_in_words(self):
		from webnotes.utils import money_in_words
		company_currency = get_company_currency(self.doc.company)
		
		disable_rounded_total = cint(webnotes.conn.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)
Esempio n. 4
0
	def set_total_in_words(self):
		from webnotes.utils import money_in_words
		company_currency = get_company_currency(self.doc.company)
		
		disable_rounded_total = cint(webnotes.conn.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)
Esempio n. 5
0
	def set_amount_in_words(self):
		from webnotes.utils import money_in_words
		base_currency = webnotes.conn.get_value("Company", self.doc.currency,
			"default_currency")
		
		self.doc.fields[self.fmap.grand_total_in_words] = \
			money_in_words(self.doc.grand_total, base_currency)
		self.doc.fields[self.fmap.rounded_total_in_words] = \
			money_in_words(self.doc.rounded_total, base_currency)
		
		self.doc.fields[self.fmap.grand_total_in_words_print] = \
			money_in_words(self.doc.fields.get(self.fmap.grand_total_print),
			self.doc.currency)
		self.doc.fields[self.fmap.rounded_total_in_words_print] = \
			money_in_words(self.doc.fields.get(self.fmap.rounded_total_print),
			self.doc.currency)
Esempio n. 6
0
    def set_amount_in_words(self):
        from webnotes.utils import money_in_words
        base_currency = webnotes.conn.get_value("Company", self.doc.currency,
                                                "default_currency")

        self.doc.fields[self.fmap.grand_total_in_words] = \
         money_in_words(self.doc.grand_total, base_currency)
        self.doc.fields[self.fmap.rounded_total_in_words] = \
         money_in_words(self.doc.rounded_total, base_currency)

        self.doc.fields[self.fmap.grand_total_in_words_print] = \
         money_in_words(self.doc.fields.get(self.fmap.grand_total_print),
         self.doc.currency)
        self.doc.fields[self.fmap.rounded_total_in_words_print] = \
         money_in_words(self.doc.fields.get(self.fmap.rounded_total_print),
         self.doc.currency)
Esempio n. 7
0
	def validate(self):
		from webnotes.utils import money_in_words
		self.check_existing()
		
		if not (len(self.doclist.get({"parentfield": "earning_details"})) or 
			len(self.doclist.get({"parentfield": "deduction_details"}))):
				self.get_emp_and_leave_details()
		else:
			self.get_leave_details(self.doc.leave_without_pay)

		if not self.doc.net_pay:
			self.calculate_net_pay()
			
		company_currency = get_company_currency(self.doc.company)
		self.doc.total_in_words = money_in_words(self.doc.rounded_total, company_currency)
Esempio n. 8
0
	def set_print_format_fields(self):
		for d in getlist(self.doclist, 'entries'):
			#msgprint(self.doc.company)
			chk_type = sql("select master_type, account_type from `tabAccount` where name='%s'" % d.account)
			master_type, acc_type = chk_type and cstr(chk_type[0][0]) or '', chk_type and cstr(chk_type[0][1]) or ''
			if master_type in ['Supplier', 'Customer']:
				if not self.doc.pay_to_recd_from:
					self.doc.pay_to_recd_from = webnotes.conn.get_value(master_type, ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name')
			
			if acc_type == 'Bank or Cash':
				company_currency = get_company_currency(self.doc.company)
				amt = flt(d.debit) and d.debit or d.credit	
				self.doc.total_amount = company_currency +' '+ cstr(amt)
				from webnotes.utils import money_in_words
				self.doc.total_amount_in_words = money_in_words(amt, company_currency)
Esempio n. 9
0
	def validate(self):
		from webnotes.utils import money_in_words
		self.check_existing()
		
		if not (len(self.doclist.get({"parentfield": "earning_details"})) or 
			len(self.doclist.get({"parentfield": "deduction_details"}))):
				self.get_emp_and_leave_details()
		else:
			self.get_leave_details(self.doc.leave_without_pay)

		if not self.doc.net_pay:
			self.calculate_net_pay()
			
		company_currency = get_company_currency(self.doc.company)
		self.doc.total_in_words = money_in_words(self.doc.rounded_total, company_currency)
Esempio n. 10
0
	def set_print_format_fields(self):
		for d in getlist(self.doclist, 'entries'):
			account_type, master_type = webnotes.conn.get_value("Account", d.account, 
				["account_type", "master_type"])
				
			if master_type in ['Supplier', 'Customer']:
				if not self.doc.pay_to_recd_from:
					self.doc.pay_to_recd_from = webnotes.conn.get_value(master_type, 
						' - '.join(d.account.split(' - ')[:-1]), 
						master_type == 'Customer' and 'customer_name' or 'supplier_name')
			
			if account_type == 'Bank or Cash':
				company_currency = get_company_currency(self.doc.company)
				amt = flt(d.debit) and d.debit or d.credit	
				self.doc.total_amount = company_currency + ' ' + cstr(amt)
				from webnotes.utils import money_in_words
				self.doc.total_amount_in_words = money_in_words(amt, company_currency)
Esempio n. 11
0
	def set_print_format_fields(self):
		for d in getlist(self.doclist, 'entries'):
			account_type, master_type = webnotes.conn.get_value("Account", d.account, 
				["account_type", "master_type"])
				
			if master_type in ['Supplier', 'Customer']:
				if not self.doc.pay_to_recd_from:
					self.doc.pay_to_recd_from = webnotes.conn.get_value(master_type, 
						' - '.join(d.account.split(' - ')[:-1]), 
						master_type == 'Customer' and 'customer_name' or 'supplier_name')
			
			if account_type == 'Bank or Cash':
				company_currency = get_company_currency(self.doc.company)
				amt = flt(d.debit) and d.debit or d.credit	
				self.doc.total_amount = company_currency +' '+ cstr(amt)
				from webnotes.utils import money_in_words
				self.doc.total_amount_in_words = money_in_words(amt, company_currency)
Esempio n. 12
0
    def set_print_format_fields(self):
        for d in getlist(self.doclist, 'entries'):
            #msgprint(self.doc.company)
            chk_type = sql(
                "select master_type, account_type from `tabAccount` where name='%s'"
                % d.account)
            master_type, acc_type = chk_type and cstr(
                chk_type[0][0]) or '', chk_type and cstr(chk_type[0][1]) or ''
            if master_type in ['Supplier', 'Customer']:
                if not self.doc.pay_to_recd_from:
                    self.doc.pay_to_recd_from = webnotes.conn.get_value(
                        master_type, ' - '.join(d.account.split(' - ')[:-1]),
                        master_type == 'Customer' and 'customer_name'
                        or 'supplier_name')

            if acc_type == 'Bank or Cash':
                company_currency = get_company_currency(self.doc.company)
                amt = flt(d.debit) and d.debit or d.credit
                self.doc.total_amount = company_currency + ' ' + cstr(amt)
                from webnotes.utils import money_in_words
                self.doc.total_amount_in_words = money_in_words(
                    amt, company_currency)
Esempio n. 13
0
	def get_total_in_words(self, currency, amount):
		from webnotes.utils import money_in_words
		return money_in_words(amount, currency)	
def execute():
    import webnotes
    from webnotes.utils import flt
    from webnotes.model.code import get_obj
    from webnotes.utils import money_in_words

    vouchers = webnotes.conn.sql("""
		select 
			parent, parenttype, modified, docstatus, 
			sum(if(category in ('Valuation and Total', 'Total') and add_deduct_tax='Add',
 				tax_amount, 0)) as tax_added, 
			sum(if(category in ('Valuation and Total', 'Total') and add_deduct_tax='Deduct', 
 				tax_amount, 0)) as tax_ded			
		from 
			`tabPurchase Taxes and Charges`
		where 
			modified >= '2012-07-12'
			and parenttype != 'Purchase Taxes and Charges Master'
			and parent not like 'old_p%'
			and docstatus != 2
		group by parenttype, parent
		order by modified
	""",
                                 as_dict=1)

    for d in vouchers:
        current_total_tax = webnotes.conn.sql(
            """select total_tax from `tab%s` where name = %s""" %
            (d['parenttype'], '%s'), d['parent'])
        correct_total_tax = flt(d['tax_added']) - flt(d['tax_ded'])

        if flt(current_total_tax[0][0]) != correct_total_tax:
            if d['parenttype'] == 'Purchase Invoice':
                webnotes.conn.sql(
                    """
					update `tab%s` 
					set 
						total_tax = %s, 
						other_charges_added = %s, 
						other_charges_added_import = other_charges_added / conversion_rate, 
						other_charges_deducted = %s, 
						other_charges_deducted_import = other_charges_deducted / conversion_rate, 
						grand_total = net_total + other_charges_added - other_charges_deducted,
						grand_total_import = grand_total / conversion_rate,
						total_amount_to_pay = grand_total - total_tds_on_voucher,
						outstanding_amount = total_amount_to_pay - total_advance
					where 
						name = %s
				""" % (d['parenttype'], '%s', '%s', '%s', '%s'),
                    (correct_total_tax, d['tax_added'], d['tax_ded'],
                     d['parent']))

            else:
                webnotes.conn.sql(
                    """
					update `tab%s` 
					set 
						total_tax = %s, 
						other_charges_added = %s, 
						other_charges_added_import = other_charges_added / conversion_rate, 
						other_charges_deducted = %s, 
						other_charges_deducted_import = other_charges_deducted / conversion_rate,
						grand_total = net_total + total_tax, 
						grand_total_import = grand_total / conversion_rate,
						rounded_total = round(grand_total)
					where 
						name = %s
				""" % (d['parenttype'], '%s', '%s', '%s', '%s'),
                    (correct_total_tax, d['tax_added'], d['tax_ded'],
                     d['parent']))

            # set in words
            obj = get_obj(d['parenttype'], d['parent'], with_children=1)

            base_currency = webnotes.conn.get_value('Company', obj.doc.company, 'default_currency')\
             or get_defaults('default_currency')

            webnotes.conn.set_value(d['parenttype'], d['parent'], \
             'in_words', money_in_words(obj.doc.grand_total, base_currency))
            webnotes.conn.set_value(d['parenttype'], d['parent'], \
             'in_words_import', money_in_words(obj.doc.grand_total_import, obj.doc.currency))

            # fix gl entries
            if d['parenttype'] == 'Purchase Invoice' and d['docstatus'] == 1:
                webnotes.conn.sql(
                    """update `tabGL Entry` set is_cancelled = 'Yes' 
					where voucher_type = %s and voucher_no = %s""",
                    (d['parenttype'], d['parent']))

                obj.make_gl_entries()
Esempio n. 15
0
 def get_total_in_words(self, currency, amount):
     from webnotes.utils import money_in_words
     return money_in_words(amount, currency)
Esempio n. 16
0
	def validate(self):
		from webnotes.utils import money_in_words
		self.check_existing()
		company_currency = get_company_currency(self.doc.company)
		self.doc.total_in_words = money_in_words(self.doc.rounded_total, company_currency)
Esempio n. 17
0
 def validate(self):
     from webnotes.utils import money_in_words
     self.check_existing()
     company_currency = get_company_currency(self.doc.company)
     self.doc.total_in_words = money_in_words(self.doc.rounded_total,
                                              company_currency)
Esempio n. 18
0
def execute():
    import webnotes
    from webnotes.utils import flt
    from webnotes.model.code import get_obj
    from webnotes.utils import money_in_words

    vouchers = webnotes.conn.sql(
        """
		select 
			parent, parenttype, modified, docstatus, 
			sum(if(category in ('Valuation and Total', 'Total') and add_deduct_tax='Add',
 				tax_amount, 0)) as tax_added, 
			sum(if(category in ('Valuation and Total', 'Total') and add_deduct_tax='Deduct', 
 				tax_amount, 0)) as tax_ded			
		from 
			`tabPurchase Taxes and Charges`
		where 
			modified >= '2012-07-12'
			and parenttype != 'Purchase Taxes and Charges Master'
			and parent not like 'old_p%'
			and docstatus != 2
		group by parenttype, parent
		order by modified
	""",
        as_dict=1,
    )

    for d in vouchers:
        current_total_tax = webnotes.conn.sql(
            """select total_tax from `tab%s` where name = %s""" % (d["parenttype"], "%s"), d["parent"]
        )
        correct_total_tax = flt(d["tax_added"]) - flt(d["tax_ded"])

        if flt(current_total_tax[0][0]) != correct_total_tax:
            if d["parenttype"] == "Purchase Invoice":
                webnotes.conn.sql(
                    """
					update `tab%s` 
					set 
						total_tax = %s, 
						other_charges_added = %s, 
						other_charges_added_import = other_charges_added / conversion_rate, 
						other_charges_deducted = %s, 
						other_charges_deducted_import = other_charges_deducted / conversion_rate, 
						grand_total = net_total + other_charges_added - other_charges_deducted,
						grand_total_import = grand_total / conversion_rate,
						total_amount_to_pay = grand_total - total_tds_on_voucher,
						outstanding_amount = total_amount_to_pay - total_advance
					where 
						name = %s
				"""
                    % (d["parenttype"], "%s", "%s", "%s", "%s"),
                    (correct_total_tax, d["tax_added"], d["tax_ded"], d["parent"]),
                )

            else:
                webnotes.conn.sql(
                    """
					update `tab%s` 
					set 
						total_tax = %s, 
						other_charges_added = %s, 
						other_charges_added_import = other_charges_added / conversion_rate, 
						other_charges_deducted = %s, 
						other_charges_deducted_import = other_charges_deducted / conversion_rate,
						grand_total = net_total + total_tax, 
						grand_total_import = grand_total / conversion_rate,
						rounded_total = round(grand_total)
					where 
						name = %s
				"""
                    % (d["parenttype"], "%s", "%s", "%s", "%s"),
                    (correct_total_tax, d["tax_added"], d["tax_ded"], d["parent"]),
                )

                # set in words
            obj = get_obj(d["parenttype"], d["parent"], with_children=1)

            base_currency = webnotes.conn.get_value("Company", obj.doc.company, "default_currency") or get_defaults(
                "default_currency"
            )

            webnotes.conn.set_value(
                d["parenttype"], d["parent"], "in_words", money_in_words(obj.doc.grand_total, base_currency)
            )
            webnotes.conn.set_value(
                d["parenttype"],
                d["parent"],
                "in_words_import",
                money_in_words(obj.doc.grand_total_import, obj.doc.currency),
            )

            # fix gl entries
            if d["parenttype"] == "Purchase Invoice" and d["docstatus"] == 1:
                webnotes.conn.sql(
                    """update `tabGL Entry` set is_cancelled = 'Yes' 
					where voucher_type = %s and voucher_no = %s""",
                    (d["parenttype"], d["parent"]),
                )

                obj.make_gl_entries()