Skip to content

Commit

Permalink
Fixed codeclimate issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Tsoganov authored and Sergei Tsoganov committed Oct 3, 2023
1 parent 20dd41e commit dd9b534
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/e_invoice/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,7 @@ def build_invoice_details(invoice)

def build_invoice_totals(invoice)
builder.InvoiceSumGroup do
builder.Balance do
builder.BalanceDate invoice.balance_date if invoice.balance_date
builder.BalanceBegin format_decimal(invoice.balance_begin) if invoice.balance_begin
builder.Inbound format_decimal(invoice.inbound) if invoice.inbound
builder.Outbound format_decimal(invoice.outbound) if invoice.outbound
builder.BalanceEnd format_decimal(invoice.balance_end) if invoice.balance_end
end
build_invoice_balance(invoice)
builder.InvoiceSum format_decimal(invoice.subtotal, scale: 4)
builder.TotalVATSum format_decimal(invoice.vat_amount)
builder.TotalSum format_decimal(invoice.total)
Expand All @@ -123,6 +117,16 @@ def build_invoice_totals(invoice)
end
end

def build_invoice_balance(invoice)
builder.Balance do
builder.BalanceDate invoice.balance_date if invoice.balance_date
builder.BalanceBegin format_decimal(invoice.balance_begin) if invoice.balance_begin
builder.Inbound format_decimal(invoice.inbound) if invoice.inbound
builder.Outbound format_decimal(invoice.outbound) if invoice.outbound
builder.BalanceEnd format_decimal(invoice.balance_end) if invoice.balance_end
end
end

def build_invoice_payment_details(invoice)
builder.PaymentInfo do
builder.Currency invoice.currency
Expand Down
2 changes: 2 additions & 0 deletions test/generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def test_generates_e_invoice_xml
</Extension>
</InvoiceInformation>
<InvoiceSumGroup>
<Balance/>
<InvoiceSum>100.0000</InvoiceSum>
<TotalVATSum>20.00</TotalSum>
<TotalSum>120.00</TotalSum>
Expand Down Expand Up @@ -274,6 +275,7 @@ def test_generates_prepaid_e_invoice_xml
</Extension>
</InvoiceInformation>
<InvoiceSumGroup>
<Balance/>
<InvoiceSum>100.0000</InvoiceSum>
<TotalVATSum>20.00</TotalSum>
<TotalSum>120.00</TotalSum>
Expand Down

0 comments on commit dd9b534

Please sign in to comment.