diff --git a/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php index 0e920fe9..803dec47 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php @@ -19,12 +19,15 @@ use App\Classes\ValueObjects\Constants\BusinessType; use App\Classes\ValueObjects\Constants\CompanyType; use App\Classes\ValueObjects\Constants\RoleTypes; use App\Classes\Jobs\CreatePerfexCRMCustomer; +use App\Classes\Modules\Segments\DataTransferObjects\SeasonalSegmentObject; use App\Models\Company; +use App\Models\Segment; use App\Models\User; +use Carbon\Carbon; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\App; - +use App\Classes\Modules\Segments\Services\CreatesSeasonalSegment; class CreateCustomerLogic extends AbstractControllerLogic { @@ -63,6 +66,9 @@ class CreateCustomerLogic extends AbstractControllerLogic /** @var CreatePerfexCRMLeadProcessor */ private $createPerfexCRMLeadProcessor; + /** @var CreatesSeasonalSegment */ + private $createsSeasonalSegment; + /** * CreateCustomerLogic constructor. * @param CreateUserProcessor $createUserProcessor @@ -73,9 +79,10 @@ class CreateCustomerLogic extends AbstractControllerLogic * @param AuthenticationProcessor $authenticationProcessor * @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor * @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor + * @param CreatesSeasonalSegment $createsSeasonalSegment */ public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateContactProcessor $createContactProcessor, AssignEmployeeProcessor $assignEmployeeProcessor, AssignSegmentProcessor $assignSegmentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, - CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor) + CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor, CreatesSeasonalSegment $createsSeasonalSegment) { $this->createUserProcessor = $createUserProcessor; $this->createCompanyProcessor = $createCompanyProcessor; @@ -85,6 +92,7 @@ class CreateCustomerLogic extends AbstractControllerLogic $this->authenticationProcessor = $authenticationProcessor; $this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor; $this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor; + $this->createsSeasonalSegment = $createsSeasonalSegment; } /** @@ -109,8 +117,20 @@ class CreateCustomerLogic extends AbstractControllerLogic $Object = new EmploymentObject($company, $user); $this->assignEmployeeProcessor->execute($Object); + // assign STANDARD_SEGMENT to all new customers $this->assignSegmentProcessor->execute($company); + // assign other standard segment to all new customers + $otherDefaultSegmentToAdd = Segment::whereIn('name', ['HONEY TRAP NEW REGISTRATION'])->get(); + $start_date = Carbon::now(); + $end_date = $start_date->addDays(30); + foreach ($otherDefaultSegmentToAdd as $segment) { + $seasonalSegmentObject = new SeasonalSegmentObject($company->id, $segment->id, $start_date, $end_date ?? null); + + $this->createsSeasonalSegment->execute($seasonalSegmentObject); + $this->assignSegmentProcessor->execute($company, $segment->id); + } + if(config('perfexcrm.is_enabled') == 'true'){ //$this->createPerfexCRMLeadProcessor->execute($request); $createLeadPerfexCRMObject = new CreateLeadPerfexCRMObject( diff --git a/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php b/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php index f9493b17..31d814a0 100644 --- a/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php @@ -32,6 +32,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading 'DocNo', 'DocDate', 'DebtorCode', + 'Ref', 'DebtorName', 'CurrencyCode', 'ShipInfo', @@ -67,7 +68,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading if($start_date && $end_date) { $query->whereBetween('created_at', [ - Carbon::parse($start_date)->format('Y-m-d 0:00:00'), + Carbon::parse($start_date)->format('Y-m-d 0:00:00'), Carbon::parse($end_date)->format('Y-m-d 23:59:59') ]); } @@ -95,6 +96,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading '<>', $transaction->updated_at->format('m/d/Y H:m'), $company->debtor, + $booking->marking, '', 'MYR', $booking->marking, @@ -107,4 +109,4 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading 'CIEF' ]; } -} \ No newline at end of file +}