mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 07:25:19 +02:00
Disable edits for certain transaction fields for Plaid transactions
This commit is contained in:
parent
b912e4c1fa
commit
540d7bb4bd
8 changed files with 30 additions and 36 deletions
|
@ -56,6 +56,10 @@ class Entry < ApplicationRecord
|
|||
Balance::TrendCalculator.new(self, entries, balances).trend
|
||||
end
|
||||
|
||||
def linked?
|
||||
plaid_id.present?
|
||||
end
|
||||
|
||||
class << self
|
||||
def search(params)
|
||||
EntrySearch.new(params).build_query(all)
|
||||
|
|
|
@ -103,36 +103,6 @@ class PlaidItem < ApplicationRecord
|
|||
save!
|
||||
end
|
||||
|
||||
# def auto_match_categories!
|
||||
# if family.categories.none?
|
||||
# family.categories.bootstrap!
|
||||
# end
|
||||
|
||||
# alias_matcher = build_category_alias_matcher(family.categories)
|
||||
|
||||
# accounts.each do |account|
|
||||
# matchable_transactions = account.transactions
|
||||
# .where(category_id: nil)
|
||||
# .where.not(plaid_category: nil)
|
||||
# .enrichable(:category_id)
|
||||
|
||||
# matchable_transactions.each do |transaction|
|
||||
# category = alias_matcher.match(transaction.plaid_category_detailed)
|
||||
|
||||
# if category.present?
|
||||
# # Matcher could either return a string or a Category object
|
||||
# user_category = if category.is_a?(String)
|
||||
# family.categories.find_or_create_by!(name: category)
|
||||
# else
|
||||
# category
|
||||
# end
|
||||
|
||||
# transaction.enrich_attribute(:category_id, user_category.id, source: "plaid")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
def supports_product?(product)
|
||||
supported_products.include?(product)
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class PlaidItem::Syncer
|
|||
end
|
||||
|
||||
def perform_post_sync
|
||||
plaid_item.auto_match_categories!
|
||||
# no-op
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
min: options[:min] || -99999999999999,
|
||||
max: options[:max] || 99999999999999,
|
||||
step: currency.step,
|
||||
disabled: options[:disabled],
|
||||
data: {
|
||||
"money-field-target": "amount",
|
||||
"auto-submit-form-target": ("auto" if options[:auto_submit])
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
<%= entry.currency %>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
<% if entry.linked? %>
|
||||
<span title="Linked with Plaid">
|
||||
<%= icon("refresh-ccw", size: "sm") %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<span class="text-sm text-secondary">
|
||||
|
|
|
@ -15,20 +15,22 @@
|
|||
<%= f.date_field :date,
|
||||
label: t(".date_label"),
|
||||
max: Date.current,
|
||||
disabled: @entry.linked?,
|
||||
"data-auto-submit-form-target": "auto" %>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<%= f.select :nature,
|
||||
[["Buy", "outflow"], ["Sell", "inflow"]],
|
||||
{ container_class: "w-1/3", label: "Type", selected: @entry.amount.negative? ? "inflow" : "outflow" },
|
||||
{ data: { "auto-submit-form-target": "auto" } } %>
|
||||
{ data: { "auto-submit-form-target": "auto" }, disabled: @entry.linked? } %>
|
||||
|
||||
<%= f.fields_for :entryable do |ef| %>
|
||||
<%= ef.number_field :qty,
|
||||
label: t(".quantity_label"),
|
||||
step: "any",
|
||||
value: trade.qty.abs,
|
||||
"data-auto-submit-form-target": "auto" %>
|
||||
"data-auto-submit-form-target": "auto",
|
||||
disabled: @entry.linked? %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
@ -37,7 +39,9 @@
|
|||
label: t(".cost_per_share_label"),
|
||||
disable_currency: true,
|
||||
auto_submit: true,
|
||||
min: 0 %>
|
||||
min: 0,
|
||||
disabled: @entry.linked?,
|
||||
disable_currency: @entry.linked? %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,12 @@
|
|||
<% if entry.transaction.transfer? %>
|
||||
<%= icon "arrow-left-right", class: "mt-1" %>
|
||||
<% end %>
|
||||
|
||||
<% if entry.linked? %>
|
||||
<span title="Linked with Plaid">
|
||||
<%= icon("refresh-ccw", size: "sm") %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<span class="text-sm text-secondary">
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<%= f.date_field :date,
|
||||
label: t(".date_label"),
|
||||
max: Date.current,
|
||||
disabled: @entry.linked?,
|
||||
"data-auto-submit-form-target": "auto" %>
|
||||
|
||||
<% unless @entry.transaction.transfer? %>
|
||||
|
@ -25,13 +26,15 @@
|
|||
<%= f.select :nature,
|
||||
[["Expense", "outflow"], ["Income", "inflow"]],
|
||||
{ container_class: "w-1/3", label: t(".nature"), selected: @entry.amount.negative? ? "inflow" : "outflow" },
|
||||
{ data: { "auto-submit-form-target": "auto" } } %>
|
||||
{ data: { "auto-submit-form-target": "auto" }, disabled: @entry.linked? } %>
|
||||
|
||||
<%= f.money_field :amount, label: t(".amount"),
|
||||
container_class: "w-2/3",
|
||||
auto_submit: true,
|
||||
min: 0,
|
||||
value: @entry.amount.abs %>
|
||||
value: @entry.amount.abs,
|
||||
disabled: @entry.linked?,
|
||||
disable_currency: @entry.linked? %>
|
||||
</div>
|
||||
|
||||
<%= f.fields_for :entryable do |ef| %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue