364 lines
8.1 KiB
C++
364 lines
8.1 KiB
C++
/*
|
|
File: Invoice.cpp
|
|
Description: Implements the Invoice class which represents an invoice in the Vehicle Service Management System.
|
|
Provides constructors, accessors, and mutators for invoice details such as ID, booking, costs,
|
|
discount percentage, total amount, payment details, and status.
|
|
Author: Trenser
|
|
Date: 19-May-2026
|
|
*/
|
|
|
|
#include "Invoice.h"
|
|
|
|
int Invoice::m_uid = 0;
|
|
|
|
/*
|
|
Function: Invoice
|
|
Description: Default constructor that initializes a new invoice with a unique ID,
|
|
null booking, zero costs, zero discount, zero total amount,
|
|
and default payment method and status.
|
|
Parameters:
|
|
- None
|
|
Returns:
|
|
- A new Invoice object.
|
|
*/
|
|
Invoice::Invoice()
|
|
: m_id("INV" + std::to_string(++m_uid)),
|
|
m_booking(nullptr),
|
|
m_laborCost(0.0),
|
|
m_partsCost(0.0),
|
|
m_discountPercentage(0.0),
|
|
m_totalAmount(0.0),
|
|
m_paymentMethod(util::PaymentMode()),
|
|
m_status(util::PaymentStatus()) {}
|
|
|
|
/*
|
|
Function: Invoice
|
|
Description: Parameterized constructor that initializes a new invoice with a unique ID and specified details.
|
|
Parameters:
|
|
- bookingId: ID of the associated service booking.
|
|
- booking: Pointer to the ServiceBooking object.
|
|
- invoiceDate: Timestamp of when the invoice was created.
|
|
- laborCost: Cost of labor for the service.
|
|
- parts: Map of inventory items used in the service.
|
|
- partsCost: Total cost of parts.
|
|
- discountPercentage: Discount applied to the invoice.
|
|
- totalAmount: Final total amount after discount.
|
|
- paymentDate: Timestamp of when payment was made.
|
|
- paymentMethod: Payment mode (ONLINE/OFFLINE).
|
|
- status: Payment status (PENDING/COMPLETED).
|
|
Returns:
|
|
- A new Invoice object.
|
|
*/
|
|
Invoice::Invoice(
|
|
const std::string& bookingId,
|
|
ServiceBooking* booking,
|
|
const util::Timestamp& invoiceDate,
|
|
double laborCost, const util::Map<int,
|
|
InventoryItem*>& parts,
|
|
double partsCost,
|
|
double discountPercentage,
|
|
double totalAmount,
|
|
const util::Timestamp& paymentDate,
|
|
util::PaymentMode paymentMethod,
|
|
util::PaymentStatus status
|
|
)
|
|
: m_id("INV" + std::to_string(++m_uid)),
|
|
m_bookingId(bookingId),
|
|
m_booking(booking),
|
|
m_invoiceDate(invoiceDate),
|
|
m_laborCost(laborCost),
|
|
m_parts(parts),
|
|
m_partsCost(partsCost),
|
|
m_discountPercentage(discountPercentage),
|
|
m_totalAmount(totalAmount),
|
|
m_paymentDate(paymentDate),
|
|
m_paymentMethod(paymentMethod),
|
|
m_status(status) {}
|
|
|
|
/*
|
|
Function: getId
|
|
Description: Retrieves the unique ID of the invoice.
|
|
Returns:
|
|
- const std::string& representing the invoice ID.
|
|
*/
|
|
const std::string& Invoice::getId() const
|
|
{
|
|
return m_id;
|
|
}
|
|
|
|
/*
|
|
Function: getBookingId
|
|
Description: Retrieves the booking ID associated with the invoice.
|
|
Returns:
|
|
- const std::string& representing the booking ID.
|
|
*/
|
|
const std::string& Invoice::getBookingId() const
|
|
{
|
|
return m_bookingId;
|
|
}
|
|
|
|
/*
|
|
Function: getBooking
|
|
Description: Retrieves the pointer to the associated ServiceBooking.
|
|
Returns:
|
|
- ServiceBooking* representing the booking.
|
|
*/
|
|
ServiceBooking* Invoice::getBooking() const
|
|
{
|
|
return m_booking;
|
|
}
|
|
|
|
/*
|
|
Function: getInvoiceDate
|
|
Description: Retrieves the timestamp of the invoice creation date.
|
|
Returns:
|
|
- const util::Timestamp& representing the invoice date.
|
|
*/
|
|
const util::Timestamp& Invoice::getInvoiceDate() const
|
|
{
|
|
return m_invoiceDate;
|
|
}
|
|
|
|
/*
|
|
Function: getLaborCost
|
|
Description: Retrieves the labor cost associated with the invoice.
|
|
Returns:
|
|
- double representing the labor cost.
|
|
*/
|
|
double Invoice::getLaborCost() const
|
|
{
|
|
return m_laborCost;
|
|
}
|
|
|
|
/*
|
|
Function: getParts
|
|
Description: Retrieves the map of inventory items used in the service.
|
|
Returns:
|
|
- const util::Map<int, InventoryItem*>& representing the parts.
|
|
*/
|
|
const util::Map<int, InventoryItem*>& Invoice::getParts() const
|
|
{
|
|
return m_parts;
|
|
}
|
|
|
|
/*
|
|
Function: getPartsCost
|
|
Description: Retrieves the total cost of parts used in the service.
|
|
Returns:
|
|
- double representing the parts cost.
|
|
*/
|
|
double Invoice::getPartsCost() const
|
|
{
|
|
return m_partsCost;
|
|
}
|
|
|
|
/*
|
|
Function: getDiscountPercentage
|
|
Description: Retrieves the discount percentage applied to the invoice.
|
|
Returns:
|
|
- double representing the discount percentage.
|
|
*/
|
|
double Invoice::getDiscountPercentage() const
|
|
{
|
|
return m_discountPercentage;
|
|
}
|
|
|
|
/*
|
|
Function: getTotalAmount
|
|
Description: Retrieves the total amount of the invoice after discount.
|
|
Returns:
|
|
- double representing the total amount.
|
|
*/
|
|
double Invoice::getTotalAmount() const
|
|
{
|
|
return m_totalAmount;
|
|
}
|
|
|
|
/*
|
|
Function: getPaymentDate
|
|
Description: Retrieves the timestamp of the payment date.
|
|
Returns:
|
|
- const util::Timestamp& representing the payment date.
|
|
*/
|
|
const util::Timestamp& Invoice::getPaymentDate() const
|
|
{
|
|
return m_paymentDate;
|
|
}
|
|
|
|
/*
|
|
Function: getPaymentMethod
|
|
Description: Retrieves the payment mode used for the invoice.
|
|
Returns:
|
|
- util::PaymentMode representing the payment method.
|
|
*/
|
|
util::PaymentMode Invoice::getPaymentMethod() const
|
|
{
|
|
return m_paymentMethod;
|
|
}
|
|
|
|
/*
|
|
Function: getStatus
|
|
Description: Retrieves the payment status of the invoice.
|
|
Returns:
|
|
- util::PaymentStatus representing the payment status.
|
|
*/
|
|
util::PaymentStatus Invoice::getStatus() const
|
|
{
|
|
return m_status;
|
|
}
|
|
|
|
/*
|
|
Function: setId
|
|
Description: Sets the unique ID of the invoice.
|
|
Parameters:
|
|
- id: New invoice ID string.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setId(const std::string& id)
|
|
{
|
|
m_id = id;
|
|
}
|
|
|
|
/*
|
|
Function: setBookingId
|
|
Description: Sets the booking ID associated with the invoice.
|
|
Parameters:
|
|
- bookingId: New booking ID string.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setBookingId(const std::string& bookingId)
|
|
{
|
|
m_bookingId = bookingId;
|
|
}
|
|
|
|
/*
|
|
Function: setBooking
|
|
Description: Sets the associated ServiceBooking pointer.
|
|
Parameters:
|
|
- booking: Pointer to the ServiceBooking object.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setBooking(ServiceBooking* booking)
|
|
{
|
|
m_booking = booking;
|
|
}
|
|
|
|
/*
|
|
Function: setInvoiceDate
|
|
Description: Sets the invoice creation date.
|
|
Parameters:
|
|
- invoiceDate: New timestamp for the invoice date.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setInvoiceDate(const util::Timestamp& invoiceDate)
|
|
{
|
|
m_invoiceDate = invoiceDate;
|
|
}
|
|
|
|
/*
|
|
Function: setLaborCost
|
|
Description: Sets the labor cost for the invoice.
|
|
Parameters:
|
|
- laborCost: New labor cost value.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setLaborCost(double laborCost)
|
|
{
|
|
m_laborCost = laborCost;
|
|
}
|
|
|
|
/*
|
|
Function: setParts
|
|
Description: Sets the inventory items used in the service.
|
|
Parameters:
|
|
- parts: Map of inventory items.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setParts(const util::Map<int, InventoryItem*>& parts)
|
|
{
|
|
m_parts = parts;
|
|
}
|
|
|
|
/*
|
|
Function: setPartsCost
|
|
Description: Sets the total cost of parts used in the service.
|
|
Parameters:
|
|
- partsCost: New parts cost value.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setPartsCost(double partsCost)
|
|
{
|
|
m_partsCost = partsCost;
|
|
}
|
|
|
|
/*
|
|
Function: setDiscountPercentage
|
|
Description: Sets the discount percentage applied to the invoice.
|
|
Parameters:
|
|
- discountPercentage: New discount percentage value.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setDiscountPercentage(double discountPercentage)
|
|
{
|
|
m_discountPercentage = discountPercentage;
|
|
}
|
|
|
|
/*
|
|
Function: setTotalAmount
|
|
Description: Sets the total amount of the invoice.
|
|
Parameters:
|
|
- totalAmount: New total amount value.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setTotalAmount(double totalAmount)
|
|
{
|
|
m_totalAmount = totalAmount;
|
|
}
|
|
|
|
/*
|
|
Function: setPaymentDate
|
|
Description: Sets the payment date for the invoice.
|
|
Parameters:
|
|
- paymentDate: New timestamp for the payment date.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setPaymentDate(const util::Timestamp& paymentDate)
|
|
{
|
|
m_paymentDate = paymentDate;
|
|
}
|
|
|
|
/*
|
|
Function: setPaymentMethod
|
|
Description: Sets the payment mode for the invoice.
|
|
Parameters:
|
|
- paymentMethod: New payment mode value.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setPaymentMethod(util::PaymentMode paymentMethod)
|
|
{
|
|
m_paymentMethod = paymentMethod;
|
|
}
|
|
|
|
/*
|
|
Function: setStatus
|
|
Description: Sets the payment status of the invoice.
|
|
Parameters:
|
|
- status: New payment status value.
|
|
Returns:
|
|
- void
|
|
*/
|
|
void Invoice::setStatus(util::PaymentStatus status)
|
|
{
|
|
m_status = status;
|
|
} |