Merge pull request #8679 from turbo124/v5-stable

v5.6.24
This commit is contained in:
David Bomba 2023-08-01 19:41:11 +10:00 committed by GitHub
commit ad7c03977c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 287600 additions and 283590 deletions

View File

@ -1 +1 @@
5.6.23
5.6.24

View File

@ -40,16 +40,13 @@ class RecurringExpenseToExpenseFactory
$expense->tax_name3 = $recurring_expense->tax_name3;
$expense->tax_rate3 = $recurring_expense->tax_rate3;
$expense->date = now()->format('Y-m-d');
$expense->payment_date = $recurring_expense->payment_date ?: now()->format('Y-m-d');
// $expense->payment_date = $recurring_expense->payment_date ?: now()->format('Y-m-d');
$expense->amount = $recurring_expense->amount;
$expense->foreign_amount = $recurring_expense->foreign_amount ?: 0;
//11-09-2022 - we should be tracking the recurring expense!!
$expense->recurring_expense_id = $recurring_expense->id;
// $expense->private_notes = $recurring_expense->private_notes;
// $expense->public_notes = $recurring_expense->public_notes;
$expense->public_notes = self::transformObject($recurring_expense->public_notes, $recurring_expense);
$expense->private_notes = self::transformObject($recurring_expense->private_notes, $recurring_expense);

View File

@ -183,6 +183,48 @@ class InvoiceFilters extends QueryFilters
->where('client_id', $this->decodePrimaryKey($client_id));
}
/**
* @param string $date
* @return Builder
* @throws InvalidArgumentException
*/
public function date(string $date = ''): Builder
{
if (strlen($date) == 0) {
return $this->builder;
}
if (is_numeric($date)) {
$date = Carbon::createFromTimestamp((int)$date);
} else {
$date = Carbon::parse($date);
}
return $this->builder->where('date', '>=', $date);
}
/**
* @param string $date
* @return Builder
* @throws InvalidArgumentException
*/
public function due_date(string $date = ''): Builder
{
if (strlen($date) == 0) {
return $this->builder;
}
if (is_numeric($date)) {
$date = Carbon::createFromTimestamp((int)$date);
} else {
$date = Carbon::parse($date);
}
return $this->builder->where('due_date', '>=', $date);
}
/**
* Sorts the list based on $sort.
*

View File

@ -12,11 +12,13 @@
namespace App\Helpers\Invoice;
use App\Models\Quote;
use App\Models\Client;
use App\Models\Credit;
use App\Models\Invoice;
use App\Models\PurchaseOrder;
use App\Models\RecurringQuote;
use App\Models\RecurringInvoice;
use App\DataMapper\Tax\RuleInterface;
use App\Utils\Traits\NumberFormatter;
class InvoiceItemSumInclusive
@ -25,6 +27,71 @@ class InvoiceItemSumInclusive
use Discounter;
use Taxer;
private array $eu_tax_jurisdictions = [
'AT', // Austria
'BE', // Belgium
'BG', // Bulgaria
'CY', // Cyprus
'CZ', // Czech Republic
'DE', // Germany
'DK', // Denmark
'EE', // Estonia
'ES', // Spain
'FI', // Finland
'FR', // France
'GR', // Greece
'HR', // Croatia
'HU', // Hungary
'IE', // Ireland
'IT', // Italy
'LT', // Lithuania
'LU', // Luxembourg
'LV', // Latvia
'MT', // Malta
'NL', // Netherlands
'PL', // Poland
'PT', // Portugal
'RO', // Romania
'SE', // Sweden
'SI', // Slovenia
'SK', // Slovakia
];
private array $tax_jurisdictions = [
'AT', // Austria
'BE', // Belgium
'BG', // Bulgaria
'CY', // Cyprus
'CZ', // Czech Republic
'DE', // Germany
'DK', // Denmark
'EE', // Estonia
'ES', // Spain
'FI', // Finland
'FR', // France
'GR', // Greece
'HR', // Croatia
'HU', // Hungary
'IE', // Ireland
'IT', // Italy
'LT', // Lithuania
'LU', // Luxembourg
'LV', // Latvia
'MT', // Malta
'NL', // Netherlands
'PL', // Poland
'PT', // Portugal
'RO', // Romania
'SE', // Sweden
'SI', // Slovenia
'SK', // Slovakia
'US', // USA
'AU', // Australia
];
protected RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice;
private $currency;
@ -39,6 +106,12 @@ class InvoiceItemSumInclusive
private $tax_collection;
private bool $calc_tax = false;
private ?Client $client;
private RuleInterface $rule;
public function __construct(RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice)
{
$this->tax_collection = collect([]);
@ -47,6 +120,7 @@ class InvoiceItemSumInclusive
if ($this->invoice->client) {
$this->currency = $this->invoice->client->currency();
$this->shouldCalculateTax();
} else {
$this->currency = $this->invoice->vendor->currency();
}
@ -107,12 +181,46 @@ class InvoiceItemSumInclusive
return $this;
}
/**
* Attempts to calculate taxes based on the clients location
*
* @return self
*/
private function calcTaxesAutomatically(): self
{
$this->rule->tax($this->item);
$precision = strlen(substr(strrchr($this->rule->tax_rate1, "."), 1));
$this->item->tax_name1 = $this->rule->tax_name1;
$this->item->tax_rate1 = round($this->rule->tax_rate1, $precision);
$precision = strlen(substr(strrchr($this->rule->tax_rate2, "."), 1));
$this->item->tax_name2 = $this->rule->tax_name2;
$this->item->tax_rate2 = round($this->rule->tax_rate2, $precision);
$precision = strlen(substr(strrchr($this->rule->tax_rate3, "."), 1));
$this->item->tax_name3 = $this->rule->tax_name3;
$this->item->tax_rate3 = round($this->rule->tax_rate3, $precision);
return $this;
}
/**
* Taxes effect the line totals and item costs. we decrement both on
* application of inclusive tax rates.
*/
private function calcTaxes()
{
if ($this->calc_tax) {
$this->calcTaxesAutomatically();
}
$item_tax = 0;
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / 100));
@ -275,4 +383,36 @@ class InvoiceItemSumInclusive
$this->setTotalTaxes($item_tax);
}
private function shouldCalculateTax(): self
{
if (!$this->invoice->company?->calculate_taxes || $this->invoice->company->account->isFreeHostedClient()) {
$this->calc_tax = false;
return $this;
}
if (in_array($this->client->company->country()->iso_3166_2, $this->tax_jurisdictions) ) { //only calculate for supported tax jurisdictions
$class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule";
$this->rule = new $class();
if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2))
return $this;
$this->rule
->setEntity($this->invoice)
->init();
$this->calc_tax = $this->rule->shouldCalcTax();
return $this;
}
return $this;
}
}

