mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
solve unit tests
This commit is contained in:
@ -86,13 +86,15 @@ class EstimatesRequest extends FormRequest
|
||||
|
||||
$companyCurrency = CompanySetting::getSetting('currency', $this->header('company'));
|
||||
|
||||
$customerCurrency = Customer::find($this->customer_id)->currency_id;
|
||||
$customer = Customer::find($this->customer_id);
|
||||
|
||||
if ((string)$customerCurrency !== $companyCurrency) {
|
||||
$rules['exchange_rate'] = [
|
||||
'required',
|
||||
];
|
||||
};
|
||||
if ($companyCurrency && $customer) {
|
||||
if ((string)$customer->currency_id !== $companyCurrency) {
|
||||
$rules['exchange_rate'] = [
|
||||
'required',
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
if ($this->isMethod('PUT')) {
|
||||
$rules['estimate_number'] = [
|
||||
@ -115,7 +117,7 @@ class EstimatesRequest extends FormRequest
|
||||
|
||||
return collect($this->except('items', 'taxes'))
|
||||
->merge([
|
||||
'creator_id' => $this->user()->id,
|
||||
'creator_id' => $this->user()->id ?? null,
|
||||
'status' => $this->has('estimateSend') ? Estimate::STATUS_SENT : Estimate::STATUS_DRAFT,
|
||||
'company_id' => $this->header('company'),
|
||||
'tax_per_item' => CompanySetting::getSetting('tax_per_item', $this->header('company')) ?? 'NO ',
|
||||
|
||||
@ -53,11 +53,13 @@ class ExpenseRequest extends FormRequest
|
||||
],
|
||||
];
|
||||
|
||||
if ($companyCurrency !== $this->currency_id) {
|
||||
$rules['exchange_rate'] = [
|
||||
'required',
|
||||
];
|
||||
};
|
||||
if ($companyCurrency && $this->currency_id) {
|
||||
if ($companyCurrency !== $this->currency_id) {
|
||||
$rules['exchange_rate'] = [
|
||||
'required',
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
@ -86,13 +86,15 @@ class InvoicesRequest extends FormRequest
|
||||
|
||||
$companyCurrency = CompanySetting::getSetting('currency', $this->header('company'));
|
||||
|
||||
$customerCurrency = Customer::find($this->customer_id)->currency_id;
|
||||
$customer = Customer::find($this->customer_id);
|
||||
|
||||
if ((string)$customerCurrency !== $companyCurrency) {
|
||||
$rules['exchange_rate'] = [
|
||||
'required',
|
||||
];
|
||||
};
|
||||
if ($customer && $companyCurrency) {
|
||||
if ((string)$customer->currency_id !== $companyCurrency) {
|
||||
$rules['exchange_rate'] = [
|
||||
'required',
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
if ($this->isMethod('PUT')) {
|
||||
$rules['invoice_number'] = [
|
||||
@ -115,7 +117,7 @@ class InvoicesRequest extends FormRequest
|
||||
|
||||
return collect($this->except('items', 'taxes'))
|
||||
->merge([
|
||||
'creator_id' => $this->user()->id,
|
||||
'creator_id' => $this->user()->id ?? null,
|
||||
'status' => $this->has('invoiceSend') ? Invoice::STATUS_SENT : Invoice::STATUS_DRAFT,
|
||||
'paid_status' => Invoice::STATUS_UNPAID,
|
||||
'company_id' => $this->header('company'),
|
||||
|
||||
@ -65,13 +65,15 @@ class PaymentRequest extends FormRequest
|
||||
|
||||
$companyCurrency = CompanySetting::getSetting('currency', $this->header('company'));
|
||||
|
||||
$customerCurrency = Customer::find($this->customer_id)->currency_id;
|
||||
$customer = Customer::find($this->customer_id);
|
||||
|
||||
if ((string)$customerCurrency !== $companyCurrency) {
|
||||
$rules['exchange_rate'] = [
|
||||
'required',
|
||||
];
|
||||
};
|
||||
if ($customer && $companyCurrency) {
|
||||
if ((string)$customer->currency_id !== $companyCurrency) {
|
||||
$rules['exchange_rate'] = [
|
||||
'required',
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
@ -83,13 +83,15 @@ class RecurringInvoiceRequest extends FormRequest
|
||||
]
|
||||
];
|
||||
|
||||
$customerCurrency = Customer::find($this->customer_id)->currency_id;
|
||||
$customer = Customer::find($this->customer_id);
|
||||
|
||||
if ((string)$customerCurrency !== $companyCurrency) {
|
||||
$rules['exchange_rate'] = [
|
||||
'required',
|
||||
];
|
||||
};
|
||||
if ($customer && $companyCurrency) {
|
||||
if ((string)$customer->currency_id !== $companyCurrency) {
|
||||
$rules['exchange_rate'] = [
|
||||
'required',
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
@ -419,7 +419,7 @@ class User extends Authenticatable implements HasMedia
|
||||
if (Schema::hasColumn('companies', 'owner_id')) {
|
||||
$company = Company::find(request()->header('company'));
|
||||
|
||||
if ($company && $this->id === $company->owner_id) {
|
||||
if ($company && $this->id == $company->owner_id) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -21,7 +21,7 @@ class CompanyPolicy
|
||||
|
||||
public function delete(User $user, Company $company)
|
||||
{
|
||||
if ($user->id === $company->owner_id) {
|
||||
if ($user->id == $company->owner_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class CompanyPolicy
|
||||
|
||||
public function transferOwnership(User $user, Company $company)
|
||||
{
|
||||
if ($user->id === $company->owner_id) {
|
||||
if ($user->id == $company->owner_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user