Skip to content

Commit

Permalink
Close #2025 Billing update export csv to include adjustments (#2030)
Browse files Browse the repository at this point in the history
  • Loading branch information
Regene27 authored Nov 13, 2024
1 parent db08f9a commit faf961d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def call
def headers
['Invoice Number', 'Invoice Issued Date', 'Invoice Printing Date', 'Subscription Date',
'Customer Name', 'Customer Register Date', 'Customer Number', 'Place Name',
'Intel Phone Number', 'Sub Total', 'Discount', 'Payment State',
'Intel Phone Number', 'Sub Total', 'Adjustment', 'Discount', 'Payment State',
'Grand Total', 'Payment Date', 'Receiver Name'
]
end
Expand All @@ -48,6 +48,7 @@ def attributes(order)
place_name(order),
intel_phone_number(order),
display_subtotal(order),
display_adjustment(order),
display_discount(order),
payment_state(order),
display_total(order),
Expand Down Expand Up @@ -85,15 +86,15 @@ def intel_phone_number(order)
end

def display_subtotal(order)
order.display_item_total.to_s.gsub(',', ' ').gsub('.00', '').gsub('៛', '')
order.display_item_total.to_s.gsub(',', '').gsub('.00', '').gsub('៛', '')
end

def payment_state(order)
order.payment_state.to_s
end

def display_total(order)
order.display_total.to_s.gsub(',', ' ').gsub('.00', '').gsub('៛', '')
order.display_total.to_s.gsub(',', '').gsub('.00', '').gsub('៛', '')
end

def payment_date(order)
Expand All @@ -117,11 +118,13 @@ def receiver_name(order)
end

def display_discount(order)
if order.display_adjustment_total.to_s.include?('-')
"-#{order.display_adjustment_total.to_s.gsub(',', ' ').gsub('.00', '').gsub('-', '').gsub('៛', '')}"
else
order.display_adjustment_total.to_s.gsub(',', ' ').gsub('.00', '').gsub('-', '').gsub('៛', '').to_s
end
total_discount = order.adjustments.select { |adj| adj.amount.negative? }.sum(&:amount)
"-#{total_discount.abs.to_s.gsub(',', '').gsub('.00', '').gsub('៛', '')}"
end

def display_adjustment(order)
total_adjustment = order.adjustments.select { |adj| adj.amount.positive? }.sum(&:amount)
total_adjustment.to_s.gsub(',', '').gsub('.00', '').gsub('៛', '')
end

def place_name(order)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<%= I18n.t('spree.billing.amount_remaining') %>
<div class="row col-7 d-flex justify-content-between">
<%= I18n.t('spree.currency.riel') %>
<%= text_field :amount, '', class: 'form-control', style: 'width: 85%; margin-right: 5%;', id: "#{payment.id}_amount_remaining", disabled: true %>
<%= f.text_field :amount, class: 'form-control', style: 'width: 85%; margin-right: 5%;', id: "#{payment.id}_amount_remaining", disabled: true %>
</div>
</div>
</div>
Expand Down

0 comments on commit faf961d

Please sign in to comment.