View File

@ -25,6 +25,7 @@ use App\Models\Subscription;
use App\Repositories\ClientContactRepository;
use App\Repositories\ClientRepository;
use App\Utils\Number;
use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
@ -34,6 +35,7 @@ use Livewire\Component;
class BillingPortalPurchasev2 extends Component
{
use MakesHash;
/**
* Random hash generated by backend to handle the tracking of state.
*
@ -422,6 +424,7 @@ class BillingPortalPurchasev2 extends Component
$client_repo = new ClientRepository(new ClientContactRepository());
$data = [
'name' => '',
'group_id' => $this->encodePrimaryKey($this->subscription->group_id),
'contacts' => [
['email' => $this->email],
],

View File

@ -71,7 +71,7 @@ class UpdateInvoiceRequest extends Request
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
$rules['status_id'] = 'bail|sometimes|not_in:5'; //do not all cancelled invoices to be modfified.
$rules['status_id'] = 'bail|sometimes|not_in:5'; //do not allow cancelled invoices to be modfified.
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
// not needed.

View File

@ -106,7 +106,7 @@ class ValidRefundableRequest implements Rule
if ($payment->credits()->exists()) {
$paymentable_credit = $payment->credits->where('id', $credit->id)->first();
if (! $paymentable_invoice) {
if (! $paymentable_credit) {
$this->error_msg = ctrans('texts.credit_not_related_to_payment', ['credit' => $credit->hashed_id]);
return false;

View File

@ -103,8 +103,11 @@ class RecurringExpensesCron
$expense = RecurringExpenseToExpenseFactory::create($recurring_expense);
$expense->saveQuietly();
if($expense->company->mark_expenses_paid)
$expense->payment_date = now()->format('Y-m-d');
$expense->number = $this->getNextExpenseNumber($expense);
$expense->save();
$expense->saveQuietly();
$recurring_expense->next_send_date = $recurring_expense->nextSendDate();
$recurring_expense->next_send_date_client = $recurring_expense->next_send_date;

View File

@ -15,12 +15,13 @@ use App\Events\Payment\PaymentWasRefunded;
use App\Events\Payment\PaymentWasVoided;
use App\Services\Ledger\LedgerService;
use App\Services\Payment\PaymentService;
use App\Utils\Ninja;
use App\Utils\Ninja;
use App\Utils\Number;
use App\Utils\Traits\Inviteable;
use App\Utils\Traits\MakesDates;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\Payment\Refundable;
use Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
@ -251,6 +252,11 @@ class Payment extends BaseModel
return $this->belongsTo(Currency::class);
}
public function transaction(): BelongsTo
{
return $this->belongsTo(BankTransaction::class);
}
public function exchange_currency()
{
return $this->belongsTo(Currency::class, 'exchange_currency_id', 'id');

View File

@ -198,7 +198,7 @@ class Product extends BaseModel
],
]);
return $converter->convert($this->notes);
return $converter->convert($this->notes ?? '');
}
public function portalUrl($use_react_url): string

View File

@ -54,13 +54,14 @@ class DeletePayment
/** @return $this */
private function cleanupPayment()
{
$this->payment->is_deleted = true;
$this->payment->delete();
// BankTransaction::where('payment_id', $this->payment->id)->cursor()->each(function ($bt){
// $bt->payment_id = null;
// $bt->save();
// });
BankTransaction::where('payment_id', $this->payment->id)->cursor()->each(function ($bt){
$bt->payment_id = null;
$bt->save();
});
return $this;
}

View File

@ -15,8 +15,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.6.23'),
'app_tag' => env('APP_TAG','5.6.23'),
'app_version' => env('APP_VERSION','5.6.24'),
'app_tag' => env('APP_TAG','5.6.24'),
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),

