-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[trep-engine.scm] upgrade engine to improve calculated-cells handling #1618
[trep-engine.scm] upgrade engine to improve calculated-cells handling #1618
Conversation
8c1904e
to
0deb8b1
Compare
This is very nice! Lots to like here. I like the idea of using a version 2 structure and then using the conversion procedure. Very clean. I actually quite like the use of record because the field names used throughout the code when values are retrieved make the code so much more readable than the use of vector-ref. The assoc-list would work as well since it would show the key name. The use of records has the added benefit of leaving the current column definition almost unchanged except for the vector -> make-cell conversion. So if people want to upgrade custom reports to v2 to get the extra parameter, it is quite easy with only that one change and the additional tr? parameter in the calculator functions. Also although it's nice to see the key/value pair in the column definition with the assoc-list, it's a lot of extra code repeating these on every column, and I guess another potential source for errors? You mention it might be safer so that could be a +, although I don't quite have the knowledge to know why. All in all this is a solid upgrade I think. |
Yes it's a source of errors, however |
2de42e8
to
5e219e2
Compare
Modified. Remove arbitrary versioning. Maintain legacy vector to alist upgrade. |
d8af9a9
to
fb4e8dc
Compare
That's pretty nice as well. I like your invalid-cell? function doing a good job at replacing what the record was doing in terms of making sure the required "fields" are propertly named. Having the keys in the column definitions definitely makes the code more readable. And I like the use of the cut macro to retrieve the values to avoid having to revert back to the longer lambda form that the use of record had gotten rid of. |
fb4e8dc
to
7329258
Compare
calculated-cells was formerly a vector of RHS info - heading, calculator-fn, subtotal? etc. This upgrades it so that calculator-fn now accepts two arguments - split and transaction-row? which is a bool. It uses a basic record with version and list-of-cells, and each cell is a record (instead of a vector) with relevant members. This also enables the engine to handle previous calculated-cells -- note the income-gst-statement.scm will offer the previous one and will be transparently upgraded to the above -- see the function upgrade-to-calculated-cells-v2
7329258
to
ab002d1
Compare
This branch offers an upgrade to trep-engine so that the calculator-fn handles both split and transaction-row?. calculated-cells is now a versioned record cells, each cell has 7 fields.
for use by #1617 by @dawansv -- instead of
vector
you'll need tomake-cell
.Note income-gst-statement.scm stil offers the previous list of vectors, each vector has 6 fields, as a proof of backward compatibility.
EDIT: instead of records, it may be safer to use an assoc-list which is easier to upgrade eg.