Example #1
0
    def validate(self):
        self.title = self.driver_name
        if not self.active_date:
            frappe.throw(_("Active Date need to be filled"))
        elif not self.commission_rule:
            frappe.throw(_("Commission Rule need to be filled"))
        elif self.active_date <= self.last_clearance_date:
            frappe.throw(
                _("The active date need to be after last clearance date"))

        last_acr = frappe.db.sql("""
                        select name from `tabAssign Commission Rule`
                        where driver = %s and docstatus = 1 and name != %s order by modified desc limit 1
                        """, (self.driver, self.name),
                                 as_dict=True)

        last_acr_clr = frappe.db.sql("""
                        select name from `tabClearance With Driver`
                        where assign_com_rule = (select name from `tabAssign Commission Rule`
                        where driver = %s and docstatus = 1 and name != %s order by modified desc limit 1)
			and docstatus = 1
                        """, (self.driver, self.name),
                                     as_dict=True)

        if (len(last_acr_clr) == 0 and len(last_acr) > 0):

            frappe.throw(
                _("The Assign Commission Rule {0} is submitted and not used with \
                        any clearance, please modify it or do clearance first."
                  ).format(last_acr[0]['name']))

        self.check_driver_acrl()
Example #2
0
	def validate_last_fillup(self):
		last_fillup = frappe.get_list("Fill Up Record",
			fields=["odometer_km","odometer_mile"],
			filters = {
				"vehicle": self.vehicle,
				"docstatus": 1
			})
		
		fleet_settings = frappe.get_single("Fleet Settings")

		if fleet_settings.distance == "km":
			if last_fillup and last_fillup[0].odometer_km > self.odometer_km:
				frappe.throw(_("Odometer was showing higher number in previous transaction"))

		if fleet_settings.distance == "mile":
			if last_fillup and last_fillup[0].odometer_mile > self.odometer_mile:
				frappe.throw(_("Odometer was showing higher number in previous transaction"))
Example #3
0
    def on_submit(self):
        if not (self.receiving_payment_account) or not (
                self.account_paid_from) or not (self.expenses_account):
            frappe.throw(
                _("All Transactions Accounts need to be filled to be able to submit"
                  ))

        self.update_to_clearance()

        self.posting_date = self.clearance_date
        self.make_gl_entries()
Example #4
0
    def check_driver_acrl(self):

        any_acrl = frappe.db.sql("""
                select * from `tabAssign Commission Rule` where driver = %s and name != %s and docstatus = 0""",
                                 (self.driver, self.name),
                                 as_dict=True)

        #     		frappe.msgprint(_("The AnyACRL is: {0}"). format(AnyACRL[0]['name']))

        if len(any_acrl) > 0:
            frappe.throw(
                _("There is {0} saved and not submmited for this driver, please complete and submit it"
                  ).format(any_acrl[0]['name']))
Example #5
0
    def validate_last_fillup(self):
        last_fillup = frappe.get_list("Fill Up Record",
                                      fields=["odometer_km", "odometer_mile"],
                                      filters={
                                          "vehicle": self.vehicle,
                                          "docstatus": 1
                                      })

        fleet_settings = frappe.get_single("Fleet Settings")

        if fleet_settings.distance == "km":
            if last_fillup and last_fillup[0].odometer_km > self.odometer_km:
                frappe.throw(
                    _("Odometer was showing higher number in previous transaction"
                      ))

        if fleet_settings.distance == "mile":
            if last_fillup and last_fillup[
                    0].odometer_mile > self.odometer_mile:
                frappe.throw(
                    _("Odometer was showing higher number in previous transaction"
                      ))
Example #6
0
    def on_submit(self):

        last_acr = frappe.db.sql("""
			select name from `tabAssign Commission Rule`
                        where driver = %s and docstatus = 1 and name != %s order by modified desc limit 1
			""", (self.driver, self.name),
                                 as_dict=True)

        last_acr_clr = frappe.db.sql("""
			select name from `tabClearance With Driver` 
			where assign_com_rule = (select name from `tabAssign Commission Rule` 
			where driver = %s and docstatus = 1 and name != %s order by modified desc limit 1)
			""", (self.driver, self.name),
                                     as_dict=True)

        if (len(last_acr_clr) == 0 and len(last_acr) > 0):

            frappe.throw(
                _("The Assign Commission Rule {0} is submitted and not used with \
			any clearance, please modify it or do clearance first.").format(
                    last_acr[0]['name']))
Example #7
0
	def validate_arrival_departure(self):
		if (self.arrival_odometer_mile and self.departure_odometer_mile) or (self.arrival_odometer_km and self.departure_odometer_km):
			if self.arrival_odometer_mile < self.departure_odometer_mile or self.arrival_odometer_km < self.departure_odometer_km:
				frappe.throw(_("Arrival Odometer Reading cannot be Greater than Departure Odometer"))
Example #8
0
 def validate(self):
     self.title = self.driver_name
     if (self.clearance_date < self.last_clearance_date):
         frappe.throw(
             _("Clearance Date can not be before Last Clearance Date"))