Exemple #1
0
    def set_total_in_words(self):
        from dataent.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)
Exemple #2
0
 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)
Exemple #3
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)

        self.calculate_net_pay()

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

        if dataent.db.get_single_value("HR Settings",
                                       "max_working_hours_against_timesheet"):
            max_working_hours = dataent.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)):
                dataent.msgprint(_(
                    "Total working hours should not be greater than max working hours {0}"
                ).format(max_working_hours),
                                 alert=True)
def execute():
    company_currency = dict(
        dataent.db.sql("select name, default_currency from `tabCompany`"))
    bank_or_cash_accounts = dataent.db.sql_list(
        """select name from `tabAccount`
		where account_type in ('Bank', 'Cash') and docstatus < 2""")

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

        je_doc = dataent.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:
            dataent.db.sql(
                """update `tabJournal Entry` set total_amount=%s, total_amount_in_words=%s
				where name = %s""", (total_amount, total_amount_in_words, je))
Exemple #5
0
    def set_total_in_words(self):
        from dataent.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)
Exemple #6
0
    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]))
Exemple #7
0
    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 = dataent.db.get_value(
                "Student Group", d.student_group, "program")
            if self.program and student_group_program and self.program != student_group_program:
                dataent.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)