SELECT
	id,
	dealer_id as customer_id,
	dealer_group_id as customer_group_id,
	cutoff_date,
	receiving_date as payment_date,
	payment_id as payment_type_code,
	encachement_date as encachement_date,
	receivable_total_price as total_price,
	receivable_total_tax as total_duty,
	receivable_total_amount as total_payment,
	receivable_total_carry as total_carry,
	previous_charge_amount as pre_total,
	previous_charge_amount + receivable_total_price + receivable_total_tax + receivable_total_carry - receivable_total_amount as total,
	NULL as trade_sheet_cnt,
	print_sheet as print_sheet_date,
	ledger_sheet as print_ledger_date,
	NOW() as created_at,
	NOW() as updated_at
FROM receivables
INTO OUTFILE "/tmp/receivables.csv" FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"';