This commit is contained in:
weiz 2024-05-15 10:29:42 +08:00
parent 27a62f3c6f
commit feaf5eb957
2 changed files with 17 additions and 8 deletions

View File

@ -90,13 +90,17 @@
$data['total_refund_amount'] = FinancialRefund::where('contract_id', $data['id'])->sum('amount');
//未到账金额
$data['not_total_refund_amount'] = bcsub($data['signed_amount'], $data['total_refund_amount'], 2);
//开票已回款金额
$data['invoice_has_refund_amount'] = FinancialRefund::where('contract_id', $data['id'])->where('invoice_id', 'in', $invoice_ids)->sum('amount');
//开票未回款金额
$invoice_has_refund_amount = FinancialRefund::where('contract_id', $data['id'])->where('invoice_id', 'in', $invoice_ids)->sum('amount');
$data['invoice_not_refund_amount'] = bcsub($data['total_invoice_amount'], $invoice_has_refund_amount, 2);
$data['invoice_not_refund_amount'] = bcsub($data['total_invoice_amount'], $data['invoice_has_refund_amount'], 2);
//回款未开票金额
$data['refund_not_invoice_amount'] = bcsub($data['total_refund_amount'], $invoice_has_refund_amount, 2);
$data['refund_not_invoice_amount'] = bcsub($data['total_refund_amount'], $data['invoice_has_refund_amount'], 2);
//结算金额
$data['total_settlement_amount'] = FinancialSettlement::where('contract_id', $data['id'])->sum('amount');
//到账日期
$last_refund = FinancialRefund::where('contract_id', $data['id'])->order('id desc')->findOrEmpty();
$data['refund_date'] = $last_refund['create_time'] ?? '';
$financial_settlement = FinancialSettlement::where('contract_id', $data['id'])->order('id desc')->findOrEmpty();
if ($financial_settlement->isEmpty()) {
$data['is_settlement'] = 0; //未结算

View File

@ -77,12 +77,17 @@
$data['sign_time'] = $contract['create_time'];
$data['invoice_type_text'] = $data->invoice_type_text;
$data['refund_amount'] = FinancialRefund::where('invoice_id', $data['id'])->sum('amount') ?? 0.00;
if ($data['refund_amount'] <= 0) {
$data['is_refund'] = '未到账';
} elseif ($data['refund_amount'] < $data['apply_amount']) {
$data['is_refund'] = '部分到账';
$rate = bcdiv($data['refund_amount'], $data['apply_amount'], 2);
if (($rate * 100) <= 0) {
$data['is_refund'] = '未到账(设定0%)';
} elseif (($rate * 100) <= 30) {
$data['is_refund'] = '一般到账(设定30%以下)';
} elseif (($rate * 100) <= 60) {
$data['is_refund'] = '部分到账(设定60%以下)';
} elseif (($rate * 100) < 100) {
$data['is_refund'] = '大额到账(设定100%以下)';
} else {
$data['is_refund'] = '已到账';
$data['is_refund'] = '已到账(设定100%)';
}
$last_refund = FinancialRefund::where('invoice_id', $data['id'])->order('id desc')->findOrEmpty();
$data['refund_date'] = $last_refund['create_time'] ?? '';