Example #1
0
    def calculate_totals(self):
        self.doc.grand_total = flt(
            self.doc.get("taxes")[-1].total if self.doc.get("taxes") else self.
            doc.net_total)

        self.doc.total_taxes_and_charges = flt(
            self.doc.grand_total - self.doc.net_total,
            self.doc.precision("total_taxes_and_charges"))

        self._set_in_company_currency(self.doc, ["total_taxes_and_charges"])

        if self.doc.doctype in [
                "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"
        ]:
            self.doc.base_grand_total = flt(self.doc.grand_total * self.doc.conversion_rate) \
             if self.doc.total_taxes_and_charges else self.doc.base_net_total
        else:
            self.doc.taxes_and_charges_added = self.doc.taxes_and_charges_deducted = 0.0
            for tax in self.doc.get("taxes"):
                if tax.category in ["Valuation and Total", "Total"]:
                    if tax.add_deduct_tax == "Add":
                        self.doc.taxes_and_charges_added += flt(
                            tax.tax_amount_after_discount_amount)
                    else:
                        self.doc.taxes_and_charges_deducted += flt(
                            tax.tax_amount_after_discount_amount)

            self.doc.round_floats_in(
                self.doc,
                ["taxes_and_charges_added", "taxes_and_charges_deducted"])

            self.doc.base_grand_total = flt(self.doc.grand_total * self.doc.conversion_rate) \
             if (self.doc.taxes_and_charges_added or self.doc.taxes_and_charges_deducted) \
             else self.doc.base_net_total

            self._set_in_company_currency(
                self.doc,
                ["taxes_and_charges_added", "taxes_and_charges_deducted"])

        self.doc.round_floats_in(self.doc, ["grand_total", "base_grand_total"])

        if self.doc.meta.get_field("rounded_total"):
            self.doc.rounded_total = round_based_on_smallest_currency_fraction(
                self.doc.grand_total, self.doc.currency,
                self.doc.precision("rounded_total"))
        if self.doc.meta.get_field("base_rounded_total"):
            company_currency = get_company_currency(self.doc.company)

            self.doc.base_rounded_total = \
             round_based_on_smallest_currency_fraction(self.doc.base_grand_total,
              company_currency, self.doc.precision("base_rounded_total"))
Example #2
0
	def set_rounded_total(self):
		if frappe.db.get_single_value("Global Defaults", "disable_rounded_total"):
			self.doc.rounded_total = self.doc.base_rounded_total = 0
			return

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

		if self.doc.meta.get_field("base_rounded_total"):
			company_currency = erpnext.get_company_currency(self.doc.company)

			self.doc.base_rounded_total = \
				round_based_on_smallest_currency_fraction(self.doc.base_grand_total,
					company_currency, self.doc.precision("base_rounded_total"))
    def set_rounded_total(self):
        if frappe.db.get_single_value("Global Defaults",
                                      "disable_rounded_total"):
            self.doc.rounded_total = self.doc.base_rounded_total = 0
            return

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

        if self.doc.meta.get_field("base_rounded_total"):
            company_currency = erpnext.get_company_currency(self.doc.company)

            self.doc.base_rounded_total = \
             round_based_on_smallest_currency_fraction(self.doc.base_grand_total,
              company_currency, self.doc.precision("base_rounded_total"))
Example #4
0
	def calculate_totals(self):
		self.doc.grand_total = flt(self.doc.get("taxes")[-1].total
			if self.doc.get("taxes") else self.doc.net_total)

		self.doc.total_taxes_and_charges = flt(self.doc.grand_total - self.doc.net_total,
			self.doc.precision("total_taxes_and_charges"))

		self._set_in_company_currency(self.doc, ["total_taxes_and_charges"])

		if self.doc.doctype in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
			self.doc.base_grand_total = flt(self.doc.grand_total * self.doc.conversion_rate) \
				if self.doc.total_taxes_and_charges else self.doc.base_net_total
		else:
			self.doc.taxes_and_charges_added = self.doc.taxes_and_charges_deducted = 0.0
			for tax in self.doc.get("taxes"):
				if tax.category in ["Valuation and Total", "Total"]:
					if tax.add_deduct_tax == "Add":
						self.doc.taxes_and_charges_added += flt(tax.tax_amount_after_discount_amount)
					else:
						self.doc.taxes_and_charges_deducted += flt(tax.tax_amount_after_discount_amount)

			self.doc.round_floats_in(self.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"])

			self.doc.base_grand_total = flt(self.doc.grand_total * self.doc.conversion_rate) \
				if (self.doc.taxes_and_charges_added or self.doc.taxes_and_charges_deducted) \
				else self.doc.base_net_total

			self._set_in_company_currency(self.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"])

		self.doc.round_floats_in(self.doc, ["grand_total", "base_grand_total"])

		if self.doc.meta.get_field("rounded_total"):
			self.doc.rounded_total = round_based_on_smallest_currency_fraction(self.doc.grand_total,
				self.doc.currency, self.doc.precision("rounded_total"))
		if self.doc.meta.get_field("base_rounded_total"):
			company_currency = get_company_currency(self.doc.company)

			self.doc.base_rounded_total = \
				round_based_on_smallest_currency_fraction(self.doc.base_grand_total,
					company_currency, self.doc.precision("base_rounded_total"))
Example #5
0
	def set_rounded_total(self):
		if self.doc.meta.get_field("rounded_total"):
			if self.doc.is_rounded_total_disabled():
				self.doc.rounded_total = self.doc.base_rounded_total = 0
				return

			self.doc.rounded_total = round_based_on_smallest_currency_fraction(self.doc.grand_total,
				self.doc.currency, self.doc.precision("rounded_total"))

			#if print_in_rate is set, we would have already calculated rounding adjustment
			self.doc.rounding_adjustment += flt(self.doc.rounded_total - self.doc.grand_total,
				self.doc.precision("rounding_adjustment"))

			self._set_in_company_currency(self.doc, ["rounding_adjustment", "rounded_total"])
Example #6
0
	def set_rounded_total(self):
		if self.doc.meta.get_field("rounded_total"):
			if self.doc.is_rounded_total_disabled():
				self.doc.rounded_total = self.doc.base_rounded_total = 0
				return

			self.doc.rounded_total = round_based_on_smallest_currency_fraction(self.doc.grand_total,
				self.doc.currency, self.doc.precision("rounded_total"))

			#if print_in_rate is set, we would have already calculated rounding adjustment
			self.doc.rounding_adjustment += flt(self.doc.rounded_total - self.doc.grand_total,
				self.doc.precision("rounding_adjustment"))

			self._set_in_company_currency(self.doc, ["rounding_adjustment", "rounded_total"])
Example #7
0
def update_totals(gst_tax, doc):
    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.set_payment_schedule()
Example #8
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 not doc.is_rounded_total_disabled():
            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"))

        calculate_outstanding_amount(doc)

    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()
Example #9
0
def update_totals(vat_tax, base_vat_tax, doc):
	"""Update the grand total values in the form."""
	doc.base_grand_total -= base_vat_tax
	doc.grand_total -= vat_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, erpbee.get_company_currency(doc.company))
	doc.set_payment_schedule()