mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
commit
91884dd255
@ -1 +1 @@
|
||||
5.8.13
|
||||
5.8.14
|
@ -78,7 +78,7 @@ class ExpenseExport extends BaseExport
|
||||
'expense.net_amount'
|
||||
];
|
||||
|
||||
$this->input['report_keys'] = array_merge($this->input['report_keys'], $tax_keys);
|
||||
$this->input['report_keys'] = array_unique(array_merge($this->input['report_keys'], $tax_keys));
|
||||
|
||||
$query = Expense::query()
|
||||
->with('client')
|
||||
|
@ -167,7 +167,7 @@ class InvoiceExport extends BaseExport
|
||||
$entity['invoice.user_id'] = $invoice->user ? $invoice->user->present()->name() : '';
|
||||
}
|
||||
|
||||
|
||||
nlog($entity);
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
@ -247,24 +247,25 @@ class InvoiceFilters extends QueryFilters
|
||||
return $this->builder->where('due_date', '>=', $date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by date range
|
||||
*
|
||||
* @param string $date_range
|
||||
* @return Builder
|
||||
*/
|
||||
public function date_range(string $date_range = ''): Builder
|
||||
{
|
||||
$parts = explode(",", $date_range);
|
||||
|
||||
if (count($parts) != 3) {
|
||||
if (count($parts) != 2) {
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
if(!in_array($parts[0], ['date','due_date'])) {
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$start_date = Carbon::parse($parts[1]);
|
||||
$end_date = Carbon::parse($parts[2]);
|
||||
$start_date = Carbon::parse($parts[0]);
|
||||
$end_date = Carbon::parse($parts[1]);
|
||||
|
||||
return $this->builder->whereBetween($parts[0], [$start_date, $end_date]);
|
||||
return $this->builder->whereBetween('date', [$start_date, $end_date]);
|
||||
} catch(\Exception $e) {
|
||||
return $this->builder;
|
||||
}
|
||||
@ -272,6 +273,33 @@ class InvoiceFilters extends QueryFilters
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by due date range
|
||||
*
|
||||
* @param string $date_range
|
||||
* @return Builder
|
||||
*/
|
||||
public function due_date_range(string $date_range = ''): Builder
|
||||
{
|
||||
$parts = explode(",", $date_range);
|
||||
|
||||
if (count($parts) != 2) {
|
||||
return $this->builder;
|
||||
}
|
||||
try {
|
||||
|
||||
$start_date = Carbon::parse($parts[0]);
|
||||
$end_date = Carbon::parse($parts[1]);
|
||||
|
||||
return $this->builder->whereBetween('due_date', [$start_date, $end_date]);
|
||||
} catch(\Exception $e) {
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sorts the list based on $sort.
|
||||
*
|
||||
|
@ -99,22 +99,24 @@ class BankTransactionController extends BaseController
|
||||
|
||||
public function bulk(BulkBankTransactionRequest $request)
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$action = $request->input('action');
|
||||
|
||||
$ids = request()->input('ids');
|
||||
|
||||
$bank_transactions = BankTransaction::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
|
||||
|
||||
if ($action == 'convert_matched') { //catch this action
|
||||
if ($action == 'convert_matched' && $user->can('edit', $bank_transactions->first())) { //catch this action
|
||||
$this->bank_transaction_repo->convert_matched($bank_transactions);
|
||||
} else {
|
||||
$bank_transactions->each(function ($bank_transaction, $key) use ($action) {
|
||||
$bank_transactions->each(function ($bank_transaction, $key) use ($action, $user) {
|
||||
if($user->can('edit', $bank_transaction))
|
||||
$this->bank_transaction_repo->{$action}($bank_transaction);
|
||||
});
|
||||
}
|
||||
|
||||
/* Need to understand which permission are required for the given bulk action ie. view / edit */
|
||||
|
||||
return $this->listResponse(BankTransaction::withTrashed()->whereIn('id', $this->transformKeys($ids))->company());
|
||||
}
|
||||
|
||||
|
@ -22,10 +22,7 @@ class BulkBankTransactionRequest extends Request
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
/** @var \App\Models\User $user **/
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->isAdmin();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
|
@ -23,6 +23,9 @@ class CreateBankTransactionRequest extends Request
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->user()->can('create', BankTransaction::class);
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->can('create', BankTransaction::class);
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property float $amount
|
||||
* @property float $balance
|
||||
* @property float|null $partial
|
||||
* @property string|null $partial_due_date
|
||||
* @property string|null|\Carbon\Carbon $partial_due_date
|
||||
* @property string|null $last_viewed
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
@ -401,7 +401,7 @@ class Invoice extends BaseModel
|
||||
public function getStatusAttribute()
|
||||
{
|
||||
$due_date = $this->due_date ? Carbon::parse($this->due_date) : false;
|
||||
$partial_due_date = $this->partial_due_Date ? Carbon::parse($this->partial_due_date) : false;
|
||||
$partial_due_date = $this->partial_due_date ? Carbon::parse($this->partial_due_date) : false;
|
||||
|
||||
if ($this->status_id == self::STATUS_SENT && $due_date && $due_date->gt(now())) {
|
||||
return self::STATUS_UNPAID;
|
||||
|
@ -31,8 +31,6 @@ class EntityPolicy
|
||||
*/
|
||||
public function before($user, $ability)
|
||||
{
|
||||
//if($user->isAdmin())
|
||||
// return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +132,7 @@ class InvoiceTransformer extends EntityTransformer
|
||||
'is_amount_discount' => (bool) ($invoice->is_amount_discount ?: false),
|
||||
'footer' => $invoice->footer ?: '',
|
||||
'partial' => (float) ($invoice->partial ?: 0.0),
|
||||
'partial_due_date' => ($invoice->partial_due_date && $invoice->partial_due_date != "-0001-11-30") ? $invoice->partial_due_date : '',
|
||||
'partial_due_date' => ($invoice->partial_due_date && $invoice->partial_due_date != "-0001-11-30") ? $invoice->partial_due_date->format('Y-m-d') : '',
|
||||
'custom_value1' => (string) $invoice->custom_value1 ?: '',
|
||||
'custom_value2' => (string) $invoice->custom_value2 ?: '',
|
||||
'custom_value3' => (string) $invoice->custom_value3 ?: '',
|
||||
|
@ -17,8 +17,8 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||
'app_version' => env('APP_VERSION', '5.8.13'),
|
||||
'app_tag' => env('APP_TAG', '5.8.13'),
|
||||
'app_version' => env('APP_VERSION', '5.8.14'),
|
||||
'app_tag' => env('APP_TAG', '5.8.14'),
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', false),
|
||||
|
@ -139,7 +139,7 @@ Route::group(['middleware' => ['throttle:api', 'api_db', 'token_auth', 'locale']
|
||||
|
||||
Route::post('bank_integrations/bulk', [BankIntegrationController::class, 'bulk'])->name('bank_integrations.bulk');
|
||||
|
||||
Route::resource('bank_transactions', BankTransactionController::class); // name = (clients. index / create / show / update / destroy / edit
|
||||
Route::resource('bank_transactions', BankTransactionController::class); // name = (bank_transactions. index / create / show / update / destroy / edit
|
||||
Route::post('bank_transactions/bulk', [BankTransactionController::class, 'bulk'])->name('bank_transactions.bulk');
|
||||
Route::post('bank_transactions/match', [BankTransactionController::class, 'match'])->name('bank_transactions.match');
|
||||
|
||||
|
@ -31,6 +31,8 @@ class BankTransactionApiTest extends TestCase
|
||||
use DatabaseTransactions;
|
||||
use MockAccountData;
|
||||
|
||||
public $faker;
|
||||
|
||||
protected function setUp() :void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -44,6 +46,18 @@ class BankTransactionApiTest extends TestCase
|
||||
Model::reguard();
|
||||
}
|
||||
|
||||
public function testBankTransactionCreate()
|
||||
{
|
||||
nlog("creeeeate");
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->get('/api/v1/bank_transactions/create');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
|
||||
public function testBankTransactionGetClientStatus()
|
||||
{
|
||||
|
@ -185,7 +185,7 @@ class InvoiceTest extends TestCase
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->get('/api/v1/invoices?date_range=date,1971-01-01,1971-01-03', )
|
||||
])->get('/api/v1/invoices?date_range=1971-01-01,1971-01-03', )
|
||||
->assertStatus(200);
|
||||
|
||||
$arr = $response->json();
|
||||
|
@ -55,7 +55,7 @@ class InvoiceTest extends TestCase
|
||||
->create([
|
||||
'company_id' => $this->company->id,
|
||||
'user_id' => $this->user->id,
|
||||
'client_id' => $this->user->id
|
||||
'client_id' => $this->client->id
|
||||
]);
|
||||
|
||||
$this->assertNull($i->partial_due_date);
|
||||
@ -64,7 +64,7 @@ class InvoiceTest extends TestCase
|
||||
->create([
|
||||
'company_id' => $this->company->id,
|
||||
'user_id' => $this->user->id,
|
||||
'client_id' => $this->user->id,
|
||||
'client_id' => $this->client->id,
|
||||
'partial_due_date' => '2023-10-10',
|
||||
]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user