|
|
@@ -103,13 +103,9 @@ $controller = new class($number) {
|
|
|
$sale = $this->getSale();
|
|
|
if(!$sale) {
|
|
|
$location_id = $this->request->int("location_id");
|
|
|
- $location = Location::get($location_id);
|
|
|
- if(!$location) {
|
|
|
- throw new RuntimeException(__("Location not found."));
|
|
|
- }
|
|
|
+ $location = Location::require($location_id);
|
|
|
|
|
|
$sale = new Sale();
|
|
|
- $sale->company_id = $company->id;
|
|
|
$sale->location_id = $location->id;
|
|
|
$sale->user_id = $this->user->id;
|
|
|
$sale->status = SaleStatuses::NEW;
|
|
|
@@ -119,11 +115,9 @@ $controller = new class($number) {
|
|
|
$success_message = __("Lead created successfully.");
|
|
|
}
|
|
|
else {
|
|
|
- $sale->company_id = $company->id;
|
|
|
$sale->status = $this->request->int("status");
|
|
|
$sale->currency = $this->request->string("currency");
|
|
|
$sale->tax_rate = $this->request->decimal("tax_rate", 2);
|
|
|
- $sale->date_predicted_sold = $this->request->date("date_predicted_sold");
|
|
|
|
|
|
if(!SaleStatuses::validate($sale->status)) {
|
|
|
throw new RuntimeException(__("Status is invalid."));
|
|
|
@@ -134,6 +128,9 @@ $controller = new class($number) {
|
|
|
$success_message = __("Lead updated successfully.");
|
|
|
}
|
|
|
|
|
|
+ $sale->company_id = $company->id;
|
|
|
+ $sale->date_predicted_sold = $this->request->date("date_predicted_sold");
|
|
|
+
|
|
|
$sale->commit();
|
|
|
|
|
|
if(Http::isAjax()) {
|