/
home
/
sjslayjy
/
public_html
/
mosaram
/
app
/
Http
/
Controllers
/
Upload File
HOME
<?php namespace App\Http\Controllers; use Mail; use Illuminate\Http\Request; use DatePeriod; use DateInterval; use DateTime; use DB; use Session; use Illuminate\Support\Facades\Response; use SimpleXMLElement; use App\Models\TallyData; class TestController extends Controller { public function upload() { echo '<h1>:) </h1><h3>stop stop, first check excel columns and tabel columns, if all right then comment dd and enjoy the data uploading through Comma Seperated Values...</h3>'; dd('thankyou :)'); dd('thankyou :)'); dd('thankyou :)'); $row = 1; if (($handle = fopen("testfile.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); // if($row > 1){ //print_r($data); //DB::table("engineer_spare_parts")->where('engineer_id', $data[1])->where('id', $data[0])->update(array("warehouse"=>$data[2])); $last_id = DB::table('secondary_discount_party_ledgers')->insertGetId(array( 'product_company_id' => $data['1'], 'transaction_date' => $data['2'], 'retailer_id' => $data['3'], 'dealer_id' => $data['4'], 'particular' => $data['5'], 'type' => $data['6'], 'credit' => $data['7'], 'debit' => $data['8'], 'balance' => $data['9'], //'mode' => $data['10'], 'against' => $data['11'] )); //dd('uploaded...'); // DB::table('secondary_discount_party_ledgers')->insert( // array( // 'product_company_id' => $data['1'], // 'transaction_date' => $data['2'], // 'retailer_id' => $data['3'], // 'dealer_id' => $data['4'], // 'particular' => $data['5'], // 'type' => $data['6'], // 'credit' => $data['7'], // 'debit' => $data['8'], // 'balance' => $data['9'], // 'mode' => $data['10'], // 'against' => $data['11'] // ) // ); //dd($last_id); // } $row++; } echo 'uploaded...'; } } public function send_mail() { Mail::send('emails.test', ['email' => 'bipinyadav18390@gmail.com'], function ($message) { $message->from('logimetrix@gmail.com', 'web title'); $message->subject("Testing Email Logimetrix"); $message->to('bipinyadav18390@gmail.com'); }); } public function unzip() { $path = base_path('zip/vendor1.zip'); // echo $path; // exit; $zip = zip_open($path); if ($zip) { while ($zip_entry = zip_read($zip)) { $fp = fopen($path, "w"); if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp, "$buf"); zip_entry_close($zip_entry); fclose($fp); } } zip_close($zip); } } public function get_stock_value() { $stocks = \DB::table('inventories')->select(\DB::raw("sum(inventories.quantity) as stock_qty"), 'inventories.*', 'products.name as product_name', 'product_categories.category as product_category', 'products.id as product_id') ->join('products', 'products.id', 'inventories.product_id') ->join('product_categories', 'product_categories.id', 'products.product_category_id') ->whereIn('dealer_id', [1, 30, 31])->whereIN('products.product_category_id', [1, 2])->groupBy('inventories.product_id')->get(); $n = 0; $data = []; foreach ($stocks as $stock) { $data[$n]['product_name'] = $stock->product_name; $data[$n]['product_category'] = $stock->product_category; $data[$n]['stock_qty'] = $stock->stock_qty; $data[$n]['product_id'] = $stock->product_id; $period = new DatePeriod( new DateTime('2019-09-01'), new DateInterval('P1D'), new DateTime(date('Y-m-d', strtotime("tomorrow"))) ); $date_range = []; $m = 0; foreach ($period as $key => $value) { $date_range[$m] = $value->format('Y-m-d'); $m++; } $periods = array_reverse($date_range); $value = 0; $required = $stock->stock_qty; foreach ($periods as $date) { $warehouse_dis = \DB::table('warehouse_dis')->where('product_id', $stock->product_id)->whereIn('dealer_id', [1, 30, 31])->whereDate('created_at', $date)->get(); foreach ($warehouse_dis as $warehouse) { if ($required >= $warehouse->quantity && $required != 0) { $value = $value + ($warehouse->quantity * $warehouse->rate); $required = $required - $warehouse->quantity; } if ($required < $warehouse->quantity && $required != 0) { $value = $value + ($required * $warehouse->rate); $required = 0; } if ($required == 0) { break; } } $company_dis = \DB::table('company_dis')->where('product_id', $stock->product_id)->whereIn('dealer_id', [1, 30, 31])->whereDate('created_at', $date)->get(); foreach ($company_dis as $warehouse) { if ($required >= $warehouse->quantity && $required != 0) { $value = $value + ($warehouse->quantity * $warehouse->rate); $required = $required - $warehouse->quantity; } if ($required < $warehouse->quantity && $required != 0) { $value = $value + ($required * $warehouse->rate); $required = 0; } if ($required == 0) { break; } } if ($required == 0) { break; } } $data[$n]['value_of_stock'] = $value; $n++; } return view('dashboard.report.get-stock-value', ['data' => $data]); } public function get_company_wise_stock_value($product_id) { // echo $product_id; // exit(); $stocks = \DB::table('inventories')->select(\DB::raw("sum(inventories.quantity) as stock_qty"), 'inventories.*', 'products.name as product_name', 'product_categories.category as product_category') ->join('products', 'products.id', 'inventories.product_id', 'inventories.product_brand_id ') ->join('product_categories', 'product_categories.id', 'products.product_category_id') ->whereIn('dealer_id', [1, 30, 31])->whereIN('products.product_category_id', [1, 2])->where('inventories.product_id', $product_id)->groupBy('inventories.product_brand_id')->get(); // dd($stocks); $n = 0; $data = []; foreach ($stocks as $stock) { $data[$n]['product_name'] = $stock->product_name; $data[$n]['product_category'] = $stock->product_category; $data[$n]['stock_qty'] = $stock->stock_qty; $data[$n]['company_name'] = getModelById('ProductCompany', $stock->product_brand_id)->name; $period = new DatePeriod( new DateTime('2019-09-01'), new DateInterval('P1D'), new DateTime(date('Y-m-d', strtotime("tomorrow"))) ); $date_range = []; $m = 0; foreach ($period as $key => $value) { $date_range[$m] = $value->format('Y-m-d'); $m++; } $periods = array_reverse($date_range); $value = 0; $required = $stock->stock_qty; foreach ($periods as $date) { $warehouse_dis = \DB::table('warehouse_dis')->where('product_id', $stock->product_id)->whereIn('dealer_id', [1, 30, 31])->whereDate('created_at', $date)->get(); foreach ($warehouse_dis as $warehouse) { if ($required >= $warehouse->quantity && $required != 0) { $value = $value + ($warehouse->quantity * $warehouse->rate); $required = $required - $warehouse->quantity; } if ($required < $warehouse->quantity && $required != 0) { $value = $value + ($required * $warehouse->rate); $required = 0; } if ($required == 0) { break; } } $company_dis = \DB::table('company_dis')->where('product_id', $stock->product_id)->whereIn('dealer_id', [1, 30, 31])->whereDate('created_at', $date)->get(); foreach ($company_dis as $warehouse) { if ($required >= $warehouse->quantity && $required != 0) { $value = $value + ($warehouse->quantity * $warehouse->rate); $required = $required - $warehouse->quantity; } if ($required < $warehouse->quantity && $required != 0) { $value = $value + ($required * $warehouse->rate); $required = 0; } if ($required == 0) { break; } } if ($required == 0) { break; } } $data[$n]['value_of_stock'] = $value; $n++; } // dd($data); return view('dashboard.report.get-company-wise-stock-value', ['data' => $data]); } public function trackUsers(Request $request) { } public function companyInvoicePaymentUpdate(Request $request) { $bank_statement = \App\BankStatement::whereNotNull('transfer_type')->whereNotNull('history')->get(); // dd($bank_statement); foreach ($bank_statement as $key => $value) { // dd($value->history); $bank_history = json_decode($value->history, true); // dd($bank_history); foreach ($bank_history as $k => $v) { // dd($v['amount']); $companyInvoicePaymentUpdate = \App\CompanyInvoicePayment::where(['invoice_id' => $v['invoice_id'], 'payment_id' => $value->id])->first(); $companyInvoicePaymentUpdate->payment_amount = $v['amount']; $companyInvoicePaymentUpdate->save(); // dd($companyInvoicePaymentUpdate); } } echo 'Successful'; // dd($bank_statement); } public function dealerToDealerPaymentRollback(Request $request) { $bank_statement = \App\BankStatement::where(['transfer_type' => 2])->get(); // dd($bank_statement); foreach ($bank_statement as $key => $value) { if ($value->history != '') { $bank_history = json_decode($value->history, true); foreach ($bank_history as $k => $v) { // dd($v['amount']); $companyInvoicePaymentUpdate = \App\CompanyInvoicePayment::where(['invoice_id' => $v['invoice_id'], 'payment_id' => $value->id])->first(); $companyDi = \App\WarehouseDi::where('id', $companyInvoicePaymentUpdate->invoice_id)->first(); // $companyDi->payment_date = null; if (($companyDi->remaining_amount + $v['amount']) != $companyDi->total) { $companyDi->remaining_amount = $companyDi->remaining_amount + $v['amount']; $companyDi->payment_amount = $v['amount']; } else { $companyDi->remaining_amount = $companyDi->total; $companyDi->payment_amount = null; $companyDi->is_paid = 0; $companyDi->payment_date = null; } $companyDi->save(); \App\CompanyInvoicePayment::where(['invoice_id' => $v['invoice_id'], 'payment_id' => $value->id])->delete(); \App\CompanyInvoiceLedger::where('voucher_no', $value->series)->delete(); // dd($companyInvoicePaymentUpdate); } } else { \App\CompanyInvoiceLedger::where('voucher_no', $value->series)->delete(); } \App\BankStatement::where(['transfer_type' => 2])->delete(); // dd($value->history); // dd($bank_history); } // dd($bank_statement); echo 'Successful Dealer to dealer all payements roll back'; } public function ledgerCreate(Request $request) { $loading_slip_invoice = \App\LoadingSlipInvoice::where('id', 18025)->first(); $ledger = new \App\PartyInvoiceLedger(); $ledger->retailer_id = $loading_slip_invoice->retailer_id; $ledger->dealer_id = $loading_slip_invoice->dealer_id; $ledger->particular = "Purchase of " . $loading_slip_invoice->product . " from " . getModelById('Dealer', $loading_slip_invoice->dealer_id)->name . "(" . getModelById('Dealer', $loading_slip_invoice->dealer_id)->address1 . ")"; $ledger->credit = 0; $ledger->debit = $loading_slip_invoice->total; $ledger->balance = $loading_slip_invoice->total; $ledger->against = $loading_slip_invoice->invoice_number; $ledger->save(); } function partyLedgerFix($voucher_no) { $ledger = \App\PartyInvoiceLedger::where('against', '449')->first(); $bank_statement = \App\BankStatement::where('series', '449')->first(); $partyInvoicePayment = \App\PartyInvoicePayment::where('receipt_id', $bank_statement->id)->get(); foreach ($partyInvoicePayment as $key => $value) { $loading_slip_invoice = \App\LoadingSlipInvoice::where('id', $value->invoice_id)->first(); if (($loading_slip_invoice->remaining_amount + $value->payment_amount) == $loading_slip_invoice->total) { $loading_slip_invoice->is_paid = 0; } $loading_slip_invoice->remaining_amount = $loading_slip_invoice->remaining_amount + $value->payment_amount; $loading_slip_invoice->save(); } } public function avg_rate_sale(Request $request) { $total_sale_quantity = \App\Token::where('master_rake_id', 238)->where('to_type', 2)->sum('quantity'); // $total_sale_price = \App\Token::where('master_rake_id',238)->where('to_type',2)->sum('rate'); $total_sale_price = \App\Token::select('rate')->where('master_rake_id', 238)->where('to_type', 2)->groupBy('rate')->get(); $count_sale = \App\Token::where('master_rake_id', 238)->where('to_type', 2)->count('rate'); // dd($total_sale_price); $tSalePrice = 0; foreach ($total_sale_price as $value) { $tSalePrice = $tSalePrice + $value->rate; } if (count($total_sale_price) != 0 && $tSalePrice != 0) { // $average_rate_of_sale = $total_sale_price/$total_sale_quantity; $average_rate_of_sale = $tSalePrice / count($total_sale_price); } else { $average_rate_of_sale = 0; } echo $average_rate_of_sale; } public function getProductCompany1() { $opening_dealers = \App\OpeningInventory::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $loading_dealers = \App\ProductLoading::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $WarehouseDi_from_dealers = \App\WarehouseDi::whereNotNull('from_dealer_id')->distinct()->pluck('from_dealer_id')->toArray(); $WarehouseDi_to_dealers = \App\WarehouseDi::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $companyDi_dealers = \App\CompanyDi::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $standard_dealers = \App\Standardization::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $excess_shortage_dealers = \App\RakeExcessShortage::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $distincts_dealers = array(); // $distincts_dealers = array_unique(array_merge($opening_dealers,$distincts_dealers,$loading_dealers,$WarehouseDi_from_dealers,$WarehouseDi_to_dealers,$companyDi_dealers,$standard_dealers,$excess_shortage_dealers)); $distincts_dealers = [0 => 30]; // echo count($distincts_dealers); // dd('stop'); asort($distincts_dealers); // dd($distincts_dealers); // dd('stop'); $productCompany = []; foreach ($distincts_dealers as $dealer_id) { $Company = \App\Inventory::select('dealer_id', 'product_brand_id', 'product_id')->where('dealer_id', $dealer_id)->groupBy('product_id')->get(); //dd($Company); foreach ($Company as $key => $p_company) { $cement_product_ids = \App\Product::where('product_category_id', 1)->pluck('id'); foreach ($cement_product_ids as $id) { if ($id == $p_company->product_id) { if (array_key_exists($p_company->dealer_id, $productCompany)) { if (array_key_exists($p_company->product_brand_id, $productCompany[$p_company->dealer_id])) { if (!array_key_exists($p_company->product_id, $productCompany[$p_company->dealer_id][$p_company->product_brand_id])) { $productCompany[$p_company->dealer_id][$p_company->product_brand_id][$p_company->product_id] = $p_company->product_id; } } else { $productCompany[$p_company->dealer_id][$p_company->product_brand_id][$p_company->product_id] = $p_company->product_id; } } else { $productCompany[$p_company->dealer_id][$p_company->product_brand_id][$p_company->product_id] = $p_company->product_id; } } } } } // dd($productCompany); return $productCompany; } public function partiesStock(Request $request) { $data = array(); // echo "this is parties stock"; // dd('stop'); $opening_dealers = \App\OpeningInventory::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $loading_dealers = \App\ProductLoading::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $WarehouseDi_from_dealers = \App\WarehouseDi::whereNotNull('from_dealer_id')->distinct()->pluck('from_dealer_id')->toArray(); $WarehouseDi_to_dealers = \App\WarehouseDi::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $companyDi_dealers = \App\CompanyDi::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $standard_dealers = \App\Standardization::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $excess_shortage_dealers = \App\RakeExcessShortage::whereNotNull('dealer_id')->distinct()->pluck('dealer_id')->toArray(); $distincts_dealers = array(); $distincts_dealers = array_unique(array_merge($opening_dealers, $distincts_dealers, $loading_dealers, $WarehouseDi_from_dealers, $WarehouseDi_to_dealers, $companyDi_dealers, $standard_dealers, $excess_shortage_dealers)); // dd($distincts_dealers); // dd('stop'); //product companies $opening_product_brands = \App\OpeningInventory::whereNotNull('product_brand_id')->distinct()->pluck('product_brand_id')->toArray(); $loading_product_brands = \App\ProductLoading::whereNotNull('product_company_id')->distinct()->pluck('product_company_id')->toArray(); $WarehouseDi_from_product_brands = \App\WarehouseDi::whereNotNull('product_brand_id')->distinct()->pluck('product_brand_id')->toArray(); $companyDi_product_brands = \App\CompanyDi::whereNotNull('product_company_id')->distinct()->pluck('product_company_id')->toArray(); $standard_product_brands = \App\Standardization::whereNotNull('open_product_brand_id')->distinct()->pluck('open_product_brand_id')->toArray(); $excess_shortage_product_brands = \App\RakeExcessShortage::whereNotNull('product_brand_id')->distinct()->pluck('product_brand_id')->toArray(); $distincts_product_brands = array(); $distincts_product_brands = array_unique(array_merge($opening_product_brands, $loading_product_brands, $WarehouseDi_from_product_brands, $companyDi_product_brands, $standard_product_brands, $excess_shortage_product_brands)); // end product companies //product $opening_products = \App\OpeningInventory::whereNotNull('product_id')->distinct()->pluck('product_id')->toArray(); $loading_products = \App\ProductLoading::whereNotNull('product_id')->distinct()->pluck('product_id')->toArray(); $WarehouseDi_from_products = \App\WarehouseDi::whereNotNull('product_id')->distinct()->pluck('product_id')->toArray(); $companyDi_products = \App\CompanyDi::whereNotNull('product_id')->distinct()->pluck('product_id')->toArray(); $standard_products = \App\Standardization::whereNotNull('open_product_id')->distinct()->pluck('open_product_id')->toArray(); $excess_shortage_products = \App\RakeExcessShortage::whereNotNull('product_id')->distinct()->pluck('product_id')->toArray(); $distincts_products = array(); $distincts_products = array_unique(array_merge($opening_products, $loading_products, $WarehouseDi_from_products, $companyDi_products, $standard_products, $excess_shortage_products)); $dealers_stock = array(); $temp = array(); $total = 0; $product_company = array(); $product_company = $this->getProductCompany1(); foreach ($product_company as $dealer_id => $value) { foreach ($value as $product_brand_id => $product) { foreach ($product as $product_id) { if ($product_brand_id) { $opening_stock = \App\OpeningInventory::where('dealer_id', $dealer_id)->where('product_brand_id', $product_brand_id)->where('product_id', $product_id)->sum('quantity'); } else { $opening_stock = \App\OpeningInventory::where('dealer_id', $dealer_id)->where('product_id', $product_id)->sum('quantity'); } $balance = $opening_stock; /*------out------*/ $loading_query = \App\ProductLoading::query(); if ($product_brand_id) { $loading_query->where('product_company_id', $product_brand_id); $data['product_brand_id'] = $product_brand_id; } $product_loadings = $loading_query->where('dealer_id', $dealer_id)->where('product_id', $product_id)->sum('quantity'); $balance -= $product_loadings; $warehouse_di_query = \App\WarehouseDi::query(); if ($product_brand_id) { $warehouse_di_query->where('product_brand_id', $product_brand_id); $data['product_brand_id'] = $product_brand_id; } $warehouse_dis = $warehouse_di_query->where('from_dealer_id', $dealer_id)->where('product_id', $product_id)->sum('quantity'); $balance -= $warehouse_dis; $standardization_query = \App\Standardization::query(); if ($product_brand_id) { $standardization_query->where('open_product_brand_id', $product_brand_id); $data['product_brand_id'] = $product_brand_id; } $standardizations = $standardization_query->where('dealer_id', $dealer_id)->where('open_product_id', $product_id)->sum('open_quantity'); $balance -= $standardizations; $StockAdjustment_query = \App\StockAdjustment::query(); if ($product_brand_id) { $StockAdjustment_query->where('product_brand_id', $product_brand_id); } $stock_adjustments = $StockAdjustment_query->where('dealer_id', $dealer_id)->where('adjust_type', 2)->where('product_id', $product_id)->sum('quantity'); $balance -= $stock_adjustments; /*------out------*/ /*------in------*/ $excess_query = \App\RakeExcessShortage::query(); if ($product_brand_id) { $excess_query->where('product_brand_id', $product_brand_id); $data['product_brand_id'] = $product_brand_id; } $excesses = $excess_query->where('dealer_id', $dealer_id)->where('product_id', $product_id)->sum('quantity'); $balance += $excesses; $unloading_query = \App\ProductUnloading::query(); if ($product_brand_id) { $unloading_query->where('product_company_id', $product_brand_id); $data['product_brand_id'] = $product_brand_id; } $product_unloadings = $unloading_query->where('dealer_id', $dealer_id)->where('product_id', $product_id)->sum('quantity'); $balance += $product_unloadings; $standardization_query = \App\Standardization::query(); if ($product_brand_id) { $standardization_query->where('closed_product_brand_id', $product_brand_id); } $standardizations = $standardization_query->where('dealer_id', $dealer_id)->where('closed_product_id', $product_id)->sum('packed_quantity'); $balance += $standardizations; $return_query = \App\ReturnedProduct::query(); if ($product_brand_id) { $return_query->where('product_brand_id', $product_brand_id); $data['product_brand_id'] = $product_brand_id; } $returns = $return_query->where('dealer_id', $dealer_id)->where('product_id', $product_id)->sum('returned_quantity'); $balance += $returns; $company_di_query = \App\CompanyDi::query(); if ($product_brand_id) { $company_di_query->where('product_company_id', $product_brand_id); $data['product_brand_id'] = $product_brand_id; } $company_dis = $company_di_query->where('dealer_id', $dealer_id)->where('product_id', $product_id)->sum('quantity'); $balance += $company_dis; $warehouse_di_query = \App\WarehouseDi::query(); if ($product_brand_id) { $warehouse_di_query->where('product_brand_id', $product_brand_id); $data['product_brand_id'] = $product_brand_id; } $warehouse_dis = $warehouse_di_query->where('dealer_id', $dealer_id)->where('product_id', $product_id)->sum('quantity'); $balance += $warehouse_dis; $StockAdjustment_query = \App\StockAdjustment::query(); if ($product_brand_id) { $StockAdjustment_query->where('product_brand_id', $product_brand_id); } $stock_adjustments = $StockAdjustment_query->where('dealer_id', $dealer_id)->where('adjust_type', 1)->where('product_id', $product_id)->sum('quantity'); $balance += $stock_adjustments; /*------in------*/ $Inventory = \App\Inventory::query(); if ($product_brand_id) { $Inventory = $Inventory->where('product_brand_id', $product_brand_id); } $Inventory = $Inventory->where('dealer_id', $dealer_id)->where('product_id', $product_id)->sum('quantity'); // echo "this is final balance :".$balance; if ($balance != 0) { $temp[$dealer_id][$product_brand_id][$product_id][0] = $balance; $temp[$dealer_id][$product_brand_id][$product_id][1] = $Inventory; // $temp['inv_stock'] = $Inventory; // if(!array_key_exists($dealer_id, $temp)) { // $temp[$dealer_id][$product_brand_id][$product_id] = $balance; // } else { // if(!array_key_exists($product_brand_id, $temp[$dealer_id])) { // $temp[$dealer_id][$product_brand_id][$product_id] = $balance; // } else { // if(!array_key_exists($product_id, $temp[$dealer_id][$product_brand_id])) { // $temp[$dealer_id][$product_brand_id][$product_id] = $balance; // } else { // $temp[$dealer_id][$product_brand_id][$product_id] = $balance; // } // } // } } } } } // dd($temp); $data['temp'] = $temp; return view('dashboard.test.show-data', $data); } public function getVoucherNoUpdate() { $data = array(); // $data['loading_slips'] = \App\ProductLoading::where('is_freight_paid',0)->with('token')->get(); // $data['freight_list'] = \App\FreightList::all(); // return view("dashboard.token.freight-payment", $data); // $data = array(); $data['warehouses'] = \App\Warehouse::where('is_active', 1)->get(); // $data['companies'] = \App\Company::where('is_active', 1)->where('for_invoice', 1)->get(); $data['dealers'] = \App\Dealer::where('is_active', 1)->get(); $data['retailers'] = \App\Retailer::where('is_active', 1)->get(); // $data['products'] = \App\Product::where('is_active', 1)->get(); // $data['units'] = \App\Unit::where('is_active', 1)->get(); return view('dashboard.test.update-voucher-details', $data); } public function voucherNoDetails($voucher_no) { $response = array(); // dd($voucher_no); $partyLedgerDetails = \App\PartyInvoiceLedger::where('against', $voucher_no)->first(); // dd($partyLedgerDetails); if (!is_null($partyLedgerDetails)) { $response['flag'] = true; $response['voucherNo'] = $partyLedgerDetails; $response['retailer'] = getModelById('Retailer', $partyLedgerDetails->retailer_id)->name . ' (' . $partyLedgerDetails->retailer_id . ')'; $response['dealer'] = getModelById('Dealer', $partyLedgerDetails->dealer_id)->name . ' (' . $partyLedgerDetails->dealer_id . ')'; $bank_statement = \App\BankStatement::where('series', $voucher_no); if ($partyLedgerDetails->credit > 0) { $response['amount'] = $partyLedgerDetails->credit; $bank_statement = $bank_statement->where('type', 'receipt')->first(); } if ($partyLedgerDetails->debit > 0) { $response['amount'] = $partyLedgerDetails->debit; $bank_statement = $bank_statement->where('type', 'payment')->first(); } // dd($bank_statement); $history = json_decode($bank_statement->history, true); // dd($history); $response['bankTransactionDetails'] = $bank_statement; $response['invoice_history'] = $history; } else { $response['flag'] = false; $response['message'] = "Warehouse Di not exits"; } return response()->json($response); } public function partyInvoiceDetails($dealer_id, $retailer_id) { // dd($dealer_id.' kk'.$retailer_id); $response = array(); $response['invoices'] = \App\LoadingSlipInvoice::where('remaining_amount', '>', 0) ->where('dealer_id', $dealer_id)->where('retailer_id', $retailer_id) ->get(); $total_debit = \App\PartyInvoiceLedger::where('retailer_id', $retailer_id)->where('dealer_id', $dealer_id)->sum('debit'); $total_credit = \App\PartyInvoiceLedger::where('retailer_id', $retailer_id)->where('dealer_id', $dealer_id)->sum('credit'); $balance = $total_debit - $total_credit; // dd($balance); if ($balance < 0) { $response['party_balance'] = abs($balance); } else { $response['party_balance'] = 0; } $response['dealer'] = getModelById('Dealer', $dealer_id)->name . ' (' . $dealer_id . ')'; $response['retailer'] = getModelById('Retailer', $retailer_id)->name . ' (' . $retailer_id . ')'; return response()->json($response); // dd($response['invoices']); } public function voucherNoUpdate(Request $request) { // dd($request->all()); $response = array(); $validator = \Validator::make( $request->all(), array( 'voucher_no' => 'required', 'update_dealer' => 'required', 'update_retailer' => 'required', ) ); if ($validator->fails()) { $response['flag'] = false; $response['errors'] = $this->parseErrorResponse($validator->getMessageBag()); } else { $partyLedgerDetails = \App\PartyInvoiceLedger::where('against', $request->voucher_no)->first(); if (($request->update_dealer == $partyLedgerDetails->dealer_id) && ($request->update_retailer == $partyLedgerDetails->retailer_id)) { $response['flag'] = false; $response['message'] = "Update Retailer & dealer are same !!"; } else { $voucherHistory = new \App\VoucherChangeHistory(); $voucherHistory->current_dealer_id = $partyLedgerDetails->dealer_id; $voucherHistory->current_retailer_id = $partyLedgerDetails->retailer_id; $voucherHistory->update_dealer_id = $request->update_dealer; $voucherHistory->update_retailer_id = $request->update_retailer; $voucherHistory->save(); $bank_statement = \App\BankStatement::where('series', $request->voucher_no); if ($partyLedgerDetails->credit > 0) { $bank_statement = $bank_statement->where('type', 'receipt')->first(); } if ($partyLedgerDetails->debit > 0) { $bank_statement = $bank_statement->where('type', 'payment')->first(); } $voucherHistory->current_invoice_history = $bank_statement->history; $voucherHistory->save(); $paymentDetails = \App\PartyInvoicePayment::where('receipt_id', $bank_statement->id)->get(); if (!is_null($paymentDetails)) { foreach ($paymentDetails as $k => $v) { $invoice = \App\LoadingSlipInvoice::where('id', $v->invoice_id)->first(); if ($invoice->total == ($invoice->remaining_amount + $v->payment_amount)) { $invoice->is_paid = 0; } $invoice->remaining_amount = $invoice->remaining_amount + $v->payment_amount; $invoice->save(); } } if (!is_null($paymentDetails)) { \App\PartyInvoicePayment::where('receipt_id', $bank_statement->id)->delete(); } if ($request->invoice_payment != "") { $jsonData = []; $n = 0; foreach ($request->invoice_payment as $key => $value) { if ($key != "" && $value != "") { $invoice_id = $key; $invoiceNew = \App\LoadingSlipInvoice::where('id', $invoice_id)->first(); if (is_null($invoiceNew)) { $is_valid = false; $msg = "Invoice Not found"; } else if ($value > $invoiceNew->remaining_amount) { $is_valid = false; $msg = 'Amount is greater than remaining amount(' . $invoiceNew->remaining_amount . ')'; } else if ($invoiceNew->remaining_amount == 0) { $is_valid = false; $msg = 'Invoice Already Paid'; } else { $invoiceNew->is_paid = 1; $invoiceNew->remaining_amount = $invoiceNew->remaining_amount - $value; $jsonData[$n]['invoice'] = $invoice_id; $jsonData[$n]['invoice_number'] = $invoiceNew->invoice_number; $jsonData[$n]['amount'] = $value; $jsonData[$n]['date'] = date('d/m/Y'); $jsonData[$n]['refund_amount'] = (float)0; $n++; if ($invoiceNew->save()) { $payment = new \App\PartyInvoicePayment(); $payment->invoice_id = $invoice_id; $payment->payment_amount = $value; $payment->payment_date = $bank_statement->transaction_date; $payment->bank_account_id = $bank_statement->bank_id; $payment->bank_reference_number = $bank_statement->reference_number; $payment->payment_mode = $bank_statement->mode; $payment->receipt_id = $bank_statement->id; $payment->save(); $is_valid = true; } else { $is_valid = false; $msg = 'Something Went Wrong'; } } } } $partyLedgerDetails->dealer_id = $request->update_dealer; $partyLedgerDetails->retailer_id = $request->update_retailer; $partyLedgerDetails->save(); $retailer = getModelById('Retailer', $request->update_retailer); $bank_particular = $retailer->name . " - " . $retailer->address; $bank_statement->particular = $bank_particular; $bank_statement->dealer_id = $request->update_dealer; $bank_statement->history = json_encode($jsonData); $voucherHistory->update_invoice_history = json_encode($jsonData); $voucherHistory->save(); } else { $partyLedgerDetails->dealer_id = $request->update_dealer; $partyLedgerDetails->retailer_id = $request->update_retailer; $partyLedgerDetails->save(); $retailer = getModelById('Retailer', $request->update_retailer); $bank_particular = $retailer->name . " - " . $retailer->address; $bank_statement->particular = $bank_particular; $bank_statement->dealer_id = $request->update_dealer; $bank_statement->history = null; } $voucherHistory->voucher_no = $request->voucher_no; $voucherHistory->user_id = \Auth::user()->id; $voucherHistory->ip_address = request()->ip(); $voucherHistory->date = date('Y-m-d'); $voucherHistory->save(); $bank_statement->save(); $response['flag'] = true; $response['message'] = "Voucher Update successfully"; $response['voucherNo'] = $request->voucher_no; } } return response()->json($response); } public function deleteVoucher($type, $voucher_no) { // dd($type.' '.$voucher_no); if (strtoupper($type) == 'COMPANY') { $companyLedgerDetails = \App\CompanyInvoiceLedger::where('voucher_no', $voucher_no)->first(); $bank_statement = \App\BankStatement::where('series', $voucher_no); if ($companyLedgerDetails->credit > 0) { $bank_statement = $bank_statement->where('type', 'receipt')->first(); $bank_delete = \App\BankStatement::where('series', $voucher_no)->where('type', 'receipt'); } if ($companyLedgerDetails->debit > 0) { $bank_statement = $bank_statement->where('type', 'payment')->first(); $bank_delete = \App\BankStatement::where('series', $voucher_no)->where('type', 'payment'); } $transictions = json_decode($bank_statement->history, true); // dd($transictions); foreach ($transictions as $key => $value) { // dd($value['invoice_id']); if ($value['invoice_type'] == 'warehouse_dis') { $invoice = \App\WarehouseDi::where('invoice_number', $value['invoice_number'])->where('id', $value['invoice_id'])->first(); } else { $invoice = \App\CompanyDi::where('invoice_number', $value['invoice_number'])->where('id', $value['invoice_id'])->first(); } if ($invoice->total == ($invoice->remaining_amount + $value['amount'])) { $invoice->is_paid = 0; } $invoice->remaining_amount = $invoice->remaining_amount + $value['amount']; $invoice->save(); } $companyInvoicePayment = \App\CompanyInvoicePayment::where('payment_id', $bank_statement->id)->get(); // dd($companyInvoicePayment); \App\CompanyInvoicePayment::where('payment_id', $bank_statement->id)->delete(); \App\CompanyInvoiceLedger::where('voucher_no', $voucher_no)->delete(); $bank_delete->delete(); // if ($invoicetype == 'warehouse_dis'){ // $invoice = \App\WarehouseDi::where('invoice_number',$invoice_number)->where('id', $invoice_id)->first(); // } else{ // $invoice = \App\CompanyDi::where('invoice_number',$invoice_number)->where('id', $invoice_id)->first(); // } } if (strtoupper($type) == 'PARTY') { $partyInvoiceLedger = \App\PartyInvoiceLedger::where('against', $voucher_no)->first(); $bank_statement = \App\BankStatement::where('series', $voucher_no); if ($partyInvoiceLedger->credit > 0) { $bank_statement = $bank_statement->where('type', 'receipt')->first(); $invoicePaymentDetails = \App\PartyInvoicePayment::where('receipt_id', $bank_statement->id)->get(); if (!is_null($invoicePaymentDetails)) { foreach ($invoicePaymentDetails as $key => $value) { $invoice = \App\LoadingSlipInvoice::find($value->invoice_id); if ($invoice->total == ($invoice->remaining_amount + $value->payment_amount)) { $invoice->is_paid = 0; } $invoice->remaining_amount = $invoice->remaining_amount + $value->payment_amount; $invoice->save(); } \App\PartyInvoicePayment::where('receipt_id', $bank_statement->id)->delete(); } \App\PartyInvoiceLedger::where('against', $voucher_no)->delete(); $bank_delete = \App\BankStatement::where('series', $voucher_no)->where('type', 'receipt'); $bank_delete->delete(); } } echo $voucher_no . ' Voucher No Ledger and statement delete'; } function returnLedgerEntryFix() { $ledgerRetunEntry = \App\PartyInvoiceLedger::whereNull('dealer_id')->get(); // dd($ledgerRetunEntry); foreach ($ledgerRetunEntry as $key => $value) { $returnProduct = \App\ReturnedProduct::where('retailer_id', $value->retailer_id)->where('invoice_number', $value->against)->first(); $invoice = \App\LoadingSlipInvoice::where('invoice_number', $value->against)->select('id', 'invoice_number', 'retailer_id', 'retailer_name', 'dealer_id', 'product_id', 'loading_slip_id', 'rate', 'secondary_discount', 'freight_discount', 'is_cn', 'cn_qty')->with('product_loading:id,quantity,transporter_id,unit_id,product_company_id') ->first(); // dd($invoice); $rate = $invoice->rate - $invoice->freight_discount; if ($invoice->secondary_discount != "") { $rate = $rate - $invoice->secondary_discount; } $return_amount = $returnProduct->returned_quantity * $rate; $ledger = \App\PartyInvoiceLedger::find($value->id); // dd($ledger); $ledger->dealer_id = $invoice->dealer_id; $ledger->type = 'credit'; $ledger->credit = $return_amount; $ledger->debit = 0; if ($ledger->save()) { $loading_slip_invoice = \App\LoadingSlipInvoice::find($invoice->id); if (date('m') <= 3) { $financial_year = (date('Y') - 1) . '-' . date('Y'); } else { $financial_year = date('Y') . '-' . (date('Y') + 1); } $session = \App\Session::where('session', $financial_year)->where('is_active', 1)->first(); if ($loading_slip_invoice == null) { $loading_slip_invoice->is_cn = 1; $loading_slip_invoice->cn_qty = $returnProduct->returned_quantity; } else { $loading_slip_invoice->is_cn = 1; $loading_slip_invoice->cn_qty = $loading_slip_invoice->cn_qty + $returnProduct->returned_quantity; } $loading_slip_invoice->save(); $credit_history = \DB::table('credit_note_history')->where('dealer_id', $invoice->dealer_id)->where('session', $session->id)->orderBy('id', 'desc')->first(); if ($credit_history != null) { $series = $credit_history->series + 1; } else { $series = 1; } $cnLastId = new \App\CreditNoteHistory(); $cnLastId->dealer_id = $invoice->dealer_id; $cnLastId->retailer_id = $invoice->retailer_id; $cnLastId->loading_slip_invoice_id = $invoice->id; $cnLastId->return_id = $returnProduct->id; $cnLastId->return_qty = $returnProduct->returned_quantity; $cnLastId->qty = $invoice->product_loading->quantity; $cnLastId->credit_note_amount = $return_amount; $cnLastId->date = date('Y-m-d', strtotime($value->created_at)); $cnLastId->series = $series; $cnLastId->session = $session->id; $cnLastId->user_id = \Auth::user()->id; $cnLastId->save(); $ledger->cn_against = $cnLastId->id; $ledger->particular = $ledger->particular . ' #' . $series; // $ledger->particular = 'credit note series-'.$series; $ledger->save(); if ($loading_slip_invoice->secondary_discount > 0) { // $sdPerticular = "Returned Product Credit Against Invoice ".$invoice->invoice_number." ( ".$invoice->product->name." ) qty ( ".$request->returned_quantity." ) "; $sdReturn_amount = $returnProduct->returned_quantity * $invoice->secondary_discount; $cnLastId->sd_credit_note_amount = $sdReturn_amount; $cnLastId->save(); $sdLedger = new \App\SecondaryDiscountPartyLedger(); $sdLedger->transaction_date = date('Y-m-d', strtotime($value->created_at)); $sdLedger->retailer_id = $invoice->retailer_id; $sdLedger->dealer_id = $invoice->dealer_id; $sdLedger->credit = $sdReturn_amount; $sdLedger->debit = 0; $sdLedger->against = $invoice->invoice_number; $sdLedger->cn_against = $cnLastId->id; $sdLedger->particular = $ledger->particular; $sdLedger->save(); } } // dd($ledgerRetunEntry); } } public function getCompanyVoucher(Request $request) { $data = array(); $data['serial'] = $request->serial; $data['previous'] = $request->previous; $credit = "credit"; $bank = \App\BankStatement::where('series', $request->serial)->where('status', $credit)->get(); foreach ($bank as $key => $value) { if (!is_null($value['series'])) { $value['series']; $value['amount']; $hi = $value['history']; $data = json_decode($hi); foreach ($data as $datas) { $invoice_number = $datas->invoice_number; $return_amount = $datas->amount; $return_date = $datas->date; \App\WarehouseDi::where('invoice_number', $invoice_number)->where('payment_date', 'LIKE', '%' . $return_date . '%')->update(['remaining_amount' => $return_amount, 'is_paid' => 0, 'payment_amount' => 0, 'payment_date' => 0]); \App\CompanyInvoicePayment::where('invoice_number', $invoice_number)->delete(); \App\CompanyInvoiceLedger::where('voucher_no', $request->serial)->update(['debit' => 0]); } } } $data['acting_company'] = Session::get('acting_company'); $data['bank_accounts'] = \App\BankAccount::where('is_active', 1)->with('bank')->get(); $data['product_companies'] = \App\ProductCompany::where('is_active', 1)->get(); $data['dealers'] = \App\Dealer::where('is_active', 1)->whereIn('id', [1, 30, 31])->get(); $data['dealers1'] = \App\Dealer::where('is_active', 1)->get(); if ($request->isMethod('post')) { $validator = \Validator::make( $request->all(), array( 'product_company_id' => 'required', 'dealer_id' => 'required' ) ); if ($validator->fails()) { return redirect('user/comany-di-payment') ->withErrors($validator) ->withInput(); } else { $product_company_id = $request->product_company_id; $from_dealer_id = $request->from_dealer; $dealer_id = $request->dealer_id; //code to get advanced amount . added by alok maurya $total_debit = \App\CompanyInvoiceLedger::where('dealer_id', $request->dealer_id)->where('product_company_id', $request->product_company_id)->sum('debit'); $total_credit = \App\CompanyInvoiceLedger::where('product_company_id', $request->product_company_id)->where('dealer_id', $request->dealer_id)->sum('credit'); $balance = 0; if ($total_debit >= $total_credit) { $balance = $total_debit - $total_credit; } if ($balance > 0) { $data['advanced_payment'] = $balance; } else { $data['advanced_payment'] = 0; } // end of advanced amount code $invoices = []; $company_dis = \DB::table('company_dis')->where('product_company_id', $product_company_id)->where('dealer_id', $dealer_id)->where('remaining_amount', '>', 0)->whereNotNull('invoice_number')->get(); $warehouse_dis = \DB::table('warehouse_dis')->where('dealer_id', $dealer_id)->where('product_company_id', $product_company_id)->where('remaining_amount', '>', 0)->whereNotNull('invoice_number')->get(); if ($company_dis != null && $warehouse_dis != null) { $n = 0; foreach ($company_dis as $key => $company_di) { $company_di->invoice_type = 'company_dis'; $invoices[$n] = $company_di; $n++; } foreach ($warehouse_dis as $key1 => $warehouse_di) { $warehouse_di->invoice_type = 'warehouse_dis'; $invoices[$n] = $warehouse_di; $n++; } } else if ($company_dis == null && $warehouse_dis != null) { $n = 0; foreach ($warehouse_dis as $key1 => $warehouse_di) { $warehouse_di->invoice_type = 'warehouse_dis'; $invoices[$n] = $warehouse_di; $n++; } } else if ($company_dis != null && $warehouse_dis == null) { $n = 0; foreach ($company_dis as $key => $company_di) { $company_di->invoice_type = 'company_dis'; $invoices[$n] = $company_di; $n++; } } $data['product_company_id'] = $request->product_company_id; $data['from_dealer_id'] = $from_dealer_id; $data['transfer_type'] = $request->transfer_type; $data['dealer_id'] = $request->dealer_id; $data['invoices'] = $invoices; } } return view('dashboard.invoice.refund-amount-company-to-dealer', $data); } public function getCompanyVoucherNoUpdate() { $data = array(); // $data['loading_slips'] = \App\ProductLoading::where('is_freight_paid',0)->with('token')->get(); // $data['freight_list'] = \App\FreightList::all(); // return view("dashboard.token.freight-payment", $data); // $data = array(); $data['warehouses'] = \App\Warehouse::where('is_active', 1)->get(); // $data['companies'] = \App\Company::where('is_active', 1)->where('for_invoice', 1)->get(); $data['dealers'] = \App\Dealer::where('is_active', 1)->get(); $data['retailers'] = \App\Retailer::where('is_active', 1)->get(); // $data['products'] = \App\Product::where('is_active', 1)->get(); // $data['units'] = \App\Unit::where('is_active', 1)->get(); return view('dashboard.test.update-company-voucher-details', $data); } public function companyVoucherNoUpdate(Request $request) { // dd($request->all()); $response = array(); $validator = \Validator::make( $request->all(), array( 'voucher_no' => 'required', // 'update_dealer' => 'required', // 'update_retailer' => 'required', ) ); if ($validator->fails()) { $response['flag'] = false; $response['errors'] = $this->parseErrorResponse($validator->getMessageBag()); } else { $companyVoucherLogs = new \App\CompanyVoucherUpdateLog(); $companyLedgerDetails = \App\CompanyInvoiceLedger::where('voucher_no', $request->voucher_no)->first(); if (!is_null($companyLedgerDetails->product_company_id)) { $type = 1; } if (!is_null($companyLedgerDetails->from_dealer)) { $type = 2; } $bank_statement = \App\BankStatement::where('series', $request->voucher_no); if ($companyLedgerDetails->credit > 0) { $bank_statement = $bank_statement->where('type', 'receipt')->first(); } if ($companyLedgerDetails->debit > 0) { $bank_statement = $bank_statement->where('type', 'payment')->first(); } $companyVoucherLogs->current_invoice_history = $bank_statement->history; $companyPaymentDetails = \App\CompanyInvoicePayment::where('payment_id', $bank_statement->id)->get(); $invoices = json_decode($bank_statement->history, true); // dd(json_decode($bank_statement->history,true)); if (!is_null($invoices)) { foreach ($invoices as $k => $v) { // dd($v['invoice_type']); if ($v['invoice_type'] == 'warehouse_dis') { $invoiceRollback = \App\WarehouseDi::find($v['invoice_id']); } else { $invoiceRollback = \App\CompanyDi::find($v['invoice_id']); } if (!is_null($invoiceRollback)) { $totalAmt = $invoiceRollback->total; $remAmount = $invoiceRollback->remaining_amount; $updRemAmt = $remAmount + $v['amount']; $invoiceRollback->remaining_amount = $invoiceRollback->remaining_amount + $v['amount']; if ($totalAmt == $updRemAmt) { $invoiceRollback->is_paid = 0; } $invoiceRollback->payment_date = null; $invoiceRollback->payment_amount = null; $invoiceRollback->save(); } } } if (!is_null($companyPaymentDetails)) { \App\CompanyInvoicePayment::where('payment_id', $bank_statement->id)->delete(); } $updAmount = $request->update_amount; $bank_statement->amount = $updAmount; if ($bank_statement->type == 'receipt') { $companyLedgerDetails->credit = $updAmount; } if ($bank_statement->type == 'payment') { $companyLedgerDetails->debit = $updAmount; } $companyLedgerDetails->save(); if ($type == 1) { $total_debit = \App\CompanyInvoiceLedger::where('dealer_id', $companyLedgerDetails->dealer_id)->where('product_company_id', $companyLedgerDetails->product_company_id)->sum('debit'); $total_credit = \App\CompanyInvoiceLedger::where('product_company_id', $companyLedgerDetails->product_company_id)->where('dealer_id', $companyLedgerDetails->dealer_id)->sum('credit'); } if ($type == 2) { $total_debit = \App\CompanyInvoiceLedger::where('dealer_id', $companyLedgerDetails->dealer_id)->where('from_dealer_id', $companyLedgerDetails->from_dealer_id)->sum('debit'); $total_credit = \App\CompanyInvoiceLedger::where('from_dealer_id', $companyLedgerDetails->from_dealer_id)->where('dealer_id', $companyLedgerDetails->dealer_id)->sum('credit'); } $balance = 0; if ($total_debit >= $total_credit) { $balance = $total_debit - $total_credit; } if ($balance > 0) { $data['advanced_payment'] = $balance; } else { $data['advanced_payment'] = 0; } $totalAmount = $updAmount + $balance; $invoicesUpd = []; if ($type == 1) { $company_dis = \DB::table('company_dis')->where('product_company_id', $companyLedgerDetails->product_company_id)->where('dealer_id', $companyLedgerDetails->dealer_id)->where('remaining_amount', '>', 0)->whereNotNull('invoice_number')->get(); $warehouse_dis = \DB::table('warehouse_dis')->where('dealer_id', $companyLedgerDetails->dealer_id)->where('product_company_id', $companyLedgerDetails->product_company_id)->where('remaining_amount', '>', 0)->whereNotNull('invoice_number')->get(); } if ($type == 2) { $company_dis = null; $warehouse_dis = \DB::table('warehouse_dis')->where('dealer_id', $companyLedgerDetails->dealer_id)->where('from_dealer_id', $companyLedgerDetails->from_dealer_id)->where('remaining_amount', '>', 0)->whereNotNull('invoice_number')->get(); } if ($company_dis != null && $warehouse_dis != null) { $n = 0; foreach ($company_dis as $key => $company_di) { $company_di->invoice_type = 'company_dis'; $invoicesUpd[$n] = $company_di; $n++; } foreach ($warehouse_dis as $key1 => $warehouse_di) { $warehouse_di->invoice_type = 'warehouse_dis'; $invoicesUpd[$n] = $warehouse_di; $n++; } } else if ($company_dis == null && $warehouse_dis != null) { $n = 0; foreach ($warehouse_dis as $key1 => $warehouse_di) { $warehouse_di->invoice_type = 'warehouse_dis'; $invoicesUpd[$n] = $warehouse_di; $n++; } } else if ($company_dis != null && $warehouse_dis == null) { $n = 0; foreach ($company_dis as $key => $company_di) { $company_di->invoice_type = 'company_dis'; $invoicesUpd[$n] = $company_di; $n++; } } if ($invoicesUpd != '') { $n = 0; $jsonData = []; foreach ($invoicesUpd as $key => $invoiceUpd) { $invoice_id = $invoiceUpd->id; $invoice_type = $invoiceUpd->invoice_type; if ($invoice_type == 'warehouse_dis') { $companyInvoiceNew = \App\WarehouseDi::find($invoice_id); } else { $companyInvoiceNew = \App\CompanyDi::find($invoice_id); } $companyPayment = new \App\CompanyInvoicePayment(); $companyInvoiceAmt = 0; $remainingAmount = $companyInvoiceNew->remaining_amount; if ($remainingAmount <= $totalAmount && $totalAmount != 0) { $companyInvoiceAmt = $remainingAmount; $jsonData[$n]['invoice_number'] = $invoiceUpd->invoice_number; $jsonData[$n]['invoice_id'] = $invoice_id; $jsonData[$n]['invoice_type'] = $invoice_type; $jsonData[$n]['amount'] = $companyInvoiceAmt; $jsonData[$n]['date'] = date('Y-m-d', strtotime($bank_statement->created_at)); $companyPayment->invoice_id = $invoice_id; $companyPayment->invoice_number = $invoiceUpd->invoice_number; $companyPayment->payment_amount = $companyInvoiceAmt; $companyPayment->payment_date = $bank_statement->transaction_date; $companyPayment->bank_account_id = $bank_statement->bank_id; $companyPayment->bank_reference_number = $bank_statement->reference_number; $companyPayment->payment_mode = $bank_statement->mode; $companyPayment->payment_id = $bank_statement->id; $companyInvoiceNew->is_paid = 1; $companyInvoiceNew->payment_date = $bank_statement->transaction_date; $companyInvoiceNew->payment_amount = $companyInvoiceAmt; $companyInvoiceNew->remaining_amount = $companyInvoiceNew->remaining_amount - $companyInvoiceAmt; $totalAmount = $totalAmount - $remainingAmount; } else if ($remainingAmount > $totalAmount && $totalAmount != 0) { $companyInvoiceAmt = $totalAmount; $jsonData[$n]['invoice_number'] = $invoiceUpd->invoice_number; $jsonData[$n]['invoice_id'] = $invoice_id; $jsonData[$n]['invoice_type'] = $invoice_type; $jsonData[$n]['amount'] = $companyInvoiceAmt; $jsonData[$n]['date'] = date('Y-m-d', strtotime($bank_statement->created_at)); $companyPayment->invoice_id = $invoice_id; $companyPayment->invoice_number = $invoiceUpd->invoice_number; $companyPayment->payment_amount = $companyInvoiceAmt; $companyPayment->payment_date = $bank_statement->transaction_date; $companyPayment->bank_account_id = $bank_statement->bank_id; $companyPayment->bank_reference_number = $bank_statement->reference_number; $companyPayment->payment_mode = $bank_statement->mode; $companyPayment->payment_id = $bank_statement->id; $companyInvoiceNew->is_paid = 1; $companyInvoiceNew->payment_date = $bank_statement->transaction_date; $companyInvoiceNew->payment_amount = $companyInvoiceAmt; $companyInvoiceNew->remaining_amount = $companyInvoiceNew->remaining_amount - $companyInvoiceAmt; $totalAmount = 0; } $companyVoucherLogs->update_invoice_history = json_encode($jsonData); $companyPayment->save(); $companyInvoiceNew->save(); $n++; // dd($companyInvoiceNew); } $bank_statement->history = json_encode($jsonData); } $bank_statement->save(); $companyVoucherLogs->current_amount = $request->amount; $companyVoucherLogs->update_amount = $updAmount; $companyVoucherLogs->transfer_type = $type; $companyVoucherLogs->voucher_no = $request->voucher_no; $companyVoucherLogs->current_company_id = $companyLedgerDetails->product_company_id; $companyVoucherLogs->current_from_dealer_id = $companyLedgerDetails->from_dealer_id; $companyVoucherLogs->current_dealer_id = $companyLedgerDetails->dealer_id; $companyVoucherLogs->update_company_id = $companyLedgerDetails->product_company_id; $companyVoucherLogs->update_from_dealer_id = $companyLedgerDetails->from_dealer_id; $companyVoucherLogs->update_dealer_id = $companyLedgerDetails->from_dealer_id; $companyVoucherLogs->user_id = \Auth::user()->id; $companyVoucherLogs->ip_address = request()->ip(); $companyVoucherLogs->date = date('Y-m-d'); $companyVoucherLogs->save(); $response['flag'] = true; $response['message'] = "Company Voucher Update successfully"; $response['voucherNo'] = $request->voucher_no; } return response()->json($response); } public function companyVoucherNoDetails($voucher_no) { $response = array(); // dd($voucher_no); $companyLedgerDetails = \App\CompanyInvoiceLedger::where('voucher_no', $voucher_no)->first(); // dd($companyLedgerDetails); if (!is_null($companyLedgerDetails)) { $response['flag'] = true; $response['voucherNo'] = $companyLedgerDetails; $response['product_company'] = getModelById('ProductCompany', $companyLedgerDetails->product_company_id)->name . ' (' . $companyLedgerDetails->product_company_id . ')'; $response['from_dealer'] = getModelById('Dealer', $companyLedgerDetails->from_dealer_id)->name . ' (' . $companyLedgerDetails->from_dealer_id . ')'; $response['dealer'] = getModelById('Dealer', $companyLedgerDetails->dealer_id)->name . ' (' . $companyLedgerDetails->dealer_id . ')'; $bank_statement = \App\BankStatement::where('series', $voucher_no); if ($companyLedgerDetails->credit > 0) { $response['amount'] = $companyLedgerDetails->credit; $bank_statement = $bank_statement->where('type', 'receipt')->first(); } if ($companyLedgerDetails->debit > 0) { $response['amount'] = $companyLedgerDetails->debit; $bank_statement = $bank_statement->where('type', 'payment')->first(); } // dd($bank_statement); $history = json_decode($bank_statement->history, true); // dd($history); $response['bankTransactionDetails'] = $bank_statement; $response['invoice_history'] = $history; } else { $response['flag'] = false; $response['message'] = "Company Voucher not exits"; } return response()->json($response); } public function getRetailerData($id) { $datas = \App\Retailer::where('id', $id)->first(); if ($datas->limit != null || $datas->limit != 0) { $data['retailer'] = $datas->limit; } else { $data['retailer'] = "Limit Not Set"; } return response()->json($data); } // public function file() // { // // dd('stop'); // $row = 1; // if (($handle = fopen("retailers.csv", "r")) !== FALSE) { // while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) { // $num = count($data); // if ($row > 0) { // // echo "<pre>"; // // print_r($data); // // exit; // $UpdateDetails = \App\Retailer::where('id', '=', $data[0])->first(); // if($UpdateDetails) // { //$UpdateDetails->marketing_manager_id = $data[2]; // // $UpdateDetails->group_id = $data[3]; // $UpdateDetails->pincode = $data[8]; // $UpdateDetails->save();} // } // $row++; // } // } // } ////////////////////////UPDATE PRODUCT, FREIGHT, WAREHOUSE, DEALER ////////////////////// public function updateloading() { $data = array(); $data['loadings'] = \App\Product_loadings::where('is_approved', 1)->get(); $data['dealers'] = \App\Dealer::where('is_active', 1)->get(); $data['retailers'] = \App\Retailer::where('is_active', 1)->get(); $data['freights'] = \App\Freightlist::where('id', 1)->get(); $data['products'] = \App\Product::get(); $data['productCompany'] = \App\ProductCompany::where('is_active', 1)->get(); $data['warehouse_select'] = \App\Warehouse::where('is_active', 1)->get(); return view('dashboard.test.update-product-loading', $data); } public function updateProductLoading(Request $request) { //dd($request->all()); $response = array(); $validator = \Validator::make( $request->all(), array( //'new_freight' =>'required' ) ); if ($validator->fails()) { $response['flag'] = false; $response['errors'] = $validator->getMessageBag(); } else { $product_loading = \App\ProductLoading::where('id', $request->loading_id)->first(); if (is_null($product_loading)) { $response['flag'] = false; $response['error'] = "Product Loading Detail Not found"; } else { $product_new = \App\Product::where('id', $request->product_id)->first(); if (!empty($request->product_id)) { $product_loading->product_id = $request->product_id; $product_loading->product_name = $product_new->name; } if (!empty($request->new_freight)) { $product_loading->freight = $request->new_freight; } if (!empty($request->warehouse_id)) { $product_loading->from_warehouse_id = $request->warehouse_id; } if (!empty($request->new_quantity)) { $product_loading->quantity = $request->new_quantity; $token_id = \App\Token::where('id', $product_loading->token_id)->first(); if ($product_loading->is_invoice_generated == 1) { $invoice_id = str_replace(',', '', $request->invoice); $invoice = \App\LoadingSlipInvoice::where('invoice_number', $invoice_id)->first(); $invoice->dealer_id = $request->dealers; $invoice->quantity = $request->new_quantity; $rate = $token_id->rate; if ($invoice->secondary_discount != "") { $rate = $rate - $invoice->secondary_discount; } // dd($rate); $rate = $rate * 100 / (100 + $product_new->cgst + $product_new->sgst); $amount = $rate * $request->new_quantity; $cgst_amount = ($product_new->cgst / 100) * $amount; $sgst_amount = ($product_new->sgst / 100) * $amount; $total = $amount + $cgst_amount + $sgst_amount; $invoice->cgst = $cgst_amount; $invoice->sgst = $sgst_amount; $invoice->total = $total; $invoice->remaining_amount = $total; $invoice->product_hsn = $product_new->hsn_code; $partyInvoice = \App\PartyInvoiceLedger::where('against', $invoice_id)->first(); if ($partyInvoice) { if ($partyInvoice->credit != 0.00) { $partyInvoice->credit = $total; } else { $partyInvoice->debit = $total; } $partyInvoice->dealer_id = $request->dealers; $partyInvoice->save(); } $invoice->save(); } } if (!empty($request->dealers)) { $dealer_new = \App\Dealer::where('id', $request->dealers)->first(); $product_loading->dealer_id = $request->dealers; $product_loading->dealer_name = $dealer_new->name; } if (!empty($request->product_id)) { $product_loading->product_id = $request->product_id; $product_loading->product_name = getModelById('Product', $request->product_id)->name; $lp = \App\LabourPayments::where('product_loading_id', $request->loading_id)->first(); if (!empty($lp)) { $lp->product_id = $request->product_id; $lp->product_name = getModelById('Product', $request->product_id)->name; $lp->save(); $token = \App\Token::where('id', $request->token_id)->first(); if ($token->token_type == 1) { if ($request->dealers != $product_loading->dealer_id || $request->warehouse_id != $product_loading->from_warehouse_id || $request->product_id != $product_loading->product_id) { $inventory2 = \App\Inventory::where('dealer_id', $product_loading->dealer_id) ->where('warehouse_id', 24) ->where('product_brand_id', $token->product_company_id) ->where('product_id', $product_loading->product_id) ->first(); $inventory1 = \App\Inventory::where('dealer_id', $request->dealers) ->where('warehouse_id', 24) ->where('product_brand_id', $token->product_company_id) ->where('product_id', $request->product_id) ->first(); if (!is_null($inventory1)) { $inventory1->quantity = $inventory1->quantity - $request->new_quantity; $inventory1->save(); } else { $inventory1 = new \App\Inventory(); $inventory1->dealer_id = $request->dealer_id; $inventory1->warehouse_id = 24; $inventory1->product_brand_id = $token->product_company_id; $inventory1->product_id = $request->product_id; $inventory1->quantity = 0 - $request->new_quantity; $inventory1->unit_id = $token->unit_id; $inventory1->save(); } if (!is_null($inventory2)) { $inventory2->quantity = $inventory2->quantity + $product_loading->quantity; $inventory2->save(); } else { $inventory2 = new \App\Inventory(); $inventory2->dealer_id = $product_loading->dealers; $inventory2->warehouse_id = 24; $inventory2->product_brand_id = $token->product_company_id; $inventory2->product_id = $product_loading->regular_product_id; $inventory2->quantity = 0 + $product_loading->new_quantity; $inventory2->unit_id = $token->unit_id; $inventory2->save(); } } } if ($token->token_type == 2) { if ($request->dealers != $product_loading->dealer_id || $request->warehouse_id != $product_loading->from_warehouse_id || $request->product_id != $product_loading->product_id) { $inventory2 = \App\Inventory::where('dealer_id', $product_loading->dealer_id) ->where('warehouse_id', $product_loading->from_warehouse_id) ->where('product_brand_id', $token->product_company_id) ->where('product_id', $product_loading->product_id) ->first(); $inventory1 = \App\Inventory::where('dealer_id', $request->dealers) ->where('warehouse_id', $request->warehouse_id) ->where('product_brand_id', $token->product_company_id) ->where('product_id', $request->product_id) ->first(); if (!is_null($inventory1)) { $inventory1->quantity = $inventory1->quantity - $request->new_quantity; $inventory1->save(); } else { $inventory1 = new \App\Inventory(); $inventory1->dealer_id = $request->dealer_id; $inventory1->warehouse_id = $request->warehouse_id; $inventory1->product_brand_id = $token->product_company_id; $inventory1->product_id = $request->product_id; $inventory1->quantity = 0 - $request->new_quantity; $inventory1->unit_id = $token->unit_id; $inventory1->save(); } if (!is_null($inventory2)) { $inventory2->quantity = $inventory2->quantity + $product_loading->quantity; $inventory2->save(); } else { $inventory2 = new \App\Inventory(); $inventory2->dealer_id = $product_loading->dealers; $inventory2->warehouse_id = $product_loading->warehouse_id; $inventory2->product_brand_id = $token->product_company_id; $inventory2->product_id = $product_loading->regular_product_id; $inventory2->quantity = 0 + $product_loading->new_quantity; $inventory2->unit_id = $token->unit_id; $inventory2->save(); } } // $inventory = \App\Inventory::where('dealer_id', $request->dealers)->where('warehouse_id', $token->from_warehouse_id)->where('product_brand_id', $token->product_company_id)->where('product_id', $request->product_id)->first(); // if ($inventory) { // $inventory->quantity = $inventory->quantity - $request->regular_quantity; // $inventory->save(); // } else { // $inventory = new \App\Inventory(); // $inventory->dealer_id = $request->dealers; // $inventory->warehouse_id = $request->from_warehouse_id; // $inventory->product_brand_id = $token->product_company_id; // $inventory->product_id = $request->regular_product_id; // $inventory->unit_id = $token->unit_id; // $inventory->quantity = 0 - $request->regular_quantity; // $inventory->save(); // } } } } if ($product_loading->save()) { //$product_loading = \App\ProductLoading::where('product_loading_id',$request->loading_id)->first(); $response['flag'] = true; $response['message'] = "Product Loading Updated Successfully"; } else { $response['flag'] = false; $response['error'] = "Something Went Wrong"; } } } return response()->json($response); } public function loadingDetails($loading_id) { // dd($loading_id); $response = array(); // dd($warehouse_di_id); // $decoded_value = base64_decode($loading_slip_id); // $loadingSlipDetailsArray = explode(',', $decoded_value); $loadingDetails = \App\ProductLoading::find($loading_id); //dd($loadingDetails); if (!is_null($loadingDetails)) { $response['flag'] = true; $slips = 0; if ($loadingDetails->loading_slip_type == 1) { $slips = "Regular Slip"; } else { $slips = "Direct"; } $warehouse = $loadingDetails->from_warehouse_id; $warehouse_name = 0; if ($warehouse) { $warehouse_name = \App\Warehouse::where('id', $warehouse)->first(); } $response['dealer_name'] = $loadingDetails->dealer_name . $loadingDetails->dealer_id; $response['retailer_name'] = $loadingDetails->retailer_name; $response['token_no'] = $loadingDetails->token_id; $response['loading_slip_type'] = $slips; $response['quantity'] = $loadingDetails->quantity; $response['token_no'] = $loadingDetails->token_id; $response['freight'] = $loadingDetails->freight; $response['product_company_name'] = $loadingDetails->product_company_name; $response['product_name'] = $loadingDetails->product_name; $s = ''; $array = explode(' ', $loadingDetails->invoice_number); //dd($array); foreach ($array as $invoices) { $s .= "<option value=" . $invoices . ">" . $invoices . "</option>"; // array_push($s,$a); } $response['invoice'] = $s; $response['warehouse'] = $warehouse_name->name; } else { $response['flag'] = false; $response['message'] = "loading data not exits"; } return response()->json($response); } public function fetch_tally_data() { $xml_request = '<ENVELOPE> <HEADER> <VERSION>1</VERSION> <TALLYREQUEST>Export</TALLYREQUEST> <TYPE>Data</TYPE> <ID>List of Ledgers</ID> </HEADER> <BODY> <DESC> <TDL> <TDLMESSAGE> <REPORT NAME="List of Ledgers" ><FORMS>List of Ledgers</FORMS></REPORT> <FORM NAME="List of Ledgers" ><TOPPARTS>List of Ledgers</TOPPARTS> <XMLTAG>"List of Ledgers"</XMLTAG> </FORM> <PART NAME="List of Ledgers" ><TOPLINES>List of Ledgers</TOPLINES> <REPEAT>List of Ledgers : Collection of Ledgers</REPEAT> <SCROLLED>Vertical</SCROLLED></PART> <LINE NAME="List of Ledgers"><LEFTFIELDS>List of Ledgers</LEFTFIELDS></LINE> <FIELD NAME="List of Ledgers" ><XMLTAG>"NAME"</XMLTAG><SET>$Name</SET></FIELD> <COLLECTION NAME="Collection of Ledgers" ><TYPE>Ledger</TYPE></COLLECTION> </TDLMESSAGE> </TDL> </DESC> </BODY> </ENVELOPE> '; // Send the request to Tally and get the response $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:9000'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_request); $response = curl_exec($ch); curl_close($ch); // Parse the XML response $xml = simplexml_load_string($response); echo "<pre>"; print_r($xml); } public function fetch_group() { $xml_request = '<ENVELOPE> <HEADER> <VERSION>1</VERSION> <TALLYREQUEST>Export</TALLYREQUEST> <TYPE>Data</TYPE> <ID>List of Groups</ID> </HEADER> <BODY> <DESC> <TDL> <TDLMESSAGE> <REPORT NAME="List of Groups" ><FORMS>List of Groups</FORMS></REPORT> <FORM NAME="List of Groups" ><TOPPARTS>List of Groups</TOPPARTS> <XMLTAG>"List of Groups"</XMLTAG> </FORM> <PART NAME="List of Groups" ><TOPLINES>List of Groups</TOPLINES> <REPEAT>List of Groups : Collection of Groups</REPEAT> <SCROLLED>Vertical</SCROLLED></PART> <LINE NAME="List of Groups"><LEFTFIELDS>List of Groups</LEFTFIELDS></LINE> <FIELD NAME="List of Groups" ><XMLTAG>"NAME"</XMLTAG><SET>$Name</SET></FIELD> <COLLECTION NAME="Collection of Groups" ><TYPE>Groups</TYPE></COLLECTION> </TDLMESSAGE> </TDL> </DESC> </BODY> </ENVELOPE> '; // Send the request to Tally and get the response $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:9000'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_request); $response = curl_exec($ch); curl_close($ch); // Parse the XML response $xml = simplexml_load_string($response); echo "<pre>"; print_r($xml); } public function fetch_voucher_type() { $xml_request = '<ENVELOPE> <HEADER> <VERSION>1</VERSION> <TALLYREQUEST>Export</TALLYREQUEST> <TYPE>Data</TYPE> <ID>List of Voucher Type</ID> </HEADER> <BODY> <DESC> <TDL> <TDLMESSAGE> <REPORT NAME="List of Voucher Type" ><FORMS>List of Voucher Type</FORMS></REPORT> <FORM NAME="List of Voucher Type" ><TOPPARTS>List of Voucher Type</TOPPARTS> <XMLTAG>"List of Voucher Type"</XMLTAG> </FORM> <PART NAME="List of Voucher Type" ><TOPLINES>List of Voucher Type</TOPLINES> <REPEAT>List of Voucher Type : Collection of Voucher Type</REPEAT> <SCROLLED>Vertical</SCROLLED></PART> <LINE NAME="List of Voucher Type"><LEFTFIELDS>List of Voucher Type</LEFTFIELDS></LINE> <FIELD NAME="List of Voucher Type" ><XMLTAG>"NAME"</XMLTAG><SET>$Name</SET></FIELD> <COLLECTION NAME="Collection of Voucher Type" ><TYPE>Voucher Type</TYPE></COLLECTION> </TDLMESSAGE> </TDL> </DESC> </BODY> </ENVELOPE>'; // Send the request to Tally and get the response $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:9000'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_request); $response = curl_exec($ch); // Parse the XML response $xml = simplexml_load_string($response); echo "<pre>"; print_r($xml); curl_close($ch); } public function stocksummary() { $xml_request = '<ENVELOPE> <HEADER> <TALLYREQUEST>Export Data</TALLYREQUEST> </HEADER> <BODY> <EXPORTDATA> <REQUESTDESC> <STATICVARIABLES> <!-- Expand ALL levels in detailed format = Yes or No--> <EXPLODEALLLEVELS>YES</EXPLODEALLLEVELS> <!-- Format = Detailed or Condensed --> <!-- Yes means Detailed --> <!-- No means Condensed --> <EXPLODEFLAG>YES</EXPLODEFLAG> <!-- Show ALL Accts (incl Empty A/cs) = Yes or No--> <DSPSHOWALLACCOUNTS>Yes</DSPSHOWALLACCOUNTS> <!-- Show Opening balances = Yes or No --> <DSPSHOWOPENING>Yes</DSPSHOWOPENING> <!-- Show goods inwards = Yes or No --> <DSPSHOWINWARDS>YES</DSPSHOWINWARDS> <!-- Show goods outwards = Yes or No--> <DSPSHOWOUTWARDS>YES</DSPSHOWOUTWARDS> <!-- Show Closing balances = Yes or No --> <DSPSHOWCLOSING>Yes</DSPSHOWCLOSING> <!--Method of Information = Grouped or Item-wise--> <!-- Yes means Grouped--> <!-- No means Item-wise --> <ISITEMWISE>No</ISITEMWISE> </STATICVARIABLES> <REPORTNAME>Stock Summary</REPORTNAME> </REQUESTDESC> </EXPORTDATA> </BODY> </ENVELOPE>'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:9000'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_request); $response = curl_exec($ch); // Parse the XML response $xml = simplexml_load_string($response); echo "<pre>"; print_r($response); curl_close($ch); } public function fetch_stock_items() { $xml_request = '<ENVELOPE> <HEADER> <VERSION>1</VERSION> <TALLYREQUEST>Export</TALLYREQUEST> <TYPE>Data</TYPE> <ID>List of Stock Items</ID> </HEADER> <BODY> <DESC> <TDL> <TDLMESSAGE> <REPORT NAME="List of Stock Items" ><FORMS>List of Stock Items</FORMS></REPORT> <FORM NAME="List of Stock Items" ><TOPPARTS>List of Stock Items</TOPPARTS> <XMLTAG>"List of Stock Items"</XMLTAG> </FORM> <PART NAME="List of Stock Items" ><TOPLINES>List of Stock Items</TOPLINES> <REPEAT>List of Stock Items : Collection of Stock Items</REPEAT> <SCROLLED>Vertical</SCROLLED></PART> <LINE NAME="List of Stock Items"><LEFTFIELDS>List of Stock Items</LEFTFIELDS></LINE> <FIELD NAME="List of Stock Items" ><XMLTAG>"NAME"</XMLTAG><SET>$Name</SET></FIELD> <FIELD NAME="List of Stock Items" ><XMLTAG>"NAME"</XMLTAG><SET>$Name</SET></FIELD> <COLLECTION NAME="Collection of Stock Items" ><TYPE>Stock Items</TYPE></COLLECTION> </TDLMESSAGE> </TDL> </DESC> </BODY> </ENVELOPE> '; // Send the request to Tally and get the response $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:9000'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_request); echo $response = curl_exec($ch); // Parse the XML response $xml = simplexml_load_string($response); echo "<pre>"; print_r($xml); curl_close($ch); } public function CreateInvoiceVoucher() { $requestXML = '<ENVELOPE> <HEADER> <TALLYREQUEST>Import Data</TALLYREQUEST> </HEADER> <BODY> <IMPORTDATA> <REQUESTDESC> <REPORTNAME>Vouchers</REPORTNAME> <STATICVARIABLES> <SVCURRENTCOMPANY>MOSARAM SHIVRAM DAS</SVCURRENTCOMPANY> </STATICVARIABLES> </REQUESTDESC> <REQUESTDATA> <TALLYMESSAGE xmlns:UDF="TallyUDF"> <VOUCHER VCHTYPE="Sales" ACTION="Create"> <DATE>2023-02-14</DATE> <PARTYLEDGERNAME>Abida Parveen Khad Bhandar,Gajipur</PARTYLEDGERNAME> <VOUCHERTYPENAME>Sales</VOUCHERTYPENAME> <ALLLEDGERENTRIES.LIST> <LEDGERNAME>Cash</LEDGERNAME> <AMOUNT>-90.00</AMOUNT> </ALLLEDGERENTRIES.LIST> </VOUCHER> </TALLYMESSAGE> </REQUESTDATA> </IMPORTDATA> </BODY> </ENVELOPE>'; /* Actual code for importing goes here */ $headers = array("Content-type: text/xml", "Content-length: " . strlen($requestXML), "Connection: close"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:9000'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $data = curl_exec($ch); if (curl_errno($ch)) { print curl_error($ch); echo " something went wrong..... try later"; } else { echo " request accepted"; print $data; curl_close($ch); } } public function saleInput() { $requestXML = '<ENVELOPE> <HEADER> <TALLYREQUEST>Import Data</TALLYREQUEST> </HEADER> <BODY> <IMPORTDATA> <REQUESTDESC> <REPORTNAME>All Masters</REPORTNAME> <STATICVARIABLES> <SVCURRENTCOMPANY>MOSARAM SHIVRAM DAS</SVCURRENTCOMPANY> </STATICVARIABLES> </REQUESTDESC> <REQUESTDATA> <TALLYMESSAGE xmlns:UDF="TallyUDF"> <VOUCHER VCHTYPE="Tax Invoice" ACTION="Create" OBJVIEW="Invoice Voucher View"> <ADDRESS.LIST TYPE="String"> <ADDRESS>Narayanpur Terva</ADDRESS> </ADDRESS.LIST> <BASICBUYERADDRESS.LIST TYPE="String"> <BASICBUYERADDRESS>Narayanpur Terva</BASICBUYERADDRESS> </BASICBUYERADDRESS.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <DATE>20220402</DATE> <GUID>2fe275e4-4606-40d4-85e2-2f4047f002e3-00019cb6</GUID> <GSTREGISTRATIONTYPE>Consumer</GSTREGISTRATIONTYPE> <VATDEALERTYPE>Regular</VATDEALERTYPE> <STATENAME>Uttar Pradesh</STATENAME> <VOUCHERTYPENAME>Tax Invoice</VOUCHERTYPENAME> <ENTEREDBY>mrsd</ENTEREDBY> <COUNTRYOFRESIDENCE>India</COUNTRYOFRESIDENCE> <PLACEOFSUPPLY>Uttar Pradesh</PLACEOFSUPPLY> <PARTYNAME>Aasara Enterprises,Narayanpur Terva</PARTYNAME> <PARTYLEDGERNAME>Aasara Enterprises,Narayanpur Terva</PARTYLEDGERNAME> <PARTYMAILINGNAME>Aasara Enterprises,Narayanpur Terva</PARTYMAILINGNAME> <VOUCHERNUMBER>2</VOUCHERNUMBER> <BASICBASEPARTYNAME>Aasara Enterprises,Narayanpur Terva</BASICBASEPARTYNAME> <CSTFORMISSUETYPE/> <CSTFORMRECVTYPE/> <FBTPAYMENTTYPE>Default</FBTPAYMENTTYPE> <PERSISTEDVIEW>Invoice Voucher View</PERSISTEDVIEW> <BASICBUYERNAME>Aasara Enterprises,Narayanpur Terva</BASICBUYERNAME> <CONSIGNEECOUNTRYNAME>India</CONSIGNEECOUNTRYNAME> <VCHGSTCLASS/> <VCHENTRYMODE>Item Invoice</VCHENTRYMODE> <VOUCHERTYPEORIGNAME>Sales</VOUCHERTYPEORIGNAME> <DIFFACTUALQTY>No</DIFFACTUALQTY> <ISMSTFROMSYNC>No</ISMSTFROMSYNC> <ISDELETED>No</ISDELETED> <ISSECURITYONWHENENTERED>No</ISSECURITYONWHENENTERED> <ASORIGINAL>No</ASORIGINAL> <AUDITED>No</AUDITED> <FORJOBCOSTING>No</FORJOBCOSTING> <ISOPTIONAL>No</ISOPTIONAL> <EFFECTIVEDATE>20220401</EFFECTIVEDATE> <USEFOREXCISE>No</USEFOREXCISE> <ISFORJOBWORKIN>No</ISFORJOBWORKIN> <ALLOWCONSUMPTION>No</ALLOWCONSUMPTION> <USEFORINTEREST>No</USEFORINTEREST> <USEFORGAINLOSS>No</USEFORGAINLOSS> <USEFORGODOWNTRANSFER>No</USEFORGODOWNTRANSFER> <USEFORCOMPOUND>No</USEFORCOMPOUND> <USEFORSERVICETAX>No</USEFORSERVICETAX> <ISONHOLD>No</ISONHOLD> <ISBOENOTAPPLICABLE>No</ISBOENOTAPPLICABLE> <ISGSTSECSEVENAPPLICABLE>No</ISGSTSECSEVENAPPLICABLE> <ISEXCISEVOUCHER>No</ISEXCISEVOUCHER> <EXCISETAXOVERRIDE>No</EXCISETAXOVERRIDE> <USEFORTAXUNITTRANSFER>No</USEFORTAXUNITTRANSFER> <IGNOREPOSVALIDATION>No</IGNOREPOSVALIDATION> <EXCISEOPENING>No</EXCISEOPENING> <USEFORFINALPRODUCTION>No</USEFORFINALPRODUCTION> <ISTDSOVERRIDDEN>No</ISTDSOVERRIDDEN> <ISTCSOVERRIDDEN>No</ISTCSOVERRIDDEN> <ISTDSTCSCASHVCH>No</ISTDSTCSCASHVCH> <INCLUDEADVPYMTVCH>No</INCLUDEADVPYMTVCH> <ISSUBWORKSCONTRACT>No</ISSUBWORKSCONTRACT> <ISVATOVERRIDDEN>No</ISVATOVERRIDDEN> <IGNOREORIGVCHDATE>No</IGNOREORIGVCHDATE> <ISVATPAIDATCUSTOMS>No</ISVATPAIDATCUSTOMS> <ISDECLAREDTOCUSTOMS>No</ISDECLAREDTOCUSTOMS> <ISSERVICETAXOVERRIDDEN>No</ISSERVICETAXOVERRIDDEN> <ISISDVOUCHER>No</ISISDVOUCHER> <ISEXCISEOVERRIDDEN>No</ISEXCISEOVERRIDDEN> <ISEXCISESUPPLYVCH>No</ISEXCISESUPPLYVCH> <ISGSTOVERRIDDEN>No</ISGSTOVERRIDDEN> <GSTNOTEXPORTED>No</GSTNOTEXPORTED> <IGNOREGSTINVALIDATION>No</IGNOREGSTINVALIDATION> <ISGSTREFUND>No</ISGSTREFUND> <OVRDNEWAYBILLAPPLICABILITY>No</OVRDNEWAYBILLAPPLICABILITY> <ISVATPRINCIPALACCOUNT>No</ISVATPRINCIPALACCOUNT> <IGNOREEINVVALIDATION>No</IGNOREEINVVALIDATION> <IRNJSONEXPORTED>No</IRNJSONEXPORTED> <IRNCANCELLED>No</IRNCANCELLED> <ISSHIPPINGWITHINSTATE>No</ISSHIPPINGWITHINSTATE> <ISOVERSEASTOURISTTRANS>No</ISOVERSEASTOURISTTRANS> <ISDESIGNATEDZONEPARTY>No</ISDESIGNATEDZONEPARTY> <ISCANCELLED>No</ISCANCELLED> <HASCASHFLOW>No</HASCASHFLOW> <ISPOSTDATED>No</ISPOSTDATED> <USETRACKINGNUMBER>No</USETRACKINGNUMBER> <ISINVOICE>Yes</ISINVOICE> <MFGJOURNAL>No</MFGJOURNAL> <HASDISCOUNTS>No</HASDISCOUNTS> <ASPAYSLIP>No</ASPAYSLIP> <ISCOSTCENTRE>No</ISCOSTCENTRE> <ISSTXNONREALIZEDVCH>No</ISSTXNONREALIZEDVCH> <ISEXCISEMANUFACTURERON>No</ISEXCISEMANUFACTURERON> <ISBLANKCHEQUE>No</ISBLANKCHEQUE> <ISVOID>No</ISVOID> <ORDERLINESTATUS>No</ORDERLINESTATUS> <VATISAGNSTCANCSALES>No</VATISAGNSTCANCSALES> <VATISPURCEXEMPTED>No</VATISPURCEXEMPTED> <ISVATRESTAXINVOICE>No</ISVATRESTAXINVOICE> <VATISASSESABLECALCVCH>No</VATISASSESABLECALCVCH> <ISVATDUTYPAID>Yes</ISVATDUTYPAID> <ISDELIVERYSAMEASCONSIGNEE>No</ISDELIVERYSAMEASCONSIGNEE> <ISDISPATCHSAMEASCONSIGNOR>No</ISDISPATCHSAMEASCONSIGNOR> <ISDELETEDVCHRETAINED>No</ISDELETEDVCHRETAINED> <CHANGEVCHMODE>No</CHANGEVCHMODE> <RESETIRNQRCODE>No</RESETIRNQRCODE> <ALLINVENTORYENTRIES.LIST> <STOCKITEMNAME>Careto</STOCKITEMNAME> <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE> <ISLASTDEEMEDPOSITIVE>No</ISLASTDEEMEDPOSITIVE> <ISAUTONEGATE>No</ISAUTONEGATE> <ISCUSTOMSCLEARANCE>No</ISCUSTOMSCLEARANCE> <ISTRACKCOMPONENT>No</ISTRACKCOMPONENT> <ISTRACKPRODUCTION>No</ISTRACKPRODUCTION> <ISPRIMARYITEM>No</ISPRIMARYITEM> <ISSCRAP>No</ISSCRAP> <RATE>10.00/Drum</RATE> <AMOUNT>100.00</AMOUNT> <ACTUALQTY> 10 Drum</ACTUALQTY> <BILLEDQTY> 10 Drum</BILLEDQTY> <BATCHALLOCATIONS.LIST> <GODOWNNAME>JAIN GODOWN</GODOWNNAME> <BATCHNAME>Primary Batch</BATCHNAME> <DESTINATIONGODOWNNAME>JAIN GODOWN</DESTINATIONGODOWNNAME> <INDENTNO/> <ORDERNO/> <TRACKINGNUMBER/> <DYNAMICCSTISCLEARED>No</DYNAMICCSTISCLEARED> <AMOUNT>100.00</AMOUNT> <ACTUALQTY> 10 Drum</ACTUALQTY> <BILLEDQTY> 10 Drum</BILLEDQTY> </BATCHALLOCATIONS.LIST> <ACCOUNTINGALLOCATIONS.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <LEDGERNAME>Sales @ 18% (Gst)</LEDGERNAME> <GSTCLASS/> <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE> <LEDGERFROMITEM>No</LEDGERFROMITEM> <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES> <ISPARTYLEDGER>No</ISPARTYLEDGER> <ISLASTDEEMEDPOSITIVE>No</ISLASTDEEMEDPOSITIVE> <ISCAPVATTAXALTERED>No</ISCAPVATTAXALTERED> <ISCAPVATNOTCLAIMED>No</ISCAPVATNOTCLAIMED> <AMOUNT>100.00</AMOUNT> </ACCOUNTINGALLOCATIONS.LIST> </ALLINVENTORYENTRIES.LIST> <LEDGERENTRIES.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <LEDGERNAME>Aasara Enterprises,Narayanpur Terva</LEDGERNAME> <GSTCLASS/> <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE> <LEDGERFROMITEM>No</LEDGERFROMITEM> <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES> <ISPARTYLEDGER>Yes</ISPARTYLEDGER> <ISLASTDEEMEDPOSITIVE>Yes</ISLASTDEEMEDPOSITIVE> <ISCAPVATTAXALTERED>No</ISCAPVATTAXALTERED> <ISCAPVATNOTCLAIMED>No</ISCAPVATNOTCLAIMED> <AMOUNT>-118.00</AMOUNT> <BILLALLOCATIONS.LIST> <NAME>1</NAME> <BILLTYPE>Agst Ref</BILLTYPE> <TDSDEDUCTEEISSPECIALRATE>No</TDSDEDUCTEEISSPECIALRATE> <AMOUNT>-118.00</AMOUNT> </BILLALLOCATIONS.LIST> </LEDGERENTRIES.LIST> <LEDGERENTRIES.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <BASICRATEOFINVOICETAX.LIST TYPE="Number"> <BASICRATEOFINVOICETAX> 9</BASICRATEOFINVOICETAX> </BASICRATEOFINVOICETAX.LIST> <LEDGERNAME>Input CGST @9%</LEDGERNAME> <GSTCLASS/> <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE> <LEDGERFROMITEM>No</LEDGERFROMITEM> <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES> <ISPARTYLEDGER>No</ISPARTYLEDGER> <ISLASTDEEMEDPOSITIVE>No</ISLASTDEEMEDPOSITIVE> <ISCAPVATTAXALTERED>No</ISCAPVATTAXALTERED> <ISCAPVATNOTCLAIMED>No</ISCAPVATNOTCLAIMED> <AMOUNT>9.00</AMOUNT> <VATEXPAMOUNT>9.00</VATEXPAMOUNT> </LEDGERENTRIES.LIST> <LEDGERENTRIES.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <LEDGERNAME>Input SGST@9%</LEDGERNAME> <GSTCLASS/> <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE> <LEDGERFROMITEM>No</LEDGERFROMITEM> <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES> <ISPARTYLEDGER>No</ISPARTYLEDGER> <ISLASTDEEMEDPOSITIVE>No</ISLASTDEEMEDPOSITIVE> <ISCAPVATTAXALTERED>No</ISCAPVATTAXALTERED> <ISCAPVATNOTCLAIMED>No</ISCAPVATNOTCLAIMED> <AMOUNT>9.00</AMOUNT> <VATEXPAMOUNT>9.00</VATEXPAMOUNT> </LEDGERENTRIES.LIST> </VOUCHER> <TALLYMESSAGE xmlns:UDF="TallyUDF"> <COMPANY> <REMOTECMPINFO.LIST MERGE="Yes"> <NAME>2fe275e4-4606-40d4-85e2-2f4047f002e3</NAME> <REMOTECMPNAME>MOSARAM SHIVRAM DAS</REMOTECMPNAME> <REMOTECMPSTATE>Uttar Pradesh</REMOTECMPSTATE> </REMOTECMPINFO.LIST> </COMPANY> </TALLYMESSAGE> </REQUESTDATA> </IMPORTDATA> </BODY> </ENVELOPE>'; $headers = array("Content-type: text/xml", "Content-length: " . strlen($requestXML), "Connection: close"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:9000'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $data = curl_exec($ch); if (curl_errno($ch)) { print curl_error($ch); echo " something went wrong..... try later"; } else { echo " request accepted"; print $data; curl_close($ch); } } public function InputOpeningBalance() { $requestXML = '<ENVELOPE> <HEADER> <VERSION>1</VERSION> <TALLYREQUEST>Import</TALLYREQUEST> <TYPE>Data</TYPE> <ID>All Masters</ID> </HEADER> <BODY> <DESC> <STATICVARIABLES> <IMPORTDUPS>@@DUPCOMBINE</IMPORTDUPS> </STATICVARIABLES> </DESC> <DATA> <TALLYMESSAGE> <LEDGER NAME="Adarsh Khad Bhandar,Sherpur" Action = "Create"> <NAME>Adarsh Khad Bhandar,Sherpur</NAME> <PARENT>Sundry Debtors</PARENT> <OPENINGBALANCE>-12500</OPENINGBALANCE> </LEDGER> </TALLYMESSAGE> </DATA> </BODY> </ENVELOPE>'; /* Actual code for importing goes here */ $headers = array("Content-type: text/xml", "Content-length: " . strlen($requestXML), "Connection: close"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:9000'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $data = curl_exec($ch); if (curl_errno($ch)) { print curl_error($ch); echo " something went wrong..... try later"; } else { echo " request accepted"; curl_close($ch); } } public function insert_tally_data() { $ledgerName = "1"; $ledgerParent = "mohit"; $ledgerGroup = "mohit"; $xml = new SimpleXMLElement("<ENVELOPE></ENVELOPE>"); $xml->addChild("HEADER"); $xml->HEADER->addChild("TALLYREQUEST", "Import Data"); $xml->addChild("BODY"); $xml->BODY->addChild("IMPORTDATA"); $xml->BODY->IMPORTDATA->addChild("REQUESTDESC"); $xml->BODY->IMPORTDATA->REQUESTDESC->addChild("REPORTNAME", "Ledgers"); $xml->BODY->IMPORTDATA->REQUESTDESC->addChild("STATICVARIABLES"); $xml->BODY->IMPORTDATA->REQUESTDESC->STATICVARIABLES->addChild("SVCURRENTCOMPANY", "Mohit"); $xml->BODY->IMPORTDATA->addChild("REQUESTDATA"); $ledger = $xml->BODY->IMPORTDATA->REQUESTDATA->addChild("TALLYMESSAGE"); $ledger->addAttribute("xmlns:UDF", "TallyUDF"); $ledger->addChild("LEDGER NAME", $ledgerName); $ledger->addChild("PARENT", $ledgerParent); $ledger->addChild("GROUP NAME", $ledgerGroup); $response = Response::make($xml->asXML(), 200); $response->header('Content-Type', 'text/xml'); echo $response; } public function tally_insert_credit_amount(Request $request) { $bankName = "AXIS BANK LTS"; $accountNumber = "1234567890"; $transactionDate = "2022-12-31"; $transactionAmount = "10000.00"; $transactionType = "Credit"; $transactionNarration = "Test transaction"; $xml = new SimpleXMLElement("<ENVELOPE></ENVELOPE>"); $xml->addChild("HEADER"); $xml->HEADER->addChild("TALLYREQUEST", "Import Data"); $xml->addChild("BODY"); $xml->BODY->addChild("IMPORTDATA"); $xml->BODY->IMPORTDATA->addChild("REQUESTDESC"); $xml->BODY->IMPORTDATA->REQUESTDESC->addChild("REPORTNAME", "Bank Transactions"); $xml->BODY->IMPORTDATA->REQUESTDESC->addChild("STATICVARIABLES"); $xml->BODY->IMPORTDATA->REQUESTDESC->STATICVARIABLES->addChild("SVCURRENTCOMPANY", "Logimetrix Tech Solutions"); $xml->BODY->IMPORTDATA->addChild("REQUESTDATA"); $bankTransaction = $xml->BODY->IMPORTDATA->REQUESTDATA->addChild("TALLYMESSAGE"); $bankTransaction->addAttribute("xmlns:UDF", "TallyUDF"); $bankTransaction->addChild("BANKALLOCATIONS.LIST"); $bankTransaction->BANKALLOCATIONS_LIST->addChild("DATE", $transactionDate); $bankTransaction->BANKALLOCATIONS_LIST->addChild("INSTRUMENTDATE", $transactionDate); $bankTransaction->BANKALLOCATIONS_LIST->addChild("INSTRUMENTNUMBER", $accountNumber); $bankTransaction->BANKALLOCATIONS_LIST->addChild("NAME", $bankName); $bankTransaction->BANKALLOCATIONS_LIST->addChild("AMOUNT", $transactionAmount); $bankTransaction->BANKALLOCATIONS_LIST->addChild("TYPE", $transactionType); $bankTransaction->BANKALLOCATIONS_LIST->addChild("NARRATION", $transactionNarration); $response = Response::make($xml->asXML(), 200); $response->header('Content-Type', 'text/xml'); echo $response; } // public function addCompany(Request $request) // { // $xmlRequest = '<ENVELOPE> // <HEADER> // <TALLYREQUEST>Import Data</TALLYREQUEST> // </HEADER> // <BODY> // <IMPORTDATA> // <REQUESTDESC> // <REPORTNAME>Company</REPORTNAME> // <STATICVARIABLES> // <SVCURRENTCOMPANY>Mohit</SVCURRENTCOMPANY> // </STATICVARIABLES> // <TDL> // <TDLMESSAGE> // <XMLTAG> // <![CDATA[ // <COMPANY> // <NAME>Logimetrix Techsolution pvt. ltd.</NAME> // <ADDRESS.LIST> // <ADDRESS> // <ADDRESS1>Vikash khand </ADDRESS1> // <CITY>lucknow</CITY> // <STATE>Uttar Pradesh</STATE> // <PINCODE>226010</PINCODE> // <COUNTRY>India</COUNTRY> // </ADDRESS> // </ADDRESS.LIST> // </COMPANY> // ]]> // </XMLTAG> // </TDLMESSAGE> // </TDL> // </REQUESTDESC> // </IMPORTDATA> // </BODY> // </ENVELOPE>'; // $url = "http://localhost:9000"; // $ch = curl_init(); // curl_setopt($ch, CURLOPT_URL, $url); // curl_setopt($ch, CURLOPT_POST, 1); // curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); // curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $response = curl_exec($ch); // curl_close($ch); // echo $response; // // Do something with the response // } public function datainsert(Request $request) { $xmlRequest = '<ENVELOPE> <HEADER> <TALLYREQUEST>Import Data</TALLYREQUEST> </HEADER> <BODY> <IMPORTDATA> <REQUESTDESC> <REPORTNAME>Vouchers</REPORTNAME> <STATICVARIABLES> <SVCURRENTCOMPANY>MOSARAM SHIVRAM DAS</SVCURRENTCOMPANY> </STATICVARIABLES> </REQUESTDESC> <REQUESTDATA> <TALLYMESSAGE xmlns:UDF="TallyUDF"> <VOUCHER REMOTEID="2fe275e4-4606-40d4-85e2-2f4047f002e3-00019cf5" VCHKEY="2fe275e4-4606-40d4-85e2-2f4047f002e3-0000ae6c:000001f0" VCHTYPE="TAX INVOICE" ACTION="Create" OBJVIEW="Invoice Voucher View"> <ADDRESS.LIST TYPE="String"> <ADDRESS>Tambour</ADDRESS> </ADDRESS.LIST> <DISPATCHFROMADDRESS.LIST TYPE="String"> <DISPATCHFROMADDRESS>567,Gajanand Bhavan,</DISPATCHFROMADDRESS> <DISPATCHFROMADDRESS>Dr. B. D. Kapoor Marg</DISPATCHFROMADDRESS> <DISPATCHFROMADDRESS>Vijay Laxmi Nagar</DISPATCHFROMADDRESS> <DISPATCHFROMADDRESS>Sitapur (U.P.)</DISPATCHFROMADDRESS> <DISPATCHFROMADDRESS>261001</DISPATCHFROMADDRESS> </DISPATCHFROMADDRESS.LIST> <BASICBUYERADDRESS.LIST TYPE="String"> <BASICBUYERADDRESS>Tambour</BASICBUYERADDRESS> </BASICBUYERADDRESS.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <DATE>20220402</DATE> <GUID>2fe275e4-4606-40d4-85e2-2f4047f002e3-00019cf5</GUID> <GSTREGISTRATIONTYPE>Consumer</GSTREGISTRATIONTYPE> <VATDEALERTYPE/> <STATENAME>Uttar Pradesh</STATENAME> <VOUCHERTYPENAME>TAX INVOICE</VOUCHERTYPENAME> <ENTEREDBY>mrsd</ENTEREDBY> <COUNTRYOFRESIDENCE>India</COUNTRYOFRESIDENCE> <PLACEOFSUPPLY>Uttar Pradesh</PLACEOFSUPPLY> <PARTYNAME>Ashok Khad Bhandar ,Tambour</PARTYNAME> <PARTYLEDGERNAME>Ashok Khad Bhandar ,Tambour</PARTYLEDGERNAME> <PARTYMAILINGNAME>Ashok Khad Bhandar ,Tambour</PARTYMAILINGNAME> <DISPATCHFROMNAME>MOSARAM SHIVRAM DAS</DISPATCHFROMNAME> <DISPATCHFROMSTATENAME>Uttar Pradesh</DISPATCHFROMSTATENAME> <DISPATCHFROMPINCODE>261001</DISPATCHFROMPINCODE> <DISPATCHFROMPLACE>SITAPUR</DISPATCHFROMPLACE> <CONSIGNEEMAILINGNAME>Ashok Khad Bhandar,Tambour</CONSIGNEEMAILINGNAME> <CONSIGNEESTATENAME>Uttar Pradesh</CONSIGNEESTATENAME> <VOUCHERNUMBER>MRSD/21-22/5984</VOUCHERNUMBER> <BASICBASEPARTYNAME>Ashok Khad Bhandar ,Tambour</BASICBASEPARTYNAME> <CSTFORMISSUETYPE/> <CSTFORMRECVTYPE/> <FBTPAYMENTTYPE>Default</FBTPAYMENTTYPE> <PERSISTEDVIEW>Invoice Voucher View</PERSISTEDVIEW> <BASICBUYERNAME>Ashok Khad Bhandar,Tambour</BASICBUYERNAME> <CONSIGNEECOUNTRYNAME>India</CONSIGNEECOUNTRYNAME> <VCHGSTCLASS/> <VCHENTRYMODE>Item Invoice</VCHENTRYMODE> <VOUCHERTYPEORIGNAME>TAX INVOICE</VOUCHERTYPEORIGNAME> <DIFFACTUALQTY>No</DIFFACTUALQTY> <ISMSTFROMSYNC>No</ISMSTFROMSYNC> <ISDELETED>No</ISDELETED> <ISSECURITYONWHENENTERED>No</ISSECURITYONWHENENTERED> <ASORIGINAL>No</ASORIGINAL> <AUDITED>No</AUDITED> <FORJOBCOSTING>No</FORJOBCOSTING> <ISOPTIONAL>No</ISOPTIONAL> <EFFECTIVEDATE>20220402</EFFECTIVEDATE> <USEFOREXCISE>No</USEFOREXCISE> <ISFORJOBWORKIN>No</ISFORJOBWORKIN> <ALLOWCONSUMPTION>No</ALLOWCONSUMPTION> <USEFORINTEREST>No</USEFORINTEREST> <USEFORGAINLOSS>No</USEFORGAINLOSS> <USEFORGODOWNTRANSFER>No</USEFORGODOWNTRANSFER> <USEFORCOMPOUND>No</USEFORCOMPOUND> <USEFORSERVICETAX>No</USEFORSERVICETAX> <ISONHOLD>No</ISONHOLD> <ISBOENOTAPPLICABLE>No</ISBOENOTAPPLICABLE> <ISGSTSECSEVENAPPLICABLE>No</ISGSTSECSEVENAPPLICABLE> <ISEXCISEVOUCHER>No</ISEXCISEVOUCHER> <EXCISETAXOVERRIDE>No</EXCISETAXOVERRIDE> <USEFORTAXUNITTRANSFER>No</USEFORTAXUNITTRANSFER> <IGNOREPOSVALIDATION>No</IGNOREPOSVALIDATION> <EXCISEOPENING>No</EXCISEOPENING> <USEFORFINALPRODUCTION>No</USEFORFINALPRODUCTION> <ISTDSOVERRIDDEN>No</ISTDSOVERRIDDEN> <ISTCSOVERRIDDEN>No</ISTCSOVERRIDDEN> <ISTDSTCSCASHVCH>No</ISTDSTCSCASHVCH> <INCLUDEADVPYMTVCH>No</INCLUDEADVPYMTVCH> <ISSUBWORKSCONTRACT>No</ISSUBWORKSCONTRACT> <ISVATOVERRIDDEN>No</ISVATOVERRIDDEN> <IGNOREORIGVCHDATE>No</IGNOREORIGVCHDATE> <ISVATPAIDATCUSTOMS>No</ISVATPAIDATCUSTOMS> <ISDECLAREDTOCUSTOMS>No</ISDECLAREDTOCUSTOMS> <ISSERVICETAXOVERRIDDEN>No</ISSERVICETAXOVERRIDDEN> <ISISDVOUCHER>No</ISISDVOUCHER> <ISEXCISEOVERRIDDEN>No</ISEXCISEOVERRIDDEN> <ISEXCISESUPPLYVCH>No</ISEXCISESUPPLYVCH> <ISGSTOVERRIDDEN>No</ISGSTOVERRIDDEN> <GSTNOTEXPORTED>No</GSTNOTEXPORTED> <IGNOREGSTINVALIDATION>No</IGNOREGSTINVALIDATION> <ISGSTREFUND>No</ISGSTREFUND> <OVRDNEWAYBILLAPPLICABILITY>No</OVRDNEWAYBILLAPPLICABILITY> <ISVATPRINCIPALACCOUNT>No</ISVATPRINCIPALACCOUNT> <IGNOREEINVVALIDATION>No</IGNOREEINVVALIDATION> <IRNJSONEXPORTED>No</IRNJSONEXPORTED> <IRNCANCELLED>No</IRNCANCELLED> <ISSHIPPINGWITHINSTATE>No</ISSHIPPINGWITHINSTATE> <ISOVERSEASTOURISTTRANS>No</ISOVERSEASTOURISTTRANS> <ISDESIGNATEDZONEPARTY>No</ISDESIGNATEDZONEPARTY> <ISCANCELLED>No</ISCANCELLED> <HASCASHFLOW>No</HASCASHFLOW> <ISPOSTDATED>No</ISPOSTDATED> <USETRACKINGNUMBER>No</USETRACKINGNUMBER> <ISINVOICE>Yes</ISINVOICE> <MFGJOURNAL>No</MFGJOURNAL> <HASDISCOUNTS>No</HASDISCOUNTS> <ASPAYSLIP>No</ASPAYSLIP> <ISCOSTCENTRE>No</ISCOSTCENTRE> <ISSTXNONREALIZEDVCH>No</ISSTXNONREALIZEDVCH> <ISEXCISEMANUFACTURERON>No</ISEXCISEMANUFACTURERON> <ISBLANKCHEQUE>No</ISBLANKCHEQUE> <ISVOID>No</ISVOID> <ORDERLINESTATUS>No</ORDERLINESTATUS> <VATISAGNSTCANCSALES>No</VATISAGNSTCANCSALES> <VATISPURCEXEMPTED>No</VATISPURCEXEMPTED> <ISVATRESTAXINVOICE>No</ISVATRESTAXINVOICE> <VATISASSESABLECALCVCH>No</VATISASSESABLECALCVCH> <ISVATDUTYPAID>Yes</ISVATDUTYPAID> <ISDELIVERYSAMEASCONSIGNEE>No</ISDELIVERYSAMEASCONSIGNEE> <ISDISPATCHSAMEASCONSIGNOR>No</ISDISPATCHSAMEASCONSIGNOR> <ISDELETEDVCHRETAINED>No</ISDELETEDVCHRETAINED> <CHANGEVCHMODE>No</CHANGEVCHMODE> <RESETIRNQRCODE>No</RESETIRNQRCODE> <ALTERID> 143592</ALTERID> <MASTERID> 105717</MASTERID> <VOUCHERKEY>191778879701488</VOUCHERKEY> <EWAYBILLDETAILS.LIST> <CONSIGNORADDRESS.LIST TYPE="String"> <CONSIGNORADDRESS>567,Gajanand Bhavan,, Dr. B. D. Kapoor Marg, Vijay Laxmi Nagar, Sitapur (U.P.), 261001</CONSIGNORADDRESS> </CONSIGNORADDRESS.LIST> <CONSIGNEEADDRESS.LIST TYPE="String"> <CONSIGNEEADDRESS>Tambour</CONSIGNEEADDRESS> </CONSIGNEEADDRESS.LIST> <CONSIGNEEPINCODE>0</CONSIGNEEPINCODE> <CONSIGNORPLACE>SITAPUR</CONSIGNORPLACE> <CONSIGNORPINCODE>261001</CONSIGNORPINCODE> <SHIPPEDFROMSTATE>Uttar Pradesh</SHIPPEDFROMSTATE> <SHIPPEDTOSTATE>Uttar Pradesh</SHIPPEDTOSTATE> <IGNOREGSTINVALIDATION>No</IGNOREGSTINVALIDATION> <ISCANCELLED>No</ISCANCELLED> <ISCANCELPENDING>No</ISCANCELPENDING> <IGNOREGENERATIONVALIDATION>No</IGNOREGENERATIONVALIDATION> <ISEXPORTEDFORGENERATION>No</ISEXPORTEDFORGENERATION> <TRANSPORTDETAILS.LIST> <TRANSPORTMODE>1 - Road</TRANSPORTMODE> <OLDVEHICLETYPE/> <IGNOREVEHICLENOVALIDATION>UP-4848484848484</IGNOREVEHICLENOVALIDATION> <ISTRANSIDPENDING>No</ISTRANSIDPENDING> <ISTRANSIDUPDATED>No</ISTRANSIDUPDATED> <IGNORETRANSIDVALIDATION>No</IGNORETRANSIDVALIDATION> <ISEXPORTEDFORTRANSPORTERID>No</ISEXPORTEDFORTRANSPORTERID> <ISPARTBPENDING>No</ISPARTBPENDING> <ISPARTBUPDATED>No</ISPARTBUPDATED> <IGNOREPARTBVALIDATION>No</IGNOREPARTBVALIDATION> <ISEXPORTEDFORPARTB>No</ISEXPORTEDFORPARTB> </TRANSPORTDETAILS.LIST> <EXTENSIONDETAILS.LIST> </EXTENSIONDETAILS.LIST> </EWAYBILLDETAILS.LIST> <EXCLUDEDTAXATIONS.LIST> </EXCLUDEDTAXATIONS.LIST> <OLDAUDITENTRIES.LIST> </OLDAUDITENTRIES.LIST> <ACCOUNTAUDITENTRIES.LIST> </ACCOUNTAUDITENTRIES.LIST> <AUDITENTRIES.LIST> </AUDITENTRIES.LIST> <DUTYHEADDETAILS.LIST> </DUTYHEADDETAILS.LIST> <ALLINVENTORYENTRIES.LIST> <STOCKITEMNAME>Butachlor</STOCKITEMNAME> <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE> <ISLASTDEEMEDPOSITIVE>No</ISLASTDEEMEDPOSITIVE> <ISAUTONEGATE>No</ISAUTONEGATE> <ISCUSTOMSCLEARANCE>No</ISCUSTOMSCLEARANCE> <ISTRACKCOMPONENT>No</ISTRACKCOMPONENT> <ISTRACKPRODUCTION>No</ISTRACKPRODUCTION> <ISPRIMARYITEM>No</ISPRIMARYITEM> <ISSCRAP>No</ISSCRAP> <RATE>84.75/ltr</RATE> <AMOUNT>1694.92</AMOUNT> <ACTUALQTY> 20.0 ltr</ACTUALQTY> <BILLEDQTY> 20.0 ltr</BILLEDQTY> <BATCHALLOCATIONS.LIST> <GODOWNNAME>JAIN GODOWN</GODOWNNAME> <BATCHNAME>Primary Batch</BATCHNAME> <DESTINATIONGODOWNNAME>JAIN GODOWN</DESTINATIONGODOWNNAME> <INDENTNO/> <ORDERNO/> <TRACKINGNUMBER/> <DYNAMICCSTISCLEARED>No</DYNAMICCSTISCLEARED> <AMOUNT>1694.92</AMOUNT> <ACTUALQTY> 20.0 ltr</ACTUALQTY> <BILLEDQTY> 20.0 ltr</BILLEDQTY> <ADDITIONALDETAILS.LIST> </ADDITIONALDETAILS.LIST> <VOUCHERCOMPONENTLIST.LIST> </VOUCHERCOMPONENTLIST.LIST> </BATCHALLOCATIONS.LIST> <ACCOUNTINGALLOCATIONS.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <LEDGERNAME>Sales @ 18% (Gst)</LEDGERNAME> <GSTCLASS/> <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE> <LEDGERFROMITEM>No</LEDGERFROMITEM> <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES> <ISPARTYLEDGER>No</ISPARTYLEDGER> <ISLASTDEEMEDPOSITIVE>No</ISLASTDEEMEDPOSITIVE> <ISCAPVATTAXALTERED>No</ISCAPVATTAXALTERED> <ISCAPVATNOTCLAIMED>No</ISCAPVATNOTCLAIMED> <AMOUNT>1694.92</AMOUNT> <SERVICETAXDETAILS.LIST> </SERVICETAXDETAILS.LIST> <BANKALLOCATIONS.LIST> </BANKALLOCATIONS.LIST> <BILLALLOCATIONS.LIST> </BILLALLOCATIONS.LIST> <INTERESTCOLLECTION.LIST> </INTERESTCOLLECTION.LIST> <OLDAUDITENTRIES.LIST> </OLDAUDITENTRIES.LIST> <ACCOUNTAUDITENTRIES.LIST> </ACCOUNTAUDITENTRIES.LIST> <AUDITENTRIES.LIST> </AUDITENTRIES.LIST> <INPUTCRALLOCS.LIST> </INPUTCRALLOCS.LIST> <DUTYHEADDETAILS.LIST> </DUTYHEADDETAILS.LIST> <EXCISEDUTYHEADDETAILS.LIST> </EXCISEDUTYHEADDETAILS.LIST> <RATEDETAILS.LIST> </RATEDETAILS.LIST> <SUMMARYALLOCS.LIST> </SUMMARYALLOCS.LIST> <STPYMTDETAILS.LIST> </STPYMTDETAILS.LIST> <EXCISEPAYMENTALLOCATIONS.LIST> </EXCISEPAYMENTALLOCATIONS.LIST> <TAXBILLALLOCATIONS.LIST> </TAXBILLALLOCATIONS.LIST> <TAXOBJECTALLOCATIONS.LIST> </TAXOBJECTALLOCATIONS.LIST> <TDSEXPENSEALLOCATIONS.LIST> </TDSEXPENSEALLOCATIONS.LIST> <VATSTATUTORYDETAILS.LIST> </VATSTATUTORYDETAILS.LIST> <COSTTRACKALLOCATIONS.LIST> </COSTTRACKALLOCATIONS.LIST> <REFVOUCHERDETAILS.LIST> </REFVOUCHERDETAILS.LIST> <INVOICEWISEDETAILS.LIST> </INVOICEWISEDETAILS.LIST> <VATITCDETAILS.LIST> </VATITCDETAILS.LIST> <ADVANCETAXDETAILS.LIST> </ADVANCETAXDETAILS.LIST> </ACCOUNTINGALLOCATIONS.LIST> <DUTYHEADDETAILS.LIST> </DUTYHEADDETAILS.LIST> <SUPPLEMENTARYDUTYHEADDETAILS.LIST> </SUPPLEMENTARYDUTYHEADDETAILS.LIST> <TAXOBJECTALLOCATIONS.LIST> </TAXOBJECTALLOCATIONS.LIST> <REFVOUCHERDETAILS.LIST> </REFVOUCHERDETAILS.LIST> <EXCISEALLOCATIONS.LIST> </EXCISEALLOCATIONS.LIST> <EXPENSEALLOCATIONS.LIST> </EXPENSEALLOCATIONS.LIST> </ALLINVENTORYENTRIES.LIST> <SUPPLEMENTARYDUTYHEADDETAILS.LIST> </SUPPLEMENTARYDUTYHEADDETAILS.LIST> <EWAYBILLERRORLIST.LIST> </EWAYBILLERRORLIST.LIST> <IRNERRORLIST.LIST> </IRNERRORLIST.LIST> <INVOICEDELNOTES.LIST> </INVOICEDELNOTES.LIST> <INVOICEORDERLIST.LIST> </INVOICEORDERLIST.LIST> <INVOICEINDENTLIST.LIST> </INVOICEINDENTLIST.LIST> <ATTENDANCEENTRIES.LIST> </ATTENDANCEENTRIES.LIST> <ORIGINVOICEDETAILS.LIST> </ORIGINVOICEDETAILS.LIST> <INVOICEEXPORTLIST.LIST> </INVOICEEXPORTLIST.LIST> <LEDGERENTRIES.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <LEDGERNAME>Ashok Khad Bhandar ,Tambour</LEDGERNAME> <GSTCLASS/> <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE> <LEDGERFROMITEM>No</LEDGERFROMITEM> <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES> <ISPARTYLEDGER>Yes</ISPARTYLEDGER> <ISLASTDEEMEDPOSITIVE>Yes</ISLASTDEEMEDPOSITIVE> <ISCAPVATTAXALTERED>No</ISCAPVATTAXALTERED> <ISCAPVATNOTCLAIMED>No</ISCAPVATNOTCLAIMED> <AMOUNT>-2000.00</AMOUNT> <SERVICETAXDETAILS.LIST> </SERVICETAXDETAILS.LIST> <BANKALLOCATIONS.LIST> </BANKALLOCATIONS.LIST> <BILLALLOCATIONS.LIST> <NAME>1</NAME> <BILLTYPE>Agst Ref</BILLTYPE> <TDSDEDUCTEEISSPECIALRATE>No</TDSDEDUCTEEISSPECIALRATE> <AMOUNT>-2000.00</AMOUNT> <INTERESTCOLLECTION.LIST> </INTERESTCOLLECTION.LIST> <STBILLCATEGORIES.LIST> </STBILLCATEGORIES.LIST> </BILLALLOCATIONS.LIST> <INTERESTCOLLECTION.LIST> </INTERESTCOLLECTION.LIST> <OLDAUDITENTRIES.LIST> </OLDAUDITENTRIES.LIST> <ACCOUNTAUDITENTRIES.LIST> </ACCOUNTAUDITENTRIES.LIST> <AUDITENTRIES.LIST> </AUDITENTRIES.LIST> <INPUTCRALLOCS.LIST> </INPUTCRALLOCS.LIST> <DUTYHEADDETAILS.LIST> </DUTYHEADDETAILS.LIST> <EXCISEDUTYHEADDETAILS.LIST> </EXCISEDUTYHEADDETAILS.LIST> <RATEDETAILS.LIST> </RATEDETAILS.LIST> <SUMMARYALLOCS.LIST> </SUMMARYALLOCS.LIST> <STPYMTDETAILS.LIST> </STPYMTDETAILS.LIST> <EXCISEPAYMENTALLOCATIONS.LIST> </EXCISEPAYMENTALLOCATIONS.LIST> <TAXBILLALLOCATIONS.LIST> </TAXBILLALLOCATIONS.LIST> <TAXOBJECTALLOCATIONS.LIST> </TAXOBJECTALLOCATIONS.LIST> <TDSEXPENSEALLOCATIONS.LIST> </TDSEXPENSEALLOCATIONS.LIST> <VATSTATUTORYDETAILS.LIST> </VATSTATUTORYDETAILS.LIST> <COSTTRACKALLOCATIONS.LIST> </COSTTRACKALLOCATIONS.LIST> <REFVOUCHERDETAILS.LIST> </REFVOUCHERDETAILS.LIST> <INVOICEWISEDETAILS.LIST> </INVOICEWISEDETAILS.LIST> <VATITCDETAILS.LIST> </VATITCDETAILS.LIST> <ADVANCETAXDETAILS.LIST> </ADVANCETAXDETAILS.LIST> </LEDGERENTRIES.LIST> <LEDGERENTRIES.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <BASICRATEOFINVOICETAX.LIST TYPE="Number"> <BASICRATEOFINVOICETAX> 9</BASICRATEOFINVOICETAX> </BASICRATEOFINVOICETAX.LIST> <LEDGERNAME>Input CGST @9%</LEDGERNAME> <GSTCLASS/> <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE> <LEDGERFROMITEM>No</LEDGERFROMITEM> <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES> <ISPARTYLEDGER>No</ISPARTYLEDGER> <ISLASTDEEMEDPOSITIVE>No</ISLASTDEEMEDPOSITIVE> <ISCAPVATTAXALTERED>No</ISCAPVATTAXALTERED> <ISCAPVATNOTCLAIMED>No</ISCAPVATNOTCLAIMED> <AMOUNT>152.54</AMOUNT> <VATEXPAMOUNT>152.54</VATEXPAMOUNT> <SERVICETAXDETAILS.LIST> </SERVICETAXDETAILS.LIST> <BANKALLOCATIONS.LIST> </BANKALLOCATIONS.LIST> <BILLALLOCATIONS.LIST> </BILLALLOCATIONS.LIST> <INTERESTCOLLECTION.LIST> </INTERESTCOLLECTION.LIST> <OLDAUDITENTRIES.LIST> </OLDAUDITENTRIES.LIST> <ACCOUNTAUDITENTRIES.LIST> </ACCOUNTAUDITENTRIES.LIST> <AUDITENTRIES.LIST> </AUDITENTRIES.LIST> <INPUTCRALLOCS.LIST> </INPUTCRALLOCS.LIST> <DUTYHEADDETAILS.LIST> </DUTYHEADDETAILS.LIST> <EXCISEDUTYHEADDETAILS.LIST> </EXCISEDUTYHEADDETAILS.LIST> <RATEDETAILS.LIST> </RATEDETAILS.LIST> <SUMMARYALLOCS.LIST> </SUMMARYALLOCS.LIST> <STPYMTDETAILS.LIST> </STPYMTDETAILS.LIST> <EXCISEPAYMENTALLOCATIONS.LIST> </EXCISEPAYMENTALLOCATIONS.LIST> <TAXBILLALLOCATIONS.LIST> </TAXBILLALLOCATIONS.LIST> <TAXOBJECTALLOCATIONS.LIST> </TAXOBJECTALLOCATIONS.LIST> <TDSEXPENSEALLOCATIONS.LIST> </TDSEXPENSEALLOCATIONS.LIST> <VATSTATUTORYDETAILS.LIST> </VATSTATUTORYDETAILS.LIST> <COSTTRACKALLOCATIONS.LIST> </COSTTRACKALLOCATIONS.LIST> <REFVOUCHERDETAILS.LIST> </REFVOUCHERDETAILS.LIST> <INVOICEWISEDETAILS.LIST> </INVOICEWISEDETAILS.LIST> <VATITCDETAILS.LIST> </VATITCDETAILS.LIST> <ADVANCETAXDETAILS.LIST> </ADVANCETAXDETAILS.LIST> </LEDGERENTRIES.LIST> <LEDGERENTRIES.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <LEDGERNAME>Input SGST@9%</LEDGERNAME> <GSTCLASS/> <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE> <LEDGERFROMITEM>No</LEDGERFROMITEM> <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES> <ISPARTYLEDGER>No</ISPARTYLEDGER> <ISLASTDEEMEDPOSITIVE>No</ISLASTDEEMEDPOSITIVE> <ISCAPVATTAXALTERED>No</ISCAPVATTAXALTERED> <ISCAPVATNOTCLAIMED>No</ISCAPVATNOTCLAIMED> <AMOUNT>152.54</AMOUNT> <VATEXPAMOUNT>152.54</VATEXPAMOUNT> <SERVICETAXDETAILS.LIST> </SERVICETAXDETAILS.LIST> <BANKALLOCATIONS.LIST> </BANKALLOCATIONS.LIST> <BILLALLOCATIONS.LIST> </BILLALLOCATIONS.LIST> <INTERESTCOLLECTION.LIST> </INTERESTCOLLECTION.LIST> <OLDAUDITENTRIES.LIST> </OLDAUDITENTRIES.LIST> <ACCOUNTAUDITENTRIES.LIST> </ACCOUNTAUDITENTRIES.LIST> <AUDITENTRIES.LIST> </AUDITENTRIES.LIST> <INPUTCRALLOCS.LIST> </INPUTCRALLOCS.LIST> <DUTYHEADDETAILS.LIST> </DUTYHEADDETAILS.LIST> <EXCISEDUTYHEADDETAILS.LIST> </EXCISEDUTYHEADDETAILS.LIST> <RATEDETAILS.LIST> </RATEDETAILS.LIST> <SUMMARYALLOCS.LIST> </SUMMARYALLOCS.LIST> <STPYMTDETAILS.LIST> </STPYMTDETAILS.LIST> <EXCISEPAYMENTALLOCATIONS.LIST> </EXCISEPAYMENTALLOCATIONS.LIST> <TAXBILLALLOCATIONS.LIST> </TAXBILLALLOCATIONS.LIST> <TAXOBJECTALLOCATIONS.LIST> </TAXOBJECTALLOCATIONS.LIST> <TDSEXPENSEALLOCATIONS.LIST> </TDSEXPENSEALLOCATIONS.LIST> <VATSTATUTORYDETAILS.LIST> </VATSTATUTORYDETAILS.LIST> <COSTTRACKALLOCATIONS.LIST> </COSTTRACKALLOCATIONS.LIST> <REFVOUCHERDETAILS.LIST> </REFVOUCHERDETAILS.LIST> <INVOICEWISEDETAILS.LIST> </INVOICEWISEDETAILS.LIST> <VATITCDETAILS.LIST> </VATITCDETAILS.LIST> <ADVANCETAXDETAILS.LIST> </ADVANCETAXDETAILS.LIST> </LEDGERENTRIES.LIST> <PAYROLLMODEOFPAYMENT.LIST> </PAYROLLMODEOFPAYMENT.LIST> <ATTDRECORDS.LIST> </ATTDRECORDS.LIST> <GSTEWAYCONSIGNORADDRESS.LIST> </GSTEWAYCONSIGNORADDRESS.LIST> <GSTEWAYCONSIGNEEADDRESS.LIST> </GSTEWAYCONSIGNEEADDRESS.LIST> <TEMPGSTRATEDETAILS.LIST> </TEMPGSTRATEDETAILS.LIST> </VOUCHER> </TALLYMESSAGE> <TALLYMESSAGE xmlns:UDF="TallyUDF"> <COMPANY> <REMOTECMPINFO.LIST MERGE="Yes"> <NAME>2fe275e4-4606-40d4-85e2-2f4047f002e3</NAME> <REMOTECMPNAME>MOSARAM SHIVRAM DAS</REMOTECMPNAME> <REMOTECMPSTATE>Uttar Pradesh</REMOTECMPSTATE> </REMOTECMPINFO.LIST> </COMPANY> </TALLYMESSAGE> <TALLYMESSAGE xmlns:UDF="TallyUDF"> <COMPANY> <REMOTECMPINFO.LIST MERGE="Yes"> <NAME>2fe275e4-4606-40d4-85e2-2f4047f002e3</NAME> <REMOTECMPNAME>MOSARAM SHIVRAM DAS</REMOTECMPNAME> <REMOTECMPSTATE>Uttar Pradesh</REMOTECMPSTATE> </REMOTECMPINFO.LIST> </COMPANY> </TALLYMESSAGE> </REQUESTDATA> </IMPORTDATA> </BODY> </ENVELOPE> '; $tallyServer = 'http://localhost:9000/import'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $tallyServer); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: text/xml' ]); $response = curl_exec($ch); curl_close($ch); var_dump($response); } public function payment(Request $request) { $xmlRequest = ' <ENVELOPE> <HEADER> <TALLYREQUEST>Import Data</TALLYREQUEST> </HEADER> <BODY> <IMPORTDATA> <REQUESTDESC> <REPORTNAME>Vouchers</REPORTNAME> <STATICVARIABLES> <SVCURRENTCOMPANY>MOSARAM SHIVRAM DAS</SVCURRENTCOMPANY> </STATICVARIABLES> </REQUESTDESC> <REQUESTDATA> <TALLYMESSAGE> <VOUCHER REMOTEID="" VCHTYPE="Receipt" ACTION="Create" OBJVIEW="Accounting Voucher View"> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <DATE>20220402</DATE> <GUID/> <NARRATION>import receipt</NARRATION> <TAXUNITNAME>Default Tax Unit</TAXUNITNAME> <VOUCHERTYPENAME>Receipt</VOUCHERTYPENAME> <VOUCHERNUMBER>MRSD/21-22/5972</VOUCHERNUMBER> <PARTYLEDGERNAME>ASHOK KHAD BHANDAR, TAMBOUR</PARTYLEDGERNAME> <CSTFORMISSUETYPE/> <CSTFORMRECVTYPE/> <FBTPAYMENTTYPE>Default</FBTPAYMENTTYPE> <PERSISTEDVIEW>Accounting Voucher View</PERSISTEDVIEW> <VCHGSTCLASS/> <EFFECTIVEDATE>20220402</EFFECTIVEDATE> <HASCASHFLOW>Yes</HASCASHFLOW> <ALLLEDGERENTRIES.LIST> <LEDGERNAME>ASHOK KHAD BHANDAR, TAMBOUR</LEDGERNAME> <GSTCLASS/> <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE> <AMOUNT>2000</AMOUNT> <CATEGORY></CATEGORY> </ALLLEDGERENTRIES.LIST> <ALLLEDGERENTRIES.LIST> <OLDAUDITENTRYIDS.LIST TYPE="Number"> <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> </OLDAUDITENTRYIDS.LIST> <LEDGERNAME>HDFC Bank Limited</LEDGERNAME> <GSTCLASS/> <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE> <LEDGERFROMITEM>No</LEDGERFROMITEM> <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES> <ISPARTYLEDGER>Yes</ISPARTYLEDGER> <ISLASTDEEMEDPOSITIVE>Yes</ISLASTDEEMEDPOSITIVE> <AMOUNT>-2000</AMOUNT> <BANKALLOCATIONS.LIST> <DATE>20220402</DATE> <INSTRUMENTDATE></INSTRUMENTDATE> <NAME>MRSD/21-22/5971</NAME> <TRANSACTIONTYPE>Cheque/DD</TRANSACTIONTYPE> <PAYMENTFAVOURING>ASHOK KHAD BHANDAR, TAMBOUR</PAYMENTFAVOURING> <UNIQUEREFERENCENUMBER>MRSD/21-22/5970</UNIQUEREFERENCENUMBER> <PAYMENTMODE>Transacted</PAYMENTMODE> <STATUS>No</STATUS> <CHEQUEPRINTED> 1</CHEQUEPRINTED> <AMOUNT>-2000</AMOUNT> </BANKALLOCATIONS.LIST> </ALLLEDGERENTRIES.LIST> </VOUCHER> </TALLYMESSAGE> </REQUESTDATA> </IMPORTDATA> </BODY> </ENVELOPE>'; $headers = array("Content-type: text/xml", "Content-length: " . strlen($xmlRequest), "Connection: close"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:9000'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $data = curl_exec($ch); if (curl_errno($ch)) { print curl_error($ch); echo " something went wrong..... try later"; } else { echo " request accepted"; print $data; curl_close($ch); } } public function checkauth() { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://tallysolutions.com/api/"); // Replace with the correct API URL. curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "username=logimetrix8@gmail.com&password=mohit1234567890"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); if ($response === false) { echo "cURL Error: " . curl_error($ch); } else { // Handle the API response as needed. $auth = json_decode($response); $token = $auth->access_token; print_r($auth); } } public function test(){ $listOfLedgerXML ='<ENVELOPE> <HEADER> <VERSION>1</VERSION> <TALLYREQUEST>Export</TALLYREQUEST> <TYPE>Data</TYPE> <ID>List of Ledgers</ID> </HEADER> <BODY> <DESC> <TDL> <TDLMESSAGE> <REPORT NAME="List of Ledgers" ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No"> <FORMS>List of Ledgers</FORMS> </REPORT> <FORM NAME="List of Ledgers" ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No"> <TOPPARTS>List of Ledgers</TOPPARTS> <XMLTAG>"List of Ledgers"</XMLTAG> </FORM> <PART NAME="List of Ledgers" ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No"> <TOPLINES>List of Ledgers</TOPLINES> <REPEAT>List of Ledgers : Collection of Ledgers</REPEAT> <SCROLLED>Vertical</SCROLLED> </PART> <LINE NAME="List of Ledgers" ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No"> <LEFTFIELDS>List of Ledgers</LEFTFIELDS> </LINE> <FIELD NAME="List of Ledgers" ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No"> <SET>\$Name</SET> <XMLTAG>"LEDGERNAME"</XMLTAG> </FIELD> <COLLECTION NAME="Collection of Ledgers" ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No"> <TYPE>Ledger</TYPE> </COLLECTION> </TDLMESSAGE> </TDL> </DESC> </BODY> </ENVELOPE>'; $url = "http://localhost:9000"; $res_str = $listOfLedgerXML; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS,"xmlRequest=" . $res_str); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300); $data = curl_exec($ch); // echo '<pre>'; // var_dump($data);die; // curl_close($ch); // get the result array // $object = (array) simplexml_load_string( $data ); if (curl_errno($ch)) { print curl_error($ch); echo " something went wrong..... try later"; } else { echo " request accepted"; print $data; curl_close($ch); } } }