def register_payments(self, person_id, payments, date=None, comments=None):

        if isinstance(payments, basestring):
            try:
                payments = json.loads(payments)
            except (ValueError, TypeError):
                payments = []

        if not date:
            date = current.request.utcnow

        # Data to write
        data = {"status": 2,
                "paid_on": date,
                }
        if comments:
            data["comments"] = comments

        atable = current.s3db.dvr_allowance

        updated = 0
        failed = 0

        # Customise allowance resource
        r = S3Request("dvr", "allowance",
                      current.request,
                      args = [],
                      get_vars = {},
                      )
        r.customise_resource("dvr_allowance")
        onaccept = current.s3db.onaccept

        db = current.db
        accessible = current.auth.s3_accessible_query("update", atable)
        for payment in payments:
            record_id = payment.get("r")
            query = accessible & \
                    (atable.id == record_id) & \
                    (atable.person_id == person_id) & \
                    (atable.status != 2) & \
                    (atable.deleted != True)
            success = db(query).update(**data)
            if success:
                record = {"id": record_id, "person_id": person_id}
                record.update(data)
                onaccept(atable, record, method="update")
                updated += 1
            else:
                failed += 1

        return updated, failed

    # -------------------------------------------------------------------------
Helper function to register payments
dataset/ETHPy150Open sahana/eden/modules/s3db/dvr.py/DVRRegisterPayment.register_payments