mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 04:55:20 +02:00
Auto naming of Transfer Transaction (#1393)
* Remove Description field * Auto naming of tranfer transaction * Fix transfer test * Improve Transfer entries names
This commit is contained in:
parent
2b61821336
commit
47288a1629
5 changed files with 4 additions and 9 deletions
|
@ -14,8 +14,7 @@ class Account::TransfersController < ApplicationController
|
|||
@transfer = Account::Transfer.build_from_accounts from_account, to_account, \
|
||||
date: transfer_params[:date],
|
||||
amount: transfer_params[:amount].to_d,
|
||||
currency: transfer_params[:currency],
|
||||
name: transfer_params[:name]
|
||||
currency: transfer_params[:currency]
|
||||
|
||||
if @transfer.save
|
||||
@transfer.entries.each(&:sync_account_later)
|
||||
|
|
|
@ -43,12 +43,12 @@ class Account::Transfer < ApplicationRecord
|
|||
end
|
||||
|
||||
class << self
|
||||
def build_from_accounts(from_account, to_account, date:, amount:, currency:, name:)
|
||||
def build_from_accounts(from_account, to_account, date:, amount:, currency:)
|
||||
outflow = from_account.entries.build \
|
||||
amount: amount.abs,
|
||||
currency: from_account.currency,
|
||||
date: date,
|
||||
name: name,
|
||||
name: "Transfer to #{to_account.name}",
|
||||
marked_as_transfer: true,
|
||||
entryable: Account::Transaction.new
|
||||
|
||||
|
@ -56,7 +56,7 @@ class Account::Transfer < ApplicationRecord
|
|||
amount: amount.abs * -1,
|
||||
currency: from_account.currency,
|
||||
date: date,
|
||||
name: name,
|
||||
name: "Transfer from #{from_account.name}",
|
||||
marked_as_transfer: true,
|
||||
entryable: Account::Transaction.new
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
</section>
|
||||
|
||||
<section class="space-y-2">
|
||||
<%= f.text_field :name, value: transfer.name, label: t(".description"), placeholder: t(".description_placeholder"), required: true %>
|
||||
<%= f.collection_select :from_account_id, Current.family.accounts.alphabetically, :id, :name, { prompt: t(".select_account"), label: t(".from") }, required: true %>
|
||||
<%= f.collection_select :to_account_id, Current.family.accounts.alphabetically, :id, :name, { prompt: t(".select_account"), label: t(".to") }, required: true %>
|
||||
<%= f.money_field :amount, label: t(".amount"), required: true, hide_currency: true %>
|
||||
|
|
|
@ -9,8 +9,6 @@ en:
|
|||
form:
|
||||
amount: Amount
|
||||
date: Date
|
||||
description: Description
|
||||
description_placeholder: Transfer from Checking to Savings
|
||||
expense: Expense
|
||||
from: From
|
||||
income: Income
|
||||
|
|
|
@ -17,7 +17,6 @@ class TransfersTest < ApplicationSystemTestCase
|
|||
click_on "Transfer"
|
||||
assert_text "New transfer"
|
||||
|
||||
fill_in "Description", with: "Transfer txn name"
|
||||
select checking_name, from: "From"
|
||||
select savings_name, from: "To"
|
||||
fill_in "account_transfer[amount]", with: 500
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue