mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Basic transaction categories CRUD actions (inline) (#601)
* Fix dropdown issues and add dummy transaction category modal * Minor namings tweaks * Add search type * Use new menu controller * Complete basic transaction category inline CRUD actions * Fix lint error --------- Co-authored-by: Jakub Kottnauer <jk@jakubkottnauer.com>
This commit is contained in:
parent
315c4bf1ec
commit
d29d465a3c
23 changed files with 254 additions and 101 deletions
|
@ -1,20 +1,24 @@
|
|||
class Transaction::Category < ApplicationRecord
|
||||
has_many :transactions
|
||||
has_many :transactions, dependent: :nullify
|
||||
belongs_to :family
|
||||
|
||||
validates :name, :color, :family, presence: true
|
||||
|
||||
before_update :clear_internal_category, if: :name_changed?
|
||||
|
||||
COLORS = %w[#e99537 #4da568 #6471eb #db5a54 #df4e92 #c44fe9 #eb5429 #61c9ea #805dee #6ad28a]
|
||||
|
||||
UNCATEGORIZED_COLOR = "#737373"
|
||||
|
||||
DEFAULT_CATEGORIES = [
|
||||
{ internal_category: "income", color: "#e99537" },
|
||||
{ internal_category: "food_and_drink", color: "#4da568" },
|
||||
{ internal_category: "entertainment", color: "#6471eb" },
|
||||
{ internal_category: "personal_care", color: "#db5a54" },
|
||||
{ internal_category: "general_services", color: "#df4e92" },
|
||||
{ internal_category: "auto_and_transport", color: "#c44fe9" },
|
||||
{ internal_category: "rent_and_utilities", color: "#eb5429" },
|
||||
{ internal_category: "home_improvement", color: "#61c9ea" }
|
||||
{ internal_category: "income", color: COLORS[0] },
|
||||
{ internal_category: "food_and_drink", color: COLORS[1] },
|
||||
{ internal_category: "entertainment", color: COLORS[2] },
|
||||
{ internal_category: "personal_care", color: COLORS[3] },
|
||||
{ internal_category: "general_services", color: COLORS[4] },
|
||||
{ internal_category: "auto_and_transport", color: COLORS[5] },
|
||||
{ internal_category: "rent_and_utilities", color: COLORS[6] },
|
||||
{ internal_category: "home_improvement", color: COLORS[7] }
|
||||
]
|
||||
|
||||
def self.ransackable_attributes(auth_object = nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue