SELECT
	id,
	supplier_id + 1 as supplier_id,
	supplier_id + 1 as supplier_group_id,
	cutoff_date,
	paying_date as payment_date,
	payment_id as payment_type_code,
	IF(supplier_id=1,2,1) as currency_type_code,
	payable_total_price as total_price,
	payable_total_tax as total_duty,
	payable_total_amount as total_payment,
	0 as total_carry,
	previous_charge_amount as pre_total,
	previous_charge_amount + payable_total_price + payable_total_tax - payable_total_amount as total,
	NULL as trade_sheet_cnt,
	print_sheet as print_ledger_date,
	NOW() as created_at,
	NOW() as updated_at
FROM payables
INTO OUTFILE "/tmp/payables.csv" FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"';