<?php
namespace App\Worldspan\LineParser\Types\Line;

/**
 *
 * @author Lucian Sirbu
 */
class RX extends \App\Worldspan\LineParser\Types\WorldspanBaseLine
{
	protected $extractRegexp = "/^(?P<rawData>X.+)/sm";

	protected $children = [
        /**
         * This record contains the fare values of a resulting exchange ticket transaction
         * The record has been re-written to include the values required to complete the ARC Refund/Exchange Notice (REN) when used for exchange ticketing
         * Fields are only sent when they are part of the exchange transaction
         */

        ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 2,                    'val'=> 'X\\',                'req'=> true,],              // Record identifier
        ['key'=> 'ExchangeFareIndicator',                            'type'=> 'Alphanumeric',                     'len'=> 1,                                                  'req'=> true,],             // Exchange Fare Indicator (see Note 3)
        ['key'=> '#018',                                             'type'=> 'Separator',                                                                                    'req'=> true,],             // Field Separator

        ['key'=> 'complex:5',                                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'NTF-',               'req'=> true,],              // New Total Fare field identifier
            ['key'=> 'TotalFareOfNewTicketAmount',                       'type'=> 'StringDelimitedByChar',            'len'=> [0, 8],          'val'=> '\\',                 'req'=> true,],             // Total Fare of new ticket amount (Identical to total amount in the G record) (This field is only sent for ARC exchanges)
		]],
        ['key'=> '#023',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:7',                                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'OBF-',               'req'=> true,],              // Old Base Fare field identifier
            ['key'=> 'BaseFareAmountOfOriginalrefundedTicket',           'type'=> 'StringDelimitedByChar',            'len'=> [0, 8],          'val'=> '\\',                 'req'=> true,],             // Base Fare amount of original/refunded ticket
		]],
        ['key'=> '#026',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:9',                                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'OT1-',               'req'=> true,],              // Old Tax 1 field identifier
            ['key'=> 'Tax1Code',                                         'type'=> 'StringDelimitedByChar',            'len'=> 2,                    'val'=> '\\',                 'req'=> true,],             // Tax 1 code
            ['key'=> 'Tax1AmountOfOriginalrefundedTicket',               'type'=> 'StringDelimitedByChar',            'len'=> [0, 8],          'val'=> '\\',                 'req'=> true,],             // Tax 1 amount of original/refunded ticket
		]],
        ['key'=> '#030',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:11',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'OT2-',               'req'=> true,],              // Old Tax 2 field identifier
            ['key'=> 'Tax2Code',                                         'type'=> 'StringDelimitedByChar',            'len'=> 2,                    'val'=> '\\',                 'req'=> true,],             // Tax 2 code
            ['key'=> 'Tax2AmountOfOriginalrefundedTicket',               'type'=> 'StringDelimitedByChar',            'len'=> [0, 8],          'val'=> '\\',                 'req'=> true,],             // Tax 2 amount of original/refunded ticket
		]],
        ['key'=> '#034',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:13',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'OT3-',               'req'=> true,],              // Old Tax 3 field identifier
            ['key'=> 'Tax3Code',                                         'type'=> 'StringDelimitedByChar',            'len'=> 2,                    'val'=> '\\',                 'req'=> true,],             // Tax 3 code
            ['key'=> 'Tax3AmountOfOriginalrefundedTicket',               'type'=> 'StringDelimitedByChar',            'len'=> [0, 8],          'val'=> '\\',                 'req'=> true,],             // Tax 3 amount of original/refunded ticket
		]],
        ['key'=> '#038',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:15',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'OTF-',               'req'=> true,],              // Old total Cost field identifier
            ['key'=> 'TotalCostOfOriginalrefundedTicket',                'type'=> 'StringDelimitedByChar',            'len'=> [0, 8],          'val'=> '\\',                 'req'=> true,],             // Total Cost of original/refunded ticket (Sum of BF-, T1-, T2- and T3-)
		]],
        ['key'=> '#042',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:17',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'AF-',                'req'=> true,],              // Administrative Fee field identifier (see Note 9)
            ['key'=> 'AdministrativeFeeAmount',                          'type'=> 'StringDelimitedByChar',            'len'=> [0, 8],          'val'=> '\\',                 'req'=> true,],             // Administrative Fee amount
		]],
        ['key'=> '#045',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:19',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'RFC-',               'req'=> true,],              // Currency code of re-issued fare field identifier
            ['key'=> 'CurrencyCodeOfReissuedFare',                       'type'=> 'StringDelimitedByChar',            'len'=> 3,                    'val'=> '\\',                 'req'=> true,],             // Currency code of re-issued fare (see note 10)
		]],
        ['key'=> '#048',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:21',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'RF-',                'req'=> true,],              // Re-issued fare amount field identifier
            ['key'=> 'ReissuedFareAmount',                               'type'=> 'FloatRaw',                                                                                        'req'=> false,],             // Re-issued fare amount (see note 10)
		]],
        ['key'=> '#051',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:23',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'BFC-',               'req'=> true,],              // Currency code of base fare
            ['key'=> 'CurrencyCode',                                     'type'=> 'StringDelimitedByChar',            'len'=> 3,                    'val'=> '\\',                 'req'=> false,],             // Currency code
		]],
        ['key'=> '#054',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:25',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'BF-',                'req'=> true,],              // Base Fare of Exchange Amount
            ['key'=> 'BaseFareAmountOfExchange',                         'type'=> 'StringDelimitedByChar',            'len'=> [0, 8],          'val'=> '\\',                 'req'=> false,],             // Base Fare amount of Exchange
		]],
        ['key'=> '#057',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:27',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'PC-',                'req'=> true,],              // Previous Currency code (see note 7)
            ['key'=> 'PreviousCurrencyCode',                             'type'=> 'StringTrimmedDelimitedByChar',     'len'=> [0, 9],          'val'=> '\\',                 'req'=> false,],             // Previous Currency code
		]],
        ['key'=> '#060',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:29',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'T1-',                'req'=> true,],              // Tax 1 field identifier
            ['key'=> 'Tax1Code',                                         'type'=> 'StringRaw',                        'len'=> 2,                                                  'req'=> false,],             // tax 1 code (see note 5)
            ['key'=> 'Tax1OfExchangeAmount',                             'type'=> 'FloatRaw',                                                                                     'req'=> false,],             // Tax 1 of exchange amount
            ['key'=> 'Tax1StatusIndicator',                              'type'=> 'StringTrimmedDelimitedByChar',     'len'=> 2,                    'val'=> '\\',                 'req'=> false,],             // Tax Status Indicator (see note 6)
		]],
        ['key'=> '#065',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:31',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'T2-',                'req'=> true,],              // Tax 2 field identifier
            ['key'=> 'Tax2Code',                                         'type'=> 'StringRaw',                        'len'=> 2,                                                  'req'=> false,],             // tax 1 code (see note 5)
            ['key'=> 'Tax2OfExchangeAmount',                             'type'=> 'FloatRaw',                                                                                     'req'=> false,],             // Tax 1 of exchange amount
            ['key'=> 'Tax2StatusIndicator',                              'type'=> 'StringTrimmedDelimitedByChar',     'len'=> 2,                    'val'=> '\\',                 'req'=> false,],             // Tax Status Indicator (see note 6)
		]],
        ['key'=> '#070',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:33',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'T3-',                'req'=> true,],              // Tax 3 field identifier
            ['key'=> 'Tax3Code',                                         'type'=> 'StringRaw',                        'len'=> 2,                                                  'req'=> false,],             // tax 1 code (see note 5)
            ['key'=> 'Tax3OfExchangeAmount',                             'type'=> 'FloatRaw',                                                                                     'req'=> false,],             // Tax 1 of exchange amount
            ['key'=> 'Tax3StatusIndicator',                              'type'=> 'StringTrimmedDelimitedByChar',     'len'=> 2,                    'val'=> '\\',                 'req'=> false,],             // Tax Status Indicator (see note 6)
		]],
        ['key'=> '#075',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:35',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'AP-',                'req'=> true,],              // Admin/Penalty Fee
            ['key'=> 'AdminPenaltyFeeAmount',                            'type'=> 'StringDelimitedByChar',            'len'=> [0, 8],          'val'=> '\\',                 'req'=> false,],             // Admin/Penalty Fee Amount
		]],
        ['key'=> '#078',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:37',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'TFC-',               'req'=> true,],              // Currency code of total fare field identifier (see note 8)
            ['key'=> 'CurrencyCodeOfTotalFare',                          'type'=> 'StringTrimmedDelimitedByChar',     'len'=> 3,                    'val'=> '\\',                 'req'=> false,],             // Currency code of total fare
		]],
        ['key'=> '#082',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:39',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'TF-',                'req'=> true,],              // Total Exchange fare (see note 8)
            ['key'=> 'TotalExchangeAmount',                              'type'=> 'FloatRaw',                                                                                     'req'=> false,],             // Total Exchange Amount
            ['key'=> 'NOADC',                                            'type'=> 'Set',                                                            'val'=>['NOADC'],             'req'=> false,],             // Total Exchange Amount
		]],
        ['key'=> '#085',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:41',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'MA-',                'req'=> true,],              // MCO Amount Identifier
            ['key'=> 'MCOAmount',                                        'type'=> 'StringDelimitedByChar',            'len'=> [0, 8],          'val'=> '\\',                 'req'=> false,],             // MCO Amount
		]],
        ['key'=> '#088',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:43',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'P1-',                'req'=> true,],              // PFC 1 field identifier
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'aaan',               'req'=> false,],             // PFC 1 of original/refunded ticket
		]],
        ['key'=> '#091',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:45',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'P2-',                'req'=> true,],              // PFC 2 field identifier
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'aaan',               'req'=> false,],             // PFC 2 of original/refunded ticket
		]],
        ['key'=> '#094',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:47',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'P3-',                'req'=> true,],              // PFC 3 field identifier
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'aaan',               'req'=> false,],             // PFC 3 of original/refunded ticket
		]],
        ['key'=> '#097',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator
        ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'P4-',                'req'=> false,],             // PFC 4 field identifier
        ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'aaan',               'req'=> false,],             // PFC 4 of original/refunded ticket
	];
}
