• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Andy Miller
#1 Posted : Thursday, November 2, 2006 5:54:12 PM(UTC)
Andy Miller

Rank: Member

Joined: 11/5/2003(UTC)
Posts: 2,136

Was thanked: 1 time(s) in 1 post(s)
This one is kind of subtle, I hope I can explain it clearly...


The Order.ShippingAddress property setter runs the Calculate() method (probably to account for tax changes). Amoung other things, this calculates



_GrandTotal = [2](_SubTotal - _OrderDiscounts) + (_ShippingTotal - _ShippingDiscounts) + _HandlingTotal + _TaxTotal + _TaxTotal2 - postOrderAdjustment[/2]



The deserializer that is automatically generated for the Order class sets ShippingAddress before it sets ShippingTotal and TaxTotal. This means _GrandTotal is incorrectly calculated when the order is deserialized for a web service.



So when I use the Orders_Order_PaymentSummary web service method, I get the wrong total.



One solution is to call Calculate() in all the property setters that go into the calculation of GrandTotal: OrderDiscounts, ShippingTotal, etc. Another would be to remove Calculate from the ShippingAddress setter and create a separate method like SetShippingAddress(). This would sort of mimic the behavior of the other "serializer" Order.Mapper.ConvertDataRow which does not use the ShippingAddress property (it assigns a value to the _ShippingAddress field directly...presumably to avoid the Calculate).
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing
Andy Miller
#2 Posted : Thursday, November 2, 2006 6:10:59 PM(UTC)
Andy Miller

Rank: Member

Joined: 11/5/2003(UTC)
Posts: 2,136

Was thanked: 1 time(s) in 1 post(s)
I'm partial to the second solution (using SetShippingAddress) since using a method implies that some kind of calculation is taking place in the method...that it's not just setting a value.



So I marked the Set property with <Obsolete> and found that it was only used in 6 places.



Here's what I have so far...



<SPAN class=cln>[color=#2b91af><SPAN class=cln> 214 <SPAN class=cb1>Public[/color] <SPAN class=cb1>[color=#0000ff>Property]As[/color] Contacts.Address</PRE>
<SPAN class=cln> 215 <SPAN class=cb1>[color=#0000ff>Get</PRE>
216 <SPAN class=cb1>If[/color] (<SPAN class=cb1>[color=#0000ff>Me._ShippingAddress]Is[/color] <SPAN class=cb1>[color=#0000ff>Nothing)]Then[/color]</PRE>
<SPAN class=cln> 217 <SPAN class=cb1>[color=#0000ff>Me._ShippingAddress]New[/color] Contacts.Address</PRE>
<SPAN class=cln> 218 <SPAN class=cb1>[color=#0000ff>If]Me[/color]._shippingAddressXml &lt;&gt; <SPAN class=cb1>[color=#0000ff>String.Empty)]Then[/color]</PRE>
<SPAN class=cln> 219 <SPAN class=cb1>[color=#0000ff>Me._ShippingAddress.FromXmlString(_shippingAddressXml)</PRE>
220 <SPAN class=cb1>End[/color] <SPAN class=cb1>[color=#0000ff>If</PRE>
221 <SPAN class=cb1>End[/color] <SPAN class=cb1>[color=#0000ff>If</PRE>
222 <SPAN class=cb1>Return[/color] <SPAN class=cb1>[color=#0000ff>Me._ShippingAddress</PRE>
223 <SPAN class=cb1>End[/color] <SPAN class=cb1>[color=#0000ff>Get</PRE>
224 &lt;Obsolete()&gt; <SPAN class=cb1>Set[/color](<SPAN class=cb1>[color=#0000ff>ByVal]As[/color] Contacts.Address)</PRE>
<SPAN class=cln> 225 _ShippingAddress = Value</PRE>
<SPAN class=cln> 226 <SPAN class=cb2>[color=#008000>'Calculate()</PRE>
227 <SPAN class=cb1>End[/color] <SPAN class=cb1>[color=#0000ff>Set</PRE>
228 <SPAN class=cb1>End[/color] <SPAN class=cb1>[color=#0000ff>Property</PRE>
229 <SPAN class=cb2>'AFM[/color]</PRE>
<SPAN class=cln> 230 <SPAN class=cb1>[color=#0000ff>Public]Sub[/color] SetShippingAddress(<SPAN class=cb1>[color=#0000ff>ByVal]As[/color] Contacts.Address)</PRE>
<SPAN class=cln> 231 _ShippingAddress = value</PRE>
<SPAN class=cln> 232 Calculate()</PRE>
<SPAN class=cln> 233 <SPAN class=cb1>[color=#0000ff>End]Sub[/color]</PRE>
<SPAN class=cln> 234 <SPAN class=cb2><FONT color=#008000>'AFM-End</PRE>
</FONT></PRE>
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

©2024 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012