mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Always force a baseType
This commit is contained in:
parent
701b474efa
commit
0a1f41f1f1
@ -146,10 +146,21 @@ class IncomeTransformer implements BankRevenueInterface
|
||||
'date' => $transaction->date,
|
||||
'bank_account_id' => $transaction->accountId,
|
||||
'description' => $transaction->description->original,
|
||||
'base_type' => property_exists($transaction, 'baseType') ? $transaction->baseType : '',
|
||||
'base_type' => property_exists($transaction, 'baseType') ? $transaction->baseType : $this->calculateBaseType($transaction),
|
||||
];
|
||||
}
|
||||
|
||||
private function calculateBaseType($transaction)
|
||||
{
|
||||
//CREDIT / DEBIT
|
||||
|
||||
if(property_exists($transaction, 'highLevelCategoryId') && $transaction->highLevelCategoryId == 10000012)
|
||||
return 'CREDIT';
|
||||
|
||||
return 'DEBIT';
|
||||
|
||||
}
|
||||
|
||||
private function convertCurrency(string $code)
|
||||
{
|
||||
|
||||
|
@ -553,8 +553,7 @@ class BankTransactionController extends BaseController
|
||||
$bt = (new MatchBankTransactions(auth()->user()->company()->id, auth()->user()->company()->db, $request->all()))->handle();
|
||||
|
||||
return $this->itemResponse($bt);
|
||||
// return response()->json(['message' => 'Processing....'], 200);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,13 +30,13 @@ class MatchBankTransactionRequest extends Request
|
||||
{
|
||||
|
||||
$rules = [
|
||||
'id' => 'required|bail',
|
||||
'invoice_ids' => 'nullable|string|sometimes',
|
||||
'ninja_category_id' => 'nullable|string|sometimes'
|
||||
'id.*' => 'required|bail',
|
||||
'invoice_ids.*' => 'nullable|string|sometimes',
|
||||
'ninja_category_id.*' => 'nullable|string|sometimes'
|
||||
];
|
||||
|
||||
if(isset($this->vendor_id))
|
||||
$rules['vendor_id'] = 'bail|required|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||
$rules['vendor_id.*'] = 'bail|required|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||
|
||||
return $rules;
|
||||
|
||||
@ -44,17 +44,20 @@ class MatchBankTransactionRequest extends Request
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$input = $this->all();
|
||||
$inputs = $this->all();
|
||||
|
||||
if(array_key_exists('id', $input))
|
||||
$input['id'] = $this->decodePrimaryKey($input['id']);
|
||||
foreach($inputs as $input)
|
||||
{
|
||||
if(array_key_exists('id', $input))
|
||||
$input['id'] = $this->decodePrimaryKey($input['id']);
|
||||
|
||||
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('ninja_category_id', $input) && strlen($input['ninja_category_id']) >= 1)
|
||||
$input['ninja_category_id'] = $this->decodePrimaryKey($input['ninja_category_id']);
|
||||
|
||||
$input = $this->decodePrimaryKeys($input);
|
||||
|
||||
$this->replace($input);
|
||||
$input = $this->decodePrimaryKeys($input);
|
||||
}
|
||||
|
||||
$this->replace($inputs);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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) $this->decodePrimaryKey($expense->transaction_id) ?: '',
|
||||
'transaction_id' => (string) $this->encodePrimaryKey($expense->transaction_id) ?: '',
|
||||
'date' => $expense->date ?: '',
|
||||
'number' => (string)$expense->number ?: '',
|
||||
'payment_date' => $expense->payment_date ?: '',
|
||||
|
@ -79,7 +79,7 @@ class PaymentTransformer extends EntityTransformer
|
||||
'refunded' => (float) $payment->refunded,
|
||||
'applied' => (float) $payment->applied,
|
||||
'transaction_reference' => $payment->transaction_reference ?: '',
|
||||
'transaction_id' => $this->decodePrimaryKey($payment->transaction_id) ?: '',
|
||||
'transaction_id' => $this->encodePrimaryKey($payment->transaction_id) ?: '',
|
||||
'date' => $payment->date ?: '',
|
||||
'is_manual' => (bool) $payment->is_manual,
|
||||
'created_at' => (int) $payment->created_at,
|
||||
|
Loading…
x
Reference in New Issue
Block a user