cancel invoice/bill

This commit is contained in:
denisdulici
2020-03-28 17:54:36 +03:00
parent 889be5fd98
commit 75413a0496
30 changed files with 445 additions and 104 deletions

View File

@ -1,5 +1,6 @@
<?php
use App\Events\Purchase\BillCancelled;
use App\Events\Purchase\BillCreated;
use App\Events\Purchase\BillReceived;
use App\Jobs\Banking\CreateDocumentTransaction;
@ -32,7 +33,7 @@ $factory->define(Bill::class, function (Faker $faker) use ($company) {
$contact = factory(Contact::class)->states('enabled', 'vendor')->create();
}
$statuses = ['draft', 'received', 'partial', 'paid'];
$statuses = ['draft', 'received', 'partial', 'paid', 'cancelled'];
return [
'company_id' => $company->id,
@ -62,6 +63,8 @@ $factory->state(Bill::class, 'partial', ['status' => 'partial']);
$factory->state(Bill::class, 'paid', ['status' => 'paid']);
$factory->state(Bill::class, 'cancelled', ['status' => 'cancelled']);
$factory->state(Bill::class, 'recurring', function (Faker $faker) {
$frequencies = ['monthly', 'weekly'];
@ -175,6 +178,10 @@ $factory->afterCreating(Bill::class, function ($bill, $faker) use ($company) {
$transaction = dispatch_now(new CreateDocumentTransaction($updated_bill, $payment_request));
break;
case 'cancelled':
event(new BillCancelled($updated_bill));
break;
}
});

View File

@ -1,5 +1,6 @@
<?php
use App\Events\Sale\InvoiceCancelled;
use App\Events\Sale\InvoiceCreated;
use App\Events\Sale\InvoiceSent;
use App\Events\Sale\InvoiceViewed;
@ -33,7 +34,7 @@ $factory->define(Invoice::class, function (Faker $faker) use ($company) {
$contact = factory(Contact::class)->states('enabled', 'customer')->create();
}
$statuses = ['draft', 'sent', 'viewed', 'partial', 'paid'];
$statuses = ['draft', 'sent', 'viewed', 'partial', 'paid', 'cancelled'];
return [
'company_id' => $company->id,
@ -65,6 +66,8 @@ $factory->state(Invoice::class, 'partial', ['status' => 'partial']);
$factory->state(Invoice::class, 'paid', ['status' => 'paid']);
$factory->state(Invoice::class, 'cancelled', ['status' => 'cancelled']);
$factory->state(Invoice::class, 'recurring', function (Faker $faker) {
$frequencies = ['monthly', 'weekly'];
@ -184,6 +187,10 @@ $factory->afterCreating(Invoice::class, function ($invoice, $faker) use ($compan
event(new PaymentReceived($updated_invoice, $payment_request));
break;
case 'cancelled':
event(new InvoiceCancelled($updated_invoice));
break;
}
});