update rm deadcode
This commit is contained in:
@@ -11,6 +11,7 @@ use App\Repositories\Api\Service\ServiceRepository;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceItem;
|
||||
use App\Models\Service;
|
||||
use App\Support\RenewalPricing;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -230,8 +231,10 @@ class ServiceExpiry extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
$price = $this->renewalPrice($orderItem);
|
||||
$renewalPrice = $this->renewalPrice($orderItem);
|
||||
$months = $orderItem->months ?? 1;
|
||||
$addonTotal = RenewalPricing::addonTotal($service, 1);
|
||||
$price = $renewalPrice + $addonTotal;
|
||||
|
||||
if ($price <= 0) {
|
||||
Log::warning('service:expiry | Cannot create renewal invoice: zero price', ['service_id' => $service->id]);
|
||||
@@ -270,12 +273,16 @@ class ServiceExpiry extends Command
|
||||
'product_id' => $service->product_id,
|
||||
'type' => 'renewal',
|
||||
'description' => 'Gia hạn dịch vụ: ' . ($orderItem->product?->name ?? $service->server_name ?? ''),
|
||||
'months' => $orderItem->months ?? 1,
|
||||
'months' => $months,
|
||||
'quantity' => 1,
|
||||
'unit_price' => $price,
|
||||
'total_price' => $price,
|
||||
'unit_price' => $renewalPrice,
|
||||
'total_price' => $renewalPrice,
|
||||
]);
|
||||
|
||||
foreach (RenewalPricing::addonInvoiceItems($service, 1, $months) as $addonItem) {
|
||||
InvoiceItem::create($addonItem + ['invoice_id' => $invoice->id]);
|
||||
}
|
||||
|
||||
// Update service to point to the new renewal invoice
|
||||
$service->update(['invoice_id' => $invoice->id]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user