@staticmethod
    def budget_monitoring_onaccept(form):
        """
            Handle Updates of entries to reset the hidden start_date
        """

        db = current.db
        table = current.s3db.budget_monitoring

        # Read the Budget Monitoring record
        record_id = form.vars.id
        record = db(table.id == record_id).select(table.budget_entity_id,
                                                  table.start_date,
                                                  table.end_date,
                                                  limitby=(0, 1)
                                                  ).first()
        if not record:
            s3_debug("Cannot find Budget Monitoring record (no record for this ID), so can't update start_date")
            return
        budget_entity_id = record.budget_entity_id
        start_date = record.start_date
        end_date = record.end_date

        # Locate the immediately preceding record
        query = (table.budget_entity_id == budget_entity_id)  & \
                (table.deleted == False) & \
                (table.end_date < end_date)
        record = db(query).select(table.end_date,
                                  limitby=(0, 1),
                                  orderby=~(table.end_date),
                                  ).first()
        if record and record.end_date != start_date:
            # Update this record's start_date
            db(table.id == record_id).update(start_date = record.end_date)

        # Locate the immediately succeeding record
        query = (table.budget_entity_id == budget_entity_id)  & \
                (table.deleted == False) & \
                (end_date > table.end_date)
        record = db(query).select(table.id,
                                  table.start_date,
                                  limitby=(0, 1),
                                  orderby=table.end_date,
                                  ).first()
        if record and record.start_date != end_date:
            # Update that record's start_date
            record.update_record(start_date = end_date)

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3db/budget.py/S3BudgetMonitoringModel.budget_monitoring_onaccept/swapped operands of `>`