512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
|
# File 'lib/XMLFields.rb', line 512
def self.from_hash(hash, index=0, name='lineItemData')
base = hash[name][index]
if(base)
this = LineItemData.new
this.itemSequenceNumber = base['itemSequenceNumber']
this.itemDescription = base['itemDescription']
this.productCode = base['productCode']
this.quantity = base['quantity']
this.unitOfMeasure = base['unitOfMeasure']
this.taxAmount = base['taxAmount']
this.lineItemTotal = base['lineItemTotal']
this.lineItemTotalWithTax = base['lineItemTotalWithTax']
this.itemDiscountAmount = base['itemDiscountAmount']
this.commodityCode = base['commodityCode']
this.unitCost = base['unitCost']
if(base['detailTax'])
base['detailTax'].each_index {|index| this.detailTax << DetailTax.from_hash(base,index)}
end
SchemaValidation.validate_size(this.itemSequenceNumber, false, 1, 99, name, 'itemSequenceNumber')
SchemaValidation.validate_length(this.itemDescription, true, 1, 26, name, 'itemDescription')
SchemaValidation.validate_length(this.productCode, false, 1, 12, name, 'productCode')
SchemaValidation.validate_regex(this.quantity, false, /\A(\+|\-)?\d*\.?\d*\Z/, name, 'quantity')
SchemaValidation.validate_length(this.unitOfMeasure, false, 1, 12, name, 'unitOfMeasure')
SchemaValidation.validate_size(this.taxAmount, false, -999999999999, 999999999999, name, 'taxAmount')
SchemaValidation.validate_size(this.lineItemTotal, false, -999999999999, 999999999999, name, 'lineItemTotal')
SchemaValidation.validate_size(this.lineItemTotalWithTax, false, -999999999999, 999999999999, name, 'lineItemTotalWithTax')
SchemaValidation.validate_size(this.itemDiscountAmount, false, -999999999999, 999999999999, name, 'itemDiscountAmount')
SchemaValidation.validate_length(this.commodityCode, false, 1, 12, name, 'commodityCode')
SchemaValidation.validate_regex(this.unitCost, false, /\A(\+|\-)?\d*\.?\d*\Z/, name, 'unitCost')
this
else
nil
end
end
|