diff --git a/lib/receiptisan/output/preview/parameter/common.rb b/lib/receiptisan/output/preview/parameter/common.rb index eb8fdd0..b8f634a 100644 --- a/lib/receiptisan/output/preview/parameter/common.rb +++ b/lib/receiptisan/output/preview/parameter/common.rb @@ -389,7 +389,11 @@ class Tenki < CodedItem :total_kaisuu, :total_tensuu, keyword_init: true - ) + ) do + def zero_point? + tensuu.zero? + end + end # 点数欄「97食事・生活」の「基準」および「基準(生)」に埋め込む、 # 算定食事・生活療養費のローマ数字による略号 ShokujiSeikatsuKijunMarks = Struct.new(:shokuji, :seikatsu, keyword_init: true) diff --git a/lib/receiptisan/output/preview/parameter/tensuu_shuukei_calculator.rb b/lib/receiptisan/output/preview/parameter/tensuu_shuukei_calculator.rb index 5cf264d..2c9178e 100644 --- a/lib/receiptisan/output/preview/parameter/tensuu_shuukei_calculator.rb +++ b/lib/receiptisan/output/preview/parameter/tensuu_shuukei_calculator.rb @@ -155,12 +155,14 @@ def calculate_section(parameter, receipt) combine_units end - def combine_units + def combine_units # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity + entries = @shuukei_entries.reject(&:zero_point?) + CombinedTensuuShuukeiUnit.new( - tensuu: @shuukei_entries.map(&:tensuu).then { | ary | ary.uniq.length == 1 ? ary.first : nil }, - total_kaisuu: @shuukei_entries.map(&:total_kaisuu).sum.then { | sum | sum.zero? ? nil : sum }, - total_tensuu: @shuukei_entries.map(&:total_tensuu).sum.then { | sum | sum.zero? ? nil : sum }, - units: @shuukei_entries.sort_by(&:total_tensuu).reverse + tensuu: entries.map(&:tensuu).then { | ary | ary.uniq.length == 1 ? ary.first : nil }, + total_kaisuu: entries.map(&:total_kaisuu).sum.then { | sum | sum.zero? ? nil : sum }, + total_tensuu: entries.map(&:total_tensuu).sum.then { | sum | sum.zero? ? nil : sum }, + units: entries.sort_by(&:total_tensuu).reverse ) end