Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fanprint/spree_shipworks
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: bypotatoes/spree_shipworks
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 4 commits
  • 2 files changed
  • 2 contributors

Commits on Aug 5, 2015

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f1b551e View commit details

Commits on Sep 7, 2015

  1. Copy the full SHA
    9b08733 View commit details
  2. Copy the full SHA
    a7adc9a View commit details

Commits on Sep 10, 2015

  1. Merge pull request #1 from annvelents/master

    Some changes to send adjustments and shipment cost in order totals, add OrderNumber to xml
    bypotatoes committed Sep 10, 2015
    Copy the full SHA
    6a4525a View commit details
Showing with 62 additions and 10 deletions.
  1. +15 −4 README.md
  2. +47 −6 lib/spree_shipworks/xml.rb
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
SpreeShipworks
==============

Introduction goes here.
This gem provides API for your spree shop, that allows shipworks to process your orders.

Integrating
-----------

Example
=======
Add gem into your Gemfile:

Example goes here.
```
gem 'spree_shipworks', git: 'git@github.com:bypotatoes/spree_shipworks.git', branch: '3-0-stable'
```

If you need, patch your `Spree::ApiController` through `api_controller_decorator.rb`
```
Spree::ApiController.class_eval do
# code goes here
end
```
Load shipworks aplication and [add a Generic Module store](http://support.shipworks.com/support/solutions/articles/4000048147-adding-a-generic-module-store)

Testing
-------
53 changes: 47 additions & 6 deletions lib/spree_shipworks/xml.rb
Original file line number Diff line number Diff line change
@@ -101,10 +101,11 @@ def to_shipworks_xml(context)
module Order
def to_shipworks_xml(context)
context.element 'Order' do |order_context|
order_context.element 'OrderNumber', self.id
order_context.element 'OrderDate', self.created_at.to_s(:db).gsub(" ", "T")
order_context.element 'OrderNumber', self.number
order_context.element 'OrderID', self.id
order_context.element 'OrderDate', self.completed_at.to_s(:db).gsub(" ", "T")
order_context.element 'LastModified', self.updated_at.to_s(:db).gsub(" ", "T")
order_context.element 'ShippingMethod', self.shipping_method.try(:name)
order_context.element 'ShippingMethod', self.shipments.first.try(:shipping_method).try(:name)
order_context.element 'StatusCode', self.state
order_context.element 'CustomerID', self.user.try(:id)

@@ -138,11 +139,41 @@ def to_shipworks_xml(context)
end if self.line_items.present?

order_context.element 'Totals' do |totals_context|
self.adjustments.each do |adjustment|
adjustment.extend(Adjustment)
adjustment.to_shipworks_xml(totals_context)

if self.line_item_adjustments.nonzero.exists?
self.line_item_adjustments.nonzero.promotion.eligible.each do |promotion|
promotion.extend(Adjustment)
promotion.to_shipworks_xml(totals_context)
end
end

self.line_item_adjustments.nonzero.tax.eligible.each do |tax|
tax.extend(Adjustment)
tax.to_shipworks_xml(totals_context)
end

if self.shipment_adjustments.nonzero.exists?
self.shipment_adjustments.nonzero.promotion.eligible.each do |tax|
tax.extend(Adjustment)
tax.to_shipworks_xml(totals_context)
end
end

self.shipments.each do |shipment|
shipment.extend(Shipment)
shipment.extend(Adjustment)
shipment.to_shipworks_xml(totals_context)
end

if self.adjustments.nonzero.eligible.exists?
self.adjustments.nonzero.eligible.each do |adjustment|
adjustment.extend(Adjustment)
adjustment.to_shipworks_xml(totals_context)
end
end
end


end
end
end # Order
@@ -159,5 +190,15 @@ def to_shipworks_xml(context)
end
end # Payment

module Shipment
def amount
self.cost
end

def label
"shipment cost"
end
end #SmallShipment

end
end