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

@@ -2,9 +2,9 @@
namespace App\Console\Commands;
use App\Events\Purchase\BillReminded;
use App\Events\Document\DocumentReminded;
use App\Models\Common\Company;
use App\Models\Purchase\Bill;
use App\Models\Document\Document;
use App\Utilities\Overrider;
use Date;
use Illuminate\Console\Command;
@@ -80,11 +80,11 @@ class BillReminder extends Command
$date = Date::today()->addDays($day)->toDateString();
// Get upcoming bills
$bills = Bill::with('contact')->accrued()->notPaid()->due($date)->cursor();
$bills = Document::bill()->with('contact')->accrued()->notPaid()->due($date)->cursor();
foreach ($bills as $bill) {
try {
event(new BillReminded($bill));
event(new DocumentReminded($bill));
} catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) {
$this->error($e->getMessage());

View File

@@ -2,9 +2,9 @@
namespace App\Console\Commands;
use App\Events\Sale\InvoiceReminded;
use App\Events\Document\DocumentReminded;
use App\Models\Common\Company;
use App\Models\Sale\Invoice;
use App\Models\Document\Document;
use App\Utilities\Overrider;
use Date;
use Illuminate\Console\Command;
@@ -80,11 +80,11 @@ class InvoiceReminder extends Command
$date = Date::today()->subDays($day)->toDateString();
// Get upcoming invoices
$invoices = Invoice::with('contact')->accrued()->notPaid()->due($date)->cursor();
$invoices = Document::invoice()->with('contact')->accrued()->notPaid()->due($date)->cursor();
foreach ($invoices as $invoice) {
try {
event(new InvoiceReminded($invoice));
event(new DocumentReminded($invoice));
} catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) {
$this->error($e->getMessage());

View File

@@ -4,13 +4,11 @@ namespace App\Console\Commands;
use App\Events\Banking\TransactionCreated;
use App\Events\Banking\TransactionRecurring;
use App\Events\Purchase\BillCreated;
use App\Events\Purchase\BillRecurring;
use App\Events\Sale\InvoiceCreated;
use App\Events\Sale\InvoiceRecurring;
use App\Events\Document\DocumentCreated;
use App\Events\Document\DocumentRecurring;
use App\Models\Banking\Transaction;
use App\Models\Common\Recurring;
use App\Models\Sale\Invoice;
use App\Models\Document\Document;
use App\Utilities\Date;
use App\Utilities\Overrider;
use Illuminate\Console\Command;
@@ -136,16 +134,10 @@ class RecurringCheck extends Command
}
switch ($type) {
case 'App\Models\Purchase\Bill':
event(new BillCreated($clone));
case 'App\Models\Document\Document':
event(new DocumentCreated($clone));
event(new BillRecurring($clone));
break;
case 'App\Models\Sale\Invoice':
event(new InvoiceCreated($clone));
event(new InvoiceRecurring($clone));
event(new DocumentRecurring($clone));
break;
case 'App\Models\Banking\Transaction':
@@ -272,11 +264,9 @@ class RecurringCheck extends Command
return 'paid_at';
}
if ($model instanceof Invoice) {
return 'invoiced_at';
if ($model instanceof Document) {
return 'issued_at';
}
return 'billed_at';
}
protected function getTable($model)
@@ -285,10 +275,8 @@ class RecurringCheck extends Command
return 'transactions';
}
if ($model instanceof Invoice) {
return 'invoices';
if ($model instanceof Document) {
return 'documents';
}
return 'bills';
}
}