stock batch change 记录

流程为操作(issue, transfer,)过后
1.判断stock快照是否变动 – is_voucehr_stock_batch_changed
     (1.     stock为created 直接查询voucher表 stock为created voucher的总数, 对比快照中的数额是否变动
     (2.     stock为inuse 查询create_request表 查询总共被创建的voucher的总数, 对比快照中数额是否变动(每次都不等)
     (3.     for other stocks, we will need to check the exact vouchers as there will be vouchers in and out.
                total vouchers maybe the same but the vouchers may changed.   
                关联stock_id, class_id 查询voucher表得出总数 对比是否变动
     (1.     Stock为created 执行_update_voucher_stock_batch_created_vouchers($stock, $voucher_class_category)
                (1). we can get all the created batch, and then merge them together to one batch.
                (2). 创建新的batch_id,循环得出段创建新的batch_no_section记录
                (3). 更新新创建的batch_no_sectino记录 total_vouchers和total_value
                (4). _update_batch_id_by_stock_class 将stock和class_id对应的记录的batch_id全部改成新的batch_id,如果没有记录,插入新记录.
     (2.     Stock为inuse    执行_update_voucher_stock_batch_inuse_vouchers($stock, $voucher_class_category)
       (3.     Stock为其他     执行_update_voucher_stock_batch_vouchers( $stock_id, $voucher_class_category );
                 * for normal stocks, like: finance / cd / csa / cse / expired etc. we will have to get all vouchers and range them one by one.
                 * //tenant vouchers will be different from csm vouchers, as the tenant voucher will have an extra field like 'expiry_date';
                 * @param integer $stock_id
                 * @param string $voucher_class_category
3.如果没有变动直接执行get_batch_id_by_stock_class($stock_id, $voucher_class_category); 从快照里直接拿数据
voucher_stocl_batch.php, function : update_voucher_stock_batch();