View File

@ -16184,17 +16184,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
--------------------------------------------------------------------------------
photo_view
Copyright 2020 Renan C. Araújo
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
pinch_zoom

View File

@ -3,10 +3,10 @@ const MANIFEST = 'flutter-app-manifest';
const TEMP = 'flutter-temp-cache';
const CACHE_NAME = 'flutter-app-cache';
const RESOURCES = {
"/": "dad42af82faab711765c59e9a7596b11",
"/": "b7b5d670f6201b3c307ee62dc0af5241",
"flutter.js": "a85fcf6324d3c4d3ae3be1ae4931e9c5",
"favicon.png": "dca91c54388f52eded692718d5a98b8b",
"main.dart.js": "b11ed73562dd3c3db2c346bc14702036",
"main.dart.js": "0b7e8a0c2eedf8a3e94d402e0b35e2e0",
"version.json": "bf49df736fed3f74ade0dbaebf08de11",
"canvaskit/profiling/canvaskit.js": "c21852696bc1cc82e8894d851c01921a",
"canvaskit/profiling/canvaskit.wasm": "371bc4e204443b0d5e774d64a046eb99",
@ -16,7 +16,7 @@ const RESOURCES = {
"favicon.ico": "51636d3a390451561744c42188ccd628",
"assets/fonts/MaterialIcons-Regular.otf": "e7069dfd19b331be16bed984668fe080",
"assets/AssetManifest.json": "759f9ef9973f7e26c2a51450b55bb9fa",
"assets/NOTICES": "4af2c7be565a02ebf59c07ecd9e13830",
"assets/NOTICES": "6cf3e734da918534f75f16892b0e2c1f",
"assets/FontManifest.json": "087fb858dc3cbfbf6baf6a30004922f1",
"assets/packages/intl_phone_field/assets/flags/ru.png": "6974dcb42ad7eb3add1009ea0c6003e3",
"assets/packages/intl_phone_field/assets/flags/cv.png": "9b1f31f9fc0795d728328dedd33eb1c0",

272405
public/main.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

272301
public/main.foss.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -33,9 +33,14 @@ class PermissionsTest extends TestCase
public Company $company;
public $faker;
public $token;
protected function setUp() :void
{
parent::setUp();
$this->faker = \Faker\Factory::create();
$account = Account::factory()->create([
@ -75,6 +80,56 @@ class PermissionsTest extends TestCase
$company_token->save();
}
public function testClientOverviewPermissions()
{
$u = User::factory()->create([
'account_id' => $this->company->account_id,
'confirmation_code' => '123',
'email' => $this->faker->safeEmail(),
]);
$c = Client::factory()->create([
'company_id' => $this->company->id,
'user_id' => $u->id,
]);
Invoice::factory()->create([
'company_id' => $this->company->id,
'client_id' => $c->id,
'user_id' => $u->id,
'status_id' => 2
]);
$low_cu = CompanyUser::where(['company_id' => $this->company->id, 'user_id' => $this->user->id])->first();
$low_cu->permissions = '["edit_client","create_client","create_invoice","edit_invoice","create_quote","edit_quote"]';
$low_cu->save();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get('/api/v1/invoices');
$response->assertStatus(200);
$data = $response->json();
$this->assertEquals(2, count($data));
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get("/api/v1/invoices?include=client&client_id={$c->hashed_id}&sort=id|desc&per_page=10&page=1&filter=&status=active");
$response->assertStatus(200);
$data = $response->json();
$this->assertEquals(2, count($data));
}
public function testHasExcludedPermissions()
{
$low_cu = CompanyUser::where(['company_id' => $this->company->id, 'user_id' => $this->user->id])->first();