新增报销模块

This commit is contained in:
yaooo 2023-12-19 11:31:47 +08:00
parent a92eeca5d9
commit d706fafaaa

View File

@ -16,6 +16,8 @@ namespace app\adminapi\logic\expense;
use app\common\model\expense\ExpenseReimbursement;
use app\common\model\expense\ExpenseReimbursementDetailLogic;
use app\common\model\expense\ExpenseReimbursementInvoiceDetailLogic;
use app\common\logic\BaseLogic;
use think\facade\Db;
@ -40,23 +42,49 @@ class ExpenseReimbursementLogic extends BaseLogic
{
Db::startTrans();
try {
ExpenseReimbursement::create([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'approve_id' => $params['approve_id'],
'reimburser' => $params['reimburser'],
'reimbursement_date' => $params['reimbursement_date'],
'customer_id' => $params['customer_id'],
'pay_type' => $params['pay_type'],
'reimbursement_amount' => $params['reimbursement_amount'],
'reimbursement_amount_daxie' => $params['reimbursement_amount_daxie'],
'payee_name' => $params['payee_name'],
'payee_bank' => $params['payee_bank'],
'payee_account' => $params['payee_account'],
'remark' => $params['remark'],
$expenseReimbursement = ExpenseReimbursement::create([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'approve_id' => $params['approve_id'],
'reimburser' => $params['reimburser'],
'reimbursement_date' => $params['reimbursement_date'],
'customer_id' => $params['customer_id'],
'pay_type' => $params['pay_type'],
'reimbursement_amount' => $params['reimbursement_amount'],
'reimbursement_amount_daxie' => $params['reimbursement_amount_daxie'],
'payee_name' => $params['payee_name'],
'payee_bank' => $params['payee_bank'],
'payee_account' => $params['payee_account'],
'remark' => $params['remark'],
'annex' => $params['annex'],
]);
foreach ($params['detail'] ?? [] as $item)
{
ExpenseReimbursementDetailLogic::create([
'expense_id' => $expenseReimbursement->id,
'cost_subject_id' => $item['cost_subject_id'] ?? 0,
'use_to' => $item['use_to'] ?? '',
'amount' => $item['amount'] ?? 0,
'remark' => $item['remark'] ?? ''
]);
}
foreach ($params['invoice'] ?? [] as $item)
{
ExpenseReimbursementInvoiceDetailLogic::create([
'expense_id' => $expenseReimbursement->id,
'invoice_type' => $item['invoice_type'] ?? 0,
'invoice_sn' => $item['invoice_sn'] ?? '',
'tax_rate' => $item['tax_rate'] ?? 0,
'invoice_form' => $item['invoice_form'] ?? 0,
'amount' => $item['amount'] ?? 0,
'tax' => $item['tax'] ?? 0,
'annex' => $item['annex'] ?? '',
'remark' => $item['remark'] ?? ''
]);
}
Db::commit();
return true;
} catch (\Exception $e) {
@ -79,21 +107,48 @@ class ExpenseReimbursementLogic extends BaseLogic
Db::startTrans();
try {
ExpenseReimbursement::where('id', $params['id'])->update([
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'approve_id' => $params['approve_id'],
'reimburser' => $params['reimburser'],
'reimbursement_date' => $params['reimbursement_date'],
'customer_id' => $params['customer_id'],
'pay_type' => $params['pay_type'],
'reimbursement_amount' => $params['reimbursement_amount'],
'reimbursement_amount_daxie' => $params['reimbursement_amount_daxie'],
'payee_name' => $params['payee_name'],
'payee_bank' => $params['payee_bank'],
'payee_account' => $params['payee_account'],
'remark' => $params['remark'],
'org_id' => $params['org_id'],
'dept_id' => $params['dept_id'],
'approve_id' => $params['approve_id'],
'reimburser' => $params['reimburser'],
'reimbursement_date' => $params['reimbursement_date'],
'customer_id' => $params['customer_id'],
'pay_type' => $params['pay_type'],
'reimbursement_amount' => $params['reimbursement_amount'],
'reimbursement_amount_daxie' => $params['reimbursement_amount_daxie'],
'payee_name' => $params['payee_name'],
'payee_bank' => $params['payee_bank'],
'payee_account' => $params['payee_account'],
'remark' => $params['remark'],
'annex' => $params['annex'],
]);
ExpenseReimbursementDetailLogic::where('expense_id', $params['id'])->update(['delete_time' => time()]);
ExpenseReimbursementInvoiceDetailLogic::where('expense_id', $params['id'])->update(['delete_time' => time()]);
foreach ($params['detail'] ?? [] as $item)
{
ExpenseReimbursementDetailLogic::where('expense_id', $params['id'])->update([
'expense_id' => $expenseReimbursement->id,
'cost_subject_id' => $item['cost_subject_id'] ?? 0,
'use_to' => $item['use_to'] ?? '',
'amount' => $item['amount'] ?? 0,
'remark' => $item['remark'] ?? ''
]);
}
foreach ($params['invoice'] ?? [] as $item)
{
ExpenseReimbursementInvoiceDetailLogic::where('expense_id', $params['id'])->update([
'expense_id' => $expenseReimbursement->id,
'invoice_type' => $item['invoice_type'] ?? 0,
'invoice_sn' => $item['invoice_sn'] ?? '',
'tax_rate' => $item['tax_rate'] ?? 0,
'invoice_form' => $item['invoice_form'] ?? 0,
'amount' => $item['amount'] ?? 0,
'tax' => $item['tax'] ?? 0,
'annex' => $item['annex'] ?? '',
'remark' => $item['remark'] ?? ''
]);
}
Db::commit();
return true;