HTML order cycle report email, text customisable in translations

This commit is contained in:
Steve Pettitt
2016-05-10 23:04:06 +01:00
parent 7f1fc56f78
commit 6ecf896fa2
6 changed files with 76 additions and 2 deletions

View File

@@ -74,6 +74,9 @@ table.order-summary
padding-left: 5px
padding-right: 5px
.text-right
text-align: right
.social .soc-btn
padding: 3px 7px
font-size: 12px

View File

@@ -7,6 +7,7 @@ class ProducerMailer < Spree::BaseMailer
@line_items = aggregated_line_items_from(@order_cycle, @producer)
@receival_instructions = @order_cycle.receival_instructions_for @producer
@total = total_from_line_items(@line_items)
@tax_total = tax_total_from_line_items(@line_items)
subject = "[#{Spree::Config.site_name}] Order cycle report for #{producer.name}"
@@ -53,4 +54,8 @@ class ProducerMailer < Spree::BaseMailer
def total_from_line_items(aggregated_line_items)
Spree::Money.new(aggregated_line_items.values.map(&:total).reduce(:+)).to_s
end
def tax_total_from_line_items(aggregated_line_items)
Spree::Money.new(aggregated_line_items.values.map(&:included_tax).reduce(:+)).to_s
end
end

View File

@@ -0,0 +1,62 @@
%p Dear #{@producer.name},
%p
= t :producer_mail_text_before
- if @receival_instructions
%p
Stock pickup/delivery instructions:
= @receival_instructions
%p
Here is a summary of the orders for your products:
%table.order-summary
%thead
%tr
%th
= t :sku
%th
= t :supplier
%th
= t :product
%th.text-right
= t :quantity
%th.text-right
= t :price
%th.text-right
= t :subtotal
%th.text-right
= t :included_tax
%tbody
- @line_items.each_pair do |variant, line_item|
%tr
%td
#{variant.sku}
%td
#{raw(variant.product.supplier.name)}
%td
#{raw(variant.product_and_full_name)}
%td.text-right
#{line_item.quantity}
%td.text-right
#{line_item.single_money}
%td.text-right
#{line_item.display_total}
%td.text-right
#{line_item.display_included_tax}
%tr.total_row
%td
%td
%td
%td
%td
%td.text-right
#{@total}
%td.text-right
#{@tax_total}
%p
= t :producer_mail_text_after
%em
%p
#{@coordinator.name}
%p
#{@coordinator.address.address1}, #{@coordinator.address.city}, #{@coordinator.address.zipcode}
#{@coordinator.phone}
#{@coordinator.email}

View File

@@ -1,6 +1,6 @@
Dear #{@producer.name},
\
We now have all the consumer orders for the next food drop.
= t :producer_mail_text_before
\
- if @receival_instructions
Stock pickup/delivery instructions:
@@ -18,7 +18,7 @@ Here is a summary of the orders for your products:
\
Total: #{@total}
\
Thanks and best wishes,
= t :producer_mail_text_after
#{@coordinator.name}
#{@coordinator.address.address1}, #{@coordinator.address.city}, #{@coordinator.address.zipcode}
#{@coordinator.phone}

View File

@@ -401,6 +401,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using
If you are a producer or food enterprise, we are excited to have you as a part of the network."
email_signup_help_html: "We welcome all your questions and feedback; you can use the <em>Send Feedback</em> button on the site or email us at"
producer_mail_text_before: "We now have all the consumer orders for the next food drop."
producer_mail_text_after: "Thanks and best wishes,"
shopping_oc_closed: Orders are closed
shopping_oc_closed_description: "Please wait until the next cycle opens (or contact us directly to see if we can accept any late orders)"
shopping_oc_last_closed: "The last cycle closed %{distance_of_time} ago"

View File

@@ -63,6 +63,7 @@ describe ProducerMailer do
end
it "includes the total" do
puts mail.body.encoded
mail.body.should include 'Total: $20.00'
end