added creation of invoice id to create invoice job
This commit is contained in:
@@ -106,6 +106,8 @@ class MoonRentalInvoiceCreate implements ShouldQueue
|
||||
//Get the list of the moons in a list format
|
||||
$listItems = $this->GetMoonList();
|
||||
|
||||
$invoiceId = $this->CreateInvoiceId();
|
||||
|
||||
//Build a mail body to be sent to the renter
|
||||
$body = "Moon Rent is due for the following moons:<br>";
|
||||
foreach($listItems as $item) {
|
||||
@@ -113,6 +115,7 @@ class MoonRentalInvoiceCreate implements ShouldQueue
|
||||
}
|
||||
$body .= "The price for the next's month rent is " . number_format($cost, 2, ".", ",") . " ISK<br>";
|
||||
$body .= "Please remit payment to Spatial Forces on the 1st should you continue to wish to rent the moon.<br>";
|
||||
$body .= "In the description of the payment put the invoice number of: " . $invoiceId . "<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
@@ -189,4 +192,23 @@ class MoonRentalInvoiceCreate implements ShouldQueue
|
||||
//Return the list
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function CreateInvoiceId() {
|
||||
//Set continue to true as a default.
|
||||
$continue = true;
|
||||
//Continually get a unique id until one is found where it's not used.
|
||||
do {
|
||||
$invoiceId = uniqid('rmi_', true);
|
||||
|
||||
$count = MoonRentalInvoice::where(['invoice_id' => $invoiceId])->count();
|
||||
if($count == 0) {
|
||||
$continue = false;
|
||||
}
|
||||
} while ($continue == true);
|
||||
|
||||
return $invoiceId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,12 @@ class CreateAllianceMoonRentalInvoicesTable extends Migration
|
||||
if(!Schema::hasTable('alliance_moon_rental_invoices')) {
|
||||
Schema::create('alliance_moon_rental_invoices', function (Blueprint $table) {
|
||||
$table->unsignedBigIncrements('id');
|
||||
$table->string('invoice_id')->unique();
|
||||
$table->unsignedBigInteger('character_id');
|
||||
$table->string('character_name');
|
||||
$table->unsignedBigInteger('corporation_id');
|
||||
$table->string('corporation_name');
|
||||
$table->text('rental_moons');
|
||||
$table->text('rental_moons')->nullalbe();
|
||||
$table->decimal('invoice_amount', 17, 2);
|
||||
$table->dateTime('due_date');
|
||||
$table->enum('paid', ['Yes', 'No'])->default('No');
|
||||
@@ -31,9 +32,8 @@ class CreateAllianceMoonRentalInvoicesTable extends Migration
|
||||
if(!Schema::hasTable('alliance_moon_rental_payments')) {
|
||||
Schema::create('alliance_moon_rental_payments', function (Blueprint $table) {
|
||||
$table->unsignedBigIncrements('id');
|
||||
$table->unsignedBigInteger('invoice_id');
|
||||
$table->string('invoice_id')->unique();
|
||||
$table->decimal('payment_amount');
|
||||
$table->unsignedBigInteger('reference_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user