##ledgerにgroupと締め日とcreated_at, updated_atを追加
#cutoff_dateがNULLの所を埋める
update customer_ledgers as a 
    left join master_app_production.customers as b on a.customer_id=b.id 
    left join master_app_production.customer_groups as c on b.charge_customer_group_id=c.id 
      set 
        a.cutoff_date_code=c.cutoff_date_code
      where a.cutoff_date_code is NULL;
      
#時間とcustomer_group_idを埋める      
update customer_ledgers as a 
    left join master_app_production.customers as b on a.customer_id=b.id 
      set 
        a.customer_group_id=b.charge_customer_group_id, 
        a.created_at = '2011-03-01',
        a.updated_at = '2011-03-01'
      where a.customer_group_id = 0;

update supplier_ledgers as a
    left join master_app_production.suppliers as b on a.supplier_id=b.id 
    left join master_app_production.supplier_groups as c on b.payto_supplier_group_id=c.id 
      set 
        a.cutoff_date_code=c.cutoff_date_code,
        a.created_at = '2011-03-01',
        a.updated_at = '2011-03-01'
      where a.cutoff_date_code is NULL;

