Skip to content

Remove timestamp field from createBill - #12

Open
OCzarnecki wants to merge 1 commit into
chenasraf:masterfrom
OCzarnecki:oczarnecki/fix-overriding-date
Open

Remove timestamp field from createBill#12
OCzarnecki wants to merge 1 commit into
chenasraf:masterfrom
OCzarnecki:oczarnecki/fix-overriding-date

Conversation

@OCzarnecki

Copy link
Copy Markdown

Timestamp takes precedence over date, meaning that the specified date was always ignored.

Tests

Before this PR

Specifying the date as a cli argument has no effect.

$ ./cospend --project playground add augtest2 10.0 -d 2026-08-01 -D
[DEBUG] Request body: amount=10.00&date=2026-08-01&payedFor=11&payer=11&repeat=n&timestamp=1788624676&what=augtest2
[DEBUG] Request: POST http://****/ocs/v2.php/apps/cospend/api/v1/projects/playground/bills
[DEBUG] Headers: OCS-APIRequest=true, Accept=application/json, Auth=Basic olaf:***
[DEBUG] Response: 200 200 OK
Added expense: augtest2
  Amount:   10.00
  Paid by:  Olaf
  Paid for: Olaf
  Date:     2026-08-01
$ date -d @1788624676
Sat Sep  5 05:11:16 PM BST 2026

You can see that the parameters contain both a date arg and a timestamp arg, timestamp takes precedence and is what ends up in the cospend db.

After this PR

Not specifying a date has the date default to today's date (

$ ./cospend --project playground add augtest4 10.0 -D
[DEBUG] Request body: amount=10.00&date=2026-09-05&payedFor=11&payer=11&repeat=n&what=augtest4
[DEBUG] Request: POST http://****/ocs/v2.php/apps/cospend/api/v1/projects/playground/bills
[DEBUG] Headers: OCS-APIRequest=true, Accept=application/json, Auth=Basic olaf:***
[DEBUG] Response: 200 200 OK
Added expense: augtest4
  Amount:   10.00
  Paid by:  Olaf
  Paid for: Olaf

Specifying the date propagates correctly:

/cospend --project playground add augtest3 10.0 -d 2026-09-01 -D
[DEBUG] Request body: amount=10.00&date=2026-09-01&payedFor=11&payer=11&repeat=n&what=augtest3
[DEBUG] Request: POST http://****/ocs/v2.php/apps/cospend/api/v1/projects/playground/bills
[DEBUG] Headers: OCS-APIRequest=true, Accept=application/json, Auth=Basic olaf:***
[DEBUG] Response: 200 200 OK
Added expense: augtest3
  Amount:   10.00
  Paid by:  Olaf
  Paid for: Olaf
  Date:     2026-09-01

I've checked that cospend ends up with what I expect.

Timestamp takes precedence over date, meaning that the specified date
was always ignored.
@OCzarnecki

Copy link
Copy Markdown
Author

Hey @chenasraf , thanks for making this! This is my first PR on this project, so let me know if you'd like to see anything else from me :)

@chenasraf chenasraf self-assigned this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants