"""Test whether null is preserved for number fields in PB EMP201 collection.""" import os, requests, pathlib for line in pathlib.Path(r'C:\Users\SJ\.minimax-agent\projects\Workflow\.env.local').read_text().splitlines(): if line.strip() and '=' in line and not line.startswith('#'): k, v = line.split('=', 1) os.environ.setdefault(k.strip(), v.strip()) token = os.environ['PB_TOKEN'] h = {'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'} # Try PATCH with explicit null for paye_amount on a not_filed row rec = 'uw1xwj3srpua9u6' # ULTRAFIN r = requests.patch( f'https://pb.agent.apphub.co.za/api/collections/ysterbaard_SARS_EMP201_PAYE/records', headers=h, # WRONG — use the records/{id} endpoint timeout=15, ) # Get current state first r = requests.get( f'https://pb.agent.apphub.co.za/api/collections/ysterbaard_SARS_EMP201_PAYE/records', headers=h, params={'filter': f'company_period_key="uw1xwj3srpua9u6:202608"'}, timeout=15, ) r.raise_for_status() rec_id = r.json()['items'][0]['id'] print(f'ULTRAFIN record id: {rec_id}') # Now PATCH with explicit null r = requests.patch( f'https://pb.agent.apphub.co.za/api/collections/ysterbaard_SARS_EMP201_PAYE/records/{rec_id}', headers=h, json={ 'paye_amount': None, 'sdl_amount': None, 'uif_amount': None, 'total_payable': None, }, timeout=15, ) print(f'PATCH with null: status={r.status_code}') d = r.json() print(f' paye_amount: {d.get("paye_amount")!r}') print(f' sdl_amount: {d.get("sdl_amount")!r}') print(f' uif_amount: {d.get("uif_amount")!r}') print(f' total_payable: {d.get("total_payable")!r}')