<?php

namespace App\Service\DsrMiceService;
use App\Models\DsrSupplierSummary;
use App\Models\MiceSupplierSummary;
use Log;
use Auth;

class SupplierSummary
{
    // For Dsr
    public function dsrSupplierSummaryCreate($request,$transaction,$service_name){
        
        $obj['dsr_id'] = $request['dsr_id']??0;
        $obj['transaction_id'] = $transaction['id']??0;      // Single Service id
        $obj['service_name'] =$service_name;                //hotel , flight , visa ,etc
        $obj['supplier_id'] = $request['supplier_id'];
        $obj['supplier_name'] = $request['supplier_name'];
        $obj['gross_amount'] = $request['gross_amount'];
        $obj['charges'] = $request['charges'];
        $obj['supplier_amount'] = $request['supplier_amount']??0;
        $obj['tax_amount'] = $request['supplier_tax']??0;
        $obj['tax_percent'] = $request['tax_percent']??0.0;
        $obj['total'] = $request['supplier_total']??0.0;
        $obj['service_data'] = json_encode($transaction);

        $dsr_summary = DsrSupplierSummary::create($obj);

        return true;
    }

    public function miceSupplierSummaryCreate($request,$transaction,$service_name){
        
        $obj['mice_id'] = $request['mice_id']??0;
        $obj['transaction_id'] = $transaction['id']??0;
        $obj['service_name'] =$service_name;
        $obj['supplier_id'] = $request['supplier_id'];
        $obj['supplier_name'] = $request['supplier_name'];
        $obj['gross_amount'] = $request['gross_amount'];
        $obj['charges'] = $request['charges'];
        $obj['supplier_amount'] = $request['supplier_amount']??0;
        $obj['tax_amount'] = $request['supplier_tax']??0;
        $obj['tax_percent'] = $request['tax_percent']??0.0;
        $obj['total'] = $request['supplier_total']??0.0;
        $obj['service_data'] = json_encode($transaction);

        $mice_summary = MiceSupplierSummary::create($obj);

        return true;
    }
}