Parking Management Solution
Parking Management Solution
Fields:
o Account__c (Lookup to Account) – Links the parking slot to the entity it belongs to
(e.g., Serene High).
o Owner__c (Lookup to User) – Used for assigning the slot to a Security Guard Queue.
Relationship:
Child: Can be linked to multiple Vehicle__c records (via the Vehicle's lookup field).
Fields:
o Entry_Time__c (DateTime: The time the vehicle enters the parking lot)
o Exit_Time__c (DateTime: The time the vehicle exits the parking lot)
Relationship:
Parent: Account__c (Lookup relationship) – Vehicle can optionally link to the Account for
reporting purposes (optional but useful).
Fields:
o Amount__c (Currency: The total bill amount)
o Vehicle__c (Lookup to Vehicle) – Links the bill to the vehicle being billed.
Relationship:
Parent: ParkingSlot__c (Lookup relationship) – Optionally, link the bill to the parking slot for
additional tracking.
Relationships Summary:
o One Account (e.g., Serene High, Bank) can have multiple Parking Slots.
o One Parking Slot can have multiple Vehicle records over time, but only one active at
a time (current vehicle parked).
o One Vehicle record generates one Bill for the corresponding parking session.
2. Parking Slot records are tied to an Account, representing physical parking spaces.
3. Vehicle records track vehicles occupying parking slots, with lookup fields to both the
ParkingSlot and Account.
4. Bill records are created when a vehicle exits a parking slot, with references to the associated
Vehicle and Parking Slot.
By setting up these objects and relationships, you will create a comprehensive parking management
system in Salesforce that allows for parking slot tracking, vehicle record creation, and billing.
To implement the Parking Management Solution described in the document within Salesforce,
follow these steps:
Use the Account object to represent each of the 7 entities in Serene Township (e.g., Serene
High, Bank, etc.).
Designate points of contact for each Account (e.g., Association Presidents for Serene High).
Create an Auto-generated Flow that triggers upon updating this field. The flow will
automatically create or remove Parking Slot records to match the specified number of slots.
Ensure that only empty slots are removed, and the newest ones are prioritized for deletion.
Create a custom object for Parking Slot with unique alphanumeric IDs.
Use Queues to assign Parking Slot records to the respective Security Guard teams based on
their associated Account.
Design Screen Flows for Security Guards to update parking slot status (Occupied/Free)
without accessing the list view directly:
o Occupying a Slot: Guard selects a slot, enters the vehicle number, and the system
creates a Vehicle record or retrieves existing details. The Entry Time field should be
set.
o Freeing a Slot: Guard selects a slot, sees vehicle details, and marks the slot as free.
The Exit Time should be set, and a Bill record should be generated based on the
vehicle's parking duration.
5. Bill Calculation
o For Electric Vehicles (identified by the "EV" prefix in the vehicle number), apply a
20% discount on the calculated bill. Create two different page layouts for Bills: one
for regular vehicles and one for EVs.
Automatically delete Vehicle records older than one year. This can be done using a
Scheduled Apex Job that runs daily to check and delete old records.
Restrict visibility:
o Estate Managers can only view and access their own Accounts.
o Only Estate Managers can view the Parking Revenue field, which shows the total
revenue generated from Bills under each Account.
8. Test Classes
Write Apex Test Classes to ensure over 95% coverage. Include positive and negative test
scenarios for all flows and custom logic.
By following these steps, you'll build a comprehensive Parking Management solution tailored for
Serene Township using Salesforce.
4o
You said:
Please provide what what need to create ,apex class ,trigger ,screen flow
ChatGPT said:
ChatGPT
To implement the Parking Management Solution in Salesforce, the following components (Apex
classes, triggers, screen flows, etc.) need to be created:
1. Apex Classes
BillCalculationApex:
o Logic for calculating parking charges. If the parking time is less than 2 hours, set the
bill to ₹0. Otherwise, calculate ₹50 per hour beyond 2 hours. If the vehicle is electric
(starts with "EV"), apply a 20% discount.
o Logic for generating Bill records based on the vehicle’s entry and exit times.
VehicleDeletionScheduler:
o Scheduled job to delete Vehicle records older than one year. This should run daily
using a Scheduled Apex Class.
ParkingSlotManagementApex:
o Logic to automatically create or delete Parking Slot records when the number of
parking slots on an Account changes. This could be a helper class invoked by a flow
or trigger.
Test Classes:
o Test all of the above classes with both positive and negative test cases, ensuring over
95% code coverage.
2. Triggers
VehicleTrigger:
o Trigger on the Vehicle object to check whether the vehicle is electric (i.e., if the
vehicle number starts with "EV") and apply the corresponding discount on the
generated Bill record.
AccountParkingSlotTrigger:
o Trigger on the Account object to ensure that when the number of parking slots
changes, it either adds or deletes Parking Slot records.
3. Screen Flows
3. Create a Vehicle record (or retrieve the existing one) and mark the Entry
Time.
4. Automatically create a Bill record based on the parking duration (using the
Apex logic).
o A separate flow or subflow to apply the 20% discount when a vehicle's number starts
with "EV" during the bill generation process.
o Create a Queue for each Account to which Parking Slot records will be assigned.
Only Security Guards in the respective Queue can update parking slot statuses
(Occupied/Free).
Parking Slot:
o Custom object to track parking slot availability and statuses (Occupied/Free). Each
parking slot should have a unique alphanumeric identifier.
Vehicle:
o Custom object to track vehicle information (e.g., vehicle number, entry time, exit
time).
Bill:
Amount
Schedule the VehicleDeletionScheduler Apex class to run daily and remove vehicle records
older than one year.
8. Permissions
Ensure that permissions are set for the different user types:
o Estate Manager: View only their own account records, access revenue information.
o Security Guard: View and update the status of parking slots via flows but no direct
access to slot or vehicle records.
This will cover the major requirements for the Parking Management System in Salesforce.
4o
You said:
ChatGPT said:
ChatGPT
Here is the Salesforce code needed for various components of the Parking Management Solution.
apex
Copy code
newBill.Vehicle__c = vehicle.Id;
newBill.ParkingSlot__c = slot.Id;
if (parkedDurationHours < 2) {
newBill.Amount__c = 0;
} else {
newBill.Amount__c = 50 * (parkedDurationHours - 1); // ₹50 per hour after the first 2 hours
if (vehicle.Vehicle_Number__c.startsWith('EV')) {
newBill.Discount_Percentage__c = 20;
insert newBill;
return newBill;
apex
Copy code
FROM Vehicle__c
vehicle.Exit_Time__c = System.now();
update vehicle;
BillCalculationApex.generateBill(slot, vehicle);
This scheduled class will delete vehicles older than one year.
apex
Copy code
if (!oldVehicles.isEmpty()) {
delete oldVehicles;
You can schedule the above class using the Salesforce Scheduler like this:
apex
Copy code
For the Security Guard to mark a parking slot as "Occupied" or "Free" using flows:
1. In the flow, after the parking slot is set to "Free," use Apex-Defined Flow Action to call
BillCalculationApex.generateBill().
This trigger will create or remove Parking Slot records when the number of slots on an account
changes.
apex
Copy code
newSlot.Account__c = acc.Id;
newSlot.Status__c = 'Free';
insert newSlot;
delete emptySlots;
Set up Queues for Security Guards and assign Parking Slot records to these queues based on
the Account.
Ensure only Security Guards can update the Status field using record-level security and
screen flows.
Parking Slot (Custom Object): Tracks parking slot availability and statuses.
Vehicle (Custom Object): Tracks vehicle information (vehicle number, entry time, exit time).
Bill (Custom Object): Stores the parking bill details (amount, discount, etc.).
Revenue Report: Display revenue generated per account, split by normal vehicles and
electric vehicles.
With this code and the related configuration, you should be able to implement the Parking
Management Solution in Salesforce effectively.
4o