diff --git a/app/Jobs/Commands/Moons/MoonRentalInvoiceCreate.php b/app/Jobs/Commands/Moons/MoonRentalInvoiceCreate.php
deleted file mode 100644
index 4006db994..000000000
--- a/app/Jobs/Commands/Moons/MoonRentalInvoiceCreate.php
+++ /dev/null
@@ -1,231 +0,0 @@
-contact = $contact;
-
- //Setup today's date
- $this->today = Carbon::now();
- $this->today->second = 1;
- $this->today->minute = 0;
- $this->today->hour = 0;
-
- //Setup the delay
- $this->delay = $mailDelay;
-
- //Null out unused variables when calling the construct
- $this->rentals = null;
-
- //Set the connection
- $this->connection = 'redis';
- }
-
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- //Create needed variables
- $moonCalc = new MoonCalc;
- $lookup = new LookupHelper;
- $body = null;
- $delay = 60;
- $config = config('esi');
- $moons = null;
-
- //Get the rentals the contact is renting
- $this->rentals = MoonRental::where([
- 'Contact' => $this->contact,
- ])->get();
-
- //Totalize the cost of the moons
- $cost = $this->TotalizeMoonCost();
-
- //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:
";
- foreach($listItems as $item) {
- $body .= $item . "
";
- }
- $body .= "The price for the next's month rent is " . number_format($cost, 2, ".", ",") . " ISK
";
- $body .= "Please remit payment to Spatial Forces on the 1st should you continue to wish to rent the moon.
";
- $body .= "In the description of the payment put the invoice number of: " . $invoiceId . "
";
- $body .= "Sincerely,
";
- $body .= "Warped Intentions Leadership
";
-
- //Get the information compiled for creating the rental invoice
- $charInfo = $lookup->GetCharacterInfo($this->contact);
- $corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
- foreach($listItems as $item) {
- $moons .= $item . ',';
- }
- $moons = rtrim($moons, ',');
-
- //Create the moon invoice and save it to the database
- $invoice = new RentalMoonInvoice;
- $invoice->character_id = $this->contact;
- $invoice->character_name = $charInfo->name;
- $invoice->corporation_id = $charInfo->character_id;
- $invoice->corporation_name = $corpInfo->name;
- $invoice->rental_moons = $moons;
- $invoice->invoice_amount = $cost;
- $invoice->due_date = Carbon::now()->addDays(3);
- $invoice->paid = 'No';
- $invoice->save();
-
- //Dispatch a new mail job
- $subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
- //ProcessSendEveMailJob::dispatch($body, (int)$contact->Contact, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($this->delay));
- ProcessSendEveMailJob::dispatch($body, $config['primary'], 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($this->delay));
-
- MoonRentalUpdate::dispatch($this->rentals)->onQueue('moons');
- }
-
- private function TotalizeMoonCost() {
- $totalCost = 0.00;
- $price = null;
-
- foreach($this->rentals as $rental) {
- $moon = RentalMoon::where([
- 'System' => $rental->System,
- 'Planet' => $rental->Planet,
- 'Moon' => $rental->Moon,
- ])->first();
-
- $end = new Carbon($rental->Paid_Until);
-
- //If today is greater than the rental end, then calculate the moon cost
- if($today->greaterThanOrEqualTo($end)) {
- //Get the updated price for the moon
- $price = $moonCalc->SpatialMoons($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
- $moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
-
- //Check the type and figure out which price to add in
- if($rental->Type == 'alliance') {
- $totalCost += $price['alliance'];
- } else {
- $totalCost += $price['outofalliance'];
- }
- }
- }
-
- //Return the total cost to the calling function
- return $totalCost;
- }
-
- private function GetMoonList() {
- //Declare the list variable as an array
- $list = array();
-
- //Foreach of the moons, build the system, planet, and moon
- foreach($this->rentals as $moon) {
- $temp = 'Moon: ' . $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon;
- array_push($list, $temp);
- }
-
- //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;
- }
-}
diff --git a/app/Jobs/Commands/Moons/MoonRentalInvoiceVerify.php b/app/Jobs/Commands/Moons/MoonRentalInvoiceVerify.php
deleted file mode 100644
index 07f3f55d8..000000000
--- a/app/Jobs/Commands/Moons/MoonRentalInvoiceVerify.php
+++ /dev/null
@@ -1,118 +0,0 @@
-connection = 'redis';
- }
-
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- //Create the date to look through
- $date = Carbon::now()->subDays(60);
-
- //Get the open moon rental invoices
- $unpaid = MoonRentalInvoice::where([
- 'Paid' => 'No',
- ])->get();
-
- //If there are no unpaid invoices, then return out of the job as successful
- if($unpaid == null || $unpaid == false) {
- return;
- }
-
- //Foreach unpaid invoice, run through them and check if there is an entry in the player journal table to verify the invoice
- foreach($unpaid as $un) {
- //Get everything which has a description like the invoice code.
- $checkA = PlayerDonationJournal::where('description', 'like', '%' . $un->invoice_id . '%')->get();
-
- //Get the player donations and corp transfers which have the amount we are looking for
- $checkB = PlayerDonationJournal::where([
- 'amount' => $un->invoice_amount,
- ])->where('date', '>=', $date)->get();
-
- //Check each of the checkA's for the correct description
- foreach($checkA as $check) {
- //Search for the sub string of the invoice id in the description
- $desc = strstr($check->description, $un->invoice_id);
- //If the description is found, then update the invoice.
- //Create an invoice payment
- if($desc == $un->invoice_id) {
- //Insert a new moon rental payment once completed
- MoonRentalPayment::insert([
- 'invoice_id' => $un->invoice_id,
- 'payment_amount' => $un->invoice_amount,
- 'reference_payment' => $check->id,
- ]);
-
- //Update the invoice as paid
- MoonRentalInvoice::where([
- 'invoice_id' => $un->invoice_id,
- ])->update([
- 'Paid' => 'Yes',
- ]);
-
- //Increase the moon rental by another month
- $moons = $un->rental_moons;
- //Turns the moons into an array
- $moons = explode(',', $moons);
- foreach($moons as $moon) {
- //Need to separate each moon into system, planet, and moon to update the moon rental
-
- }
- }
- }
-
- //Check each of checkB's for the invoice amount
- foreach($checkB as $check) {
-
- }
- }
- }
-}
diff --git a/app/Jobs/Commands/Moons/MoonRentalUpdate.php b/app/Jobs/Commands/Moons/MoonRentalUpdate.php
deleted file mode 100644
index 02a9b080e..000000000
--- a/app/Jobs/Commands/Moons/MoonRentalUpdate.php
+++ /dev/null
@@ -1,35 +0,0 @@
-connection = 'redis';
- }
-
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- //
- }
-}
diff --git a/app/Jobs/Commands/Moons/UpdateMoonRentalPrice.php b/app/Jobs/Commands/Moons/UpdateMoonRentalPrice.php
deleted file mode 100644
index 5efce1771..000000000
--- a/app/Jobs/Commands/Moons/UpdateMoonRentalPrice.php
+++ /dev/null
@@ -1,71 +0,0 @@
-connection = 'redis';
- }
-
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- //Declare the helper for moon calculations
- $moonHelper = new MoonCalc;
- //Get all the moons from the rental database
- $moons = AllianceRentalMoon::all();
- //Get the configuration from the database for the pricing calculate of rental moons
- $config = DB::table('Config')->get();
-
- /**
- * Calculate the worth of each moon along with the rental prices.
- */
- foreach($moons as $rental) {
-
- }
- }
-}
diff --git a/app/Jobs/Commands/RentalMoons/UpdateMoonRentalPaidState.php b/app/Jobs/Commands/RentalMoons/UpdateMoonRentalPaidState.php
new file mode 100644
index 000000000..6b0d30ec8
--- /dev/null
+++ b/app/Jobs/Commands/RentalMoons/UpdateMoonRentalPaidState.php
@@ -0,0 +1,71 @@
+connection = 'redis';
+ }
+
+ /**
+ * Execute the job.
+ *
+ * @return void
+ */
+ public function handle()
+ {
+ //Get all of the moons from the rental database
+ $moons = AllianceRentalMoons::all();
+
+ /**
+ * For each of the moons check the rental until date, the paid until date,
+ * and compare them to today's current date.
+ *
+ * If the paid date is later than the rental until date, then update the rental until
+ * date to match the paid date. If the paid until date is today or less, then update the
+ * paid column of the moon to not paid. If the moon hasn't been paid 2 weeks after the first
+ * of the month, then remove the renter, and send an eve mail to alliance leadership, and the renter
+ * denoting failure of payment has resulted in the moon rental for the current month being
+ * revoked.
+ */
+ foreach($moon as $rental) {
+
+ }
+ }
+}
diff --git a/app/Jobs/Commands/RentalMoons/UpdateMoonRentalPrice.php b/app/Jobs/Commands/RentalMoons/UpdateMoonRentalPrice.php
new file mode 100644
index 000000000..23487238a
--- /dev/null
+++ b/app/Jobs/Commands/RentalMoons/UpdateMoonRentalPrice.php
@@ -0,0 +1,99 @@
+connection = 'redis';
+ }
+
+ /**
+ * Execute the job.
+ *
+ * @return void
+ */
+ public function handle()
+ {
+ //Declare the helper for moon calculations
+ $moonHelper = new MoonCalc;
+ //Get all the moons from the rental database
+ $moons = AllianceRentalMoon::all();
+
+ /**
+ * Calculate the worth of each moon along with the rental prices.
+ * For all of the moon calculations, the price of the mineral is averaged,
+ * thereby, the price of the moon worth is also averaged based on the averaging
+ * of the mineral price.
+ */
+ foreach($moons as $rental) {
+ //Calculate the total worth of the moon
+ $totalWorth = $moonHelper->SpatialMoonsTotalWorth(
+ $rental->first_ore, $rental->first_quantity,
+ $rental->second_ore, $rental->second_quantity,
+ $rental->third_ore, $rental->third_quantity,
+ $rental->fourth_ore, $rental->fourth_quantity,
+ );
+
+ //Calculate the rental prices of the moon
+ $rentalPrice = $moonHelper->SpatialMoons(
+ $rental->first_ore, $rental->first_quantity,
+ $rental->second_ore, $rental->second_quantity,
+ $rental->third_ore, $rental->third_quantity,
+ $rental->fourth_ore, $rental->fourth_quantity,
+ );
+
+ //Update the moon in the database
+ AllianceRentalMoon::where([
+ 'region' => $rental->region,
+ 'system' => $rental->system,
+ 'planet' => $rental->planet,
+ 'moon' => $rental->moon,
+ ])->update([
+ 'moon_worth' => $totalWorth,
+ 'alliance_rental_price' => $rentalPrice['alliance'],
+ 'out_of_alliance_rental_price' => $rentalPrice['outofalliance'],
+ ]);
+ }
+ }
+}