lib/economic/current_invoice_line.rb in rconomic-0.5.1 vs lib/economic/current_invoice_line.rb in rconomic-0.5.2
- old
+ new
@@ -57,29 +57,25 @@
@invoice_handle = handle
end
protected
- # Returns Hash with the properties of CurrentInvoice in the correct order,
- # camelcased and ready to be sent via SOAP
- def build_soap_data
- data = {}
-
- data['Number'] = 0 # Doesn't seem to be used
- data['InvoiceHandle'] = invoice.handle.to_hash unless invoice.blank?
- data['Description'] = description unless description.blank?
- data['DeliveryDate'] = delivery_date
- data['UnitHandle'] = { 'Number' => unit_handle[:number] } unless unit_handle.blank?
- data['ProductHandle'] = { 'Number' => product_handle[:number] } unless product_handle.blank?
- data['Quantity'] = quantity unless quantity.blank?
- data['UnitNetPrice'] = unit_net_price unless unit_net_price.blank?
- data['DiscountAsPercent'] = discount_as_percent unless discount_as_percent.blank?
- data['UnitCostPrice'] = unit_cost_price unless unit_cost_price.blank?
- data['TotalNetAmount'] = total_net_amount
- data['TotalMargin'] = total_margin unless total_margin.blank?
- data['MarginAsPercent'] = margin_as_percent unless margin_as_percent.blank?
-
- return data
+ def fields
+ to_hash = Proc.new { |h| h.to_hash }
+ [
+ ["Number", :number, Proc.new { 0 }, :required], # Doesn't seem to be used
+ ["InvoiceHandle", :invoice_handle, to_hash],
+ ["Description", :description],
+ ["DeliveryDate", :delivery_date, nil, :required],
+ ["UnitHandle", :unit_handle, to_hash],
+ ["ProductHandle", :product_handle, to_hash],
+ ["Quantity", :quantity],
+ ["UnitNetPrice", :unit_net_price],
+ ["DiscountAsPercent", :discount_as_percent],
+ ["UnitCostPrice", :unit_cost_price],
+ ["TotalNetAmount", :total_net_amount, nil, :required],
+ ["TotalMargin", :total_margin],
+ ["MarginAsPercent", :margin_as_percent]
+ ]
end
end
-
end