mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 00:34:35 -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,
|
'date' => $transaction->date,
|
||||||
'bank_account_id' => $transaction->accountId,
|
'bank_account_id' => $transaction->accountId,
|
||||||
'description' => $transaction->description->original,
|
'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)
|
private function convertCurrency(string $code)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -553,7 +553,6 @@ class BankTransactionController extends BaseController
|
|||||||
$bt = (new MatchBankTransactions(auth()->user()->company()->id, auth()->user()->company()->db, $request->all()))->handle();
|
$bt = (new MatchBankTransactions(auth()->user()->company()->id, auth()->user()->company()->db, $request->all()))->handle();
|
||||||
|
|
||||||
return $this->itemResponse($bt);
|
return $this->itemResponse($bt);
|
||||||
// return response()->json(['message' => 'Processing....'], 200);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@ class MatchBankTransactionRequest extends Request
|
|||||||
{
|
{
|
||||||
|
|
||||||
$rules = [
|
$rules = [
|
||||||
'id' => 'required|bail',
|
'id.*' => 'required|bail',
|
||||||
'invoice_ids' => 'nullable|string|sometimes',
|
'invoice_ids.*' => 'nullable|string|sometimes',
|
||||||
'ninja_category_id' => 'nullable|string|sometimes'
|
'ninja_category_id.*' => 'nullable|string|sometimes'
|
||||||
];
|
];
|
||||||
|
|
||||||
if(isset($this->vendor_id))
|
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;
|
return $rules;
|
||||||
|
|
||||||
@ -44,8 +44,10 @@ class MatchBankTransactionRequest extends Request
|
|||||||
|
|
||||||
public function prepareForValidation()
|
public function prepareForValidation()
|
||||||
{
|
{
|
||||||
$input = $this->all();
|
$inputs = $this->all();
|
||||||
|
|
||||||
|
foreach($inputs as $input)
|
||||||
|
{
|
||||||
if(array_key_exists('id', $input))
|
if(array_key_exists('id', $input))
|
||||||
$input['id'] = $this->decodePrimaryKey($input['id']);
|
$input['id'] = $this->decodePrimaryKey($input['id']);
|
||||||
|
|
||||||
@ -53,8 +55,9 @@ class MatchBankTransactionRequest extends Request
|
|||||||
$input['ninja_category_id'] = $this->decodePrimaryKey($input['ninja_category_id']);
|
$input['ninja_category_id'] = $this->decodePrimaryKey($input['ninja_category_id']);
|
||||||
|
|
||||||
$input = $this->decodePrimaryKeys($input);
|
$input = $this->decodePrimaryKeys($input);
|
||||||
|
}
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($inputs);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ class ExpenseTransformer extends EntityTransformer
|
|||||||
'private_notes' => (string) $expense->private_notes ?: '',
|
'private_notes' => (string) $expense->private_notes ?: '',
|
||||||
'public_notes' => (string) $expense->public_notes ?: '',
|
'public_notes' => (string) $expense->public_notes ?: '',
|
||||||
'transaction_reference' => (string) $expense->transaction_reference ?: '',
|
'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 ?: '',
|
'date' => $expense->date ?: '',
|
||||||
'number' => (string)$expense->number ?: '',
|
'number' => (string)$expense->number ?: '',
|
||||||
'payment_date' => $expense->payment_date ?: '',
|
'payment_date' => $expense->payment_date ?: '',
|
||||||
|
@ -79,7 +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' => $this->decodePrimaryKey($payment->transaction_id) ?: '',
|
'transaction_id' => $this->encodePrimaryKey($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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user