Files
openfoodnetwork/app/views/spree/orders/_line_item.html.haml
luisramos0 567196fe0e Fix line item verification of stock on the browser side by adding logic to handle completed orders with some reserved stock
The shopping/orders_spec is now validating this edge case by using all stock available in one of the line items
2019-06-25 14:50:03 +01:00

33 lines
1.5 KiB
Plaintext

%tr.line-item{class: "variant-#{variant.id}"}
%td.cart-item-description{'data-hook' => "cart_item_description"}
%div.item-thumb-image{"data-hook" => "cart_item_image"}
- if variant.images.length == 0
= mini_image(variant.product)
- else
= image_tag(variant.images.first.attachment.url(:mini))
= render 'spree/shared/line_item_name', line_item: line_item
- if @insufficient_stock_lines.andand.include? line_item
%span.out-of-stock
= variant.in_stock? ? t(".insufficient_stock", :on_hand => variant.on_hand) : t(".out_of_stock")
%br/
- if @unavailable_order_variants.andand.include? line_item.variant
%span.out-of-stock
= t(".unavailable_item")
%br/
%td.text-right.cart-item-price{"data-hook" => "cart_item_price"}
= line_item.single_display_amount_with_adjustments.to_html
%td.text-center.cart-item-quantity{"data-hook" => "cart_item_quantity"}
- finalized_quantity = @order.completed? ? line_item.quantity : 0
= item_form.number_field :quantity, :min => 0, "ofn-on-hand" => "#{variant.on_demand && 9999 || variant.on_hand}", "finalizedquantity" => finalized_quantity, "ng-model" => "line_item_#{line_item.id}", :class => "line_item_quantity", :size => 5
%td.cart-item-total.text-right{"data-hook" => "cart_item_total"}
= line_item.display_amount_with_adjustments.to_html unless line_item.quantity.nil?
%td.cart-item-delete.text-center{"data-hook" => "cart_item_delete"}
%a.delete{href: "#", id: "delete_#{dom_id(line_item)}"}
%i.delete.ofn-i_026-trash