diff --git a/app/Jobs/Product/UpdateOrCreateProduct.php b/app/Jobs/Product/UpdateOrCreateProduct.php
index 8544f8316..eff3edd8f 100644
--- a/app/Jobs/Product/UpdateOrCreateProduct.php
+++ b/app/Jobs/Product/UpdateOrCreateProduct.php
@@ -83,9 +83,23 @@ class UpdateOrCreateProduct implements ShouldQueue
$product = Product::withTrashed()->firstOrNew(['product_key' => $item->product_key, 'company_id' => $this->invoice->company->id]);
+ /* If a user is using placeholders in their descriptions, do not update the products */
+ $string_hit = false;
+
+ foreach ( [':MONTH',':YEAR',':QUARTER',':WEEK'] as $string )
+ {
+
+ if(stripos($product->notes, $string) !== FALSE) {
+ $string_hit = true;
+ }
+
+ }
+
+ if($string_hit)
+ continue;
+
$product->product_key = $item->product_key;
$product->notes = isset($item->notes) ? $item->notes : '';
- //$product->cost = isset($item->cost) ? $item->cost : 0; //this value shouldn't be updated.
$product->price = isset($item->cost) ? $item->cost : 0;
if (! $product->id) {
diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php
index 4611774fd..87a327350 100644
--- a/app/Repositories/BaseRepository.php
+++ b/app/Repositories/BaseRepository.php
@@ -19,6 +19,7 @@ use App\Models\Credit;
use App\Models\Invoice;
use App\Models\Quote;
use App\Models\RecurringInvoice;
+use App\Utils\Helpers;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\SavesDocuments;
@@ -108,32 +109,6 @@ class BaseRepository
}
}
- /**
- * @param $ids
- * @param $action
- *
- * @return int
- * @deprecated - this doesn't appear to be used anywhere?
- */
- // public function bulk($ids, $action)
- // {
- // if (! $ids) {
- // return 0;
- // }
-
- // $ids = $this->transformKeys($ids);
-
- // $entities = $this->findByPublicIdsWithTrashed($ids);
-
- // foreach ($entities as $entity) {
- // if (auth()->user()->can('edit', $entity)) {
- // $this->$action($entity);
- // }
- // }
-
- // return count($entities);
- // }
-
/* Returns an invoice if defined as a key in the $resource array*/
public function getInvitation($invitation, $resource)
{
@@ -171,7 +146,7 @@ class BaseRepository
* @throws \ReflectionException
*/
protected function alternativeSave($data, $model)
- {
+ { //$start = microtime(true);
//forces the client_id if it doesn't exist
if(array_key_exists('client_id', $data))
$model->client_id = $data['client_id'];
@@ -208,9 +183,19 @@ class BaseRepository
$model->custom_surcharge_tax3 = $client->company->custom_surcharge_taxes3;
$model->custom_surcharge_tax4 = $client->company->custom_surcharge_taxes4;
- if(!$model->id)
+ if(!$model->id){
$this->new_model = true;
-
+
+ $model->line_items = (collect($model->line_items))->map(function ($item) use($model,$client) {
+
+ $item->notes = Helpers::processReservedKeywords($item->notes, $client);
+
+ return $item;
+
+ });
+
+ }
+
$model->saveQuietly();
/* Model now persisted, now lets do some child tasks */
@@ -378,6 +363,8 @@ class BaseRepository
$model->save();
+// nlog("save time = ". microtime(true) - $start);
+
return $model->fresh();
}
}
diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php
index a3ba8bd67..fee637ec8 100644
--- a/app/Utils/Helpers.php
+++ b/app/Utils/Helpers.php
@@ -128,7 +128,7 @@ class Helpers
if(!$string_hit)
return $value;
- // 04-10-2022 Return Early if no reserved keywords are present, this is a very expenseive process
+ // 04-10-2022 Return Early if no reserved keywords are present, this is a very expensive process
Carbon::setLocale($entity->locale());
@@ -296,8 +296,7 @@ class Helpers
}
return $value;
- // $x = str_replace(["\n", "
"], ["\r", "
"], $value);
- // return $x;
+
}
/**