diff --git a/app/adminapi/lists/quotation/QuotationLists.php b/app/adminapi/lists/quotation/QuotationLists.php index 74dca9fea..2fc949fb5 100644 --- a/app/adminapi/lists/quotation/QuotationLists.php +++ b/app/adminapi/lists/quotation/QuotationLists.php @@ -19,6 +19,7 @@ use app\adminapi\lists\BaseAdminDataLists; use app\common\model\custom\Custom; use app\common\model\quotation\Quotation; use app\common\lists\ListsSearchInterface; +use app\common\model\quotation\QuotationDetail; /** * 报价单列表 @@ -61,7 +62,7 @@ class QuotationLists extends BaseAdminDataLists implements ListsSearchInterface $custom_ids = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id'); $where[] = ['custom_id','in',$custom_ids]; } - return Quotation::field('id,custom_id,code,quotation_date,create_user,invoice_type,amount_including_tax,freight,other_fee,total_amount,customer_require,remark') + return Quotation::field('id,custom_id,code,quotation_date,create_user,invoice_type,freight,other_fee,customer_require,remark') ->where($this->searchWhere)->where($where)->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ @@ -70,6 +71,8 @@ class QuotationLists extends BaseAdminDataLists implements ListsSearchInterface $item['custom_master_name'] = $custom['master_name']; $item['custom_master_phone'] = $custom['master_phone']; $item['invoice_type_text'] = $item->invoice_type_text; + $item['amount_including_tax'] = QuotationDetail::where('quotation_id',$item['id'])->sum('tax_inclusive_amount'); + $item['total_amount'] = $item['amount_including_tax'] + $item['freight'] + $item['other_fee']; return $item; }) ->toArray(); diff --git a/app/adminapi/logic/quotation/QuotationLogic.php b/app/adminapi/logic/quotation/QuotationLogic.php index 262f280fb..92947ace8 100644 --- a/app/adminapi/logic/quotation/QuotationLogic.php +++ b/app/adminapi/logic/quotation/QuotationLogic.php @@ -61,10 +61,8 @@ class QuotationLogic extends BaseLogic 'quotation_date' => !empty($params['quotation_date']) ? strtotime($params['quotation_date']) : 0, 'create_user' => $params['create_user'] ?? '', 'invoice_type' => $params['invoice_type'] ?? 0, - 'amount_including_tax' => $amount_including_tax, 'freight' => $params['freight'], 'other_fee' => $params['other_fee'], - 'total_amount' => $amount_including_tax + $params['freight'] + $params['other_fee'], 'customer_require' => $params['customer_require'] ?? '', 'remark' => $params['remark'] ?? '', 'annex' => $params['annex']? json_encode($params['annex']) : null, @@ -100,7 +98,7 @@ class QuotationLogic extends BaseLogic */ public static function detail($params): array { - $data = Quotation::field('id,org_id,dept_id,custom_id,quotation_date,create_user,invoice_type,amount_including_tax,freight,other_fee,total_amount,customer_require,remark,annex')->findOrEmpty($params['id']); + $data = Quotation::field('id,org_id,dept_id,custom_id,quotation_date,create_user,invoice_type,freight,other_fee,customer_require,remark,annex')->findOrEmpty($params['id']); $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); $custom = Custom::field('name,master_name,master_phone')->where('id',$data['custom_id'])->findOrEmpty(); @@ -110,6 +108,8 @@ class QuotationLogic extends BaseLogic $data['custom_master_name'] = $custom['master_name']; $data['custom_master_phone'] = $custom['master_phone']; $data['invoice_type_text'] = $data->invoice_type_text; + $data['amount_including_tax'] = QuotationDetail::where('quotation_id',$data['id'])->sum('tax_inclusive_amount'); + $data['total_amount'] = $data['amount_including_tax'] + $data['freight'] + $data['other_fee']; return $data->toArray(); } } \ No newline at end of file diff --git a/app/adminapi/validate/quotation/QuotationValidate.php b/app/adminapi/validate/quotation/QuotationValidate.php index 3ae83508c..11061c911 100644 --- a/app/adminapi/validate/quotation/QuotationValidate.php +++ b/app/adminapi/validate/quotation/QuotationValidate.php @@ -188,15 +188,6 @@ class QuotationValidate extends BaseValidate return true; } - public function checkTotalAmount($value,$rule,$data): bool|string - { - $total = $data['amount_including_tax'] + $data['freight'] + $data['other_fee']; - if($value != $total){ - return '合计金额不正确'; - } - return true; - } - public function checkAnnex($value): bool|string { if(!empty($value) && $value != ''){