Merge Invoice and Bill into Document

This commit is contained in:
Burak Çakırel
2020-12-24 01:28:38 +03:00
parent 830cc05957
commit 0c1424db47
436 changed files with 31655 additions and 37350 deletions

View File

@ -4,10 +4,10 @@ namespace App\Http\Controllers\Modals;
use App\Abstracts\Http\Controller;
use App\Http\Requests\Banking\Transaction as Request;
use App\Jobs\Banking\CreateDocumentTransaction;
use App\Jobs\Banking\CreateBankingDocumentTransaction;
use App\Models\Banking\Account;
use App\Models\Banking\Transaction;
use App\Models\Purchase\Bill;
use App\Models\Document\Document;
use App\Models\Setting\Currency;
use App\Utilities\Modules;
use App\Traits\Uploads;
@ -31,11 +31,11 @@ class BillTransactions extends Controller
/**
* Show the form for creating a new resource.
*
* @param Bill $bill
* @param Document $bill
*
* @return Response
*/
public function create(Bill $bill)
public function create(Document $bill)
{
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
@ -86,14 +86,14 @@ class BillTransactions extends Controller
/**
* Store a newly created resource in storage.
*
* @param Bill $bill
* @param Document $bill
* @param Request $request
*
* @return Response
*/
public function store(Bill $bill, Request $request)
public function store(Document $bill, Request $request)
{
$response = $this->ajaxDispatch(new CreateDocumentTransaction($bill, $request));
$response = $this->ajaxDispatch(new CreateBankingDocumentTransaction($bill, $request));
if ($response['success']) {
$response['redirect'] = route('bills.show', $bill->id);

View File

@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers\Modals;
use App\Abstracts\Http\Controller;
use App\Models\Common\Company;
class Companies extends Controller
{
/**
* Instantiate a new controller instance.
*/
public function __construct()
{
// Add CRUD permission check
$this->middleware('permission:read-settings-company')->only('index', 'show', 'edit', 'export');
$this->middleware('permission:update-settings-settings')->only('update', 'enable', 'disable');
}
/**
* Show the form for editing the specified resource.
*
* @param Company $company
*
* @return Response
*/
public function edit(Company $company)
{
$html = view('modals.companies.edit', compact('company'))->render();
return response()->json([
'success' => true,
'error' => false,
'message' => 'null',
'html' => $html,
]);
}
}

View File

@ -4,7 +4,9 @@ namespace App\Http\Controllers\Modals;
use App\Abstracts\Http\Controller;
use App\Http\Requests\Common\Contact as Request;
use App\Models\Common\Contact;
use App\Jobs\Common\CreateContact;
use App\Jobs\Common\UpdateContact;
use App\Models\Setting\Currency;
class Customers extends Controller
@ -60,6 +62,7 @@ class Customers extends Controller
$request['enabled'] = 1;
$response = $this->ajaxDispatch(new CreateContact($request));
$this->ajaxDispatch(new UpdateContact($customer, $request));
if ($response['success']) {
$response['message'] = trans('messages.success.added', ['type' => trans_choice('general.customers', 1)]);
@ -67,4 +70,54 @@ class Customers extends Controller
return response()->json($response);
}
/**
* Show the form for editing the specified resource.
*
* @param Contact $customer
*
* @return Response
*/
public function edit(Contact $customer)
{
$currencies = Currency::enabled()->pluck('name', 'code');
$contact_selector = false;
if (request()->has('contact_selector')) {
$contact_selector = request()->get('contact_selector');
}
$rand = rand();
$html = view('modals.customers.edit', compact('customer', 'currencies', 'contact_selector', 'rand'))->render();
return response()->json([
'success' => true,
'error' => false,
'message' => 'null',
'html' => $html,
]);
}
/**
* Update the specified resource in storage.
*
* @param Contact $customer
* @param Request $request
*
* @return Response
*/
public function update(Contact $customer, Request $request)
{
$request['enabled'] = 1;
$response = $this->ajaxDispatch(new UpdateContact($customer, $request));
if ($response['success']) {
$response['message'] = trans('messages.success.updated', ['type' => trans_choice('general.customers', 1)]);
}
return response()->json($response);
}
}

View File

@ -0,0 +1,116 @@
<?php
namespace App\Http\Controllers\Modals;
use App\Abstracts\Http\Controller;
use App\Http\Requests\Setting\Setting as Request;
class InvoiceItemColumns extends Controller
{
public $skip_keys = ['company_id', '_method', '_token', '_prefix', '_template'];
public function __construct()
{
// Add CRUD permission check
$this->middleware('permission:read-settings-settings')->only('index', 'edit');
$this->middleware('permission:update-settings-settings')->only('update', 'enable', 'disable');
}
/**
* Show the form for editing the specified resource.
*
* @param Contact $customer
*
* @return Response
*/
public function edit()
{
$item_names = [
'settings.invoice.item' => trans('settings.invoice.item'),
'settings.invoice.product' => trans('settings.invoice.product'),
'settings.invoice.service' => trans('settings.invoice.service'),
'custom' => trans('settings.invoice.custom'),
];
$price_names = [
'settings.invoice.price' => trans('settings.invoice.price'),
'settings.invoice.rate' => trans('settings.invoice.rate'),
'custom' => trans('settings.invoice.custom'),
];
$quantity_names = [
'settings.invoice.quantity' => trans('settings.invoice.quantity'),
'custom' => trans('settings.invoice.custom'),
];
$payment_terms = [
'0' => trans('settings.invoice.due_receipt'),
'15' => trans('settings.invoice.due_days', ['days' => 15]),
'30' => trans('settings.invoice.due_days', ['days' => 30]),
'45' => trans('settings.invoice.due_days', ['days' => 45]),
'60' => trans('settings.invoice.due_days', ['days' => 60]),
'90' => trans('settings.invoice.due_days', ['days' => 90]),
];
$html = view('modals.invoices.item_columns', compact(
'item_names',
'price_names',
'quantity_names',
'payment_terms'
))->render();
return response()->json([
'success' => true,
'error' => false,
'message' => 'null',
'html' => $html,
]);
}
/**
* Update the specified resource in storage.
*
* @param Request $request
*
* @return Response
*/
public function update(Request $request)
{
$fields = $request->all();
$prefix = $request->get('_prefix', 'invoice');
$company_id = $request->get('company_id');
if (empty($company_id)) {
$company_id = session('company_id');
}
foreach ($fields as $key => $value) {
$real_key = $prefix . '.' . $key;
// Don't process unwanted keys
if (in_array($key, $this->skip_keys)) {
continue;
}
setting()->set($real_key, $value);
}
// Save all settings
setting()->save();
$message = trans('messages.success.updated', ['type' => trans_choice('general.settings', 2)]);
$response = [
'status' => null,
'success' => true,
'error' => false,
'message' => $message,
'data' => null,
'redirect' => route('settings.invoice.edit'),
];
flash($message)->success();
return response()->json($response);
}
}

View File

@ -4,10 +4,10 @@ namespace App\Http\Controllers\Modals;
use App\Abstracts\Http\Controller;
use App\Http\Requests\Banking\Transaction as Request;
use App\Jobs\Banking\CreateDocumentTransaction;
use App\Jobs\Banking\CreateBankingDocumentTransaction;
use App\Models\Banking\Account;
use App\Models\Banking\Transaction;
use App\Models\Sale\Invoice;
use App\Models\Document\Document;
use App\Models\Setting\Currency;
use App\Utilities\Modules;
use App\Traits\Uploads;
@ -31,11 +31,11 @@ class InvoiceTransactions extends Controller
/**
* Show the form for creating a new resource.
*
* @param Invoice $invoice
* @param Document $invoice
*
* @return Response
*/
public function create(Invoice $invoice)
public function create(Document $invoice)
{
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
@ -91,14 +91,14 @@ class InvoiceTransactions extends Controller
/**
* Store a newly created resource in storage.
*
* @param Invoice $invoice
* @param Document $invoice
* @param Request $request
*
* @return Response
*/
public function store(Invoice $invoice, Request $request)
public function store(Document $invoice, Request $request)
{
$response = $this->ajaxDispatch(new CreateDocumentTransaction($invoice, $request));
$response = $this->ajaxDispatch(new CreateBankingDocumentTransaction($invoice, $request));
if ($response['success']) {
$response['redirect'] = route('invoices.show', $invoice->id);

View File

@ -4,7 +4,9 @@ namespace App\Http\Controllers\Modals;
use App\Abstracts\Http\Controller;
use App\Http\Requests\Common\Contact as Request;
use App\Models\Common\Contact;
use App\Jobs\Common\CreateContact;
use App\Jobs\Common\UpdateContact;
use App\Models\Setting\Currency;
class Vendors extends Controller
@ -67,4 +69,54 @@ class Vendors extends Controller
return response()->json($response);
}
/**
* Show the form for editing the specified resource.
*
* @param Contact $vendor
*
* @return Response
*/
public function edit(Contact $vendor)
{
$currencies = Currency::enabled()->pluck('name', 'code');
$contact_selector = false;
if (request()->has('contact_selector')) {
$contact_selector = request()->get('contact_selector');
}
$rand = rand();
$html = view('modals.vendors.edit', compact('vendor', 'currencies', 'contact_selector', 'rand'))->render();
return response()->json([
'success' => true,
'error' => false,
'message' => 'null',
'html' => $html,
]);
}
/**
* Update the specified resource in storage.
*
* @param Contact $vendor
* @param Request $request
*
* @return Response
*/
public function update(Contact $vendor, Request $request)
{
$request['enabled'] = 1;
$response = $this->ajaxDispatch(new UpdateContact($vendor, $request));
if ($response['success']) {
$response['message'] = trans('messages.success.updated', ['type' => trans_choice('general.vendors', 1)]);
}
return response()->json($response);
}
}