mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Ignore empty categories while importing (#789)
* Ignore empty categories while importing * Review fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user