mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
fix conflicts and issue with add_number_length migration
This commit is contained in:
@ -78,6 +78,10 @@ class Estimate extends Model implements HasMedia
|
||||
->orderBy('estimate_number', 'desc')
|
||||
->first();
|
||||
|
||||
// Get number length config
|
||||
$numberLength = CompanySetting::getSetting('estimate_number_length', request()->header('company'));
|
||||
$numberLengthText = "%0{$numberLength}d";
|
||||
|
||||
if (!$lastOrder) {
|
||||
// We get here if there is no order at all
|
||||
// If there is no number set it to 0, which will be 1 at the end.
|
||||
@ -94,7 +98,7 @@ class Estimate extends Model implements HasMedia
|
||||
// the %05d part makes sure that there are always 6 numbers in the string.
|
||||
// so it adds the missing zero's when needed.
|
||||
|
||||
return sprintf('%06d', intval($number) + 1);
|
||||
return sprintf($numberLengthText, intval($number) + 1);
|
||||
}
|
||||
|
||||
public function emailLogs()
|
||||
@ -379,7 +383,7 @@ class Estimate extends Model implements HasMedia
|
||||
$data['user'] = $this->user->toArray();
|
||||
$data['company'] = $this->company->toArray();
|
||||
$data['body'] = $this->getEmailBody($data['body']);
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
|
||||
\Mail::to($data['to'])->send(new SendEstimateMail($data));
|
||||
|
||||
@ -427,6 +431,10 @@ class Estimate extends Model implements HasMedia
|
||||
$estimateTemplate = EstimateTemplate::find($this->estimate_template_id);
|
||||
|
||||
$company = Company::find($this->company_id);
|
||||
$locale = CompanySetting::getSetting('language', $company->id);
|
||||
|
||||
App::setLocale($locale);
|
||||
|
||||
$logo = $company->logo_path;
|
||||
|
||||
view()->share([
|
||||
@ -473,7 +481,7 @@ class Estimate extends Model implements HasMedia
|
||||
{
|
||||
$estimateAsAttachment = CompanySetting::getSetting('estimate_email_attachment', $this->company_id);
|
||||
|
||||
if($estimateAsAttachment == 'NO') {
|
||||
if ($estimateAsAttachment == 'NO') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -82,6 +82,9 @@ class Invoice extends Model implements HasMedia
|
||||
->orderBy('invoice_number', 'desc')
|
||||
->first();
|
||||
|
||||
// Get number length config
|
||||
$numberLength = CompanySetting::getSetting('invoice_number_length', request()->header('company'));
|
||||
$numberLengthText = "%0{$numberLength}d";
|
||||
|
||||
if (!$lastOrder) {
|
||||
// We get here if there is no order at all
|
||||
@ -98,7 +101,7 @@ class Invoice extends Model implements HasMedia
|
||||
// the %06d part makes sure that there are always 6 numbers in the string.
|
||||
// so it adds the missing zero's when needed.
|
||||
|
||||
return sprintf('%06d', intval($number) + 1);
|
||||
return sprintf($numberLengthText, intval($number) + 1);
|
||||
}
|
||||
|
||||
public function emailLogs()
|
||||
@ -429,7 +432,7 @@ class Invoice extends Model implements HasMedia
|
||||
$data['user'] = $this->user->toArray();
|
||||
$data['company'] = Company::find($this->company_id);
|
||||
$data['body'] = $this->getEmailBody($data['body']);
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
|
||||
if ($this->status == Invoice::STATUS_DRAFT) {
|
||||
$this->status = Invoice::STATUS_SENT;
|
||||
@ -510,6 +513,9 @@ class Invoice extends Model implements HasMedia
|
||||
$invoiceTemplate = InvoiceTemplate::find($this->invoice_template_id);
|
||||
|
||||
$company = Company::find($this->company_id);
|
||||
$locale = CompanySetting::getSetting('language', $company->id);
|
||||
|
||||
App::setLocale($locale);
|
||||
|
||||
$logo = $company->logo_path;
|
||||
|
||||
@ -531,7 +537,7 @@ class Invoice extends Model implements HasMedia
|
||||
{
|
||||
$invoiceAsAttachment = CompanySetting::getSetting('invoice_email_attachment', $this->company_id);
|
||||
|
||||
if($invoiceAsAttachment == 'NO') {
|
||||
if ($invoiceAsAttachment == 'NO') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ class Payment extends Model implements HasMedia
|
||||
$data['user'] = $this->user->toArray();
|
||||
$data['company'] = Company::find($this->company_id);
|
||||
$data['body'] = $this->getEmailBody($data['body']);
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
|
||||
|
||||
\Mail::to($data['to'])->send(new SendPaymentMail($data));
|
||||
|
||||
@ -271,6 +271,11 @@ class Payment extends Model implements HasMedia
|
||||
$payment = Payment::where('payment_number', 'LIKE', $value . '-%')
|
||||
->orderBy('payment_number', 'desc')
|
||||
->first();
|
||||
|
||||
// Get number length config
|
||||
$numberLength = CompanySetting::getSetting('payment_number_length', request()->header('company'));
|
||||
$numberLengthText = "%0{$numberLength}d";
|
||||
|
||||
if (!$payment) {
|
||||
// We get here if there is no order at all
|
||||
// If there is no number set it to 0, which will be 1 at the end.
|
||||
@ -286,7 +291,7 @@ class Payment extends Model implements HasMedia
|
||||
// the %05d part makes sure that there are always 6 numbers in the string.
|
||||
// so it adds the missing zero's when needed.
|
||||
|
||||
return sprintf('%06d', intval($number) + 1);
|
||||
return sprintf($numberLengthText, intval($number) + 1);
|
||||
}
|
||||
|
||||
public function scopeWhereSearch($query, $search)
|
||||
@ -373,6 +378,9 @@ class Payment extends Model implements HasMedia
|
||||
public function getPDFData()
|
||||
{
|
||||
$company = Company::find($this->company_id);
|
||||
$locale = CompanySetting::getSetting('language', $company->id);
|
||||
|
||||
App::setLocale($locale);
|
||||
|
||||
$logo = $company->logo_path;
|
||||
|
||||
@ -405,7 +413,7 @@ class Payment extends Model implements HasMedia
|
||||
{
|
||||
$paymentAsAttachment = CompanySetting::getSetting('payment_email_attachment', $this->company_id);
|
||||
|
||||
if($paymentAsAttachment == 'NO') {
|
||||
if ($paymentAsAttachment == 'NO') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user