diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 995dbb646117..99549bd53224 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -923,6 +923,9 @@ class Import implements ShouldQueue $modified['company_id'] = $this->company->id; $modified['line_items'] = $this->cleanItems($modified['line_items']); + if(array_key_exists('next_send_date', $resource)) + $modified['next_send_date_client'] = $resource['next_send_date']; + if(array_key_exists('created_at', $modified)) $modified['created_at'] = Carbon::parse($modified['created_at']); diff --git a/app/Services/PurchaseOrder/ApplyNumber.php b/app/Services/PurchaseOrder/ApplyNumber.php index 9f47baec4a9c..68398c9ebd1b 100644 --- a/app/Services/PurchaseOrder/ApplyNumber.php +++ b/app/Services/PurchaseOrder/ApplyNumber.php @@ -41,7 +41,20 @@ class ApplyNumber extends AbstractService return $this->purchase_order; } - $this->trySaving(); + switch ($this->vendor->company->getSetting('counter_number_applied')) { + case 'when_saved': + $this->trySaving(); + break; + case 'when_sent': + if ($this->invoice->status_id == PurchaseOrder::STATUS_SENT) { + $this->trySaving(); + } + break; + + default: + break; + } + return $this->purchase_order; }