diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 9cf97b9a67..db45b30397 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -245,8 +245,8 @@ class LoginController extends BaseController $company_token = CompanyToken::whereRaw("BINARY `token`= ?", [$request->header('X-API-TOKEN')])->first(); $cu = CompanyUser::query() - ->where('user_id', $company_token->user_id) - ->where('company_id', $company_token->company_id); + ->where('user_id', $company_token->user_id); + //->where('company_id', $company_token->company_id); //$ct = CompanyUser::whereUserId(auth()->user()->id); return $this->refreshResponse($cu); diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 5f80c8385e..3663280ea5 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -117,6 +117,8 @@ class BaseDriver extends AbstractPaymentDriver $payment->invoices()->sync($invoices); $payment->save(); + $payment->service()->applyNumber()->save(); + return $payment; } diff --git a/app/Services/Payment/ApplyNumber.php b/app/Services/Payment/ApplyNumber.php new file mode 100644 index 0000000000..ac33ef3d45 --- /dev/null +++ b/app/Services/Payment/ApplyNumber.php @@ -0,0 +1,46 @@ +client = $payment->client; + + $this->payment = $payment; + } + + public function run() + { + if ($this->payment->number != '') { + return $this->payment; + } + + $this->payment->number = $this->getNextPaymentNumber($this->client); + + return $this->payment; + } +} diff --git a/app/Services/Payment/PaymentService.php b/app/Services/Payment/PaymentService.php index bd7337c803..802e68bab5 100644 --- a/app/Services/Payment/PaymentService.php +++ b/app/Services/Payment/PaymentService.php @@ -14,6 +14,7 @@ namespace App\Services\Payment; use App\Factory\PaymentFactory; use App\Models\Invoice; use App\Models\Payment; +use App\Services\Payment\ApplyNumber; use App\Services\Payment\DeletePayment; use App\Services\Payment\RefundPayment; use App\Services\Payment\UpdateInvoicePayment; @@ -87,4 +88,12 @@ class PaymentService { return ((new UpdateInvoicePayment($this->payment)))->run(); } + + public function applyNumber() + { + $this->payment = (new ApplyNumber($this->payment))->run(); + + return $this; + } + } diff --git a/app/Transformers/ClientGatewayTokenTransformer.php b/app/Transformers/ClientGatewayTokenTransformer.php index 3548b735a5..116e31c4ff 100644 --- a/app/Transformers/ClientGatewayTokenTransformer.php +++ b/app/Transformers/ClientGatewayTokenTransformer.php @@ -39,6 +39,7 @@ class ClientGatewayTokenTransformer extends EntityTransformer 'created_at' => (int)$cgt->created_at, 'updated_at' => (int)$cgt->updated_at, 'archived_at' => (int)$cgt->deleted_at, + 'is_deleted' => (bool) $cgt->is_deleted, ]; } } diff --git a/app/Transformers/ClientTransformer.php b/app/Transformers/ClientTransformer.php index 23ce636ff7..0f06ab572f 100644 --- a/app/Transformers/ClientTransformer.php +++ b/app/Transformers/ClientTransformer.php @@ -33,6 +33,7 @@ class ClientTransformer extends EntityTransformer protected $defaultIncludes = [ 'contacts', 'documents', + 'gateway_tokens', ]; /** diff --git a/database/migrations/2020_08_11_221627_add_is_deleted_flag_to_client_gateway_token_table.php b/database/migrations/2020_08_11_221627_add_is_deleted_flag_to_client_gateway_token_table.php new file mode 100644 index 0000000000..07e27953a6 --- /dev/null +++ b/database/migrations/2020_08_11_221627_add_is_deleted_flag_to_client_gateway_token_table.php @@ -0,0 +1,30 @@ +boolean('is_deleted')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + } +}