<?php
namespace App\Bsp\Hot230\Lines\Transaction;

/**
 * Line parser
 * @author Lucian Sirbu
 */
class BMD75 extends \App\Bsp\Hot230\HOTBase
{
	protected $children = [
		[ 'key'=>'SMSG',                 'type'=>'Constant', 'val'=>'BMD',       'len'=>3,      'label'=>'Standard Message Identifier', ],                   // X/M/Standard Message Identifier
		[ 'key'=>'SQNR',                 'type'=>'Integer',                      'len'=>8,      'label'=>'Sequence Number', ],                               // X/M/Sequence Number
		[ 'key'=>'STNQ',                 'type'=>'Constant', 'val'=>'75',        'len'=>2,      'label'=>'Standard Numeric Qualifier', ],                    // X/M/Standard Numeric Qualifier
		[ 'key'=>'DAIS',                 'type'=>'Date',     'fmt'=>'YYMMDD',    'len'=>6,      'label'=>'Date of Issue', ],                                 // X/M/Date of Issue
		[ 'key'=>'TRNN',                 'type'=>'Integer',                      'len'=>6,      'label'=>'Transaction Number', ],                            // X/M/Transaction Number
		[ 'key'=>'TDNR_airline',         'type'=>'StringRaw',                    'len'=>3,      'label'=>'Ticket/Document Number(airline number)', ],        // S/M/Ticket/Document Number
		[ 'key'=>'TDNR_ticketNumber',    'type'=>'StringRaw',                    'len'=>10,     'label'=>'Ticket/Document Number', ],
		[ 'key'=>'TDNR_extra',           'type'=>'StringRaw',                    'len'=>1,      'label'=>'Ticket/Document Number(extra digits)', ],
		[ 'key'=>'CDGT',                 'type'=>'Digits',                       'len'=>1,      'label'=>'Check-Digit', ],                                   // X/M/Check-Digit
		[ 'key'=>'EMCP',                 'type'=>'Digits',                       'len'=>1,      'label'=>'EMD Coupon Number', ],                             // X/M/EMD Coupon Number
		[ 'key'=>'EMCV',                 'type'=>'PriceAmount',                  'len'=>11,     'label'=>'EMD Coupon Value', ],                              // X/C/EMD Coupon Value
		[ 'key'=>'EMRT_airline',         'type'=>'StringRaw',                    'len'=>3,      'label'=>'EMD Related Ticket Number', ],
		[ 'key'=>'EMRT_ticketNumber',    'type'=>'StringRaw',                    'len'=>10,     'label'=>'EMD Related Ticket Number', ],
		[ 'key'=>'EMRT_extra',           'type'=>'StringRaw',                    'len'=>1,      'label'=>'EMD Related Ticket Number', ],
		[ 'key'=>'EMRC',                 'type'=>'Digits',                       'len'=>1,      'label'=>'EMD Related Coupon Number', ],                     // X/C/EMD Related Coupon Number
		[ 'key'=>'EMST',                 'type'=>'StringRaw',                    'len'=>1,      'label'=>'EMD service type', ],
		[ 'key'=>'EMSC',                 'type'=>'StringRaw',                    'len'=>3,      'label'=>'EMD Reason for Issuance Sub Code', ],              // X/C/EMD Reason for Issuance Sub Code
		[ 'key'=>'EMOC',                 'type'=>'StringRaw',                    'len'=>3,      'label'=>'EMD Fee Owner Airline Designator', ],              // X/C/EMD Fee Owner Airline Designator
		[ 'key'=>'XBOA',                 'type'=>'StringTrim',                   'len'=>1,      'label'=>'EMD Excess Baggage Over Allowance Qualifier', ],   // X/C/EMD Excess Baggage Over Allowance Qualifier
		[ 'key'=>'XBCT',                 'type'=>'StringRaw',                    'len'=>3,      'label'=>'EMD Excess Baggage Currency code', ],
		[ 'key'=>'XBRU',                 'type'=>'StringTrim',                   'len'=>12,     'label'=>'EMD Excess Baggage Rate per Unit', ],              // X/C/EMD Excess Baggage Rate per Unit
		[ 'key'=>'XBNE',                 'type'=>'StringTrim',                   'len'=>12,     'label'=>'EMD Excess Baggage Total Number in Excess', ],     // X/C/EMD Excess Baggage Total Number in Excess
		[ 'key'=>'EMCI',                 'type'=>'StringTrim',                   'len'=>1,      'label'=>'EMD Consumed at Issuance Indicator', ],            // X/M/EMD Consumed at Issuance Indicator

		[ 'key'=>'EMNS',                 'type'=>'Integer',                      'len'=>3,      'label'=>'EMD Number of services', ],
		[ 'key'=>'EMCR',                 'type'=>'StringTrim',                   'len'=>3,      'label'=>'EMD operating carrier', ],
		[ 'key'=>'EMAG',                 'type'=>'StringRaw',                    'len'=>3,      'label'=>'EMD attribute group', ],
		[ 'key'=>'EMSG',                 'type'=>'StringRaw',                    'len'=>3,      'label'=>'EMD attribute sub-group', ],
		[ 'key'=>'EMIC',                 'type'=>'StringRaw',                    'len'=>1,      'label'=>'EMD industry carrier indicator', ],

		[ 'key'=>'RESD',                 'type'=>'StringTrim',                   'len'=>16,     'label'=>'Reserved Space', ],                                //  /M/Reserved Space
		[ 'key'=>'CUTP',                 'type'=>'StringRaw',                    'len'=>3,      'label'=>'Currency Type', ],
		[ 'key'=>'CUTP_decimals',        'type'=>'Integer',                      'len'=>1,      'label'=>'Currency Type(decimals)', ],
	];

	protected function postExtract(\App\Utils\BaseParser\TextParser\ExtractedBlock $ret)
	{
		$ret = $this->postProcessPriceAmount($ret, $this->children, $ret->extractedData['CUTP_decimals']);

		return $ret;
	}
}
