Skip to content
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

Enhance the bills extractor #118

Merged
merged 21 commits into from Apr 25, 2022
Merged

Enhance the bills extractor #118

merged 21 commits into from Apr 25, 2022

Conversation

fabiodrg
Copy link
Collaborator

@fabiodrg fabiodrg commented Apr 2, 2022

Changes

  • CalendarEvent
    • Add support for 'All Day' events
    • Simplify the constructor to reduce number of parameters. Optional parameters such as location, status, ... can be initialised with setters that return the object itself allowing for chaining in constructor invoking
    • Supported in iCalendar out of the box in tested clients (Google, Outlook, Thunderbird, KOrganizer)
new CalendarEvent(
    title,
    desc,
    isHTML,
    start,
    end
)
.setLocation(loc)
.setStatus(CalendarEventStatus.FREE);
  • Update CalendarUrlGenerator to generate URLs that toggle the "All Day" in the event edit form on target platforms (Google, Microsoft, Yahoo)
  • Bills extractor
    • Refactor for using the new EventExtractor
    • Correctly calculates the bills amount, including any fees
    • Use modal rather than inline dropdowns
  • New extractor for bills with ATM references, BillsPaymentRefs
    • Sort of an extension to the Bills extractor for including ATM reference details
    • It handles cases where multiple bills are associated to the same ATM reference
  • Unit tests

Preview

"Events Modal" for pending bills and pending bills with ATM references

image

Events can be created as 'All Day' events, which is more indicated for 'reminder'-like events. Supported in online calendars, like Google, Microsoft and Yahoo. iCalendar formats also working in tested clients

image
image
image

@fabiodrg fabiodrg changed the base branch from master to dev April 2, 2022 22:32
Support AllDay events.

The class is growing in number of atributes. Some are mandatory, like
start date-times, title, description, ... while others are optional. So
the constructor now only has the essential parameters. Everything else
can be set via setters. These are kinda special because they return the
object itself, allowing for chaining.

```
new CalendarEvent(
    title,
    desc,
    isHTML,
    start,
    end
).setLocation(loc)
.setStatus(CalendarEventStatus.FREE);
```
Enforce some rules that are common in all extractors
Enhance the implementation for `chrome.storage.local.get` for matching
the API interface and behaviour. The return simulates that nothing
exists in storage, thus Extractors will use their default values. In the
previous implementation the Extractors atributes/parameters were never
initialised, reducing the testing scope
objects at runtime

The function `_validateEventParams` receives an object that should have
all properties declared in the extractor `structure.properties`. It is
used to format strings such as event title, description, etc. The
properties may declared nested objects when the name is like
`room.name`, meaning the `room` is an object with at least the property
`name`. Validating nested objects is now supported.
format strings

Previous implementation would only escape newlines if the format-strings
are in HTML. However, it would only escape the first occurence, as
`replace` stops on the first occurance. The alternative `replaceAll` is
still not widely available, therefore we keep `replace` but use a regex
pattern with the global (g) flag. It also escapes newlines for plain text string-formats.

Escapping is necessary when the string-format looks like this: `hello
'${p1}\n${p2}'`. As the `\n` is not escaped and it is between single
quotes, `'`, it the eval will fail as single and double quotes do not
work with multi-line strings.
@fabiodrg
Copy link
Collaborator Author

fabiodrg commented Apr 3, 2022

A todo list to complete this PR:

  • Finish updating CalendarUrlGenerator to support all day events. I have WIP locally, just need to add support for Yahoo. Will have to create an account for testing xd
  • Bills extractor could skip pending bills with generated references, as another extractor will handle them anyway
    • Make it customisable
  • Cleanup the CalendarEvent class interface. Improve docs
  • Simplify the unit tests for Bills extractor. Make sure to remove the no-break whitespace from the HTML, which is different from the conventional space character and was causing headaches in strict equals

@fabiodrg fabiodrg requested a review from msramalho April 4, 2022 21:55
@fabiodrg fabiodrg marked this pull request as ready for review April 6, 2022 12:59
@fabiodrg fabiodrg merged commit 53414e6 into dev Apr 25, 2022
@fabiodrg fabiodrg deleted the refactor/bills-extractor branch April 25, 2022 21:16
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.

Use 'All day' event for bill extractor
1 participant