Fixes for calculating pro rata refunds between subscriptions with differing frequencies
This commit is contained in:
parent
686b48c42b
commit
b0e61759d5
|
|
@ -22,7 +22,7 @@ use Livewire\Component;
|
|||
class SubscriptionPlanSwitch extends Component
|
||||
{
|
||||
/**
|
||||
* @var RecurringInvoice
|
||||
* @var \App\Models\RecurringInvoice
|
||||
*/
|
||||
public $recurring_invoice;
|
||||
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ class SubscriptionService
|
|||
* @param Invoice $invoice
|
||||
* @return float
|
||||
*/
|
||||
private function calculateProRataRefund($invoice) :float
|
||||
private function calculateProRataRefund($invoice, $subscription = null) :float
|
||||
{
|
||||
if (!$invoice || !$invoice->date) {
|
||||
return 0;
|
||||
|
|
@ -367,7 +367,10 @@ class SubscriptionService
|
|||
|
||||
$days_of_subscription_used = $start_date->diffInDays($current_date);
|
||||
|
||||
$days_in_frequency = $this->getDaysInFrequency();
|
||||
if($subscription)
|
||||
$days_in_frequency = $subscription->service()->getDaysInFrequency();
|
||||
else
|
||||
$days_in_frequency = $this->getDaysInFrequency();
|
||||
|
||||
if ($days_of_subscription_used >= $days_in_frequency) {
|
||||
return 0;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
{"/livewire.js":"/livewire.js?id=fe747446aa84856d8b66"}
|
||||
{"/livewire.js":"/livewire.js?id=90730a3b0e7144480175"}
|
||||
Loading…
Reference in New Issue