1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Ignore empty categories while importing (#789)

* Ignore empty categories while importing

* Review fixes
This commit is contained in:
Jakub Kottnauer 2024-05-22 14:12:56 +02:00 committed by GitHub
parent ac27a1c87f
commit 77f166a5f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 8 deletions

View file

@ -11,6 +11,8 @@ class Import < ApplicationRecord
scope :ordered, -> { order(created_at: :desc) }
FALLBACK_TRANSACTION_NAME = "Imported transaction"
def publish_later
ImportJob.perform_later(self)
end
@ -110,9 +112,9 @@ class Import < ApplicationRecord
transactions = []
csv.table.each do |row|
category = account.family.transaction_categories.find_or_initialize_by(name: row["category"])
category = account.family.transaction_categories.find_or_initialize_by(name: row["category"]) if row["category"].present?
txn = account.transactions.build \
name: row["name"].presence || "Imported transaction",
name: row["name"].presence || FALLBACK_TRANSACTION_NAME,
date: Date.iso8601(row["date"]),
category: category,
amount: BigDecimal(row["amount"]) * -1, # User inputs amounts with opposite signage of our internal representation

View file

@ -1,7 +1,7 @@
<%# locals: (category:) %>
<% category ||= null_category %>
<span class="border text-sm font-medium px-2.5 py-1 rounded-full cursor-pointer content-center"
<span class="border text-sm font-medium px-2.5 py-1 rounded-full content-center"
style="
background-color: color-mix(in srgb, <%= category.color %> 5%, white);
border-color: color-mix(in srgb, <%= category.color %> 10%, white);