SELECT
	id,
	1 as rev_number,
	input_date,
	paying_date as target_date,
	35 as user_id,
	19 as section_id,
	supplier_id + 1 as supplier_id,
	supplier_id + 1 as supplier_group_id,
	paying_date as cutoff_date,
	credit_timing_id as credit_timing_code,
	cutoff_date as cutoff_date_code,
	IF(supplier_id=1,2,1) as currency_type_code,
	total_amount,
	close_flag_id as state_code,
	paying_note as note,
	0 as invalid_flag_code,
	NULL as deleted_at,
	NOW() as created_at,
	NOW() as updated_at
FROM payings
INTO OUTFILE "/tmp/payings.csv" FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"';