v2 first commit

This commit is contained in:
denisdulici
2019-11-16 10:21:14 +03:00
parent 5b23e9c2c4
commit 6d50fa8442
3075 changed files with 3451681 additions and 65594 deletions

View File

@@ -0,0 +1,65 @@
<?php
namespace App\Listeners\Common;
use App\Abstracts\Reports\Listener;
use App\Events\Common\ReportFilterApplying;
use App\Events\Common\ReportFilterShowing;
use App\Events\Common\ReportGroupApplying;
use App\Events\Common\ReportGroupShowing;
class ExpenseSummaryReport extends Listener
{
protected $class = 'App\Reports\ExpenseSummary';
/**
* Handle filter showing event.
*
* @param $event
* @return void
*/
public function handleReportFilterShowing(ReportFilterShowing $event)
{
if (!$this->checkClass($event)) {
return;
}
$event->class->filters['years'] = $this->getYears();
$event->class->filters['accounts'] = $this->getAccounts();
$event->class->filters['categories'] = $this->getExpenseCategories();
$event->class->filters['vendors'] = $this->getVendors();
}
/**
* Handle group showing event.
*
* @param $event
* @return void
*/
public function handleReportGroupShowing(ReportGroupShowing $event)
{
if (!$this->checkClass($event)) {
return;
}
$event->class->groups['category'] = trans_choice('general.categories', 1);
$event->class->groups['account'] = trans_choice('general.accounts', 1);
$event->class->groups['vendor'] = trans_choice('general.vendors', 1);
}
/**
* Handle group applyinh event.
*
* @param $event
* @return void
*/
public function handleReportGroupApplying(ReportGroupApplying $event)
{
if (!$this->checkClass($event)) {
return;
}
$this->applyVendorGroup($event);
$this->applyAccountGroup($event);
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Listeners\Common;
use App\Abstracts\Reports\Listener;
use App\Events\Common\ReportFilterApplying;
use App\Events\Common\ReportFilterShowing;
use App\Events\Common\ReportGroupApplying;
use App\Events\Common\ReportGroupShowing;
class IncomeExpenseSummaryReport extends Listener
{
protected $class = 'App\Reports\IncomeExpenseSummary';
/**
* Handle filter showing event.
*
* @param $event
* @return void
*/
public function handleReportFilterShowing(ReportFilterShowing $event)
{
if (!$this->checkClass($event)) {
return;
}
$event->class->filters['years'] = $this->getYears();
$event->class->filters['accounts'] = $this->getAccounts();
$event->class->filters['categories'] = $this->getIncomeExpenseCategories();
$event->class->filters['customers'] = $this->getCustomers();
$event->class->filters['vendors'] = $this->getVendors();
}
/**
* Handle group showing event.
*
* @param $event
* @return void
*/
public function handleReportGroupShowing(ReportGroupShowing $event)
{
if (!$this->checkClass($event)) {
return;
}
$event->class->groups['category'] = trans_choice('general.categories', 1);
$event->class->groups['account'] = trans_choice('general.accounts', 1);
$event->class->groups['customer'] = trans_choice('general.customers', 1);
$event->class->groups['vendor'] = trans_choice('general.vendors', 1);
}
/**
* Handle group applying event.
*
* @param $event
* @return void
*/
public function handleReportGroupApplying(ReportGroupApplying $event)
{
if (!$this->checkClass($event)) {
return;
}
$this->applyCustomerGroup($event);
$this->applyVendorGroup($event);
$this->applyAccountGroup($event);
}
}

View File

@@ -0,0 +1,84 @@
<?php
namespace App\Listeners\Common;
use App\Abstracts\Reports\Listener;
use App\Events\Common\ReportFilterApplying;
use App\Events\Common\ReportFilterShowing;
use App\Events\Common\ReportGroupApplying;
use App\Events\Common\ReportGroupShowing;
class IncomeSummaryReport extends Listener
{
protected $class = 'App\Reports\IncomeSummary';
/**
* Handle filter showing event.
*
* @param $event
* @return void
*/
public function handleReportFilterShowing(ReportFilterShowing $event)
{
if (!$this->checkClass($event)) {
return;
}
$event->class->filters['years'] = $this->getYears();
$event->class->filters['accounts'] = $this->getAccounts();
$event->class->filters['categories'] = $this->getIncomeCategories();
$event->class->filters['customers'] = $this->getCustomers();
}
/**
* Handle filter applying event.
*
* @param $event
* @return void
*/
public function handleReportFilterApplying(ReportFilterApplying $event)
{
if (!$this->checkClass($event)) {
return;
}
// Apply date
$this->applyDateFilter($event);
// Apply search
$this->applySearchStringFilter($event);
}
/**
* Handle group showing event.
*
* @param $event
* @return void
*/
public function handleReportGroupShowing(ReportGroupShowing $event)
{
if (!$this->checkClass($event)) {
return;
}
$event->class->groups['category'] = trans_choice('general.categories', 1);
$event->class->groups['account'] = trans_choice('general.accounts', 1);
$event->class->groups['customer'] = trans_choice('general.customers', 1);
}
/**
* Handle group applying event.
*
* @param $event
* @return void
*/
public function handleReportGroupApplying(ReportGroupApplying $event)
{
if (!$this->checkClass($event)) {
return;
}
$this->applyCustomerGroup($event);
$this->applyAccountGroup($event);
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Listeners\Common;
use App\Abstracts\Reports\Listener;
class ProfitLossReport extends Listener
{
protected $class = 'App\Reports\ProfitLoss';
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Listeners\Common;
use App\Abstracts\Reports\Listener;
class TaxSummaryReport extends Listener
{
protected $class = 'App\Reports\TaxSummary';
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Listeners\Expense;
use App\Events\Expense\BillCreated as Event;
use App\Jobs\Expense\CreateBillHistory;
use App\Traits\Jobs;
class CreateBillCreatedHistory
{
use Jobs;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
$message = trans('messages.success.added', ['type' => $event->bill->bill_number]);
$this->dispatch(new CreateBillHistory($event->bill, 0, $message));
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Listeners\Expense;
use App\Events\Expense\BillRecurring as Event;
use App\Notifications\Expense\Bill as Notification;
class SendBillRecurringNotification
{
/**
* Handle the event.
*
* @param $event
* @return array
*/
public function handle(Event $event)
{
$bill = $event->bill;
// Notify all users assigned to this company
foreach ($bill->company->users as $user) {
if (!$user->can('read-notifications')) {
continue;
}
$user->notify(new Notification($bill, 'bill_recur_admin'));
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Listeners\Income;
use App\Events\Income\InvoiceCreated as Event;
use App\Jobs\Income\CreateInvoiceHistory;
use App\Traits\Jobs;
class CreateInvoiceCreatedHistory
{
use Jobs;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
$message = trans('messages.success.added', ['type' => $event->invoice->invoice_number]);
$this->dispatch(new CreateInvoiceHistory($event->invoice, 0, $message));
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Listeners\Income;
use App\Events\Income\PaymentReceived as Event;
use App\Jobs\Banking\CreateDocumentTransaction;
use App\Traits\Jobs;
class CreateInvoiceTransaction
{
use Jobs;
/**
* Handle the event.
*
* @param $event
* @return array
*/
public function handle(Event $event)
{
$invoice = $event->invoice;
$request = $event->request;
try {
$this->dispatch(new CreateDocumentTransaction($invoice, $request));
} catch (\Exception $e) {
$message = $e->getMessage();
$user = user();
if ($user) {
if ($user->contact) {
flash($message)->error();
redirect()->route('portal.invoices.show', $invoice->id)->send();
}
throw new \Exception($message);
}
flash($message)->error();
redirect()->route('signed.invoices.show', $invoice->id)->send();
}
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Listeners\Income;
use App\Events\Income\InvoiceCreated as Event;
use App\Traits\Incomes;
class IncreaseNextInvoiceNumber
{
use Incomes;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
// Update next invoice number
$this->increaseNextInvoiceNumber();
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Listeners\Income;
use App\Events\Income\InvoiceSent as Event;
use App\Models\Income\InvoiceHistory;
class MarkInvoiceSent
{
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
// Mark invoice as sent
if ($event->invoice->invoice_status_code != 'partial') {
$event->invoice->invoice_status_code = 'sent';
$event->invoice->save();
}
// Add invoice history
InvoiceHistory::create([
'company_id' => $event->invoice->company_id,
'invoice_id' => $event->invoice->id,
'status_code' => 'sent',
'notify' => 0,
'description' => trans('invoices.mark_sent'),
]);
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Listeners\Income;
use App\Events\Income\InvoiceViewed as Event;
class MarkInvoiceViewed
{
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
$invoice = $event->invoice;
if ($invoice->invoice_status_code != 'sent') {
return;
}
unset($invoice->paid);
$invoice->invoice_status_code = 'viewed';
$invoice->save();
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Listeners\Income;
use App\Events\Income\PaymentReceived as Event;
use App\Notifications\Portal\PaymentReceived as Notification;
class SendInvoicePaymentNotification
{
/**
* Handle the event.
*
* @param $event
* @return array
*/
public function handle(Event $event)
{
$invoice = $event->invoice;
$transaction = $invoice->transactions()->latest()->first();
// Notify the customer
if ($invoice->contact && !empty($invoice->contact_email)) {
$invoice->contact->notify(new Notification($invoice, $transaction, 'invoice_payment_customer'));
}
// Notify all users assigned to this company
foreach ($invoice->company->users as $user) {
if (!$user->can('read-notifications')) {
continue;
}
$user->notify(new Notification($invoice, $transaction, 'invoice_payment_admin'));
}
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Listeners\Income;
use App\Events\Income\InvoiceRecurring as Event;
use App\Notifications\Income\Invoice as Notification;
class SendInvoiceRecurringNotification
{
/**
* Handle the event.
*
* @param $event
* @return array
*/
public function handle(Event $event)
{
$invoice = $event->invoice;
// Notify the customer
if ($invoice->contact && !empty($invoice->contact_email)) {
$invoice->contact->notify(new Notification($invoice, 'invoice_recur_customer'));
}
// Notify all users assigned to this company
foreach ($invoice->company->users as $user) {
if (!$user->can('read-notifications')) {
continue;
}
$user->notify(new Notification($invoice, 'invoice_recur_admin'));
}
}
}

View File

@@ -1,81 +0,0 @@
<?php
namespace App\Listeners\Incomes\Invoice;
use App\Events\InvoicePaid;
use App\Http\Requests\Income\InvoicePayment as PaymentRequest;
use App\Jobs\Income\CreateInvoicePayment;
use App\Notifications\Customer\Invoice as Notification;
use App\Traits\DateTime;
use Date;
class Paid
{
use DateTime;
/**
* Handle the event.
*
* @param $event
* @return array
*/
public function handle(InvoicePaid $event)
{
$invoice = $event->invoice;
$request = $event->request;
$invoice_payment = $this->createPayment($invoice, $request);
if ($request['amount'] > $invoice->amount) {
$message = trans('messages.error.added', ['type' => trans_choice('general.payment', 1)]);
return [
'success' => false,
'error' => $message,
];
} elseif ($request['amount'] == $invoice->amount) {
$invoice->invoice_status_code = 'paid';
} else {
$invoice->invoice_status_code = 'partial';
}
$invoice->save();
// Customer add payment on invoice send user notification
foreach ($invoice->company->users as $user) {
if (!$user->can('read-notifications')) {
continue;
}
$user->notify(new Notification($invoice, $invoice_payment));
}
return [
'success' => true,
'error' => false,
];
}
protected function createPayment($invoice, $request)
{
if (!is_array($request)) {
$request = $request->input();
}
$request['invoice_id'] = $invoice->id;
$request['paid_at'] = Date::parse('now')->format('Y-m-d');
$request['company_id'] = isset($request['company_id']) ? $request['company_id'] : session('company_id');
$request['account_id'] = isset($request['account_id']) ? $request['account_id'] : setting('general.default_account');
$request['payment_method'] = isset($request['payment_method']) ? $request['payment_method'] : setting('general.default_payment_method');
$request['currency_code'] = isset($request['currency_code']) ? $request['currency_code'] : $invoice->currency_code;
$request['currency_rate'] = isset($request['currency_rate']) ? $request['currency_rate'] : $invoice->currency_rate;
$request['notify'] = isset($request['notify']) ? $request['notify'] : 0;
$payment_request = new PaymentRequest();
$payment_request->merge($request);
$invoice_payment = dispatch(new CreateInvoicePayment($payment_request, $invoice));
return $invoice_payment;
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Listeners\Updates;
namespace App\Listeners\Update;
class Listener
{

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V10;
namespace App\Listeners\Update\V10;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use File;
class Version106 extends Listener
@@ -18,7 +18,7 @@ class Version106 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V10;
namespace App\Listeners\Update\V10;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use DB;
class Version107 extends Listener
@@ -18,7 +18,7 @@ class Version107 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V10;
namespace App\Listeners\Update\V10;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Common\Company;
use App\Models\Expense\Bill;
use App\Models\Expense\BillStatus;
@@ -20,7 +20,7 @@ class Version108 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {
@@ -34,9 +34,9 @@ class Version108 extends Listener
private function updateSettings()
{
// Set new invoice settings
setting(['general.invoice_number_prefix' => setting('general.invoice_prefix', 'INV-')]);
setting(['general.invoice_number_digit' => setting('general.invoice_digit', '5')]);
setting(['general.invoice_number_next' => setting('general.invoice_start', '1')]);
setting(['general.invoice_number_prefix' => setting('invoice.prefix', 'INV-')]);
setting(['general.invoice_number_digit' => setting('invoice.digit', '5')]);
setting(['general.invoice_number_next' => setting('invoice.start', '1')]);
setting()->forget('general.invoice_prefix');
setting()->forget('general.invoice_digit');

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V10;
namespace App\Listeners\Update\V10;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Common\Company;
use Artisan;
@@ -19,7 +19,7 @@ class Version109 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V11;
namespace App\Listeners\Update\V11;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
@@ -19,7 +19,7 @@ class Version110 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V11;
namespace App\Listeners\Update\V11;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Common\Company;
use App\Utilities\Installer;
@@ -19,7 +19,7 @@ class Version112 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {
@@ -30,7 +30,7 @@ class Version112 extends Listener
// Get default locale if only 1 company
if (Company::all()->count() == 1) {
$locale = setting('general.default_locale', 'en-GB');
$locale = setting('default.locale', 'en-GB');
}
// Set default locale

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V11;
namespace App\Listeners\Update\V11;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Setting\Currency;
use Artisan;
@@ -19,7 +19,7 @@ class Version113 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V11;
namespace App\Listeners\Update\V11;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
use Illuminate\Support\Facades\Schema;
@@ -23,7 +23,7 @@ class Version119 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {
@@ -64,12 +64,10 @@ class Version119 extends Listener
$migrations = [
'\App\Models\Auth\User' => 'picture',
'\App\Models\Common\Item' => 'picture',
'\App\Models\Common\Item' => 'picture',
'\App\Models\Expense\Bill' => 'attachment',
'\App\Models\Expense\BillPayment' => 'attachment',
'\App\Models\Expense\Payment' => 'attachment',
'\App\Models\Income\Invoice' => 'attachment',
'\App\Models\Income\InvoicePayment' => 'attachment',
'\App\Models\Income\Revenue' => 'attachment',
];

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V12;
namespace App\Listeners\Update\V12;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
use App\Models\Common\Company;
@@ -26,7 +26,7 @@ class Version120 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V12;
namespace App\Listeners\Update\V12;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Artisan;
class Version1210 extends Listener
@@ -18,7 +18,7 @@ class Version1210 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V12;
namespace App\Listeners\Update\V12;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Artisan;
class Version1211 extends Listener
@@ -18,7 +18,7 @@ class Version1211 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V12;
namespace App\Listeners\Update\V12;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
@@ -19,7 +19,7 @@ class Version126 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,11 +1,12 @@
<?php
namespace App\Listeners\Updates\V12;
namespace App\Listeners\Update\V12;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Permission;
use File;
use Illuminate\Support\Str;
class Version127 extends Listener
{
@@ -19,7 +20,7 @@ class Version127 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {
@@ -45,7 +46,7 @@ class Version127 extends Listener
foreach ($dirs as $dir) {
File::deleteDirectory(app_path('Filters/' . ucfirst($dir)));
File::deleteDirectory(app_path('Http/Controllers/' . ucfirst($dir)));
File::deleteDirectory(app_path('Http/Requests/' . ucfirst(str_singular($dir))));
File::deleteDirectory(app_path('Http/Requests/' . ucfirst(Str::singular($dir))));
File::deleteDirectory(resource_path('views/' . $dir));
}
}

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V12;
namespace App\Listeners\Update\V12;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Artisan;
class Version129 extends Listener
@@ -18,7 +18,7 @@ class Version129 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V13;
namespace App\Listeners\Update\V13;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
use Artisan;
@@ -20,7 +20,7 @@ class Version130 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V13;
namespace App\Listeners\Update\V13;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
use Artisan;
@@ -20,7 +20,7 @@ class Version1311 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V13;
namespace App\Listeners\Update\V13;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Common\Company;
use App\Utilities\Installer;
use Artisan;
@@ -20,7 +20,7 @@ class Version1313 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V13;
namespace App\Listeners\Update\V13;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Common\Company;
use App\Utilities\Overrider;
use App\Models\Banking\Account;
@@ -22,7 +22,7 @@ class Version1316 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V13;
namespace App\Listeners\Update\V13;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
use Artisan;
@@ -20,7 +20,7 @@ class Version132 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V13;
namespace App\Listeners\Update\V13;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Date;
class Version135 extends Listener
@@ -18,7 +18,7 @@ class Version135 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V13;
namespace App\Listeners\Update\V13;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use Date;
class Version138 extends Listener
@@ -18,7 +18,7 @@ class Version138 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {
@@ -26,7 +26,7 @@ class Version138 extends Listener
}
// Re-format financial start
$current_setting = setting('general.financial_start', Date::now()->startOfYear()->format('d F'));
$current_setting = setting('localisation.financial_start', Date::now()->startOfYear()->format('d F'));
setting()->setExtraColumns(['company_id' => session('company_id')]);
setting(['general.financial_start' => Date::parse($current_setting)->format('d-m')]);

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Listeners\Updates\V13;
namespace App\Listeners\Update\V13;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Income\InvoiceItem;
use App\Models\Income\InvoiceItemTax;
use App\Models\Setting\Tax;
@@ -21,7 +21,7 @@ class Version139 extends Listener
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {

View File

@@ -0,0 +1,905 @@
<?php
namespace App\Listeners\Update\V20;
use App\Events\Install\UpdateFinished as Event;
use App\Listeners\Update\Listener;
use App\Models\Auth\User;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
use App\Models\Banking\Transaction;
use App\Models\Common\Company;
use App\Models\Common\Contact;
use App\Models\Common\EmailTemplate;
use App\Models\Common\Report;
use App\Utilities\Overrider;
use Artisan;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
class Version200 extends Listener
{
const ALIAS = 'core';
const VERSION = '2.0.0';
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
// Check if should listen
if (!$this->check($event)) {
return;
}
// Cache Clear
Artisan::call('cache:clear');
// Update database
Artisan::call('migrate', ['--force' => true]);
$this->updateCompanies();
$this->createDashboards();
$this->copyTransactions();
$this->copyContacts();
$this->updatePermissions();
$this->deleteOldFiles();
}
protected function updateCompanies()
{
$company_id = session('company_id');
$companies = Company::enabled()->cursor();
foreach ($companies as $company) {
$this->updateSettings($company);
$this->createEmailTemplates($company);
$this->createReports($company);
}
setting()->forgetAll();
session(['company_id' => $company_id]);
Overrider::load('settings');
}
public function updateSettings($company)
{
// Clear current settings
setting()->forgetAll();
session(['company_id' => $company->id]);
Overrider::load('settings');
$updated_settings = [
'company.name' => 'general.company_name',
'company.email' => 'general.company_email',
'company.address' => 'general.company_address',
'company.logo' => 'general.company_logo',
'localisation.financial_start' => 'general.financial_start',
'localisation.timezone' => 'general.timezone',
'localisation.date_format' => 'general.date_format',
'localisation.date_separator' => 'general.date_separator',
'localisation.percent_position' => 'general.percent_position',
'invoice.number_prefix' => 'general.invoice_number_prefix',
'invoice.number_digit' => 'general.invoice_number_digit',
'invoice.number_next' => 'general.invoice_number_next',
'invoice.item_name' => 'general.invoice_item',
'invoice.price_name' => 'general.invoice_price',
'invoice.quantity_name' => 'general.invoice_quantity',
'invoice.title' => trans_choice('general.invoices', 1),
'invoice.payment_terms' => '0',
'default.account' => 'general.default_account',
'default.currency' => 'general.default_currency',
'default.locale' => 'general.default_locale',
'default.list_limit' => 'general.list_limit',
'default.payment_method' => 'general.default_payment_method',
'default.use_gravatar' => 'general.use_gravatar',
'email.protocol' => 'general.email_protocol',
'email.sendmail_path' => 'general.email_sendmail_path',
'email.smtp_host' => 'general.smtp_host',
'email.smtp_port' => 'general.smtp_port',
'email.smtp_username' => 'general.smtp_username',
'email.smtp_password' => 'general.smtp_password',
'email.smtp_encryption' => 'general.smtp_encryption',
'schedule.send_invoice_reminder' => 'general.send_invoice_reminder',
'schedule.invoice_days' => 'general.schedule_invoice_days',
'schedule.send_bill_reminder' => 'general.send_bill_reminder',
'schedule.bill_days' => 'general.schedule_bill_days',
'schedule.time' => 'general.schedule_time',
'apps.api_key' => 'general.api_token',
'wizard.completed' => 'general.wizard',
'contact.type.customer' => 'customer',
'contact.type.vendor' => 'vendor',
'offline-payments.methods' => 'offlinepayment.methods',
];
foreach ($updated_settings as $new => $old) {
switch($new) {
case 'offline-payments.methods':
case 'default.payment_method':
$value = str_replace('offlinepayment.', 'offline-payments.', setting($old));
break;
case 'invoice.title':
case 'invoice.payment_terms':
case 'contact.type.customer':
case 'contact.type.vendor':
$value = $old;
break;
default:
$value = setting($old);
break;
}
if (($value != '0') && empty($value)) {
continue;
}
setting()->set([$new => $value]);
setting()->forget($old);
}
$removed_settings = [
'general.admin_theme',
'general.session_handler',
'general.session_lifetime',
'general.file_size',
'general.file_types',
'general.send_item_reminder',
'general.schedule_item_stocks',
];
foreach ($removed_settings as $removed_setting) {
setting()->forget($removed_setting);
}
setting()->save();
}
public function createEmailTemplates($company)
{
$templates = [
'invoice_new_customer',
'invoice_remind_customer',
'invoice_remind_admin',
'invoice_recur_customer',
'invoice_recur_admin',
'invoice_payment_customer',
'invoice_payment_admin',
'bill_remind_admin',
'bill_recur_admin',
];
foreach ($templates as $template) {
EmailTemplate::create([
'company_id' => $company->id,
'alias' => $template,
'subject' => trans('email_templates.' . $template . '.subject'),
'body' => trans('email_templates.' . $template . '.body'),
]);
}
}
public function createReports($company)
{
$rows = [
[
'company_id' => $company->id,
'name' => trans('reports.summary.income'),
'description' => 'This is the income summary by category.',
'class' => 'App\Reports\IncomeSummary',
'group' => 'category',
'period' => 'monthly',
'basis' => 'accrual',
'chart' => 'line',
'enabled' => 1,
],
[
'company_id' => $company->id,
'name' => trans('reports.summary.expense'),
'description' => 'This is the expense summary by category.',
'class' => 'App\Reports\ExpenseSummary',
'group' => 'category',
'period' => 'monthly',
'basis' => 'accrual',
'chart' => 'line',
'enabled' => 1,
],
[
'company_id' => $company->id,
'name' => trans('reports.summary.income_expense'),
'description' => 'This is the income vs expense by category.',
'class' => 'App\Reports\IncomeExpenseSummary',
'group' => 'category',
'period' => 'monthly',
'basis' => 'accrual',
'chart' => 'line',
'enabled' => 1,
],
[
'company_id' => $company->id,
'name' => trans('reports.summary.tax'),
'description' => 'This is the tax summary by category.',
'class' => 'App\Reports\TaxSummary',
'group' => 'category',
'period' => 'quarterly',
'basis' => 'accrual',
'chart' => 'line',
'enabled' => 1,
],
[
'company_id' => $company->id,
'name' => trans('reports.profit_loss'),
'description' => 'This is the profit & loss by category.',
'class' => 'App\Reports\ProfitLoss',
'group' => 'category',
'period' => 'quarterly',
'basis' => 'accrual',
'chart' => 'line',
'enabled' => 1,
],
];
foreach ($rows as $row) {
Report::create($row);
}
}
public function createDashboards()
{
$users = User::enabled()->cursor();
foreach ($users as $user) {
$companies = $user->companies;
foreach ($companies as $company) {
Artisan::call('user:seed', [
'user' => $user->id,
'company' => $company->id,
]);
}
}
}
public function copyTransactions()
{
$this->copyInvoicePayments();
$this->copyRevenues();
$this->copyBillPayments();
$this->copyPayments();
}
public function copyInvoicePayments()
{
$invoice_payments = DB::table('invoice_payments')->cursor();
foreach ($invoice_payments as $invoice_payment) {
$invoice = DB::table('invoices')->where('id', $invoice_payment->invoice_id)->first();
$payment_method = str_replace('offlinepayment.', 'offline-payments.', $invoice_payment->payment_method);
$transaction = $this->create(new Transaction(), [
'company_id' => $invoice_payment->company_id,
'type' => 'income',
'account_id' => $invoice_payment->account_id,
'paid_at' => $invoice_payment->paid_at,
'amount' => $invoice_payment->amount,
'currency_code' => $invoice_payment->currency_code,
'currency_rate' => $invoice_payment->currency_rate,
'document_id' => $invoice_payment->invoice_id,
'contact_id' => $invoice->contact_id,
'description' => $invoice_payment->description,
'category_id' => $invoice->category_id,
'payment_method' => $payment_method,
'reference' => $invoice_payment->reference,
'parent_id' => $invoice->parent_id,
'reconciled' => $invoice_payment->reconciled,
'created_at' => $invoice_payment->created_at,
'updated_at' => $invoice_payment->updated_at,
'deleted_at' => $invoice_payment->deleted_at,
]);
if (Schema::hasTable('double_entry_ledger')) {
DB::table('double_entry_ledger')
->where('ledgerable_id', $invoice_payment->id)
->where('ledgerable_type', 'App\Models\Income\InvoicePayment')
->update([
'ledgerable_id' => $transaction->id,
'ledgerable_type' => 'App\Models\Banking\Transaction',
]);
}
}
DB::table('invoice_payments')->delete();
}
public function copyRevenues()
{
$revenues = DB::table('revenues')->cursor();
foreach ($revenues as $revenue) {
$transaction = $this->create(new Transaction(), [
'company_id' => $revenue->company_id,
'type' => 'income',
'account_id' => $revenue->account_id,
'paid_at' => $revenue->paid_at,
'amount' => $revenue->amount,
'currency_code' => $revenue->currency_code,
'currency_rate' => $revenue->currency_rate,
'contact_id' => $revenue->customer_id,
'description' => $revenue->description,
'category_id' => $revenue->category_id,
'payment_method' => $revenue->payment_method,
'reference' => $revenue->reference,
'parent_id' => $revenue->parent_id,
'reconciled' => $revenue->reconciled,
'created_at' => $revenue->created_at,
'updated_at' => $revenue->updated_at,
'deleted_at' => $revenue->deleted_at,
]);
DB::table('transfers')
->where('expense_transaction_id', $revenue->id)
->update([
'expense_transaction_id' => $transaction->id,
]);
DB::table('recurring')
->where('recurable_id', $revenue->id)
->where('recurable_type', 'App\Models\Income\Revenue')
->update([
'recurable_id' => $transaction->id,
'recurable_type' => 'App\Models\Banking\Transaction',
]);
DB::table('mediables')
->where('mediable_id', $revenue->id)
->where('mediable_type', 'App\Models\Income\Revenue')
->update([
'mediable_id' => $transaction->id,
'mediable_type' => 'App\Models\Banking\Transaction',
]);
if (Schema::hasTable('double_entry_ledger')) {
DB::table('double_entry_ledger')
->where('ledgerable_id', $revenue->id)
->where('ledgerable_type', 'App\Models\Income\Revenue')
->update([
'ledgerable_id' => $transaction->id,
'ledgerable_type' => 'App\Models\Banking\Transaction',
]);
}
if (Schema::hasTable('project_revenues')) {
DB::table('project_revenues')
->where('revenue_id', $revenue->id)
->update([
'revenue_id' => $transaction->id,
]);
}
}
DB::table('revenues')->delete();
}
public function copyBillPayments()
{
$bill_payments = DB::table('bill_payments')->cursor();
foreach ($bill_payments as $bill_payment) {
$bill = DB::table('bills')->where('id', $bill_payment->bill_id)->first();
$payment_method = str_replace('offlinepayment.', 'offline-payments.', $bill_payment->payment_method);
$transaction = $this->create(new Transaction(), [
'company_id' => $bill_payment->company_id,
'type' => 'expense',
'account_id' => $bill_payment->account_id,
'paid_at' => $bill_payment->paid_at,
'amount' => $bill_payment->amount,
'currency_code' => $bill_payment->currency_code,
'currency_rate' => $bill_payment->currency_rate,
'document_id' => $bill_payment->bill_id,
'contact_id' => $bill->contact_id,
'description' => $bill_payment->description,
'category_id' => $bill->category_id,
'payment_method' => $payment_method,
'reference' => $bill_payment->reference,
'parent_id' => $bill->parent_id,
'reconciled' => $bill_payment->reconciled,
'created_at' => $bill_payment->created_at,
'updated_at' => $bill_payment->updated_at,
'deleted_at' => $bill_payment->deleted_at,
]);
if (Schema::hasTable('double_entry_ledger')) {
DB::table('double_entry_ledger')
->where('ledgerable_id', $bill_payment->id)
->where('ledgerable_type', 'App\Models\Expense\BillPayment')
->update([
'ledgerable_id' => $transaction->id,
'ledgerable_type' => 'App\Models\Banking\Transaction',
]);
}
}
DB::table('bill_payments')->delete();
}
public function copyPayments()
{
$payments = DB::table('payments')->cursor();
foreach ($payments as $payment) {
$transaction = $this->create(new Transaction(), [
'company_id' => $payment->company_id,
'type' => 'expense',
'account_id' => $payment->account_id,
'paid_at' => $payment->paid_at,
'amount' => $payment->amount,
'currency_code' => $payment->currency_code,
'currency_rate' => $payment->currency_rate,
'contact_id' => $payment->vendor_id,
'description' => $payment->description,
'category_id' => $payment->category_id,
'payment_method' => $payment->payment_method,
'reference' => $payment->reference,
'parent_id' => $payment->parent_id,
'reconciled' => $payment->reconciled,
'created_at' => $payment->created_at,
'updated_at' => $payment->updated_at,
'deleted_at' => $payment->deleted_at,
]);
DB::table('transfers')
->where('expense_transaction_id', $payment->id)
->update([
'expense_transaction_id' => $transaction->id,
]);
DB::table('recurring')
->where('recurable_id', $payment->id)
->where('recurable_type', 'App\Models\Expense\Payment')
->update([
'recurable_id' => $transaction->id,
'recurable_type' => 'App\Models\Banking\Transaction',
]);
DB::table('mediables')
->where('mediable_id', $payment->id)
->where('mediable_type', 'App\Models\Expense\Payment')
->update([
'mediable_id' => $transaction->id,
'mediable_type' => 'App\Models\Banking\Transaction',
]);
if (Schema::hasTable('double_entry_ledger')) {
DB::table('double_entry_ledger')
->where('ledgerable_id', $payment->id)
->where('ledgerable_type', 'App\Models\Expense\Payment')
->update([
'ledgerable_id' => $transaction->id,
'ledgerable_type' => 'App\Models\Banking\Transaction',
]);
}
if (Schema::hasTable('project_payments')) {
DB::table('project_payments')
->where('payment_id', $payment->id)
->update([
'payment_id' => $transaction->id,
]);
}
if (Schema::hasTable('receipts')) {
DB::table('receipts')
->where('payment_id', $payment->id)
->update([
'payment_id' => $transaction->id,
]);
}
}
DB::table('payments')->delete();
}
public function copyContacts()
{
$this->copyCustomers();
$this->copyVendors();
}
public function copyCustomers()
{
$customers = DB::table('customers')->cursor();
foreach ($customers as $customer) {
$data = (array) $customer;
$data['type'] = 'customer';
$contact = $this->create(new Contact(), $data);
DB::table('invoices')
->where('contact_id', $customer->id)
->update([
'contact_id' => $contact->id,
]);
DB::table('transactions')
->where('contact_id', $customer->id)
->update([
'contact_id' => $contact->id,
]);
if (Schema::hasTable('estimates')) {
DB::table('estimates')
->where('customer_id', $customer->id)
->update([
'customer_id' => $contact->id,
]);
}
if (Schema::hasTable('crm_companies')) {
DB::table('crm_companies')
->where('core_customer_id', $customer->id)
->update([
'core_customer_id' => $contact->id,
]);
}
if (Schema::hasTable('crm_contacts')) {
DB::table('crm_contacts')
->where('core_customer_id', $customer->id)
->update([
'core_customer_id' => $contact->id,
]);
}
if (Schema::hasTable('idea_soft_histories')) {
DB::table('idea_soft_histories')
->where('model_id', $customer->id)
->where('model_type', 'App\Models\Income\Customer')
->update([
'model_id' => $contact->id,
'model_type' => 'App\Models\Common\Contact',
]);
}
}
DB::table('customers')->delete();
}
public function copyVendors()
{
$vendors = DB::table('vendors')->cursor();
foreach ($vendors as $vendor) {
$data = (array) $vendor;
$data['type'] = 'vendor';
$contact = $this->create(new Contact(), $data);
DB::table('bills')
->where('contact_id', $vendor->id)
->update([
'contact_id' => $contact->id,
]);
DB::table('transactions')
->where('contact_id', $vendor->id)
->update([
'contact_id' => $contact->id,
]);
}
DB::table('vendors')->delete();
}
public function updatePermissions()
{
$this->attachPermissions([
'admin' => [
'common-reports' => 'c,r,u,d',
'common-search' => 'r',
'common-widgets' => 'c,r,u,d',
'modules-api-key' => 'c,u',
'settings-appearance' => 'r,u',
'settings-company' => 'r',
'settings-defaults' => 'r',
'settings-email' => 'r',
'settings-invoice' => 'r',
'settings-localisation' => 'r',
'settings-modules' => 'r,u',
'settings-schedule' => 'r',
],
'manager' => [
'common-reports' => 'c,r,u,d',
'common-search' => 'r',
'common-widgets' => 'r',
'settings-company' => 'r',
'settings-defaults' => 'r',
'settings-email' => 'r',
'settings-invoice' => 'r',
'settings-localisation' => 'r',
'settings-modules' => 'r,u',
'settings-schedule' => 'r',
],
'customer' => [
'client-portal' => 'r',
'portal-invoices' => 'r,u',
'portal-payments' => 'r,u',
'portal-transactions' => 'r',
'portal-profile' => 'r,u',
],
]);
$this->detachPermissions([
'admin' => [
'read-modules-token',
'update-modules-token',
],
'customer' => [
'read-customer-panel',
'read-customers-invoices',
'update-customers-invoices',
'read-customers-payments',
'update-customers-payments',
'read-customers-transactions',
'read-customers-profile',
'update-customers-profile',
],
]);
}
public function attachPermissions($items)
{
$map = collect([
'c' => 'create',
'r' => 'read',
'u' => 'update',
'd' => 'delete'
]);
foreach ($items as $role_name => $modules) {
$role = Role::where('name', $role_name)->first();
// Reading role permission modules
foreach ($modules as $module => $value) {
$permissions = explode(',', $value);
foreach ($permissions as $p => $perm) {
$permissionValue = $map->get($perm);
$moduleName = ucwords(str_replace("-", " ", $module));
$permission = Permission::firstOrCreate([
'name' => $permissionValue . '-' . $module,
'display_name' => ucfirst($permissionValue) . ' ' . $moduleName,
'description' => ucfirst($permissionValue) . ' ' . $moduleName,
]);
$this->command->info('Creating Permission to '.$permissionValue.' for '. $moduleName);
if (!$role->hasPermission($permission->name)) {
$role->attachPermission($permission);
} else {
$this->command->info($role_name . ': ' . $p . ' ' . $permissionValue . ' already exist');
}
}
}
}
}
public function detachPermissions($items)
{
foreach ($items as $role_name => $permissions) {
$role = Role::where('name', $role_name)->first();
foreach ($permissions as $permission) {
$role->detachPermission($permission);
$permission->delete();
}
}
}
public function deleteOldFiles()
{
$files = [
'app/Console/Commands/ModuleDelete.php',
'app/Console/Commands/ModuleDisable.php',
'app/Console/Commands/ModuleEnable.php',
'app/Console/Commands/ModuleInstall.php',
'app/Console/Stubs/modules/route-provider.stub',
'app/Console/Stubs/modules/routes.stub',
'app/Console/Stubs/modules/start.stub',
'app/Console/Stubs/modules/views/master.stub',
'app/Events/AdminMenuCreated.php',
'app/Events/BillCreated.php',
'app/Events/BillUpdated.php',
'app/Events/CompanySwitched.php',
'app/Events/CustomerMenuCreated.php',
'app/Events/InvoiceCreated.php',
'app/Events/InvoicePaid.php',
'app/Events/InvoicePrinting.php',
'app/Events/InvoiceUpdated.php',
'app/Events/ModuleInstalled.php',
'app/Events/PaymentGatewayListing.php',
'app/Events/UpdateFinished.php',
'app/Http/Controllers/Api/Expenses/Payments.php',
'app/Http/Controllers/Api/Expenses/Vendors.php',
'app/Http/Controllers/Api/Incomes/Customers.php',
'app/Http/Controllers/Api/Incomes/InvoicePayments.php',
'app/Http/Controllers/Api/Incomes/Revenues.php',
'app/Http/Controllers/ApiController.php',
'app/Http/Controllers/Controller.php',
'app/Http/Controllers/Modals/BillPayments.php',
'app/Http/Controllers/Modals/InvoicePayments.php',
'app/Http/Controllers/modules/Token.php',
'app/Http/Middleware/CustomerMenu.php',
'app/Http/Middleware/SignedUrlCompany.php',
'app/Http/Requests/Expense/BillPayment.php',
'app/Http/Requests/Expense/Payment.php',
'app/Http/Requests/Expense/Vendor.php',
'app/Http/Requests/Income/Customer.php',
'app/Http/Requests/Income/InvoicePayment.php',
'app/Http/Requests/Income/Revenue.php',
'app/Http/Requests/Request.php',
'app/Http/ViewComposers/All.php',
'app/Jobs/Expense/CreateBillPayment.php',
'app/Jobs/Income/CreateInvoicePayment.php',
'app/Models/Company/Company.php',
'app/Models/Expense/BillPayment.php',
'app/Models/Expense/Payment.php',
'app/Models/Expense/Vendor.php',
'app/Models/Income/Customer.php',
'app/Models/Income/InvoicePayment.php',
'app/Models/Income/Revenue.php',
'app/Models/Item/Item.php',
'app/Models/Model.php',
'app/Notifications/Common/Item.php',
'app/Notifications/Common/ItemReminder.php',
'app/Notifications/Customer/Invoice.php',
'app/Providers/AppServiceProvider.php',
'app/Providers/AuthServiceProvider.php',
'app/Providers/BroadcastServiceProvider.php',
'app/Providers/EventServiceProvider.php',
'app/Providers/FormServiceProvider.php',
'app/Providers/ObserverServiceProvider.php',
'app/Providers/RouteServiceProvider.php',
'app/Providers/ValidationServiceProvider.php',
'app/Providers/ViewComposerServiceProvider.php',
'app/Transformers/Company/Company.php',
'app/Transformers/Expense/BillPayments.php',
'app/Transformers/Expense/Payment.php',
'app/Transformers/Expense/Vendor.php',
'app/Transformers/Income/Customer.php',
'app/Transformers/Income/InvoicePayments.php',
'app/Transformers/Income/Revenue.php',
'app/Transformers/Item/Item.php',
'config/dotenv-editor.php',
'config/eloquentfilter.php',
'config/menus.php',
'config/modules.php',
'docker-compose.yml',
'Dockerfile',
'modules/PaypalStandard/Http/Controllers/PaypalStandard.php',
'modules/PaypalStandard/Http/routes.php',
'modules/PaypalStandard/Listeners/Gateway.php',
'modules/PaypalStandard/Providers/PaypalStandardServiceProvider.php',
'modules/PaypalStandard/start.php',
'public/css/akaunting-green.css',
'public/css/app.css',
'public/css/bootstrap3-print-fix.css',
'public/css/bootstrap-fancyfile.css',
'public/css/countdown.css',
'public/css/daterangepicker.css',
'public/css/ekko-lightbox.css',
'public/css/font-awesome.min.css',
'public/css/install.css',
'public/css/invoice.css',
'public/css/ionicons.min.css',
'public/css/jquery.countdown.css',
'public/css/modules.css',
'public/css/skin-black.css',
'public/fonts/FontAwesome.otf',
'public/fonts/fontawesome-webfont.eot',
'public/fonts/fontawesome-webfont.svg',
'public/fonts/fontawesome-webfont.ttf',
'public/fonts/fontawesome-webfont.woff',
'public/fonts/fontawesome-webfont.woff2',
'public/img/install.jpg',
'public/img/login.jpg',
'public/img/maintanance.png',
'public/js/bootstrap-fancyfile.js',
'public/js/jquery/jquery.maskMoney.js',
'resources/assets/js/app.js',
'resources/assets/js/components/Example.vue',
'resources/assets/sass/_variables.scss',
'resources/assets/sass/app.scss',
'resources/views/layouts/customer.blade.php',
'resources/views/layouts/link.blade.php',
'resources/views/modules/token/create.blade.php',
'resources/views/partials/link/content.blade.php',
'resources/views/partials/link/footer.blade.php',
'resources/views/partials/link/head.blade.php',
'resources/views/reports/profit_loss/body.blade.php',
'resources/views/reports/profit_loss/index.blade.php',
'resources/views/reports/profit_loss/print.blade.php',
'resources/views/reports/tax_summary/body.blade.php',
'resources/views/reports/tax_summary/index.blade.php',
'resources/views/reports/tax_summary/print.blade.php',
'resources/views/settings/settings/edit.blade.php',
'resources/views/vendor/flash/message.blade.php',
'resources/views/vendor/flash/modal.blade.php',
'resources/views/wizard/currencies/create.blade.php',
'resources/views/wizard/currencies/edit.blade.php',
'resources/views/wizard/taxes/create.blade.php',
'resources/views/wizard/taxes/edit.blade.php',
'routes/web.php',
];
$directories = [
'app/Filters',
'app/Http/Controllers/Customers',
'app/Http/Controllers/Reports',
'app/Http/Requests/Customer',
'app/Listeners/Incomes',
'app/Listeners/Updates',
'app/Overrides',
'modules/OfflinePayment',
'public/js/chartjs',
'public/js/daterangepicker',
'public/js/highchart',
'public/js/lightbox',
'public/js/moment',
'resources/views/customers',
'resources/views/partials/customer',
'resources/views/reports/expense_summary',
'resources/views/reports/income_expense_summary',
'resources/views/reports/income_summary',
'tests/Feature/Reports',
];
foreach ($files as $file) {
Storage::delete(base_path($file));
}
foreach ($directories as $directory) {
Storage::deleteDirectory(base_path($directory));
}
}
protected function create($model, $data)
{
$model->timestamps = false;
$model->fillable(array_merge($model->getFillable(), ['created_at', 'updated_at', 'deleted_at']));
$model->fill($data);
$model->save();
return $model;
}
}