Skip to content

Commit d46a7bd

Browse files
rchekalukRob Chekaluk
andauthored
Add ship from address reference to sales receipt (#616)
* add ship from address to sales receipt * Add bill_address and ship_address to sales receipt spec --------- Co-authored-by: Rob Chekaluk <rchekaluk@ppolitics.org>
1 parent eccc92d commit d46a7bd

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

lib/quickbooks/model/sales_receipt.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class SalesReceipt < BaseModel
2222
xml_accessor :bill_address, :from => 'BillAddr', :as => PhysicalAddress
2323
xml_accessor :delivery_info, :from => 'DeliveryInfo', :as => DeliveryInfo
2424
xml_accessor :ship_address, :from => 'ShipAddr', :as => PhysicalAddress
25+
xml_accessor :ship_from_address, :from => 'ShipFromAddr', :as => PhysicalAddress
2526
xml_accessor :po_number, :from => 'PONumber'
2627
xml_accessor :ship_method_ref, :from => 'ShipMethodRef', :as => BaseReference
2728
xml_accessor :ship_date, :from => 'ShipDate', :as => Time

spec/fixtures/sales_receipt.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,33 @@
5656
<EmailStatus>NotSet</EmailStatus>
5757
<Balance>0</Balance>
5858
<DepositToAccountRef name="Cash and cash equivalents">28</DepositToAccountRef>
59+
<BillAddr>
60+
<Id>6</Id>
61+
<Line1>Rebecca Clark</Line1>
62+
<Line2>Sunset Bakery</Line2>
63+
<Line3>1040 East Tasman Drive.</Line3>
64+
<Line4>Los Angeles, CA 91123 USA</Line4>
65+
<Lat>34.1426959</Lat>
66+
<Long>-118.1568847</Long>
67+
</BillAddr>
68+
<ShipAddr>
69+
<Id>3</Id>
70+
<Line1>1040 East Tasman Drive.</Line1>
71+
<City>Los Angeles</City>
72+
<Country>USA</Country>
73+
<CountrySubDivisionCode>CA</CountrySubDivisionCode>
74+
<PostalCode>91123</PostalCode>
75+
<Lat>33.739466</Lat>
76+
<Long>-118.0395574</Long>
77+
</ShipAddr>
78+
<ShipFromAddr>
79+
<Id>5</Id>
80+
<Line1>1040 East Tasman Drive.</Line1>
81+
<City>Los Angeles</City>
82+
<Country>USA</Country>
83+
<CountrySubDivisionCode>CA</CountrySubDivisionCode>
84+
<PostalCode>91123</PostalCode>
85+
<Lat>33.739466</Lat>
86+
<Long>-118.0395574</Long>
87+
</ShipFromAddr>
5988
</SalesReceipt>

spec/fixtures/sales_receipt_void_success_response.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@
8080
<Lat>INVALID</Lat>
8181
<Long>INVALID</Long>
8282
</ShipAddr>
83+
<ShipFromAddr>
84+
<Id>5</Id>
85+
<Line1>1040 East Tasman Drive.</Line1>
86+
<City>Los Angeles</City>
87+
<Country>USA</Country>
88+
<CountrySubDivisionCode>CA</CountrySubDivisionCode>
89+
<PostalCode>91123</PostalCode>
90+
<Lat>33.739466</Lat>
91+
<Long>-118.0395574</Long>
92+
</ShipFromAddr>
8393
<GlobalTaxCalculation>NotApplicable</GlobalTaxCalculation>
8494
<TotalAmt>10.00</TotalAmt>
8595
<PrintStatus>NotSet</PrintStatus>

spec/fixtures/sales_receipts.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@
8282
<Lat>INVALID</Lat>
8383
<Long>INVALID</Long>
8484
</ShipAddr>
85+
<ShipFromAddr>
86+
<Id>5</Id>
87+
<Line1>1040 East Tasman Drive.</Line1>
88+
<City>Los Angeles</City>
89+
<Country>USA</Country>
90+
<CountrySubDivisionCode>CA</CountrySubDivisionCode>
91+
<PostalCode>91123</PostalCode>
92+
<Lat>33.739466</Lat>
93+
<Long>-118.0395574</Long>
94+
</ShipFromAddr>
8595
<GlobalTaxCalculation>NotApplicable</GlobalTaxCalculation>
8696
<TotalAmt>10.00</TotalAmt>
8797
<PrintStatus>NotSet</PrintStatus>

spec/lib/quickbooks/model/sales_receipt_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,38 @@
5555
expect(sales_receipt.private_note).to eq("private")
5656

5757
expect(sales_receipt.total).to eq(10.00)
58+
59+
billing_address = sales_receipt.bill_address
60+
expect(billing_address).to_not be_nil
61+
expect(billing_address.id).to eq "6"
62+
expect(billing_address.line1).to eq "Rebecca Clark"
63+
expect(billing_address.line2).to eq "Sunset Bakery"
64+
expect(billing_address.line3).to eq "1040 East Tasman Drive."
65+
expect(billing_address.line4).to eq "Los Angeles, CA 91123 USA"
66+
expect(billing_address.lat).to eq "34.1426959"
67+
expect(billing_address.lon).to eq "-118.1568847"
68+
69+
shipping_address = sales_receipt.ship_address
70+
expect(shipping_address).to_not be_nil
71+
expect(shipping_address.id).to eq "3"
72+
expect(shipping_address.line1).to eq "1040 East Tasman Drive."
73+
expect(shipping_address.city).to eq "Los Angeles"
74+
expect(shipping_address.country).to eq "USA"
75+
expect(shipping_address.country_sub_division_code).to eq "CA"
76+
expect(shipping_address.postal_code).to eq "91123"
77+
expect(shipping_address.lat).to eq "33.739466"
78+
expect(shipping_address.lon).to eq "-118.0395574"
79+
80+
ship_from_address = sales_receipt.ship_from_address
81+
expect(ship_from_address).to_not be_nil
82+
expect(ship_from_address.id).to eq "5"
83+
expect(ship_from_address.line1).to eq "1040 East Tasman Drive."
84+
expect(ship_from_address.city).to eq "Los Angeles"
85+
expect(ship_from_address.country).to eq "USA"
86+
expect(ship_from_address.country_sub_division_code).to eq "CA"
87+
expect(ship_from_address.postal_code).to eq "91123"
88+
expect(ship_from_address.lat).to eq "33.739466"
89+
expect(ship_from_address.lon).to eq "-118.0395574"
5890
end
5991

6092
it "should initialize line items as empty array" do

0 commit comments

Comments
 (0)