Add invoice/estimate/payment number length setting (#425)

* Add invoice/estimate/payment number length setting
This commit is contained in:
Florian Gareis
2021-03-26 08:31:43 +01:00
committed by GitHub
parent 3f7db2793f
commit bfd9850bf6
15 changed files with 209 additions and 24 deletions

View File

@ -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()