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

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

	protected $children = [
        /**
         * This record contains the air commission for the ticketing transaction, along with the exchange air commission when applicable
         * This record has been rewritten from all previous levels
         * A new field (MCP-) has been added to accommodate a new commission structure instituted by British Airways
         */

        [                'key'=> 'key',                               'type'=> 'Constant',                'len'=> 2,             'val'=> '8\\',                'req'=> true, ],             // Record identifier
        [                'key'=> 'PassengerType',                     'type'=> 'StringDelimitedByChar',   'len'=> 3,             'val'=> '\\',                 'req'=> false, ],            // Passenger Type code - Default if unknown(see Note 5)
        [                'key'=> '#016',                              'type'=> 'Separator',                                                                    'req'=> false, ],            // Field Separator
        [                'key'=> 'star_016',                          'type'=> 'Constant',                                       'val' => '*',                 'req'=> false, ],             // Field Separator

        [                'key'=> 'complex:5',                         'type'=> 'Complex', 'merge'=>true,                                                       'req'=> false, 'children'=> [
            [            'key'=> 'key',                               'type'=> 'Set',                   'len'=> 4,              'val'=> ['EXCH',],             'req'=> true, ],             // Exchange Commission Identifier (see Note 3)
        ]],
        [                'key'=> '#018',                              'type'=> 'Separator',                                                                    'req'=> false, ],            // Field Separator

        [                'key'=> 'complex:7',                         'type'=> 'Complex', 'merge'=>true,                                                       'req'=> false, 'children'=> [
            [            'key'=> 'key',                               'type'=> 'Constant',              'len'=> 4,               'val'=> 'OCA-',               'req'=> true, ],             // Original/Recall Commission Amount field Identifier (see note 2 and 6)
            [            'key'=> 'OriginalRecallCommissionAmount',    'type'=> 'StringDelimitedByChar', 'len'=> [0, 8],          'val'=> '\\',                 'req'=> true, ],             // Original/Recall Commission Amount
        ]],
        [                'key'=> '#021',                              'type'=> 'Separator',                                                                    'req'=> false, ],            // Field Separator

        [                'key'=> 'complex:9',                         'type'=> 'Complex', 'merge'=>true,                                                       'req'=> false, 'children'=> [
            [            'key'=> 'key',                               'type'=> 'Constant',              'len'=> 4,               'val'=> 'ACA-',               'req'=> true, ],             // Admin Fee/Penalty Commission Amount field Identifier (see note 2 and 7)
            [            'key'=> 'AdminFeePenaltyCommissionAmount',   'type'=> 'StringDelimitedByChar', 'len'=> [0, 8],          'val'=> '\\',                 'req'=> true, ],             // Admin Fee/Penalty Commission Amount
        ]],
        [                'key'=> '#024',                              'type'=> 'Separator',                                                                    'req'=> false, ],            // Field Separator

        [                'key'=> 'complex:11',                        'type'=> 'Complex', 'merge'=>true,                                                       'req'=> false, 'children'=> [
            [            'key'=> 'key',                               'type'=> 'Constant',              'len'=> 4,               'val'=> 'NCA-',               'req'=> true, ],             // New Commission Amount field identifier
            [            'key'=> 'NewCommissionAmount',               'type'=> 'FloatRaw',              'len'=> [0, 8],          'val'=> '\\',                 'req'=> true, ],             // New Commission Amount (see note 2)
        ]],
        [                'key'=> '#027',                              'type'=> 'Separator',                                                                    'req'=> false, ],            // Field Separator

        [                'key'=> 'complex:13',                        'type'=> 'Complex', 'merge'=>true,                                                       'req'=> false, 'children'=> [
            [            'key'=> 'key',                               'type'=> 'Constant',             'len'=> 3,                'val'=> 'CP-',                'req'=> true, ],             // Commission Percent field identifier
            [            'key'=> 'CommissionPercent',                 'type'=> 'FloatRaw',             'len'=> [0, 5],           'val'=> '\\',                 'req'=> true, ],             // Commission Percent
        ]],
        [                'key'=> '#030',                              'type'=> 'Separator',                                                                    'req'=> false, ],            // Field Separator

        [                'key'=> 'complex:15',                        'type'=> 'Complex', 'merge'=>true,                                                       'req'=> false, 'children'=> [
            [            'key'=> 'key',                               'type'=> 'Constant',             'len'=> 3,                'val'=> 'CA-',                'req'=> true, ],              // Commission Amount field identifier
            [            'key'=> 'PNOrBlank',                         'type'=> 'Set',                  'len'=> 1,                'val'=> ['P', 'N', ' ', '', ],'req'=> false, ],              // P, N, or Blank
            [            'key'=> 'PrimaryCommission',                 'type'=> 'FloatRaw',             'len'=> [0, 8],           'val'=> '\\',                 'req'=> true, ],              // Primary Commission
        ]],
        [                'key'=> '#034',                              'type'=> 'Separator',                                                                    'req'=> false, ],             // Field Separator

        [                'key'=> 'complex:16',                        'type'=> 'Complex', 'merge'=>true,                                                       'req'=> false, 'children'=> [
            [            'key'=> 'key',                               'type'=> 'Constant',             'len'=> 4,                'val'=> 'MCP-',               'req'=> true, ],              // Money Collection Payment(see note 8)
            [            'key'=> 'MoneyCollectionAmount',             'type'=> 'StringRaw',            'len'=> [0, 6],                                         'req'=> true, ],              // Money Collection Amount
        ]],

		[                'key'=> 'star_034',                          'type'=> 'Constant',                                       'val' => '*',                 'req'=> false, ],             // Field Separator
	];
}
