mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add transaction id to expenses and payments
This commit is contained in:
parent
dd414fc588
commit
023d596844
@ -133,6 +133,8 @@ class MatchBankTransactions implements ShouldQueue
|
|||||||
|
|
||||||
foreach($invoices as $invoice){
|
foreach($invoices as $invoice){
|
||||||
|
|
||||||
|
$invoice->service()->markSent();
|
||||||
|
|
||||||
if(!$invoice->isPayable())
|
if(!$invoice->isPayable())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -171,6 +173,7 @@ class MatchBankTransactions implements ShouldQueue
|
|||||||
$expense->currency_id = $this->bt->currency_id;
|
$expense->currency_id = $this->bt->currency_id;
|
||||||
$expense->date = Carbon::parse($this->bt->date);
|
$expense->date = Carbon::parse($this->bt->date);
|
||||||
$expense->public_notes = $this->bt->description;
|
$expense->public_notes = $this->bt->description;
|
||||||
|
$expense->transaction_id = $this->bt->id;
|
||||||
$expense->save();
|
$expense->save();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -222,7 +225,7 @@ class MatchBankTransactions implements ShouldQueue
|
|||||||
$payment->status_id = Payment::STATUS_COMPLETED;
|
$payment->status_id = Payment::STATUS_COMPLETED;
|
||||||
$payment->client_id = $this->invoice->client_id;
|
$payment->client_id = $this->invoice->client_id;
|
||||||
$payment->transaction_reference = $this->bt->description;
|
$payment->transaction_reference = $this->bt->description;
|
||||||
$payment->transaction_id = $this->bt->transaction_id;
|
$payment->transaction_id = $this->bt->id;
|
||||||
$payment->currency_id = $this->bt->currency_id;
|
$payment->currency_id = $this->bt->currency_id;
|
||||||
$payment->is_manual = false;
|
$payment->is_manual = false;
|
||||||
$payment->date = $this->bt->date ? Carbon::parse($this->bt->date) : now();
|
$payment->date = $this->bt->date ? Carbon::parse($this->bt->date) : now();
|
||||||
|
@ -57,7 +57,7 @@ class BankTransactionTransformer extends EntityTransformer
|
|||||||
'currency_id' => (string) $bank_transaction->currency_id ?: '1',
|
'currency_id' => (string) $bank_transaction->currency_id ?: '1',
|
||||||
'account_type' => (string) $bank_transaction->account_type ?: '',
|
'account_type' => (string) $bank_transaction->account_type ?: '',
|
||||||
'category_id' => (int) $bank_transaction->category_id,
|
'category_id' => (int) $bank_transaction->category_id,
|
||||||
'ninja_category_id' => (int) $bank_transaction->ninja_category_id,
|
'ninja_category_id' => (string) $this->encodePrimaryKey($bank_transaction->ninja_category_id) ?: '',
|
||||||
'category_type' => (string) $bank_transaction->category_type ?: '',
|
'category_type' => (string) $bank_transaction->category_type ?: '',
|
||||||
'date' => (string) $bank_transaction->date ?: '',
|
'date' => (string) $bank_transaction->date ?: '',
|
||||||
'bank_account_id' => (int) $bank_transaction->bank_account_id,
|
'bank_account_id' => (int) $bank_transaction->bank_account_id,
|
||||||
|
@ -79,6 +79,7 @@ class PaymentTransformer extends EntityTransformer
|
|||||||
'refunded' => (float) $payment->refunded,
|
'refunded' => (float) $payment->refunded,
|
||||||
'applied' => (float) $payment->applied,
|
'applied' => (float) $payment->applied,
|
||||||
'transaction_reference' => $payment->transaction_reference ?: '',
|
'transaction_reference' => $payment->transaction_reference ?: '',
|
||||||
|
'transaction_id' => $payment->transaction_id ?: '',
|
||||||
'date' => $payment->date ?: '',
|
'date' => $payment->date ?: '',
|
||||||
'is_manual' => (bool) $payment->is_manual,
|
'is_manual' => (bool) $payment->is_manual,
|
||||||
'created_at' => (int) $payment->created_at,
|
'created_at' => (int) $payment->created_at,
|
||||||
|
@ -86,6 +86,10 @@ return new class extends Migration
|
|||||||
$table->unsignedBigInteger('transaction_id')->nullable();
|
$table->unsignedBigInteger('transaction_id')->nullable();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::table('expenses', function (Illuminate\Database\Schema\Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger('transaction_id')->nullable()->change();
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,6 +124,7 @@ class YodleeApiTest extends TestCase
|
|||||||
MatchBankTransactions::dispatchSync($this->company->id, $this->company->db, $data);
|
MatchBankTransactions::dispatchSync($this->company->id, $this->company->db, $data);
|
||||||
|
|
||||||
$payment = Payment::where('transaction_reference', $bt->description)->first();
|
$payment = Payment::where('transaction_reference', $bt->description)->first();
|
||||||
|
$payment_count = Payment::where('transaction_reference', $bt->description)->count();
|
||||||
|
|
||||||
$this->assertNotNull($payment);
|
$this->assertNotNull($payment);
|
||||||
|
|
||||||
@ -135,6 +136,7 @@ class YodleeApiTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(Invoice::STATUS_PAID, $invoice->status_id);
|
$this->assertEquals(Invoice::STATUS_PAID, $invoice->status_id);
|
||||||
$this->assertEquals(0, $invoice->balance);
|
$this->assertEquals(0, $invoice->balance);
|
||||||
|
$this->assertEquals(1, $payment_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user