From e071c3aae796b1c4a636171a843ec4abcdb166e9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 27 May 2022 09:51:54 +1000 Subject: [PATCH 1/2] Ensure freshness of models --- app/Http/Controllers/InvoiceController.php | 2 -- app/Http/ValidationRules/Payment/ValidInvoicesRules.php | 2 +- app/Services/Invoice/HandleCancellation.php | 7 +++++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index fff77983e4..78332a2ae5 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -220,8 +220,6 @@ class InvoiceController extends BaseController public function store(StoreInvoiceRequest $request) { - // $client = Client::find($request->input('client_id')); - $invoice = $this->invoice_repo->save($request->all(), InvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id)); $invoice = $invoice->service() diff --git a/app/Http/ValidationRules/Payment/ValidInvoicesRules.php b/app/Http/ValidationRules/Payment/ValidInvoicesRules.php index 25a5165234..121c1e7078 100644 --- a/app/Http/ValidationRules/Payment/ValidInvoicesRules.php +++ b/app/Http/ValidationRules/Payment/ValidInvoicesRules.php @@ -62,7 +62,7 @@ class ValidInvoicesRules implements Rule return false; } - $inv = Invoice::whereId($invoice['invoice_id'])->first(); + $inv = Invoice::withTrashed()->whereId($invoice['invoice_id'])->first(); if (! $inv) { diff --git a/app/Services/Invoice/HandleCancellation.php b/app/Services/Invoice/HandleCancellation.php index 837667cdc0..115d5c0a4b 100644 --- a/app/Services/Invoice/HandleCancellation.php +++ b/app/Services/Invoice/HandleCancellation.php @@ -51,6 +51,7 @@ class HandleCancellation extends AbstractService //adjust client balance $this->invoice->client->service()->updateBalance($adjustment)->save(); + $this->invoice->fresh(); $this->invoice->service()->workFlow()->save(); @@ -78,7 +79,8 @@ class HandleCancellation extends AbstractService $adjustment = $cancellation->adjustment * -1; $this->invoice->ledger()->updateInvoiceBalance($adjustment, "Invoice {$this->invoice->number} reversal"); - + $this->invoice->fresh(); + /* Reverse the invoice status and balance */ $this->invoice->balance += $adjustment; $this->invoice->status_id = $cancellation->status_id; @@ -90,7 +92,8 @@ class HandleCancellation extends AbstractService unset($backup->cancellation); $this->invoice->backup = $backup; $this->invoice->saveQuietly(); - + $this->invoice->fresh(); + return $this->invoice; } From 418c7c256f0ede7b2bb6c720b2f33ab7031efb45 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 27 May 2022 10:11:39 +1000 Subject: [PATCH 2/2] Prep for react app --- .github/workflows/release.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ef67001aca..f103c1f3c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,6 +39,17 @@ jobs: sudo find ./vendor/bin/ -type f -exec chmod +x {} \; sudo find ./ -type d -exec chmod 755 {} \; + - name: Prepare React FrontEnd + run: | + git clone https://${{secrets.commit_secret}}@github.com/invoiceninja/ui.git + cd ui + git checkout main + npm i + npm run build + cp -r dist/react/* ../public/react + cd .. + rm -rf ui + - name: Prepare JS/CSS assets run: | npm i