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

Monthly page call GetDueClass for due date #115

Closed
Tracked by #113
chrisK00 opened this issue Sep 7, 2023 · 4 comments · Fixed by #124
Closed
Tracked by #113

Monthly page call GetDueClass for due date #115

chrisK00 opened this issue Sep 7, 2023 · 4 comments · Fixed by #124
Assignees
Labels
subtask Task of an Epic aka Story, part of a larger task

Comments

@chrisK00
Copy link
Contributor

chrisK00 commented Sep 7, 2023

Notes

Inside SubscriptionMonthItem on this line
<div>@($"{sub.LastPayment.Day}{GetDateSuffix(sub.LastPayment.Day)}")</div>
We should set the class of the div to whatever is returned from CssUtil.GetDueClass. We don't have access to the amount of days until its due so we need to calculate that, luckily we know the next payment date because it is stored inside sub.LastPayment and we can get the date of today DateTime.Now.Date so utilizing theese we should be able to calculate the amount of days until due/days it has been overdue.

@chrisK00 chrisK00 mentioned this issue Sep 7, 2023
3 tasks
@chrisK00 chrisK00 added subtask Task of an Epic aka Story, part of a larger task and removed feature labels Sep 7, 2023
@kgrontis kgrontis self-assigned this Sep 10, 2023
@kgrontis
Copy link
Contributor

@chrisK00 I don't think the LastPayment and DateTime.Now.Date are enough to calculate the days until due. As i saw, we store Billing opoccurence and Billing interval as well on subscription. What formula did you have in mind?

I was thinking that this one should be ok for now:

public int GetDaysUntilDue(Subscription subscription)
{
    DateTime nextDueDate = new();
    switch (subscription.BillingOccurrence)
    {
        case BillingOccurrence.Month:
            nextDueDate = subscription.LastPayment.AddMonths(subscription.BillingInterval);
            break;
        case BillingOccurrence.Week:
            nextDueDate = subscription.LastPayment.AddWeeks(subscription.BillingInterval);
            break;
        case BillingOccurrence.Year:
            nextDueDate = subscription.LastPayment.AddYears(subscription.BillingInterval);
            break;
    }

    TimeSpan timeUntilDue = nextDueDate - DateTime.Now;

    return timeUntilDue.Days;
}

@chrisK00
Copy link
Contributor Author

@chrisK00 I don't think the LastPayment and DateTime.Now.Date are enough to calculate the days until due. As i saw, we store Billing opoccurence and Billing interval as well on subscription. What formula did you have in mind?

I was thinking that this one should be ok for now:

public int GetDaysUntilDue(Subscription subscription)
{
    DateTime nextDueDate = new();
    switch (subscription.BillingOccurrence)
    {
        case BillingOccurrence.Month:
            nextDueDate = subscription.LastPayment.AddMonths(subscription.BillingInterval);
            break;
        case BillingOccurrence.Week:
            nextDueDate = subscription.LastPayment.AddWeeks(subscription.BillingInterval);
            break;
        case BillingOccurrence.Year:
            nextDueDate = subscription.LastPayment.AddYears(subscription.BillingInterval);
            break;
    }

    TimeSpan timeUntilDue = nextDueDate - DateTime.Now;

    return timeUntilDue.Days;
}

If we know the next payment date (its stored in the lastpayment date on the monthly page) then shouldnt it simply be sub.Lastpayment - today in order to get the difference between the dates and then calling something like .TotalDays

@kgrontis
Copy link
Contributor

kgrontis commented Sep 10, 2023

its stored in the lastpayment date on the monthly page

This one I can't seem to be figuring out, can you please elaborate.

@chrisK00
Copy link
Contributor Author

its stored in the lastpayment date on the monthly page

This one I can't seem to be figuring out, can you please elaborate.

Understandable its a bit missleading, we should probably add a comment since we arent going to do smtn about it for now 😂

SubscriptionMonthItem.razor has a foreach loop with subscriptions. Each subscription have a property called .LastPaymentDate but the twist is that it doesnt contain the LastPaymentDate in this context. Its actually the Next Payment Date. So if we know when the next payment date is, we can calculate how many days left from now till then

chrisK00 added a commit that referenced this issue Sep 24, 2023
* Update README.md

* Update README.md

* revert version

* revert comments

* companyname

* Update README.md

* #114 Implemented CssUtil.GetDueClass & tests (#123)

* #114 Implemented CssUtil.GetDueClass & tests

* #114 Added semicolor to css rule

* #114 Changed placement of css rule.

* #114 removed dots from string result.

* #114 PR review changes.

* #115 Added call to GetDueClass method in monthly page. (#124)

* add mockups for icons and colors

