diff --git a/app/Http/Requests/BankTransaction/StoreBankTransactionRequest.php b/app/Http/Requests/BankTransaction/StoreBankTransactionRequest.php index 94af89011395..b292453df8c5 100644 --- a/app/Http/Requests/BankTransaction/StoreBankTransactionRequest.php +++ b/app/Http/Requests/BankTransaction/StoreBankTransactionRequest.php @@ -41,12 +41,11 @@ class StoreBankTransactionRequest extends Request { $input = $this->all(); + if(array_key_exists('bank_integration_id', $input) && strlen($input['bank_integration_id']) > 1) + $input['bank_integration_id'] = $this->decodePrimaryKey($input['bank_integration_id']); + $this->replace($input); } - public function messages() - { - return []; - } } diff --git a/app/Http/Requests/BankTransaction/UpdateBankTransactionRequest.php b/app/Http/Requests/BankTransaction/UpdateBankTransactionRequest.php index ba2ed783029c..b466fdae16c2 100644 --- a/app/Http/Requests/BankTransaction/UpdateBankTransactionRequest.php +++ b/app/Http/Requests/BankTransaction/UpdateBankTransactionRequest.php @@ -67,6 +67,9 @@ class UpdateBankTransactionRequest extends Request if(array_key_exists('ninja_category_id', $input) && strlen($input['ninja_category_id']) > 1) $input['ninja_category_id'] = $this->decodePrimaryKey($input['ninja_category_id']); + if(array_key_exists('bank_integration_id', $input) && strlen($input['bank_integration_id']) > 1) + $input['bank_integration_id'] = $this->decodePrimaryKey($input['bank_integration_id']); + $this->replace($input); } diff --git a/app/Http/Requests/Report/ProfitLossRequest.php b/app/Http/Requests/Report/ProfitLossRequest.php index 2886b4eb1944..3b3e7802d010 100644 --- a/app/Http/Requests/Report/ProfitLossRequest.php +++ b/app/Http/Requests/Report/ProfitLossRequest.php @@ -31,7 +31,7 @@ class ProfitLossRequest extends Request 'start_date' => 'string|date', 'end_date' => 'string|date', 'is_income_billed' => 'required|bail|bool', - 'is_expense_billed' => 'required|bail|bool', + 'is_expense_billed' => 'bool', 'include_tax' => 'required|bail|bool', 'date_range' => 'sometimes|string', 'send_email' => 'bool', diff --git a/app/Jobs/Bank/MatchBankTransactions.php b/app/Jobs/Bank/MatchBankTransactions.php index 05f31fad0bdb..58d12e42c570 100644 --- a/app/Jobs/Bank/MatchBankTransactions.php +++ b/app/Jobs/Bank/MatchBankTransactions.php @@ -175,9 +175,11 @@ class MatchBankTransactions implements ShouldQueue $expense->payment_date = Carbon::parse($this->bt->date); $expense->transaction_reference = $this->bt->description; $expense->transaction_id = $this->bt->id; + $expense->vendor_id = array_key_exists('vendor_id', $this->input) ? $this->input['vendor_id'] : null; $expense->save(); $this->bt->expense_id = $expense->id; + $this->bt->vendor_id = array_key_exists('vendor_id', $this->input) ? $this->input['vendor_id'] : null; $this->bt->status_id = BankTransaction::STATUS_CONVERTED; $this->bt->save(); @@ -293,8 +295,11 @@ class MatchBankTransactions implements ShouldQueue private function resolveCategory() :?int { - if(array_key_exists('ninja_category_id', $this->input)) - return $this->input['ninja_category_id']; + if(array_key_exists('ninja_category_id', $this->input)){ + $this->bt->ninja_category_id = $this->input['ninja_category_id']; + $this->bt->save(); + return (int)$this->input['ninja_category_id']; + } $category = $this->categories->firstWhere('highLevelCategoryId', $this->bt->category_id); diff --git a/app/Models/BankIntegration.php b/app/Models/BankIntegration.php index 3a103e3f1dcb..dce8b2b36708 100644 --- a/app/Models/BankIntegration.php +++ b/app/Models/BankIntegration.php @@ -18,6 +18,15 @@ class BankIntegration extends BaseModel use SoftDeletes; protected $fillable = [ + 'bank_account_name', + 'provider_name', + 'bank_account_number', + 'bank_account_status', + 'bank_account_type', + 'balance', + 'currency', + 'nickname', + 'from_date', ]; protected $dates = [ diff --git a/app/Models/BankTransaction.php b/app/Models/BankTransaction.php index 2efa9560334f..bfb1c2fc4d52 100644 --- a/app/Models/BankTransaction.php +++ b/app/Models/BankTransaction.php @@ -32,6 +32,8 @@ class BankTransaction extends BaseModel 'date', 'description', 'base_type', + 'expense_id', + 'vendor_id' ]; protected $dates = [ diff --git a/app/Repositories/BankIntegrationRepository.php b/app/Repositories/BankIntegrationRepository.php index d3d43bd98f00..aca7ac150b30 100644 --- a/app/Repositories/BankIntegrationRepository.php +++ b/app/Repositories/BankIntegrationRepository.php @@ -21,7 +21,7 @@ use App\Models\TaskStatus; class BankIntegrationRepository extends BaseRepository { - public function store($data, BankIntegration $bank_integration) + public function save($data, BankIntegration $bank_integration) { //stub to store diff --git a/app/Transformers/ExpenseTransformer.php b/app/Transformers/ExpenseTransformer.php index 13c8d9b7481c..fb1cb938efb0 100644 --- a/app/Transformers/ExpenseTransformer.php +++ b/app/Transformers/ExpenseTransformer.php @@ -103,7 +103,7 @@ class ExpenseTransformer extends EntityTransformer 'private_notes' => (string) $expense->private_notes ?: '', 'public_notes' => (string) $expense->public_notes ?: '', 'transaction_reference' => (string) $expense->transaction_reference ?: '', - 'transaction_id' => (string) $expense->transaction_id ?: '', + 'transaction_id' => (string) $this->decodePrimaryKey($expense->transaction_id) ?: '', 'date' => $expense->date ?: '', 'number' => (string)$expense->number ?: '', 'payment_date' => $expense->payment_date ?: '', diff --git a/app/Transformers/PaymentTransformer.php b/app/Transformers/PaymentTransformer.php index ae202667355a..f18756964b97 100644 --- a/app/Transformers/PaymentTransformer.php +++ b/app/Transformers/PaymentTransformer.php @@ -79,7 +79,7 @@ class PaymentTransformer extends EntityTransformer 'refunded' => (float) $payment->refunded, 'applied' => (float) $payment->applied, 'transaction_reference' => $payment->transaction_reference ?: '', - 'transaction_id' => $payment->transaction_id ?: '', + 'transaction_id' => $this->decodePrimaryKey($payment->transaction_id) ?: '', 'date' => $payment->date ?: '', 'is_manual' => (bool) $payment->is_manual, 'created_at' => (int) $payment->created_at,