File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 1919/**
2020 * @property int $id
2121 * @property ?int $parent_id
22+ * @property ?Invoice $parent
23+ * @property ?Invoice $quote
24+ * @property ?Invoice $credit
2225 * @property InvoiceType $type
2326 * @property string $serial_number
2427 * @property ArrayObject $serial_number_details
@@ -142,7 +145,11 @@ public function credit(): HasOne
142145 public function getLatestSerialNumber (): ?string
143146 {
144147 /** @var ?static */
145- $ latestInvoice = static ::query ()->latest ('serial_number ' )->first ();
148+ $ latestInvoice = static ::query ()
149+ ->when ($ this ->getSerialNumberPrefix (), fn (Builder $ query ) => $ query ->where ('serial_number_details->prefix ' , $ this ->getSerialNumberPrefix ()))
150+ ->when ($ this ->getSerialNumberSerie (), fn (Builder $ query ) => $ query ->where ('serial_number_details->serie ' , $ this ->getSerialNumberSerie ()))
151+ ->latest ('serial_number ' )
152+ ->first ();
146153
147154 return $ latestInvoice ?->serial_number;
148155 }
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ public function __construct(
4141
4242 public function generateFilename (): string
4343 {
44- return Str::snake ( $ this ->name ). " _ {$ this ->serial_number }.pdf " ;
44+ return Str::slug ( "{ $ this ->name } _ {$ this ->serial_number }" , separator: ' _ ' ) . " .pdf " ;
4545 }
4646
4747 public function getFilename (): string
@@ -54,7 +54,7 @@ public function getLogo(): string
5454 $ type = pathinfo ($ this ->logo , PATHINFO_EXTENSION );
5555 $ data = file_get_contents ($ this ->logo );
5656
57- return 'data:image/ ' . $ type. ';base64, ' . base64_encode ($ data );
57+ return 'data:image/ ' . $ type . ';base64, ' . base64_encode ($ data );
5858 }
5959
6060 /**
@@ -96,7 +96,7 @@ public function totalTaxAmount(): Money
9696
9797 public function totalDiscountAmount (): Money
9898 {
99- if (! $ this ->discounts ) {
99+ if (!$ this ->discounts ) {
100100 return Money::of (0 , $ this ->subTotalAmount ()->getCurrency ());
101101 }
102102
You can’t perform that action at this time.
0 commit comments