minor changes to dummy data seeder comments

This commit is contained in:
Omair Saleh
2022-11-15 19:56:03 +08:00
parent 8a4810d961
commit 634a97f3b4
+62 -31
View File
@@ -301,22 +301,33 @@ class DummyDataSeeder extends Seeder
// =============================================== //
// 1. create user
// 2. create company
// 3. create Company Module
// 4. Attach Employee
// 5. create contact
// 6. create Address
// 7. Declare Company Relationship with CIEF
// 4. Declare Company Relationship with CIEF
// 5. Attach Employee
// 6. create contact
// 7. create Address
// 8. identification verification
// =============================================== //
// Order Workflow //
// =============================================== //
// 9. Create Shipping Label
// 10. Receive Goods at warehouse
// 11. Load into container for shipping
// 12. Un-stuffing Container
// 13. last mile delivery
// 10. Receive Goods at warehouse (our record match supplier record + detect any problems)
// 11. Load into container for shipping (our record match supplier record + detect any problems)
// 12. generate invoice (add billing address + double check price)
// 13. additional charges
// 12. Un-stuffing Container (our record match supplier record + detect any problems)
// 13. last mile delivery (our record match supplier record + on hold)
// generate random number of users
for($userLoop=1; $userLoop <= rand(20, 50); $userLoop++) {
// ================= //
// === //
// 1 // ========== //
// Create user //
// ================= //
$customerName = $this->faker->name;
@@ -325,7 +336,8 @@ class DummyDataSeeder extends Seeder
/** @var User $user */
$user = $this->createsUser->execute($userObject);
// ================= //
// === //
// 2 // ========== //
// Create Company //
// ================= //
@@ -348,7 +360,8 @@ class DummyDataSeeder extends Seeder
/** @var Company $company */
$company = $this->createsCompany->execute($company_object);
// ========================//
// === //
// 3 // =================//
// Create Company Module //
// ========================//
// Company Module are sub entities of the company, and is used to declare what kind of business role this sub entity is in "Like Departments"
@@ -360,21 +373,34 @@ class DummyDataSeeder extends Seeder
/** @var CompanyModule $companyModule */
$companyModule = $this->createsCompanyModule->execute($company, $companyModuleObject);
// ==================//
// === //
// 4 // ================================== //
// Declare Company Relationship with CIEF //
// ========================================= //
// In order for 2 entities to work together they must both agree to the relationship "Like facebook friend requests".
// But at the moment since CIEF is the only Entity that has a direct relationship with importers we just declare this relationship by default.
$connectionObject = new CompanyConnectionObject($companyModule, $CIEF, mt_rand(1000, 9999) . (new GeneratesInitials())->name($companyName)->length(3)->generate(), 'CIEF');
$connection = $this->createsCompanyConnection->execute($connectionObject);
$this->approvesCompanyConnection->execute($connection);
// === //
// 5 // ===========//
// Attach Employee //
// ==================//
// employees are attached to company modules not companies, because an employee maybe working for one or many "Departments".
$Object = new EmploymentObject($companyModule, $user);
$this->assignEmployeeProcessor->execute($Object);
// ================= //
// === //
// 6 // =========== //
// Create Contact //
// ================= //
// Contacts uses eloquent polymorphic relationship to declare its owner. and for this use case it will be attached to the company not the company module.
$contactObject = new ContactObject($customerName, $this->faker->phoneNumber, $customerEmail, null);
$this->createsContact->execute($company, $contactObject);
// ================= //
// === //
// 7 // ========== //
// Create Address //
// ================= //
// Addresses uses eloquent polymorphic relationship to declare its owner. and for this use case it will be attached to the company module.
@@ -395,17 +421,9 @@ class DummyDataSeeder extends Seeder
}
// ========================================= //
// Declare Company Relationship with CIEF //
// ========================================= //
// In order for 2 entities to work together they must both agree to the relationship "Like facebook friend requests".
// But at the moment since CIEF is the only Entity that has a direct relationship with importers we just declare this relationship by default.
$connectionObject = new CompanyConnectionObject($companyModule, $CIEF, mt_rand(1000, 9999) . (new GeneratesInitials())->name($companyName)->length(3)->generate(), 'CIEF');
$connection = $this->createsCompanyConnection->execute($connectionObject);
$this->approvesCompanyConnection->execute($connection);
// ============================== //
// === //
// 8 // ======================= //
// identification verification //
// ============================== //
// please refer to company types section for more insight
@@ -417,7 +435,9 @@ class DummyDataSeeder extends Seeder
// generate random number of shipping labels
for($orderLoop=1; $orderLoop <= rand(1, 30); $orderLoop++) {
// ======================== //
// === //
// 9 // ================= //
// Create Shipping Label //
// ======================== //
// The shipping label is stored in the warehouse as an order entity.
@@ -446,7 +466,9 @@ class DummyDataSeeder extends Seeder
if($orderLoop !== 1) {
// generate random number of packing lists
for($packingListLoop=1; $packingListLoop <= rand(2, 4); $packingListLoop++) {
// ============================= //
// ==== //
// 10 // ===================== //
// Receive Goods at warehouse //
// WAREHOUSE_RECEIVE_LIST //
// ============================= //
@@ -454,6 +476,7 @@ class DummyDataSeeder extends Seeder
// A transport arrangement is attached to WAREHOUSE_RECEIVE_LIST packing list to represent the trip
// from supplier to the warehouse and is used to record the arrival date.
// create random packages
$packages = [];
for ($packagesLoop = 1; $packagesLoop <= rand(2, 5); $packagesLoop++) {
@@ -463,34 +486,40 @@ class DummyDataSeeder extends Seeder
$packingListReference = $this->faker->bothify('???#########');
$warehouseReceiveObject = new PackingListObject($packingListReference, $originWarehouse->id, PackingListType::WAREHOUSE_RECEIVE_LIST, ApprovalStatus::APPROVED);
// Creates WAREHOUSE_RECEIVE_LIST & WAREHOUSE_RECEIVE_LIST_REPLICA
/** @var PackingList $warehouseReceiveList */
$warehouseReceiveList = $this->createPackingListProcessor->execute($warehouseReceiveObject, $order);
// attach packages to packing list
foreach ($packages as $package) {
// Attach packages to both WAREHOUSE_RECEIVE_LIST & WAREHOUSE_RECEIVE_LIST_REPLICA
$this->createPackageProcessor->execute($package, $warehouseReceiveList);
}
// random arrival date in the last 30 days
$receiveDate = Carbon::today()->subDays(rand(10, 45));
// create transport arrangement for the trip from manufacturer to warehouse (to record drop off date)
// create transport arrangement for the trip from manufacturer to warehouse (to record drop off/ receive date)
$transportObject = new TransportObject(TransportType::LAND, null, $this->faker->bothify('??#########'), $receiveDate, $receiveDate, ApprovalStatus::APPROVED);
$this->createsTransport->execute($transportObject, $warehouseReceiveList);
// =================================== //
// ==== //
// 11 // =========================== //
// Load into container for shipping //
// SHIPPING_PACKING_LIST //
// =================================== //
// When a batch of goods is loaded in a container to prepare for shipping a SHIPPING_PACKING_LIST packing list is created.
// A SHIPPING_PACKING_LIST is a copy of the WAREHOUSE_RECEIVE_LIST in most cases.
$shippingPackingListObject = new PackingListObject($packingListReference, $originWarehouse->id, PackingListType::SHIPPING_PACKING_LIST, ApprovalStatus::APPROVED);
// Creates SHIPPING_PACKING_LIST & SHIPPING_PACKING_LIST_REPLICA
/** @var PackingList $warehouseReceiveList */
$shippingPackingList = $this->createPackingListProcessor->execute($shippingPackingListObject, $order);
// attach packages to packing list
foreach ($packages as $package) {
// Attach packages to both SHIPPING_PACKING_LIST & SHIPPING_PACKING_LIST_REPLICA
$this->createPackageProcessor->execute($package, $shippingPackingList);
}
@@ -501,7 +530,8 @@ class DummyDataSeeder extends Seeder
$container->packingLists()->attach($shippingPackingList);
if ($container->status !== ApprovalStatus::COMPLETED) {
// ========================================= //
// ==== //
// 12 // ================================= //
// Un-stuffing Container //
// container arrived to malaysia warehouse //
// ========================================= //
@@ -521,7 +551,8 @@ class DummyDataSeeder extends Seeder
$container->status = ApprovalStatus::COMPLETED;
$container->save();
// ======================== //
// ==== //
// 13 // ================ //
// Last Mile Delivery //
// ======================== //
// after the container is un-stuffed, the malaysian warehouse will arrange for delivery.