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

Create Budget::Phases backend #2323

Merged
merged 17 commits into from Jan 16, 2018
Merged

Create Budget::Phases backend #2323

merged 17 commits into from Jan 16, 2018

Conversation

bertocq
Copy link
Collaborator

@bertocq bertocq commented Jan 15, 2018

Where

What

We need a new Phase model that holds a lot of info about Budget Phases, (date range, summary, description, if its enabled/disabled...)

We'll be needing some strong validations to maintain the current assumption that there can't be holes in between phases, that means any Budget should always have an active phase. That means consecutive date ranges even when a phase is disabled.

How

  • Adding a Budget::Phase model that:

    • Holds all the info
    • Knows which is the next & previous phases (as well as which are next&previous enabled phases)
    • Self-validates his date range and prev/next enabled phases date ranges (so there won't be incompatibilities)
  • Moving Budget's knowledge about Phases to Budget::Phase, and generating all needed Budget::Phase's for a new Budget after creation

  • Adding a rake task that will generate Budget Phases for all existing Budgets and migrate values from the description_* columns to the new Budget::Phase objects. Check Warning section. 43dff8e

Screenshots

No front, only backend :D.

Test

Increased Budget model spec and create Budget::Phase model spec

Deployment

Just after deploy run the budgets:phases:generate_missing rake task, explanation at next section ⬇️

Warnings

⚠️ You must run rake budgets:phases:generate_missing task to generate Budget::Phase's for all existing Budgets and migrate values from description_* columns from budget's table to new budget_phase's description columns. This is a DEPRECATION warning... in release v0.14 those columns will be erased from database and all non-migrated data will be lost!

Create a new Budget::Phase model that:
* Stablishes a relation with its budget
* Stablishes relation with two other Budget::Phases (previous and next)
* Validates basic dates range, kind and description rules.
* Adds scopes to get the ones enabled as well as each individual phase

Create a factory that generates a basic and valid Budget::Phase

Create a model spec that checks kind, date range and budget validations.
Copy link
Contributor

@MariaCheca MariaCheca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bertocq bertocq merged commit 367a960 into master Jan 16, 2018
@bertocq bertocq deleted the feature/budget_phases branch January 16, 2018 22:11
clairezed pushed a commit to CDJ11/CDJ that referenced this pull request Jun 26, 2018
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.

None yet

3 participants