diff --git a/VERSION.txt b/VERSION.txt index 1358c237c3..76d1514dde 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.9.8 \ No newline at end of file +5.9.9 \ No newline at end of file diff --git a/app/Http/Requests/BankTransactionRule/StoreBankTransactionRuleRequest.php b/app/Http/Requests/BankTransactionRule/StoreBankTransactionRuleRequest.php index c6ad4e1593..28877fa13d 100644 --- a/app/Http/Requests/BankTransactionRule/StoreBankTransactionRuleRequest.php +++ b/app/Http/Requests/BankTransactionRule/StoreBankTransactionRuleRequest.php @@ -51,9 +51,9 @@ class StoreBankTransactionRuleRequest extends Request 'applies_to' => 'bail|sometimes|string', ]; - $rules['category_id'] = 'bail|sometimes|exists:expense_categories,id,company_id,'.$user->company()->id.',is_deleted,0'; - $rules['vendor_id'] = 'bail|sometimes|exists:vendors,id,company_id,'.$user->company()->id.',is_deleted,0'; - $rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.$user->company()->id.',is_deleted,0'; + $rules['category_id'] = 'bail|sometimes|nullable|exists:expense_categories,id,company_id,'.$user->company()->id.',is_deleted,0'; + $rules['vendor_id'] = 'bail|sometimes|nullable|exists:vendors,id,company_id,'.$user->company()->id.',is_deleted,0'; + $rules['client_id'] = 'bail|sometimes|nullable|exists:clients,id,company_id,'.$user->company()->id.',is_deleted,0'; return $rules; } diff --git a/app/Jobs/Bank/MatchBankTransactions.php b/app/Jobs/Bank/MatchBankTransactions.php index 6063a84d84..e5d4ddad6a 100644 --- a/app/Jobs/Bank/MatchBankTransactions.php +++ b/app/Jobs/Bank/MatchBankTransactions.php @@ -312,8 +312,11 @@ class MatchBankTransactions implements ShouldQueue if ($_amount) { $this->attachable_invoices[] = ['id' => $this->invoice->id, 'amount' => $_amount]; + $this->invoice->next_send_date = null; + $this->invoice ->service() + ->applyNumber() ->setExchangeRate() ->updateBalance($_amount * -1) ->updatePaidToDate($_amount) @@ -364,14 +367,6 @@ class MatchBankTransactions implements ShouldQueue event('eloquent.created: App\Models\Payment', $payment); - $this->invoice->next_send_date = null; - - $this->invoice - ->service() - ->applyNumber() - ->deletePdf() - ->save(); - $payment->ledger() ->updatePaymentBalance($amount * -1); @@ -390,7 +385,13 @@ class MatchBankTransactions implements ShouldQueue event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new InvoiceWasPaid($this->invoice, $payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); - $this->bt->invoice_ids = $invoices->get()->pluck('hashed_id')->implode(','); + $hashed_keys = []; + + foreach($this->attachable_invoices as $attachable_invoice){ + $hashed_keys[] = $this->encodePrimaryKey($attachable_invoice['id']); + } + + $this->bt->invoice_ids = implode(",", $hashed_keys); $this->bt->status_id = BankTransaction::STATUS_CONVERTED; $this->bt->payment_id = $payment->id; $this->bt->save(); diff --git a/app/Providers/StaticServiceProvider.php b/app/Providers/StaticServiceProvider.php index d6a08547b2..77dc905535 100644 --- a/app/Providers/StaticServiceProvider.php +++ b/app/Providers/StaticServiceProvider.php @@ -21,6 +21,7 @@ use App\Models\Language; use App\Models\Timezone; use App\Models\DateFormat; use App\Models\PaymentTerm; +use App\Models\PaymentType; use App\Models\DatetimeFormat; use Illuminate\Support\ServiceProvider; use App\DataMapper\EmailTemplateDefaults; @@ -49,9 +50,9 @@ class StaticServiceProvider extends ServiceProvider return Country::query()->orderBy('name')->get(); }); - /** @return \Illuminate\Support\Collection */ + /** @return \Illuminate\Support\Collection */ app()->singleton('payment_types', function ($app) { - return PaymentTerm::query()->orderBy('num_days')->get(); + return PaymentType::query()->orderBy('id')->get(); }); /** @return \Illuminate\Support\Collection */ diff --git a/app/Utils/Statics.php b/app/Utils/Statics.php index 9adcaf3c33..8a0d109bc2 100644 --- a/app/Utils/Statics.php +++ b/app/Utils/Statics.php @@ -11,8 +11,6 @@ namespace App\Utils; -use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; /** @@ -65,92 +63,65 @@ class Statics * @param string|bool $locale The user locale * @return array Array of statics */ - public static function company($locale = false): array + public static function company($locale = 'en'): array { $data = []; + + /** @var \Illuminate\Support\Collection<\App\Models\Industry> */ + $industries = app('industries'); + + $data['industries'] = $industries->each(function ($industry) { + $industry->name = ctrans('texts.industry_'.$industry->name); + })->sortBy(function ($industry) { + return $industry->name; + })->values(); - // foreach (config('ninja.cached_tables') as $name => $class) { - // if (! Cache::has($name)) { - // // check that the table exists in case the migration is pending - // if (! Schema::hasTable((new $class())->getTable())) { - // continue; - // } - // if ($name == 'payment_terms') { - // $orderBy = 'num_days'; - // } elseif ($name == 'fonts') { - // $orderBy = 'sort_order'; - // } elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) { - // $orderBy = 'name'; - // } else { - // $orderBy = 'id'; - // } - // $tableData = $class::orderBy($orderBy)->get(); - // if ($tableData->count()) { - // Cache::forever($name, $tableData); - // } - // } + /** @var \Illuminate\Support\Collection<\App\Models\Country> */ + $countries = app('countries'); - // $data[$name] = app($name); - // } - - if ($locale) { - - /** @var \Illuminate\Support\Collection<\App\Models\Industry> */ - $industries = app('industries'); - - $data['industries'] = $industries->each(function ($industry) { - $industry->name = ctrans('texts.industry_'.$industry->name); - })->sortBy(function ($industry) { - return $industry->name; - })->values(); - - /** @var \Illuminate\Support\Collection<\App\Models\Country> */ - $countries = app('countries'); - - $data['countries'] = $countries->each(function ($country) { - $country->name = ctrans('texts.country_'.$country->name); - })->sortBy(function ($country) { - return $country->name; - })->values(); + $data['countries'] = $countries->each(function ($country) { + $country->name = ctrans('texts.country_'.$country->name); + })->sortBy(function ($country) { + return $country->name; + })->values(); - /** @var \Illuminate\Support\Collection<\App\Models\PaymentType> */ - $payment_types = app('payment_types'); - - $data['payment_types'] = $payment_types->each(function ($pType) { - $pType->name = ctrans('texts.payment_type_'.$pType->name); - })->sortBy(function ($pType) { - return $pType->name; - })->values(); + /** @var \Illuminate\Support\Collection<\App\Models\PaymentType> */ + $payment_types = app('payment_types'); + + $data['payment_types'] = $payment_types->each(function ($pType) { + $pType->name = ctrans('texts.payment_type_'.$pType->name); + $pType->id = (string) $pType->id; + })->sortBy(function ($pType) { + return $pType->name; + })->values(); + + /** @var \Illuminate\Support\Collection<\App\Models\Language> */ + $languages = app('languages'); - - /** @var \Illuminate\Support\Collection<\App\Models\Language> */ - $payment_types = app('languages'); + $data['languages'] = $languages->each(function ($lang) { + $lang->name = ctrans('texts.lang_'.$lang->name); + })->sortBy(function ($lang) { + return $lang->name; + })->values(); - $data['languages'] = $payment_types->each(function ($lang) { - $lang->name = ctrans('texts.lang_'.$lang->name); - })->sortBy(function ($lang) { - return $lang->name; - })->values(); + + /** @var \Illuminate\Support\Collection<\App\Models\Currency> */ + $currencies = app('currencies'); - - /** @var \Illuminate\Support\Collection<\App\Models\Currency> */ - $currencies = app('currencies'); - - $data['currencies'] = $currencies->each(function ($currency) { - $currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_')); - })->sortBy(function ($currency) { - return $currency->name; - })->values(); - - $data['sizes'] = app('sizes'); - $data['datetime_formats'] = app('datetime_formats'); - $data['gateways'] = app('gateways'); - $dat['timezones'] = app('timezones'); - - $data['templates'] = app('templates'); - } + $data['currencies'] = $currencies->each(function ($currency) { + $currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_')); + })->sortBy(function ($currency) { + return $currency->name; + })->values(); + $data['sizes'] = app('sizes'); + $data['datetime_formats'] = app('datetime_formats'); + $data['gateways'] = app('gateways'); + $data['timezones'] = app('timezones'); + $data['date_formats'] = app('date_formats'); + $data['templates'] = app('templates'); + $data['bulk_updates'] = [ 'client' => \App\Models\Client::$bulk_update_columns, ]; diff --git a/config/ninja.php b/config/ninja.php index 40fdded8d1..88601cd094 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -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.9.8'), - 'app_tag' => env('APP_TAG', '5.9.8'), + 'app_version' => env('APP_VERSION', '5.9.9'), + 'app_tag' => env('APP_TAG', '5.9.9'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false), diff --git a/routes/vendor.php b/routes/vendor.php index b904014c41..f16fc36197 100644 --- a/routes/vendor.php +++ b/routes/vendor.php @@ -45,11 +45,11 @@ Route::group(['middleware' => ['auth:vendor', 'vendor_locale', 'domain_db'], 'pr Route::post('documents/download_multiple', [App\Http\Controllers\VendorPortal\DocumentController::class, 'downloadMultiple'])->name('documents.download_multiple'); Route::get('documents/{document}/download', [App\Http\Controllers\VendorPortal\DocumentController::class, 'download'])->name('documents.download'); Route::get('documents/{document}/download_pdf', [App\Http\Controllers\VendorPortal\DocumentController::class, 'download'])->name('documents.download_pdf'); - Route::get('purchase_order/{invitation_key}/download_e_purchase_order', [App\Http\Controllers\PurchaseOrderController::class, 'downloadEPurchaseOrder'])->name('purchase_order.download_e_purchase_order')->middleware('token_auth'); - + Route::resource('documents', App\Http\Controllers\VendorPortal\DocumentController::class)->only(['index', 'show']); - + }); +Route::get('purchase_order/{invitation_key}/download_e_purchase_order', [App\Http\Controllers\PurchaseOrderController::class, 'downloadEPurchaseOrder'])->name('purchase_order.download_e_purchase_order')->middleware('token_auth'); Route::fallback([BaseController::class, 'notFoundVendor']);