diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000000..a4e94fa4b0b5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,41 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: triage +assignees: '' + +--- + +**What version of Invoice Ninja are you running? ie v4.5.25 / v5.0.30** + +**What environment are you running?** +Docker +Shared Hosting +ZIP +Other + +**Have you checked log files (storage/logs/) Please provide redacted output** + +**Have you searched existing issues?** + +**Have you reported this to Slack/forum before posting?** + +**Describe the bug** +A clear and concise description of what the bug is. + +**Steps To Reproduce** +Please list the steps to reproduce the issue + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. + + + +**(v5) Can you replicate the issue on our demo site? https://demo.invoiceninja.com** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000000..9c38e2edca07 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,24 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: feature request +assignees: '' + +--- + +**What version of Invoice Ninja are you running? ie v4.5 / v5** + +**What environment are you running?** +Docker +Shared Hosting +ZIP +Other + +**Have you searched existing issues/requests?** + +**Screenshots** +If applicable, add screenshots to help explain your request/question. + +**Additional context** +Add any other context about the request/question here. diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 54bfcb799ea1..221c048ed0e5 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -95,7 +95,6 @@ class ClientService { $credits = Credit::withTrashed()->where('client_id', $this->client->id) ->where('is_deleted', false) - ->where('balance', '>', 0) ->where(function ($query) { $query->whereDate('due_date', '<=', now()->format('Y-m-d')) ->orWhereNull('due_date'); diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index 4a1c5e52d2f4..f09dad17504e 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -167,7 +167,7 @@ class CreditService } public function adjustBalance($adjustment) - { + {nlog("adjusting by {$adjustment}"); $this->credit->balance += $adjustment; return $this; diff --git a/app/Services/Payment/RefundPayment.php b/app/Services/Payment/RefundPayment.php index f16576c0d11f..edacc89e6594 100644 --- a/app/Services/Payment/RefundPayment.php +++ b/app/Services/Payment/RefundPayment.php @@ -69,16 +69,6 @@ class RefundPayment EmailRefundPayment::dispatch($this->payment, $this->payment->company, $contact); } - $transaction = [ - 'invoice' => [], - 'payment' => $this->payment->transaction_event(), - 'client' => $this->payment->client->transaction_event(), - 'credit' => [], - 'metadata' => [], - ]; - - // TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $this->payment->company->db); - $notes = ctrans('texts.refunded') . " : {$this->total_refund} - " . ctrans('texts.gateway_refund') . " : "; $notes .= $this->refund_data['gateway_refund'] !== false ? ctrans('texts.yes') : ctrans('texts.no'); @@ -210,6 +200,7 @@ class RefundPayment if ($this->payment->credits()->exists()) { //Adjust credits first!!! foreach ($this->payment->credits as $paymentable_credit) { + $available_credit = $paymentable_credit->pivot->amount - $paymentable_credit->pivot->refunded; if ($available_credit > $this->total_refund) { @@ -221,18 +212,18 @@ class RefundPayment ->updateBalance($this->total_refund) ->updatePaidToDate($this->total_refund * -1) ->save(); + $this->total_refund = 0; } else { $paymentable_credit->pivot->refunded += $available_credit; $paymentable_credit->pivot->save(); - $paymentable_credit->balance += $available_credit; $paymentable_credit->service() - ->setStatus(Credit::STATUS_SENT) + ->setStatus(Credit::STATUS_SENT) ->adjustBalance($available_credit) ->updatePaidToDate($available_credit * -1) - ->save(); + ->save(); $this->total_refund -= $available_credit; } @@ -288,16 +279,6 @@ class RefundPayment ->updateBalance($refunded_invoice['amount']) ->save(); - $transaction = [ - 'invoice' => $invoice->transaction_event(), - 'payment' => [], - 'client' => $client->transaction_event(), - 'credit' => [], - 'metadata' => [], - ]; - - // TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $invoice->company->db); - if ($invoice->is_deleted) { $invoice->delete(); } @@ -311,15 +292,6 @@ class RefundPayment $client->service()->updatePaidToDate(-1 * $refunded_invoice['amount'])->save(); - $transaction = [ - 'invoice' => [], - 'payment' => [], - 'client' => $client->transaction_event(), - 'credit' => [], - 'metadata' => [], - ]; - - // TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $client->company->db); } else { //if we are refunding and no payments have been tagged, then we need to decrement the client->paid_to_date by the total refund amount. @@ -331,15 +303,6 @@ class RefundPayment $client->service()->updatePaidToDate(-1 * $this->total_refund)->save(); - $transaction = [ - 'invoice' => [], - 'payment' => [], - 'client' => $client->transaction_event(), - 'credit' => [], - 'metadata' => [], - ]; - - // TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $client->company->db); } return $this; diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 05b17e08b085..4b2d7d1cfc48 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -239,6 +239,11 @@ class SubscriptionService ->where('status_id', Invoice::STATUS_PAID) ->first(); +if($last_invoice) + nlog($last_invoice->toArray()); +else + nlog("no invoice found"); + $refund = $this->calculateProRataRefundForSubscription($last_invoice); if($use_credit_setting != 'off') @@ -709,6 +714,12 @@ class SubscriptionService $recurring_invoice = $this->createNewRecurringInvoice($old_recurring_invoice); + //update the invoice and attach to the recurring invoice!!!!! + $invoice = Invoice::find($payment_hash->fee_invoice_id); + $invoice->recurring_id = $recurring_invoice->id; + $invoice->is_proforma = false; + $invoice->save(); + $context = [ 'context' => 'change_plan', 'recurring_invoice' => $recurring_invoice->hashed_id, @@ -910,7 +921,7 @@ class SubscriptionService $invoice = InvoiceFactory::create($this->subscription->company_id, $this->subscription->user_id); $invoice->line_items = $subscription_repo->generateLineItems($this->subscription); $invoice->subscription_id = $this->subscription->id; - $invoice->is_proforman = true; + $invoice->is_proforma = true; if(strlen($data['coupon']) >=1 && ($data['coupon'] == $this->subscription->promo_code) && $this->subscription->promo_discount > 0) { diff --git a/app/Services/Subscription/ZeroCostProduct.php b/app/Services/Subscription/ZeroCostProduct.php index b16aea48ce26..45439845c1cd 100644 --- a/app/Services/Subscription/ZeroCostProduct.php +++ b/app/Services/Subscription/ZeroCostProduct.php @@ -66,6 +66,9 @@ class ZeroCostProduct extends AbstractService ->start() ->save(); + $invoice->recurring_id = $recurring_invoice->id; + $invoice->save(); + $context = [ 'context' => 'recurring_purchase', 'recurring_invoice' => $recurring_invoice->hashed_id, diff --git a/app/Utils/Traits/Pdf/PDF.php b/app/Utils/Traits/Pdf/PDF.php index a3f0727f714f..7021fc8c3be8 100644 --- a/app/Utils/Traits/Pdf/PDF.php +++ b/app/Utils/Traits/Pdf/PDF.php @@ -19,7 +19,7 @@ class PDF extends FPDI public function Footer() { - $this->SetXY(0, -5); + $this->SetXY(0, -6); $this->SetFont('Arial', 'I', 9); $this->SetTextColor(135, 135, 135);