-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swapAndInvoice giving unexpected result #263
Comments
Hi @Tailchakra , Thanks for reporting this. We're attempting to reproduce the error. Has anything happened to the user balance in cashier? |
Hi @Tailchakra, I can’t reproduce the issue without more data. Could you provide the details for the OrderItems used in this calculation? I noticed you overrode the logic that calculates the reimbursement amount. Have you recently introduced this change, so that it might be responsible for the missing reimburseable amount? Why do you want to keep the discount to be calculated from the |
Not as far as I can see currently.
@Naoray Hi, I also had to alter the percentage coupon because it gave a 10% over the total price and not the original price. But no, it does not seem to keep it from reimbursing, little note - I cannot seem to reproduce this on my own account as well. When I swapandinvoice it works for me, but this random occurrence made me worried it may happen more often. |
@Tailchakra there is neither a public function getTotalAttribute()
{
$beforeTax = $this->getSubtotal();
return (int) $beforeTax->add($this->getTax())->getAmount();
}
As you can see, the public function getSubtotalAttribute()
{
return (int) $this->getUnitPrice()->multiply($this->quantity ?: 1)->getAmount();
} So the "issue" why you received a A tip for your // App\Models\Plan
class Plan extends Model
{
public $casts = [
'amount' => 'array',
'first_payment_amount' => 'array',
'first_payment_method' => 'array',
];
//...
}
// App\Repositories\PlanRepository
class PlanRepository implements PlanRepositoryContract
{
public static function find(string $name)
{
$plan = Plan::where('name', $name)->first();
if (is_null($plan)) {
return null;
}
return $plan->buildCashierPlan();
}
// ...
} In general I'd advise to delete your custom code for If you have further questions, please feel free to ask them :). |
@Naoray For the record, I can't seem to reproduce this myself either. With the original code it completely miscalculated the coupon discount during reimbursement , with my edits it calculates it correctly. However with this one client it not only didn't reimburse, it also extended the time of the cycle to the end of next month? My edits are documented here: https://discord.com/channels/1037712581407817839/1257434407766200351/1260923312876294225
The getTotal() was a part of the original laravel-cashier-mollie code though. Altering that to the unit_price made it work in the first place.
The 10% was a discount through a coupon. What it originally did was this: Price is 10EUR but with taxes it's 12,10EUR. Coupon took 10% from 12,10EUR and then added 21% on top of THAT causing it to give 14,64EUR discount with a 10% discount over 10EUR. That was because it took the unitprice of the getTotal instead of getSubtotal. Deleting my custom code for |
@Tailchakra could you provide me with the exact prices of the previous paid subscription (subtotal and taxes) please? If the calculation is wrong I'd like to address the issue asap.
Are you sure that the Can you also paste your |
I am using $subscription->swapAndInvoice of the Mollie Cashier repository. Usually it should refund the unused days and invoice for the full new price. Which normally works. However with the latest swapAndInvoice my customer suddenly doesn't get their old price refunded but instead the cycle gets lengthened to 30-09-2024. So now his cycle runs from 14-08-2024 to 30-09-2024. This brings two issues:
Issue 1. He didn't pay the new price for 14-08-2024 to 30-08-2024 but did instantly get the new features;
Issue 2. Maybe he didn't want the extend from 30-08-2024 to 30-09-2024.
This is in the Cashier\Subscription model:
Plan Model:
PlanRepository:
This is the expected result:
But it simply gives a new invoice with only the new price and adds this to the database cycle:
The text was updated successfully, but these errors were encountered: