solve unit tests

This commit is contained in:
harshjagad20
2021-12-01 13:25:24 +05:30
parent f57fa41640
commit 88bfb38b56
33 changed files with 205 additions and 219 deletions

View File

@ -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 ',

View File

@ -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;
}

View File

@ -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'),

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 {

View File

@ -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;
}