Example #1
0
	def get_party_total(self, party_type, gle_field, label):
		import re
		party_list = frappe.db.sql_list("select name from `tab{0}`".format(party_type))

		# account is "Bank" or "Cash"
		bc_accounts = [esc(a["name"], "()|") for a in self.get_accounts()
			if a["account_type"] in ["Bank", "Cash"]]
		bc_regex = re.compile("""(%s)""" % "|".join(bc_accounts))

		total = 0
		for gle in self.get_gl_entries(self.from_date, self.to_date):
			# check that its made against a bank or cash account
			if gle["party_type"]==party_type and gle["party"] in party_list and gle["against"] and \
					bc_regex.findall(gle["against"]):
				val = gle["debit"] - gle["credit"]
				total += (gle_field=="debit" and 1 or -1) * val

		return total, self.get_html(label, self.currency, fmt_money(total))
Example #2
0
    def get_party_total(self, party_type, gle_field, label):
        import re

        # account is of master_type Customer or Supplier
        accounts = [a["name"] for a in self.get_accounts() if a["master_type"] == party_type]

        # account is "Bank" or "Cash"
        bc_accounts = [esc(a["name"], "()|") for a in self.get_accounts() if a["account_type"] in ["Bank", "Cash"]]
        bc_regex = re.compile("""(%s)""" % "|".join(bc_accounts))

        total = 0
        for gle in self.get_gl_entries(self.from_date, self.to_date):
            # check that its made against a bank or cash account
            if gle["account"] in accounts and gle["against"] and bc_regex.findall(gle["against"]):
                val = gle["debit"] - gle["credit"]
                total += (gle_field == "debit" and 1 or -1) * val

        return total, self.get_html(label, self.currency, fmt_money(total))
Example #3
0
	def get_party_total(self, party_type, gle_field, label):
		import re
		# account is of master_type Customer or Supplier
		accounts = [a["name"] for a in self.get_accounts()
			if a["master_type"]==party_type]

		# account is "Bank" or "Cash"
		bc_accounts = [esc(a["name"], "()|") for a in self.get_accounts()
			if a["account_type"] in ["Bank", "Cash"]]
		bc_regex = re.compile("""(%s)""" % "|".join(bc_accounts))

		total = 0
		for gle in self.get_gl_entries(self.from_date, self.to_date):
			# check that its made against a bank or cash account
			if gle["account"] in accounts and gle["against"] and \
					bc_regex.findall(gle["against"]):
				val = gle["debit"] - gle["credit"]
				total += (gle_field=="debit" and 1 or -1) * val

		return total, self.get_html(label, self.currency, fmt_money(total))
Example #4
0
    def get_party_total(self, party_type, gle_field, label):
        import re
        party_list = frappe.db.sql_list(
            "select name from `tab{0}`".format(party_type))

        # account is "Bank" or "Cash"
        bc_accounts = [
            esc(a["name"], "()|") for a in self.get_accounts()
            if a["account_type"] in ["Bank", "Cash"]
        ]
        bc_regex = re.compile("""(%s)""" % "|".join(bc_accounts))

        total = 0
        for gle in self.get_gl_entries(self.from_date, self.to_date):
            # check that its made against a bank or cash account
            if gle["party_type"]==party_type and gle["party"] in party_list and gle["against"] and \
              bc_regex.findall(gle["against"]):
                val = gle["debit"] - gle["credit"]
                total += (gle_field == "debit" and 1 or -1) * val

        return total, self.get_html(label, self.currency, fmt_money(total))