696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
|
# File 'lib/active_shipping/carriers/ups.rb', line 696
def build_package_node(xml, package, options = {})
xml.Package do
if options[:return]
contents_description = package.options[:description]
xml.Description(contents_description) if contents_description
end
xml.PackagingType do
xml.Code('02')
end
xml.Dimensions do
xml.UnitOfMeasurement do
xml.Code(options[:imperial] ? 'IN' : 'CM')
end
[:length, :width, :height].each do |axis|
value = ((options[:imperial] ? package.inches(axis) : package.cm(axis)).to_f * 1000).round / 1000.0 xml.public_send(axis.to_s.capitalize, [value, 0.1].max)
end
end
xml.PackageWeight do
if (options[:service] || options[:service_code]) == DEFAULT_SERVICE_NAME_TO_CODE["UPS SurePost (USPS) < 1lb"]
code = options[:imperial] ? 'OZS' : 'KGS'
weight = options[:imperial] ? package.oz : package.kgs
else
code = options[:imperial] ? 'LBS' : 'KGS'
weight = options[:imperial] ? package.lbs : package.kgs
end
xml.UnitOfMeasurement do
xml.Code(code)
end
value = ((weight).to_f * 1000).round / 1000.0 xml.Weight([value, 0.1].max)
end
Array(package.options[:reference_numbers]).each do |reference_number_info|
xml.ReferenceNumber do
xml.Code(reference_number_info[:code] || "")
xml.Value(reference_number_info[:value])
end
end
xml.PackageServiceOptions do
if delivery_confirmation = package.options[:delivery_confirmation]
xml.DeliveryConfirmation do
xml.DCISType(PACKAGE_DELIVERY_CONFIRMATION_CODES[delivery_confirmation])
end
end
if dry_ice = package.options[:dry_ice]
xml.DryIce do
xml.RegulationSet(dry_ice[:regulation_set] || 'CFR')
xml.DryIceWeight do
xml.UnitOfMeasurement do
xml.Code(options[:imperial] ? 'LBS' : 'KGS')
end
xml.Weight(dry_ice[:weight])
end
end
end
if package_value = package.options[:insured_value]
xml.InsuredValue do
xml.CurrencyCode(package.options[:currency] || 'USD')
xml.MonetaryValue(package_value.to_f)
end
end
end
end
end
|