业务订单中已退款的收款记录也可移除关联
- 移除收款关联放开「已退款」(status 4):只解除关联、保留原收款记录;已退款记录本不计入已付金额,移除后已付金额与需代收不变,日志注明「已退款」 - 已支付/待审核规则不变;已完成/已取消订单仍不可移除 - 重新构建管理后台 Co-Authored-By: Claude Opus 5 <[EMAIL]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
9dde9a34b5
commit
4ae38b45ed
@@ -187,12 +187,21 @@ try {
|
||||
$before = $snapshot($id);
|
||||
$expect($remove($id, $payIds[0]) === false && $snapshot($id) === $before, 'Completed/cancelled orders must retain amount and paid snapshot');
|
||||
}
|
||||
foreach ([['amount' => '100.00', 'status' => 4], ['amount' => '100.00', 'status' => 1],
|
||||
foreach ([['amount' => '100.00', 'status' => 1],
|
||||
['amount' => '100.00', 'delete_time' => time()], ['amount' => '-1.00']] as $payment) {
|
||||
[$id, $payIds] = $fixture('100.00', [$payment]);
|
||||
$before = $snapshot($id);
|
||||
$expect($remove($id, $payIds[0]) === false && $snapshot($id) === $before, 'Refunded/deleted/unpaid/invalid amount must not be removed');
|
||||
$expect($remove($id, $payIds[0]) === false && $snapshot($id) === $before, 'Deleted/unpaid/invalid amount must not be removed');
|
||||
}
|
||||
// 已退款收款记录可移除:只解除关联,已付金额与需代收不变(退款记录本就不计入已付)。
|
||||
[$id, $payIds] = $fixture('1000.00', [['amount' => '200.00', 'status' => 4], ['amount' => '300.00']],
|
||||
['paid' => '300.00', 'refund_amount' => '200.00']);
|
||||
$out = $remove($id, $payIds[0]);
|
||||
$amounts($out, 1000.0, 300.0, 700.0, false);
|
||||
$expect((float) $out['paid'] === 300.0 && count($snapshot($id)[1]) === 1
|
||||
&& str_contains((string) Db::name('tcm_prescription_order_log')->where('prescription_order_id', $id)
|
||||
->order('id', 'desc')->value('summary'), '已退款'),
|
||||
'Removing a refunded receipt keeps paid and collection unchanged and logs it as refunded');
|
||||
[$id, $payIds] = $fixture('100.00', [['amount' => '100.00']], ['delete_time' => time()]);
|
||||
$before = $snapshot($id);
|
||||
$expect($remove($id, $payIds[0]) === false && $snapshot($id) === $before, 'Deleted order must not be changed');
|
||||
|
||||
Reference in New Issue
Block a user