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

/**
 * Line parser
 * @author Lucian Sirbu
 */
class BKS31 extends \App\Bsp\Hot230\HOTBase
{
	protected $children = [
		[ 'key'=>'SMSG',  'type'=>'Constant', 'val'=>'BKS',       'len'=>3,      'label'=>'Standard Message Identifier', ],    // S/M/Standard Message Identifier
		[ 'key'=>'SQNR',  'type'=>'Integer',                      'len'=>8,      'label'=>'Sequence Number', ],                // S/M/Sequence Number
		[ 'key'=>'STNQ',  'type'=>'Constant', 'val'=>'31',        'len'=>2,      'label'=>'Standard Numeric Qualifier', ],     // S/M/Standard Numeric Qualifier
		[ 'key'=>'DAIS',  'type'=>'Date',     'fmt'=>'YYMMDD',    'len'=>6,      'label'=>'Date of Issue', ],                  // S/M/Date of Issue
		[ 'key'=>'TRNN',  'type'=>'Integer',                      'len'=>6,      'label'=>'Transaction Number', ],             // S/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', ],

		// first coupon tax code
		[ 'key'=>'SEGI1', 'type'=>'Digits',                       'len'=>1,      'label'=>'Segment identifier', ],
		[ 'key'=>'CTAC1', 'type'=>'StringRaw',                    'len'=>5,      'label'=>'Coupon tax airport code', ],
		[ 'key'=>'STAC1', 'type'=>'StringRaw',                    'len'=>6,      'label'=>'Segment tax airport code', ],
		[ 'key'=>'CTCD1', 'type'=>'StringRaw',                    'len'=>2,      'label'=>'Coupon tax code', ],
		[ 'key'=>'CTTP1', 'type'=>'StringRaw',                    'len'=>3,      'label'=>'Coupon tax code', ],
		[ 'key'=>'CTRA1', 'type'=>'PriceAmount',                  'len'=>11,     'label'=>'Coupon tax code', ],
		[ 'key'=>'CUTX1', 'type'=>'StringRaw',                    'len'=>4,      'label'=>'Coupon tax currency type', ],
		[ 'key'=>'CTAA1', 'type'=>'PriceAmount',                  'len'=>11,     'label'=>'Coupon tax applicable amount', ],

		// second coupon tax code
		[ 'key'=>'SEGI2', 'type'=>'Digits',                       'len'=>1, 'allowSpaces'=>true,   'label'=>'Segment identifier', ],
		[ 'key'=>'CTAC2', 'type'=>'StringRaw',                    'len'=>5,      'label'=>'Coupon tax airport code', ],
		[ 'key'=>'STAC2', 'type'=>'StringRaw',                    'len'=>6,      'label'=>'Segment tax airport code', ],
		[ 'key'=>'CTCD1', 'type'=>'StringRaw',                    'len'=>2,      'label'=>'Coupon tax code', ],
		[ 'key'=>'CTTP1', 'type'=>'StringRaw',                    'len'=>3,      'label'=>'Coupon tax code', ],
		[ 'key'=>'CTRA2', 'type'=>'PriceAmount',                  'len'=>11, 'allowSpaces'=>true,   'label'=>'Coupon tax code', ],
		[ 'key'=>'CUTX2', 'type'=>'StringRaw',                    'len'=>4,      'label'=>'Coupon tax currency type', ],
		[ 'key'=>'CTAA2', 'type'=>'PriceAmount',                  'len'=>11, 'allowSpaces'=>true,   'label'=>'Coupon tax applicable amount', ],

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

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

		return $ret;
	}
}