* Adds font color to due period depending on severity. (#126)

* Adds font color to due period depending on severity.

* Returns text-end class for Index page.

* Preserves newline in subscription description (#131)

* Introduces subscription background color. (#135)

* Adds background color to the database

* Adds a control to select background color for a subscription

* Updates tests to include background color

* Updates migration scripts

* Update subtrack.MAUI/Utilities/CssUtil.cs

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Minor updates

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Minor adjustments

---------

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* #128 make labels less visible (#136)

* #128 make labels less visible

* Update subtrack.MAUI/wwwroot/css/app.css

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

---------

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* #125 Added US Culture as a constant (#144)

* #142 Fixed descriptions not displayed correctly. (#145)

* update roadmap

* make nav buttons larger and remove outline on back save and edit buttons (#143)

* btn outline => btn filled

* navbar simplification

* resolve comments

* format and remove non existing css class

* remove default styling

---------

Co-authored-by: ChrisK00 <christian.khalil2000@gmail.com>
Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

---------

Co-authored-by: Konstantinos Grontis <grodiscostas@hotmail.com>
Co-authored-by: denislavh <53407843+denislavh@users.noreply.github.com>
Co-authored-by: Ashwin Thyagarajan <ashwin031192@gmail.com>
Co-authored-by: Penguine-Os <yenebeb.df@gmail.com>
chrisK00 added a commit that referenced this issue Nov 1, 2023
* Update README.md

* Update README.md

* revert version

* revert comments

* companyname

* Update README.md

* #114 Implemented CssUtil.GetDueClass & tests (#123)

* #114 Implemented CssUtil.GetDueClass & tests

* #114 Added semicolor to css rule

* #114 Changed placement of css rule.

* #114 removed dots from string result.

* #114 PR review changes.

* #115 Added call to GetDueClass method in monthly page. (#124)

* add mockups for icons and colors

* Adds font color to due period depending on severity. (#126)

* Adds font color to due period depending on severity.

* Returns text-end class for Index page.

* Preserves newline in subscription description (#131)

* Introduces subscription background color. (#135)

* Adds background color to the database

* Adds a control to select background color for a subscription

* Updates tests to include background color

* Updates migration scripts

* Update subtrack.MAUI/Utilities/CssUtil.cs

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Minor updates

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Minor adjustments

---------

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* #128 make labels less visible (#136)

* #128 make labels less visible

* Update subtrack.MAUI/wwwroot/css/app.css

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

---------

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* #125 Added US Culture as a constant (#144)

* #142 Fixed descriptions not displayed correctly. (#145)

* update roadmap

* make nav buttons larger and remove outline on back save and edit buttons (#143)

* btn outline => btn filled

* navbar simplification

* resolve comments

* format and remove non existing css class

* remove default styling

---------

Co-authored-by: ChrisK00 <christian.khalil2000@gmail.com>
Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Adds subscription icon and secondary color (#149)

* Adds database columns for icon and secondary color

* Adds controls for saving icon and secondary color for subscriptions

* Use subscription icon and secondary colors in the UI

* Updates migration scripts

* Minor updates to UI

* Minor UI updates

* Updates subscription details title

* Updates subscription details title

* fix flaky test

* Revert "fix flaky test"

This reverts commit b3bb61d.

* Feature/improve subscription card design poc (#150)

* fix create sub bug. New style for cards. use dot instead of comma

* fix overflow color picker input. fix currency on index showing on newline

* fix flaky test

* fix flaky test

* roadmap

---------

Co-authored-by: Konstantinos Grontis <grodiscostas@hotmail.com>
Co-authored-by: denislavh <53407843+denislavh@users.noreply.github.com>
Co-authored-by: Ashwin Thyagarajan <ashwin031192@gmail.com>
Co-authored-by: Penguine-Os <yenebeb.df@gmail.com>
chrisK00 added a commit that referenced this issue Nov 5, 2023
* Update README.md

* Update README.md

* revert version

* revert comments

* companyname

* Update README.md

* #114 Implemented CssUtil.GetDueClass & tests (#123)

* #114 Implemented CssUtil.GetDueClass & tests

* #114 Added semicolor to css rule

* #114 Changed placement of css rule.

* #114 removed dots from string result.

* #114 PR review changes.

* #115 Added call to GetDueClass method in monthly page. (#124)

* add mockups for icons and colors

* Adds font color to due period depending on severity. (#126)

* Adds font color to due period depending on severity.

* Returns text-end class for Index page.

* Preserves newline in subscription description (#131)

* Introduces subscription background color. (#135)

* Adds background color to the database

* Adds a control to select background color for a subscription

* Updates tests to include background color

* Updates migration scripts

* Update subtrack.MAUI/Utilities/CssUtil.cs

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Minor updates

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Minor adjustments

---------

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* #128 make labels less visible (#136)

* #128 make labels less visible

* Update subtrack.MAUI/wwwroot/css/app.css

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

---------

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* #125 Added US Culture as a constant (#144)

* #142 Fixed descriptions not displayed correctly. (#145)

* update roadmap

* make nav buttons larger and remove outline on back save and edit buttons (#143)

* btn outline => btn filled

* navbar simplification

* resolve comments

* format and remove non existing css class

* remove default styling

---------

Co-authored-by: ChrisK00 <christian.khalil2000@gmail.com>
Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Adds subscription icon and secondary color (#149)

* Adds database columns for icon and secondary color

* Adds controls for saving icon and secondary color for subscriptions

* Use subscription icon and secondary colors in the UI

* Updates migration scripts

* Minor updates to UI

* Minor UI updates

* Updates subscription details title

* Updates subscription details title

* fix flaky test

* Revert "fix flaky test"

This reverts commit b3bb61d.

* Feature/improve subscription card design poc (#150)

* fix create sub bug. New style for cards. use dot instead of comma

* fix overflow color picker input. fix currency on index showing on newline

* fix flaky test

* fix flaky test

* roadmap

* order by year (#154)

* readme merge master

* fix

* return url on delete

---------

Co-authored-by: Konstantinos Grontis <grodiscostas@hotmail.com>
Co-authored-by: denislavh <53407843+denislavh@users.noreply.github.com>
Co-authored-by: Ashwin Thyagarajan <ashwin031192@gmail.com>
Co-authored-by: Penguine-Os <yenebeb.df@gmail.com>
chrisK00 added a commit that referenced this issue Dec 11, 2023
* Update README.md

* Update README.md

* revert version

* revert comments

* companyname

* Update README.md

* #114 Implemented CssUtil.GetDueClass & tests (#123)

* #114 Implemented CssUtil.GetDueClass & tests

* #114 Added semicolor to css rule

* #114 Changed placement of css rule.

* #114 removed dots from string result.

* #114 PR review changes.

* #115 Added call to GetDueClass method in monthly page. (#124)

* add mockups for icons and colors

* Adds font color to due period depending on severity. (#126)

* Adds font color to due period depending on severity.

* Returns text-end class for Index page.

* Preserves newline in subscription description (#131)

* Introduces subscription background color. (#135)

* Adds background color to the database

* Adds a control to select background color for a subscription

* Updates tests to include background color

* Updates migration scripts

* Update subtrack.MAUI/Utilities/CssUtil.cs

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Minor updates

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/UpsertSubscription.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Minor adjustments

---------

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* #128 make labels less visible (#136)

* #128 make labels less visible

* Update subtrack.MAUI/wwwroot/css/app.css

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Update subtrack.MAUI/Pages/SubscriptionDetails.razor

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

---------

Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* #125 Added US Culture as a constant (#144)

* #142 Fixed descriptions not displayed correctly. (#145)

* update roadmap

* make nav buttons larger and remove outline on back save and edit buttons (#143)

* btn outline => btn filled

* navbar simplification

* resolve comments

* format and remove non existing css class

* remove default styling

---------

Co-authored-by: ChrisK00 <christian.khalil2000@gmail.com>
Co-authored-by: chrisK00 <72318023+chrisK00@users.noreply.github.com>

* Adds subscription icon and secondary color (#149)

* Adds database columns for icon and secondary color

* Adds controls for saving icon and secondary color for subscriptions

* Use subscription icon and secondary colors in the UI

* Updates migration scripts

* Minor updates to UI

* Minor UI updates

* Updates subscription details title

* Updates subscription details title

* fix flaky test

* Revert "fix flaky test"

This reverts commit b3bb61d.

* Feature/improve subscription card design poc (#150)

* fix create sub bug. New style for cards. use dot instead of comma

* fix overflow color picker input. fix currency on index showing on newline

* fix flaky test

* fix flaky test

* roadmap

* order by year (#154)

* readme merge master

* fix

* return url on delete

* Update README.md

* Creates a settings page with controls for importing and exporting subscriptions (#157)

* Implement exporting subscriptions (#158)

* export subs

* update roadmap

* Update dotnet.yml

* do not target IOS

* Update dotnet.yml

* global.json

* more permissive .net 7 sdk

* #147 Changed status bar color for android. (#159)

* net 7 (#160)

* Implement Importing subscriptions (#161)

* added lastsubexporttime (#162)

* roadmap

---------

Co-authored-by: Konstantinos Grontis <grodiscostas@hotmail.com>
Co-authored-by: denislavh <53407843+denislavh@users.noreply.github.com>
Co-authored-by: Ashwin Thyagarajan <ashwin031192@gmail.com>
Co-authored-by: Penguine-Os <yenebeb.df@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subtask Task of an Epic aka Story, part of a larger task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants