diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 23875c3f6c9a..90dd5e35fe8e 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -215,7 +215,7 @@ class ReminderJob implements ShouldQueue $client = $client->fresh(); nlog('adjusting client balance and invoice balance by #'.$invoice->number.' '.($invoice->balance - $temp_invoice_balance)); - $client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save(); + $client->service()->updateBalance($invoice->balance - $temp_invoice_balance); $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$invoice->number}"); $transaction = [ diff --git a/app/Models/Company.php b/app/Models/Company.php index 407cdb5ce827..37d4814e4da0 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -125,6 +125,7 @@ class Company extends BaseModel 'invoice_task_project', 'report_include_deleted', 'invoice_task_lock', + 'use_vendor_currency', ]; protected $hidden = [ diff --git a/app/Models/PurchaseOrder.php b/app/Models/PurchaseOrder.php index 851822e09841..5ef33b62dc34 100644 --- a/app/Models/PurchaseOrder.php +++ b/app/Models/PurchaseOrder.php @@ -79,7 +79,8 @@ class PurchaseOrder extends BaseModel 'partial', 'paid_to_date', 'vendor_id', - 'last_viewed' + 'last_viewed', + 'currency_id', ]; protected $casts = [ diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index a4d033c34559..6ffec56c2046 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -29,7 +29,6 @@ class ClientService public function updateBalance(float $amount) { - // $this->client->balance += $amount; \DB::connection(config('database.default'))->transaction(function () use($amount) { @@ -44,8 +43,6 @@ class ClientService public function updateBalanceAndPaidToDate(float $balance, float $paid_to_date) { - // $this->client->balance += $amount; - // $this->client->paid_to_date += $amount; \DB::connection(config('database.default'))->transaction(function () use($balance, $paid_to_date) { diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 0717804d7048..9a0efc7347d9 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -117,7 +117,7 @@ class InvoiceService public function applyPayment(Payment $payment, float $payment_amount) { // $this->deletePdf(); - $this->invoice = $this->markSent(); + $this->invoice = $this->markSent()->save(); $this->invoice = (new ApplyPayment($this->invoice, $payment, $payment_amount))->run(); diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 0651bc1eb7c6..1b47cdbd5b62 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -189,6 +189,7 @@ class CompanyTransformer extends EntityTransformer 'invoice_task_project' => (bool) $company->invoice_task_project, 'report_include_deleted' => (bool) $company->report_include_deleted, 'invoice_task_lock' => (bool) $company->invoice_task_lock, + 'use_vendor_currency' => (bool) $company->use_vendor_currency, ]; } diff --git a/app/Transformers/PurchaseOrderTransformer.php b/app/Transformers/PurchaseOrderTransformer.php index fd0684c76c08..d444addf07d7 100644 --- a/app/Transformers/PurchaseOrderTransformer.php +++ b/app/Transformers/PurchaseOrderTransformer.php @@ -132,6 +132,7 @@ class PurchaseOrderTransformer extends EntityTransformer 'paid_to_date' => (float)$purchase_order->paid_to_date, 'subscription_id' => $this->encodePrimaryKey($purchase_order->subscription_id), 'expense_id' => $this->encodePrimaryKey($purchase_order->expense_id), + 'currency_id' => $purchase_order->currency_id ? (string) $purchase_order->currency_id : '', ]; } diff --git a/database/migrations/2022_11_22_215618_lock_tasks_when_invoiced.php b/database/migrations/2022_11_22_215618_lock_tasks_when_invoiced.php index 00c1925cb016..30bb7f57261c 100644 --- a/database/migrations/2022_11_22_215618_lock_tasks_when_invoiced.php +++ b/database/migrations/2022_11_22_215618_lock_tasks_when_invoiced.php @@ -22,6 +22,12 @@ return new class extends Migration Schema::table('companies', function (Blueprint $table) { $table->boolean('invoice_task_lock')->default(false); + $table->boolean('use_vendor_currency')->default(false); + }); + + Schema::table('purchase_orders', function (Blueprint $table) + { + $table->unsignedInteger('currency_id')->nullable(); }); Schema::table('bank_transactions', function (Blueprint $table)