update
This commit is contained in:
parent
9baaacfeb8
commit
50fcf30ac3
@ -20,6 +20,9 @@
|
|||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\auth\Admin;
|
use app\common\model\auth\Admin;
|
||||||
use app\common\model\dept\Dept;
|
use app\common\model\dept\Dept;
|
||||||
|
use app\common\model\financial\FinancialInvoice;
|
||||||
|
use app\common\model\financial\FinancialRefund;
|
||||||
|
use app\common\model\financial\FinancialSettlement;
|
||||||
use app\common\model\marketing\MarketingContract;
|
use app\common\model\marketing\MarketingContract;
|
||||||
use app\common\model\marketing\MarketingCustom;
|
use app\common\model\marketing\MarketingCustom;
|
||||||
|
|
||||||
@ -79,6 +82,34 @@
|
|||||||
$data['industry_nature_text'] = $data->industry_nature_text;
|
$data['industry_nature_text'] = $data->industry_nature_text;
|
||||||
$data['fund_sources_text'] = $data->fund_sources_text;
|
$data['fund_sources_text'] = $data->fund_sources_text;
|
||||||
$data['const_area_text'] = $data->const_area_text;
|
$data['const_area_text'] = $data->const_area_text;
|
||||||
|
$invoice_ids = FinancialInvoice::where('contract_id', $data['id'])->column('id');
|
||||||
|
//开票金额
|
||||||
|
$data['total_invoice_amount'] = FinancialInvoice::where('contract_id', $data['id'])->sum('apply_amount');
|
||||||
|
//未开票金额
|
||||||
|
$data['not_total_invoice_amount'] = bcsub($data['money'], $data['total_invoice_amount'], 2);
|
||||||
|
//到账金额
|
||||||
|
$data['total_refund_amount'] = FinancialRefund::where('contract_id', $data['id'])->sum('amount');
|
||||||
|
//未到账金额
|
||||||
|
$data['not_total_refund_amount'] = bcsub($data['money'], $data['total_refund_amount'], 2);
|
||||||
|
//开票未回款金额
|
||||||
|
$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['refund_not_invoice_amount'] = bcsub($data['total_refund_amount'], $invoice_has_refund_amount, 2);
|
||||||
|
//结算金额
|
||||||
|
$data['total_settlement_amount'] = FinancialSettlement::where('contract_id', $data['id'])->sum('amount');
|
||||||
|
$financial_settlement = FinancialSettlement::where('contract_id', $data['id'])->order('id desc')->findOrEmpty();
|
||||||
|
if ($financial_settlement->isEmpty()) {
|
||||||
|
$data['is_settlement'] = 0;
|
||||||
|
$data['settlement_date'] = '';
|
||||||
|
} else {
|
||||||
|
if ($data['total_settlement_amount'] >= $data['money']) {
|
||||||
|
$data['is_settlement'] = 2;
|
||||||
|
} else {
|
||||||
|
$data['is_settlement'] = 1;
|
||||||
|
}
|
||||||
|
$data['settlement_date'] = $financial_settlement['date'];
|
||||||
|
}
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user