diff --git a/VERSION.txt b/VERSION.txt index a8ed8715d837..ce167bcd29b2 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.5.96 \ No newline at end of file +5.5.97 \ No newline at end of file diff --git a/app/DataMapper/Schedule/ScheduleEntity.php b/app/DataMapper/Schedule/EmailRecord.php similarity index 90% rename from app/DataMapper/Schedule/ScheduleEntity.php rename to app/DataMapper/Schedule/EmailRecord.php index 649360f4354c..1d342c4e5d4b 100644 --- a/app/DataMapper/Schedule/ScheduleEntity.php +++ b/app/DataMapper/Schedule/EmailRecord.php @@ -11,14 +11,14 @@ namespace App\DataMapper\Schedule; -class ScheduleEntity +class EmailRecord { /** * Defines the template name * * @var string */ - public string $template = 'schedule_entity'; + public string $template = 'email_record'; /** * Defines the template name diff --git a/app/DataMapper/Tax/ClientTaxData.php b/app/DataMapper/Tax/ClientTaxData.php index 6ec89b628c84..3f92e8866781 100644 --- a/app/DataMapper/Tax/ClientTaxData.php +++ b/app/DataMapper/Tax/ClientTaxData.php @@ -13,8 +13,15 @@ namespace App\DataMapper\Tax; use App\DataMapper\Tax\ZipTax\Response; +/** + * ClientTaxData + * + * Definition for the client tax data + */ class ClientTaxData { + public int $updated_at; + public function __construct(public Response $origin, public Response $destination) { } diff --git a/app/DataMapper/Tax/CompanyTaxData.php b/app/DataMapper/Tax/CompanyTaxData.php index 7b33356faa23..269d2b8a12e9 100644 --- a/app/DataMapper/Tax/CompanyTaxData.php +++ b/app/DataMapper/Tax/CompanyTaxData.php @@ -13,8 +13,15 @@ namespace App\DataMapper\Tax; use App\DataMapper\Tax\ZipTax\Response; +/** + * CompanyTaxData + * + * Definition for the company tax data structure + */ class CompanyTaxData { + public int $updated_at; + public function __construct(public Response $origin) { } diff --git a/app/DataMapper/Tax/InvoiceTaxData.php b/app/DataMapper/Tax/InvoiceTaxData.php index 40a174bb3050..f8e8667109a5 100644 --- a/app/DataMapper/Tax/InvoiceTaxData.php +++ b/app/DataMapper/Tax/InvoiceTaxData.php @@ -13,8 +13,15 @@ namespace App\DataMapper\Tax; use App\DataMapper\Tax\ZipTax\Response; +/** + * InvoiceTaxData + * + * Definition for the invoice tax data structure + */ class InvoiceTaxData { + public int $updated_at; + public function __construct(public Response $origin) { } diff --git a/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php b/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php index 632cd8cb80b3..48d5073f4f3a 100644 --- a/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php @@ -32,7 +32,7 @@ class StoreSchedulerRequest extends Request public function rules() { $rules = [ - 'name' => ['bail', 'required', Rule::unique('schedulers')->where('company_id', auth()->user()->company()->id)], + 'name' => 'bail|sometimes|nullable|string', 'is_paused' => 'bail|sometimes|boolean', 'frequency_id' => 'bail|sometimes|integer|digits_between:1,12', 'next_run' => 'bail|required|date:Y-m-d|after_or_equal:today', diff --git a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php index 4c5038813644..a7f70f48b2b8 100644 --- a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php @@ -29,7 +29,7 @@ class UpdateSchedulerRequest extends Request public function rules(): array { $rules = [ - 'name' => ['bail', 'sometimes', Rule::unique('schedulers')->where('company_id', auth()->user()->company()->id)->ignore($this->task_scheduler->id)], + 'name' => 'bail|sometimes|nullable|string', 'is_paused' => 'bail|sometimes|boolean', 'frequency_id' => 'bail|sometimes|integer|digits_between:1,12', 'next_run' => 'bail|required|date:Y-m-d|after_or_equal:today', diff --git a/app/Models/Account.php b/app/Models/Account.php index 5dc6584aef9e..d1feea184589 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -134,6 +134,10 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $companies * @property-read \Illuminate\Database\Eloquent\Collection $company_users * @property-read \Illuminate\Database\Eloquent\Collection $users + * @property-read \Illuminate\Database\Eloquent\Collection $bank_integrations + * @property-read \Illuminate\Database\Eloquent\Collection $companies + * @property-read \Illuminate\Database\Eloquent\Collection $company_users + * @property-read \Illuminate\Database\Eloquent\Collection $users * @mixin \Eloquent */ class Account extends BaseModel diff --git a/app/Models/BankAccount.php b/app/Models/BankAccount.php index fd5ea891db41..480f544cc41b 100644 --- a/app/Models/BankAccount.php +++ b/app/Models/BankAccount.php @@ -33,6 +33,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|BankAccount withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|BankAccount withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $bank_subaccounts + * @property-read \Illuminate\Database\Eloquent\Collection $bank_subaccounts * @mixin \Eloquent */ class BankAccount extends BaseModel diff --git a/app/Models/BankIntegration.php b/app/Models/BankIntegration.php index b5e414705612..5b97aaf353ee 100644 --- a/app/Models/BankIntegration.php +++ b/app/Models/BankIntegration.php @@ -76,6 +76,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|BankIntegration withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $transactions + * @property-read \Illuminate\Database\Eloquent\Collection $transactions * @mixin \Eloquent */ class BankIntegration extends BaseModel diff --git a/app/Models/Client.php b/app/Models/Client.php index 644124f4e70e..156d931efb08 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -185,6 +185,25 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $system_logs * @property-read \Illuminate\Database\Eloquent\Collection $tasks * @method static \Illuminate\Database\Eloquent\Builder|Client wherePaymentBalance($value) + * @property mixed $tax_data + * @property-read \Illuminate\Database\Eloquent\Collection $activities + * @property-read \Illuminate\Database\Eloquent\Collection $company_ledger + * @property-read \Illuminate\Database\Eloquent\Collection $contacts + * @property-read \Illuminate\Database\Eloquent\Collection $credits + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $expenses + * @property-read \Illuminate\Database\Eloquent\Collection $gateway_tokens + * @property-read \Illuminate\Database\Eloquent\Collection $invoices + * @property-read \Illuminate\Database\Eloquent\Collection $ledger + * @property-read \Illuminate\Database\Eloquent\Collection $payments + * @property-read \Illuminate\Database\Eloquent\Collection $primary_contact + * @property-read \Illuminate\Database\Eloquent\Collection $projects + * @property-read \Illuminate\Database\Eloquent\Collection $quotes + * @property-read \Illuminate\Database\Eloquent\Collection $recurring_expenses + * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoices + * @property-read \Illuminate\Database\Eloquent\Collection $system_logs + * @property-read \Illuminate\Database\Eloquent\Collection $tasks + * @method static \Illuminate\Database\Eloquent\Builder|Client whereTaxData($value) * @mixin \Eloquent */ class Client extends BaseModel implements HasLocalePreference @@ -255,6 +274,7 @@ class Client extends BaseModel implements HasLocalePreference 'created_at' => 'timestamp', 'deleted_at' => 'timestamp', 'last_login' => 'timestamp', + 'tax_data' => 'object', ]; protected $touches = []; diff --git a/app/Models/ClientContact.php b/app/Models/ClientContact.php index 21bb1c3ba8ac..582cb7efeae0 100644 --- a/app/Models/ClientContact.php +++ b/app/Models/ClientContact.php @@ -128,6 +128,11 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations + * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations + * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations + * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications + * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations + * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations * @mixin \Eloquent */ class ClientContact extends Authenticatable implements HasLocalePreference diff --git a/app/Models/Company.php b/app/Models/Company.php index c94361099a93..174b6b1e727c 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -326,6 +326,56 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $users * @property-read \Illuminate\Database\Eloquent\Collection $vendors * @property-read \Illuminate\Database\Eloquent\Collection $webhooks + * @property int $calculate_taxes + * @property int $tax_all_products + * @property mixed $tax_data + * @property-read \Illuminate\Database\Eloquent\Collection $activities + * @property-read \Illuminate\Database\Eloquent\Collection $all_activities + * @property-read \Illuminate\Database\Eloquent\Collection $all_documents + * @property-read \Illuminate\Database\Eloquent\Collection $bank_integrations + * @property-read \Illuminate\Database\Eloquent\Collection $bank_transaction_rules + * @property-read \Illuminate\Database\Eloquent\Collection $bank_transactions + * @property-read \Illuminate\Database\Eloquent\Collection $client_contacts + * @property-read \Illuminate\Database\Eloquent\Collection $client_gateway_tokens + * @property-read \Illuminate\Database\Eloquent\Collection $clients + * @property-read \Illuminate\Database\Eloquent\Collection $company_gateways + * @property-read \Illuminate\Database\Eloquent\Collection $company_users + * @property-read \Illuminate\Database\Eloquent\Collection $contacts + * @property-read \Illuminate\Database\Eloquent\Collection $credits + * @property-read \Illuminate\Database\Eloquent\Collection $designs + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $expense_categories + * @property-read \Illuminate\Database\Eloquent\Collection $expenses + * @property-read \Illuminate\Database\Eloquent\Collection $group_settings + * @property-read \Illuminate\Database\Eloquent\Collection $groups + * @property-read \Illuminate\Database\Eloquent\Collection $invoices + * @property-read \Illuminate\Database\Eloquent\Collection $ledger + * @property-read \Illuminate\Database\Eloquent\Collection $payment_terms + * @property-read \Illuminate\Database\Eloquent\Collection $payments + * @property-read \Illuminate\Database\Eloquent\Collection $products + * @property-read \Illuminate\Database\Eloquent\Collection $projects + * @property-read \Illuminate\Database\Eloquent\Collection $purchase_orders + * @property-read \Illuminate\Database\Eloquent\Collection $quotes + * @property-read \Illuminate\Database\Eloquent\Collection $recurring_expenses + * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoices + * @property-read \Illuminate\Database\Eloquent\Collection $schedulers + * @property-read \Illuminate\Database\Eloquent\Collection $subscriptions + * @property-read \Illuminate\Database\Eloquent\Collection $system_log_relation + * @property-read \Illuminate\Database\Eloquent\Collection $system_logs + * @property-read \Illuminate\Database\Eloquent\Collection $task_schedulers + * @property-read \Illuminate\Database\Eloquent\Collection $task_statuses + * @property-read \Illuminate\Database\Eloquent\Collection $tasks + * @property-read \Illuminate\Database\Eloquent\Collection $tax_rates + * @property-read \Illuminate\Database\Eloquent\Collection $tokens + * @property-read \Illuminate\Database\Eloquent\Collection $tokens_hashed + * @property-read \Illuminate\Database\Eloquent\Collection $user_designs + * @property-read \Illuminate\Database\Eloquent\Collection $user_payment_terms + * @property-read \Illuminate\Database\Eloquent\Collection $users + * @property-read \Illuminate\Database\Eloquent\Collection $vendors + * @property-read \Illuminate\Database\Eloquent\Collection $webhooks + * @method static \Illuminate\Database\Eloquent\Builder|Company whereCalculateTaxes($value) + * @method static \Illuminate\Database\Eloquent\Builder|Company whereTaxAllProducts($value) + * @method static \Illuminate\Database\Eloquent\Builder|Company whereTaxData($value) * @mixin \Eloquent */ class Company extends BaseModel @@ -363,6 +413,39 @@ class Company extends BaseModel protected $presenter = CompanyPresenter::class; + protected array $tax_coverage_countries = [ + 'US', + // //EU countries + // '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 + // //EU Countries + ]; + protected $fillable = [ 'invoice_task_hours', 'markdown_enabled', @@ -448,6 +531,7 @@ class Company extends BaseModel 'created_at' => 'timestamp', 'deleted_at' => 'timestamp', 'client_registration_fields' => 'array', + 'tax_data' => 'object', ]; protected $with = []; @@ -468,6 +552,16 @@ class Company extends BaseModel self::ENTITY_RECURRING_QUOTE => 2048, ]; + public function shouldCalculateTax() + { + return $this->calculate_taxes && in_array($this->getSetting('country_id'), $this->tax_coverage_countries); + } + + public function refreshTaxData() + { + + } + public function documents() { return $this->morphMany(Document::class, 'documentable'); diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 4013bf1f006d..717a2e646440 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -93,6 +93,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|CompanyGateway withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|CompanyGateway withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $client_gateway_tokens + * @property-read \Illuminate\Database\Eloquent\Collection $client_gateway_tokens * @mixin \Eloquent */ class CompanyGateway extends BaseModel diff --git a/app/Models/CompanyUser.php b/app/Models/CompanyUser.php index ed785efffefe..9f00c712ba94 100644 --- a/app/Models/CompanyUser.php +++ b/app/Models/CompanyUser.php @@ -70,6 +70,9 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property-read \Illuminate\Database\Eloquent\Collection $token * @property-read \Illuminate\Database\Eloquent\Collection $tokens * @property-read \Illuminate\Database\Eloquent\Collection $users + * @property-read \Illuminate\Database\Eloquent\Collection $token + * @property-read \Illuminate\Database\Eloquent\Collection $tokens + * @property-read \Illuminate\Database\Eloquent\Collection $users * @mixin \Eloquent */ class CompanyUser extends Pivot diff --git a/app/Models/Credit.php b/app/Models/Credit.php index 752618b450c1..97fc2bedb3ed 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -192,6 +192,13 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $invitations * @property-read \Illuminate\Database\Eloquent\Collection $invoices * @property-read \Illuminate\Database\Eloquent\Collection $payments + * @property-read \Illuminate\Database\Eloquent\Collection $activities + * @property-read \Illuminate\Database\Eloquent\Collection $company_ledger + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $history + * @property-read \Illuminate\Database\Eloquent\Collection $invitations + * @property-read \Illuminate\Database\Eloquent\Collection $invoices + * @property-read \Illuminate\Database\Eloquent\Collection $payments * @mixin \Eloquent */ class Credit extends BaseModel diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 2ff2a9483126..19faa5f3d24e 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -131,6 +131,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|Expense withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Expense withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $documents * @mixin \Eloquent */ class Expense extends BaseModel diff --git a/app/Models/GatewayType.php b/app/Models/GatewayType.php index fa5e08a7a477..0b2c4b36d09c 100644 --- a/app/Models/GatewayType.php +++ b/app/Models/GatewayType.php @@ -29,6 +29,7 @@ namespace App\Models; * @method static \Illuminate\Database\Eloquent\Builder|GatewayType whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|GatewayType whereName($value) * @property-read \Illuminate\Database\Eloquent\Collection $payment_methods + * @property-read \Illuminate\Database\Eloquent\Collection $payment_methods * @mixin \Eloquent */ class GatewayType extends StaticModel diff --git a/app/Models/GroupSetting.php b/app/Models/GroupSetting.php index afa61135a2eb..5361b860be44 100644 --- a/app/Models/GroupSetting.php +++ b/app/Models/GroupSetting.php @@ -56,6 +56,8 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|GroupSetting withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $clients * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $clients + * @property-read \Illuminate\Database\Eloquent\Collection $documents * @mixin \Eloquent */ class GroupSetting extends StaticModel diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 0fb21f6454cc..5f29924ce8a6 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -212,6 +212,17 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $invitations * @property-read \Illuminate\Database\Eloquent\Collection $payments * @property-read \Illuminate\Database\Eloquent\Collection $tasks + * @property object|null $tax_data + * @property-read \Illuminate\Database\Eloquent\Collection $activities + * @property-read \Illuminate\Database\Eloquent\Collection $company_ledger + * @property-read \Illuminate\Database\Eloquent\Collection $credits + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $expenses + * @property-read \Illuminate\Database\Eloquent\Collection $history + * @property-read \Illuminate\Database\Eloquent\Collection $invitations + * @property-read \Illuminate\Database\Eloquent\Collection $payments + * @property-read \Illuminate\Database\Eloquent\Collection $tasks + * @method static \Illuminate\Database\Eloquent\Builder|Invoice whereTaxData($value) * @mixin \Eloquent */ class Invoice extends BaseModel @@ -277,9 +288,6 @@ class Invoice extends BaseModel ]; protected $casts = [ - // 'date' => 'date:Y-m-d', - // 'due_date' => 'date:Y-m-d', - // 'partial_due_date' => 'date:Y-m-d', 'line_items' => 'object', 'backup' => 'object', 'updated_at' => 'timestamp', @@ -287,6 +295,7 @@ class Invoice extends BaseModel 'deleted_at' => 'timestamp', 'is_deleted' => 'bool', 'is_amount_discount' => 'bool', + 'tax_data' => 'object', ]; protected $with = []; diff --git a/app/Models/Payment.php b/app/Models/Payment.php index b7d9d47e7565..ec0be4287091 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -137,6 +137,11 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property-read \Illuminate\Database\Eloquent\Collection $documents * @property-read \Illuminate\Database\Eloquent\Collection $invoices * @property-read \Illuminate\Database\Eloquent\Collection $paymentables + * @property-read \Illuminate\Database\Eloquent\Collection $company_ledger + * @property-read \Illuminate\Database\Eloquent\Collection $credits + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $invoices + * @property-read \Illuminate\Database\Eloquent\Collection $paymentables * @mixin \Eloquent */ class Payment extends BaseModel diff --git a/app/Models/Product.php b/app/Models/Product.php index f52c4427e99b..a72a92e9bab3 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -97,6 +97,9 @@ use League\CommonMark\CommonMarkConverter; * @method static \Illuminate\Database\Eloquent\Builder|Product withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Product withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property int|null $tax_id + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @method static \Illuminate\Database\Eloquent\Builder|Product whereTaxId($value) * @mixin \Eloquent */ class Product extends BaseModel diff --git a/app/Models/Project.php b/app/Models/Project.php index 42a53c0c756f..a48c40111f5e 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -74,6 +74,8 @@ use Laracasts\Presenter\PresentableTrait; * @method static \Illuminate\Database\Eloquent\Builder|Project withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $documents * @property-read \Illuminate\Database\Eloquent\Collection $tasks + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $tasks * @mixin \Eloquent */ class Project extends BaseModel diff --git a/app/Models/Proposal.php b/app/Models/Proposal.php index f2d75f539937..fcd291aadc3b 100644 --- a/app/Models/Proposal.php +++ b/app/Models/Proposal.php @@ -29,6 +29,7 @@ use App\Utils\Traits\MakesHash; * @method static \Illuminate\Database\Eloquent\Builder|Proposal query() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope() * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $documents * @mixin \Eloquent */ class Proposal extends BaseModel diff --git a/app/Models/PurchaseOrder.php b/app/Models/PurchaseOrder.php index dc35fcb5f2e6..7e06728715d9 100644 --- a/app/Models/PurchaseOrder.php +++ b/app/Models/PurchaseOrder.php @@ -186,6 +186,12 @@ use Illuminate\Support\Facades\Storage; * @property-read \Illuminate\Database\Eloquent\Collection $invitations * @property-read \Illuminate\Database\Eloquent\Collection $invoices * @property-read \Illuminate\Database\Eloquent\Collection $payments + * @property-read \Illuminate\Database\Eloquent\Collection $activities + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $history + * @property-read \Illuminate\Database\Eloquent\Collection $invitations + * @property-read \Illuminate\Database\Eloquent\Collection $invoices + * @property-read \Illuminate\Database\Eloquent\Collection $payments * @mixin \Eloquent */ class PurchaseOrder extends BaseModel diff --git a/app/Models/Quote.php b/app/Models/Quote.php index f62d1d5f59bc..89edeca6770f 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -185,6 +185,10 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $documents * @property-read \Illuminate\Database\Eloquent\Collection $history * @property-read \Illuminate\Database\Eloquent\Collection $invitations + * @property-read \Illuminate\Database\Eloquent\Collection $activities + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $history + * @property-read \Illuminate\Database\Eloquent\Collection $invitations * @mixin \Eloquent */ class Quote extends BaseModel diff --git a/app/Models/RecurringExpense.php b/app/Models/RecurringExpense.php index d3668a34d1e6..275fc7721de0 100644 --- a/app/Models/RecurringExpense.php +++ b/app/Models/RecurringExpense.php @@ -140,6 +140,7 @@ use Illuminate\Support\Carbon; * @method static \Illuminate\Database\Eloquent\Builder|RecurringExpense withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|RecurringExpense withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $documents * @mixin \Eloquent */ class RecurringExpense extends BaseModel diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index 34cc53715fea..5546bd846f03 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -182,6 +182,13 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $history * @property-read \Illuminate\Database\Eloquent\Collection $invitations * @property-read \Illuminate\Database\Eloquent\Collection $invoices + * @property int $is_proforma + * @property-read \Illuminate\Database\Eloquent\Collection $activities + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $history + * @property-read \Illuminate\Database\Eloquent\Collection $invitations + * @property-read \Illuminate\Database\Eloquent\Collection $invoices + * @method static \Illuminate\Database\Eloquent\Builder|RecurringInvoice whereIsProforma($value) * @mixin \Eloquent */ class RecurringInvoice extends BaseModel diff --git a/app/Models/RecurringQuote.php b/app/Models/RecurringQuote.php index 569f57d7445f..875a5af495b8 100644 --- a/app/Models/RecurringQuote.php +++ b/app/Models/RecurringQuote.php @@ -176,6 +176,11 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $history * @property-read \Illuminate\Database\Eloquent\Collection $invitations * @property-read \Illuminate\Database\Eloquent\Collection $quotes + * @property-read \Illuminate\Database\Eloquent\Collection $activities + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $history + * @property-read \Illuminate\Database\Eloquent\Collection $invitations + * @property-read \Illuminate\Database\Eloquent\Collection $quotes * @mixin \Eloquent */ class RecurringQuote extends BaseModel diff --git a/app/Models/Task.php b/app/Models/Task.php index 4a1829c98eae..81974f5b6b22 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -92,6 +92,7 @@ use Illuminate\Support\Carbon; * @method static \Illuminate\Database\Eloquent\Builder|Task withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Task withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $documents * @mixin \Eloquent */ class Task extends BaseModel diff --git a/app/Models/User.php b/app/Models/User.php index eabc9eb07bc8..04a6b5d070d9 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -146,6 +146,13 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $documents * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications * @property-read \Illuminate\Database\Eloquent\Collection $tokens + * @property-read \Illuminate\Database\Eloquent\Collection $clients + * @property-read \Illuminate\Database\Eloquent\Collection $companies + * @property-read \Illuminate\Database\Eloquent\Collection $company_users + * @property-read \Illuminate\Database\Eloquent\Collection $contacts + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications + * @property-read \Illuminate\Database\Eloquent\Collection $tokens * @mixin \Eloquent */ class User extends Authenticatable implements MustVerifyEmail diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index 84ca29d6f31d..7981cccd4938 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -108,6 +108,10 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $contacts * @property-read \Illuminate\Database\Eloquent\Collection $documents * @property-read \Illuminate\Database\Eloquent\Collection $primary_contact + * @property-read \Illuminate\Database\Eloquent\Collection $activities + * @property-read \Illuminate\Database\Eloquent\Collection $contacts + * @property-read \Illuminate\Database\Eloquent\Collection $documents + * @property-read \Illuminate\Database\Eloquent\Collection $primary_contact * @mixin \Eloquent */ class Vendor extends BaseModel diff --git a/app/Models/VendorContact.php b/app/Models/VendorContact.php index fe9b61caff53..0caf71f60371 100644 --- a/app/Models/VendorContact.php +++ b/app/Models/VendorContact.php @@ -112,6 +112,8 @@ use Laracasts\Presenter\PresentableTrait; * @method static \Illuminate\Database\Eloquent\Builder|VendorContact withoutTrashed() * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications * @property-read \Illuminate\Database\Eloquent\Collection $purchase_order_invitations + * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications + * @property-read \Illuminate\Database\Eloquent\Collection $purchase_order_invitations * @mixin \Eloquent */ class VendorContact extends Authenticatable implements HasLocalePreference diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 42f0f553ff38..5d40f1c143c1 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -739,7 +739,9 @@ class BaseDriver extends AbstractPaymentDriver $invoices_string = \implode(', ', collect($this->payment_hash->invoices())->pluck('invoice_number')->toArray()) ?: null; $amount = Number::formatMoney($this->payment_hash?->amount_with_fee() ?: 0, $this->client); - if ($abbreviated || ! $invoices_string) { + if($abbreviated && $invoices_string){ + return $invoices_string; + } elseif ($abbreviated || ! $invoices_string) { return ctrans('texts.gateway_payment_text_no_invoice', [ 'amount' => $amount, 'client' => $this->client->present()->name(), diff --git a/app/Services/Scheduler/ScheduleEntity.php b/app/Services/Scheduler/EmailRecord.php similarity index 97% rename from app/Services/Scheduler/ScheduleEntity.php rename to app/Services/Scheduler/EmailRecord.php index b7a93bd8f1e7..557addd13ec5 100644 --- a/app/Services/Scheduler/ScheduleEntity.php +++ b/app/Services/Scheduler/EmailRecord.php @@ -15,7 +15,7 @@ use App\Models\Scheduler; use Illuminate\Support\Str; use App\Utils\Traits\MakesHash; -class ScheduleEntity +class EmailRecord { use MakesHash; diff --git a/app/Services/Scheduler/SchedulerService.php b/app/Services/Scheduler/SchedulerService.php index 7a670ada6ab8..1533d26a7485 100644 --- a/app/Services/Scheduler/SchedulerService.php +++ b/app/Services/Scheduler/SchedulerService.php @@ -38,9 +38,9 @@ class SchedulerService } } - private function schedule_entity() + private function email_record() { - (new ScheduleEntity($this->scheduler))->run(); + (new EmailRecord($this->scheduler))->run(); } diff --git a/app/Services/Tax/Providers/ZipTax.php b/app/Services/Tax/Providers/ZipTax.php new file mode 100644 index 000000000000..74d43fec16c7 --- /dev/null +++ b/app/Services/Tax/Providers/ZipTax.php @@ -0,0 +1,59 @@ +callApi(['key' => $this->api_key, 'address' => $this->address]); + + if($response->successful()) + return $response->json(); + + if($this->postal_code) { + $response = $this->callApi(['key' => $this->api_key, 'address' => $this->postal_code]); + + if($response->successful()) + return $response->json(); + + } + + $response->throw(); + + } + + /** + * callApi + * + * @param array $parameters + * @return Response + */ + private function callApi(array $parameters): Response + { + $response = Http::retry(3, 1000)->withHeaders([])->get($this->endpoint, $parameters); + + return $response; + + } +} diff --git a/app/Services/Tax/TaxService.php b/app/Services/Tax/TaxService.php index 36623162ca01..8d29eb299129 100644 --- a/app/Services/Tax/TaxService.php +++ b/app/Services/Tax/TaxService.php @@ -11,6 +11,9 @@ namespace App\Services\Tax; +use App\Models\Client; +use App\Models\Company; + class TaxService { diff --git a/config/cache.php b/config/cache.php index dc2f8766b2f0..0c0ccc26109c 100644 --- a/config/cache.php +++ b/config/cache.php @@ -17,7 +17,7 @@ return [ 'default' => env('CACHE_DRIVER', 'file'), - 'limiter' => 'redis', + 'limiter' => env('LIMITER_DRIVER', null), /* |-------------------------------------------------------------------------- | Cache Stores diff --git a/config/ninja.php b/config/ninja.php index 77d2e642fba9..54a33c338a54 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.5.96', - 'app_tag' => '5.5.96', + 'app_version' => '5.5.97', + 'app_tag' => '5.5.97', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), diff --git a/database/migrations/2023_03_21_053933_tax_calculations_for_invoices.php b/database/migrations/2023_03_21_053933_tax_calculations_for_invoices.php index 1c6d885e9f37..710f59e8c6ea 100644 --- a/database/migrations/2023_03_21_053933_tax_calculations_for_invoices.php +++ b/database/migrations/2023_03_21_053933_tax_calculations_for_invoices.php @@ -31,6 +31,18 @@ return new class extends Migration $table->boolean('tax_data'); }); + Schema::table('schedulers', function (Blueprint $table){ + $table->dropUnique('schedulers_company_id_name_unique'); + }); + + Schema::table('schedulers', function (Blueprint $table) { + $table->string('name', 191)->nullable()->change(); + }); + + + + + } /** diff --git a/tests/Feature/Scheduler/ScheduleEntityTest.php b/tests/Feature/Scheduler/ScheduleEntityTest.php index 76a4ddb02522..f60a71ea1b47 100644 --- a/tests/Feature/Scheduler/ScheduleEntityTest.php +++ b/tests/Feature/Scheduler/ScheduleEntityTest.php @@ -30,7 +30,7 @@ use Illuminate\Routing\Middleware\ThrottleRequests; /** * @test - * @covers App\Services\Scheduler\SchedulerEntity + * @covers App\Services\Scheduler\EmailRecord */ class ScheduleEntityTest extends TestCase { @@ -62,7 +62,7 @@ class ScheduleEntityTest extends TestCase 'name' => 'A test entity email scheduler', 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY, 'next_run' => now()->format('Y-m-d'), - 'template' => 'schedule_entity', + 'template' => 'email_record', 'parameters' => [ 'entity' => 'invoice', 'entity_id' => $this->invoice->hashed_id, @@ -86,7 +86,7 @@ class ScheduleEntityTest extends TestCase 'name' => 'A test entity email scheduler', 'frequency_id' => 0, 'next_run' => now()->format('Y-m-d'), - 'template' => 'schedule_entity', + 'template' => 'email_record', 'parameters' => [ 'entity' => 'invoice', 'entity_id' => $this->invoice->hashed_id, @@ -108,7 +108,7 @@ class ScheduleEntityTest extends TestCase $data = [ 'name' => 'A test entity email scheduler', 'next_run' => now()->format('Y-m-d'), - 'template' => 'schedule_entity', + 'template' => 'email_record', 'parameters' => [ 'entity' => 'invoice', 'entity_id' => $this->invoice->hashed_id,