1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fixes for recurring invoice edge case

This commit is contained in:
David Bomba 2022-11-24 17:23:36 +11:00
parent 264a4df13b
commit 8f5fb2ca9f
8 changed files with 13 additions and 6 deletions

View File

@ -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 = [

View File

@ -125,6 +125,7 @@ class Company extends BaseModel
'invoice_task_project',
'report_include_deleted',
'invoice_task_lock',
'use_vendor_currency',
];
protected $hidden = [

View File

@ -79,7 +79,8 @@ class PurchaseOrder extends BaseModel
'partial',
'paid_to_date',
'vendor_id',
'last_viewed'
'last_viewed',
'currency_id',
];
protected $casts = [

View File

@ -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) {

View File

@ -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();

View File

@ -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,
];
}

View File

@ -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 : '',
];
}

View File

@ -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)