mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-10 07:55:21 +02:00
Additional merge conflict fixes
This commit is contained in:
parent
e07b2d844c
commit
1016d4f7cf
17 changed files with 55 additions and 37 deletions
|
@ -1,14 +1,26 @@
|
|||
class TransactionCategoriesController < ApplicationController
|
||||
include ActionView::RecordIdentifier
|
||||
|
||||
def update
|
||||
@entry = Current.family.entries.transactions.find(params[:transaction_id])
|
||||
@entry.update!(entry_params)
|
||||
|
||||
transaction = @entry.transaction
|
||||
|
||||
if needs_rule_notification?(transaction)
|
||||
flash[:cta] = {
|
||||
type: "category_rule",
|
||||
category_id: transaction.category_id,
|
||||
category_name: transaction.category.name
|
||||
}
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_to transaction_path(@entry) }
|
||||
format.turbo_stream do
|
||||
render turbo_stream: [
|
||||
turbo_stream.replace(
|
||||
"category_menu_transaction_#{@entry.entryable_id}",
|
||||
dom_id(@entry, :category_menu),
|
||||
partial: "categories/menu",
|
||||
locals: { transaction: @entry.transaction }
|
||||
),
|
||||
|
|
|
@ -70,9 +70,19 @@ class TransactionsController < ApplicationController
|
|||
|
||||
def update
|
||||
if @entry.update(entry_params)
|
||||
transaction = @entry.transaction
|
||||
|
||||
if needs_rule_notification?(transaction)
|
||||
flash[:cta] = {
|
||||
type: "category_rule",
|
||||
category_id: transaction.category_id,
|
||||
category_name: transaction.category.name
|
||||
}
|
||||
end
|
||||
|
||||
@entry.sync_account_later
|
||||
@entry.lock_saved_attributes!
|
||||
@entry.account_transaction.lock!(:tag_ids) if @entry.account_transaction.tags.any?
|
||||
@entry.transaction.lock!(:tag_ids) if @entry.transaction.tags.any?
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_to account_path(@entry.account), notice: "Transaction updated" }
|
||||
|
|
|
@ -133,7 +133,7 @@ class Account < ApplicationRecord
|
|||
name: "Initial Balance",
|
||||
amount: initial_balance,
|
||||
currency: currency,
|
||||
entryable: Account::Valuation.new
|
||||
entryable: Valuation.new
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ class Demo::Generator
|
|||
"Uber", "Netflix", "Spotify", "Delta Airlines", "Airbnb", "Sephora" ]
|
||||
|
||||
merchants.each do |merchant|
|
||||
UserMerchant.create!(name: merchant, family: family, color: COLORS.sample)
|
||||
FamilyMerchant.create!(name: merchant, family: family, color: COLORS.sample)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Account::Entry < ApplicationRecord
|
||||
class Entry < ApplicationRecord
|
||||
include Monetizable, Enrichable
|
||||
|
||||
monetize :amount
|
||||
|
@ -86,7 +86,7 @@ class Account::Entry < ApplicationRecord
|
|||
|
||||
entry.lock_saved_attributes!
|
||||
entry.entryable.lock_saved_attributes!
|
||||
entry.entryable.lock!(:tag_ids) if entry.account_transaction? && entry.account_transaction.tags.any?
|
||||
entry.entryable.lock!(:tag_ids) if entry.transaction? && entry.transaction.tags.any?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class Rule::ActionExecutor::SetTransactionTags < Rule::ActionExecutor
|
|||
|
||||
de = DataEnrichment.find_or_initialize_by(
|
||||
enrichable_id: txn.id,
|
||||
enrichable_type: "Account::Transaction",
|
||||
enrichable_type: "Transaction",
|
||||
attribute_name: "tag_ids",
|
||||
source: "rule"
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@ class Rule::ConditionFilter::TransactionAmount < Rule::ConditionFilter
|
|||
end
|
||||
|
||||
def apply(scope, operator, value)
|
||||
expression = build_sanitized_where_condition("ABS(account_entries.amount)", operator, value.to_d)
|
||||
expression = build_sanitized_where_condition("ABS(entries.amount)", operator, value.to_d)
|
||||
scope.where(expression)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ class Rule::ConditionFilter::TransactionName < Rule::ConditionFilter
|
|||
end
|
||||
|
||||
def apply(scope, operator, value)
|
||||
expression = build_sanitized_where_condition("account_entries.name", operator, value)
|
||||
expression = build_sanitized_where_condition("entries.name", operator, value)
|
||||
scope.where(expression)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class Transaction < ApplicationRecord
|
||||
include Entryable, Transferable, Provided
|
||||
include Entryable, Transferable, Ruleable
|
||||
|
||||
belongs_to :category, optional: true
|
||||
belongs_to :merchant, optional: true
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<%= drawer(reload_on_close: true) do %>
|
||||
<%= drawer do %>
|
||||
<%= render "trades/header", entry: @entry %>
|
||||
|
||||
<% trade = @entry.trade %>
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
<header class="flex justify-between items-center text-primary font-medium">
|
||||
<h1 class="text-xl">Transactions</h1>
|
||||
<div class="flex items-center gap-5">
|
||||
<div class="flex items-center gap-2">
|
||||
<%= contextual_menu do %>
|
||||
<%= contextual_menu_item "New rule", url: new_rule_path(resource_type: "transaction"), icon: "plus", turbo_frame: "modal" %>
|
||||
<%= contextual_menu_item "Edit rules", url: rules_path, icon: "git-branch" %>
|
||||
<%= contextual_menu_modal_action_item t(".edit_categories"), categories_path, icon: "shapes", turbo_frame: :_top %>
|
||||
<%= contextual_menu_modal_action_item t(".edit_tags"), tags_path, icon: "tags", turbo_frame: :_top %>
|
||||
<%= contextual_menu_modal_action_item t(".edit_merchants"), family_merchants_path, icon: "store", turbo_frame: :_top %>
|
||||
<%= contextual_menu_modal_action_item t(".edit_imports"), imports_path, icon: "hard-drive-upload", turbo_frame: :_top %>
|
||||
<% end %>
|
||||
<%# locals: (entry:) %>
|
||||
|
||||
<%= tag.header class: "mb-4 space-y-1", id: dom_id(entry, :header) do %>
|
||||
<div class="flex items-center gap-4">
|
||||
<h3 class="font-medium">
|
||||
<span class="text-2xl">
|
||||
<%= format_money -entry.amount_money %>
|
||||
</span>
|
||||
|
||||
<span class="text-lg text-secondary">
|
||||
<%= entry.currency %>
|
||||
|
@ -24,4 +20,4 @@
|
|||
<span class="text-sm text-secondary">
|
||||
<%= I18n.l(entry.date, format: :long) %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -6,7 +6,7 @@
|
|||
<%= contextual_menu do %>
|
||||
<%= contextual_menu_modal_action_item t(".edit_categories"), categories_path, icon: "shapes", turbo_frame: :_top %>
|
||||
<%= contextual_menu_modal_action_item t(".edit_tags"), tags_path, icon: "tags", turbo_frame: :_top %>
|
||||
<%= contextual_menu_modal_action_item t(".edit_merchants"), merchants_path, icon: "store", turbo_frame: :_top %>
|
||||
<%= contextual_menu_modal_action_item t(".edit_merchants"), family_merchants_path, icon: "store", turbo_frame: :_top %>
|
||||
<%= contextual_menu_modal_action_item t(".edit_imports"), imports_path, icon: "hard-drive-upload", turbo_frame: :_top %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<%= drawer(reload_on_close: true) do %>
|
||||
<%= drawer do %>
|
||||
<%= render "transactions/header", entry: @entry %>
|
||||
|
||||
<div class="space-y-2">
|
||||
|
@ -81,7 +81,7 @@
|
|||
label: t(".tags_label"),
|
||||
container_class: "h-40"
|
||||
},
|
||||
{ "data-auto-submit-form-target": "auto" } %>
|
||||
{ "data-auto-submit-form-target": "auto" } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% entry, account = @entry, @entry.account %>
|
||||
|
||||
<%= drawer(reload_on_close: true) do %>
|
||||
<%= drawer do %>
|
||||
<%= render "valuations/header", entry: %>
|
||||
|
||||
<div class="space-y-2">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class Rule::ActionTest < ActiveSupport::TestCase
|
||||
include Account::EntriesTestHelper
|
||||
include EntriesTestHelper
|
||||
|
||||
setup do
|
||||
@family = families(:dylan_family)
|
||||
|
@ -12,9 +12,9 @@ class Rule::ActionTest < ActiveSupport::TestCase
|
|||
@whole_foods_merchant = @family.merchants.create!(name: "Whole Foods", type: "FamilyMerchant")
|
||||
|
||||
# Some sample transactions to work with
|
||||
@txn1 = create_transaction(date: Date.current, account: @account, amount: 100, name: "Rule test transaction1", merchant: @whole_foods_merchant).account_transaction
|
||||
@txn2 = create_transaction(date: Date.current, account: @account, amount: -200, name: "Rule test transaction2").account_transaction
|
||||
@txn3 = create_transaction(date: 1.day.ago.to_date, account: @account, amount: 50, name: "Rule test transaction3").account_transaction
|
||||
@txn1 = create_transaction(date: Date.current, account: @account, amount: 100, name: "Rule test transaction1", merchant: @whole_foods_merchant).transaction
|
||||
@txn2 = create_transaction(date: Date.current, account: @account, amount: -200, name: "Rule test transaction2").transaction
|
||||
@txn3 = create_transaction(date: 1.day.ago.to_date, account: @account, amount: 50, name: "Rule test transaction3").transaction
|
||||
|
||||
@rule_scope = @account.transactions
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class Rule::ConditionTest < ActiveSupport::TestCase
|
||||
include Account::EntriesTestHelper
|
||||
include EntriesTestHelper
|
||||
|
||||
setup do
|
||||
@family = families(:empty)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class RuleTest < ActiveSupport::TestCase
|
||||
include Account::EntriesTestHelper
|
||||
include EntriesTestHelper
|
||||
|
||||
setup do
|
||||
@family = families(:empty)
|
||||
|
@ -25,7 +25,7 @@ class RuleTest < ActiveSupport::TestCase
|
|||
|
||||
transaction_entry.reload
|
||||
|
||||
assert_equal @groceries_category, transaction_entry.account_transaction.category
|
||||
assert_equal @groceries_category, transaction_entry.transaction.category
|
||||
end
|
||||
|
||||
test "compound rule" do
|
||||
|
@ -51,8 +51,8 @@ class RuleTest < ActiveSupport::TestCase
|
|||
transaction_entry1.reload
|
||||
transaction_entry2.reload
|
||||
|
||||
assert_nil transaction_entry1.account_transaction.category
|
||||
assert_equal @groceries_category, transaction_entry2.account_transaction.category
|
||||
assert_nil transaction_entry1.transaction.category
|
||||
assert_equal @groceries_category, transaction_entry2.transaction.category
|
||||
end
|
||||
|
||||
# Artificial limitation put in place to prevent users from creating overly complex rules
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue