pondersource / prejournal

An experimental bookkeeping tool that sits between source documents and journals
https://prejournal.org
MIT License
2 stars 2 forks source link

Required functionality for continuous time-pondersource-com -> m-ld push #171

Closed michielbdejong closed 2 years ago

michielbdejong commented 2 years ago

For https://github.com/federatedbookkeeping/timesheets/issues/27 we need to be able to push a given change (addition, update, or deletion of a timesheet entry) in time-pondersource-com to m-ld.

Additionally, we should make it possible to configure this push to happen automatically.

michielbdejong commented 2 years ago

Setting this in my .env:

TIMELD_HOST=https://timeld.org/api
TIMELD_USERNAME=michielbdejong
TIMELD_PASSWORD=...

And running:

php src/cli-single.php timeld-api-import "Timesheet" "michielbdejong/michielbdejong" "fedb/fedt" my-timesheet "22 August 2021" 8
michielbdejong commented 2 years ago

The timeld-api-export command seems unfinished. It calls exportTimeld which ports data from Timeld to Prejournal (so export from the Timeld perspective, but I would call it import from the Prejournal prespective).

michielbdejong commented 2 years ago

The importTimld function comes closer to what we need. Let's try to get that working.

michielbdejong commented 2 years ago

There is a side-effect of also creating the movement locally, let's comment that out. There is nothing showing up in the main fedb/fedt timesheet, but I do see a project created:

curl https://timeld.org/api/rpt/michielbdejong/own/michielbdejong -u $CREDENTIALS
{"@type":"Timesheet","@id":"michielbdejong\/michielbdejong","project":[{"@id":"fedb\/fedt"}],"external":{"@id":"my-timesheet"}}

To generate the example request body from the Timeld docs I would need to do:

php src/cli-single.php timeld-api-import Project org1/pr1 dummy http://ex.org/project/1
php src/cli-single.php timeld-api-import Timesheet org1/ts1 org1/pr1 http://ex.org/timesheet/1
php src/cli-single.php timeld-api-import Entry dummy dummy http://ex.org/timesheet/1/entry/1

But there would still not be a way to set the activity, duration, or start. :(

I'll create a command for it from scratch.

michielbdejong commented 2 years ago
prejournal=# select id, timestamp_, amount  from movements where fromcomponent=12 and tocomponent=8 and type_='worked';
 id  |     timestamp_      | amount 
-----+---------------------+--------
 121 | 2022-07-05 00:00:00 |      8
 122 | 2022-07-15 00:00:00 |      2
 123 | 2022-07-15 00:00:00 |      1
[...]

Convert that to:

{"@id":"fedb/fedt","@type":"Project"}
{"@id":"michielbdejong/my-timesheet","project":{"@id":"fedb/fedt"},"@type":"Timesheet"}
{"activity":"Worked","duration":480,"start":{"@value":"2022-07-05T00:00:00.000Z","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"@type":"Entry","vf:provider":{"@id":"http://time.pondersource.com/michiel"},"external":{"@id":"http://time.pondersource.com/movement/121"}}
{"activity":"Worked","duration":120,"start":{"@value":"2022-07-05T00:00:00.000Z","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"@type":"Entry","vf:provider":{"@id":"http://time.pondersource.com/michiel"},"external":{"@id":"http://time.pondersource.com/movement/122"}}
{"activity":"Worked","duration":60,"start":{"@value":"2022-07-05T00:00:00.000Z","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"@type":"Entry","vf:provider":{"@id":"http://time.pondersource.com/michiel"},"external":{"@id":"http://time.pondersource.com/movement/123"}}
[...]
michielbdejong commented 2 years ago

As part of this work, reported https://github.com/m-ld/timeld/issues/84 Next step: push out single entry as and when it's created.

michielbdejong commented 2 years ago

For server reset, worked through https://github.com/pondersource/prejournal/issues/172 and apart from https://github.com/m-ld/timeld/issues/87 I think that is fine now.

Next: whenever a movement of type 'worked' is created or updated, push that one entry out to timeld.org.

michielbdejong commented 2 years ago

time.pondersource.com now pushed to the fedb/from-pounder-source-with-love whenever a movement is created with type 'worked'. The description and worker name are not coming through yet. Also, should do the same for updateMovement.

michielbdejong commented 2 years ago

Ah, updateMovement is only available from import so don't need to add it there for now