Documentation
¶
Index ¶
- func Migrate(db *gorm.DB) error
- type LogisticService
- func (s *LogisticService) AddItemShipment(shipmentID string, item *models.ShipmentItem) error
- func (s *LogisticService) AddTrackingEvent(shipmentLegID string, data *models.TrackingEventModel) error
- func (s *LogisticService) ArrivedShipmentLegDelivery(shipmentLegID string, date time.Time, notes string) error
- func (s *LogisticService) CreateDistributionEvent(data *models.DistributionEventModel) error
- func (s *LogisticService) CreateShipment(data *models.ShipmentModel) error
- func (s *LogisticService) CreateShipmentFeedback(data *models.ShipmentFeedback) error
- func (s *LogisticService) CreateShipmentLeg(data *models.ShipmentLegModel) error
- func (s *LogisticService) DeleteDistributionEvent(eventID string) error
- func (s *LogisticService) DeleteItemShipment(shipmentID string, itemID string) error
- func (s *LogisticService) DeleteShipment(shipmentID string) error
- func (s *LogisticService) GenerateDistributionEventReport(distributionEventID string) (*models.DistributionEventReport, error)
- func (s *LogisticService) GenerateShipmentReport(shipmentID string) (*models.ShipmentModel, error)
- func (s *LogisticService) GetAllShipments(request http.Request, search string) (paginate.Page, error)
- func (s *LogisticService) GetDistributionEvent(eventID string) (*models.DistributionEventModel, error)
- func (s *LogisticService) GetDistributionEventReport(distributionEventID string) (*models.DistributionEventReport, error)
- func (s *LogisticService) GetShipment(shipmentID string) (*models.ShipmentModel, error)
- func (s *LogisticService) ListDistributionEvents(request http.Request, search string) (paginate.Page, error)
- func (s *LogisticService) ListShipments(request http.Request, search string) (paginate.Page, error)
- func (s *LogisticService) ProcessShipment(shipmentID string, date time.Time, notes string) error
- func (s *LogisticService) ReadyToShip(shipmentID string, date time.Time, notes *string) error
- func (s *LogisticService) ReportLostOrDamage(shipmentID string, shipmentLegID string, date time.Time, ...) error
- func (s *LogisticService) StartShipmentLegDelivery(shipmentLegID string, date time.Time, notes string) error
- func (s *LogisticService) UpdateIsDelayedForShipment(shipmentID string) error
- func (s *LogisticService) UpdateStatusShipment(shipmentID string, status string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LogisticService ¶
type LogisticService struct {
// contains filtered or unexported fields
}
func NewLogisticService ¶
func NewLogisticService(db *gorm.DB, ctx *context.ERPContext, inventoryService *inventory.InventoryService) *LogisticService
NewLogisticService creates a new instance of LogisticService with the given database connection, context and inventory service.
func (*LogisticService) AddItemShipment ¶
func (s *LogisticService) AddItemShipment(shipmentID string, item *models.ShipmentItem) error
func (*LogisticService) AddTrackingEvent ¶
func (s *LogisticService) AddTrackingEvent(shipmentLegID string, data *models.TrackingEventModel) error
func (*LogisticService) ArrivedShipmentLegDelivery ¶
func (s *LogisticService) ArrivedShipmentLegDelivery(shipmentLegID string, date time.Time, notes string) error
ArrivedShipmentLegDelivery marks a shipment leg as ARRIVED. It takes a shipment leg ID, a date, and an optional notes string as input. It first checks if the shipment leg status is IN_DELIVERY. If not, it returns an error. If the notes string is not nil, it appends the string to the shipment leg notes. If the to location ID is nil, it returns an error. If the to location warehouse ID is not nil, it adds a movement for each item in the shipment leg for the same quantity as the shipment leg quantity. Finally, it saves the shipment leg with the new status and updates the current shipment leg ID of the associated shipment. The function returns an error if the operation fails, otherwise it returns nil.
func (*LogisticService) CreateDistributionEvent ¶
func (s *LogisticService) CreateDistributionEvent(data *models.DistributionEventModel) error
func (*LogisticService) CreateShipment ¶
func (s *LogisticService) CreateShipment(data *models.ShipmentModel) error
CreateShipment creates a new shipment record in the database.
It takes a ShipmentModel as input and attempts to save it to the database. The function returns an error if the operation fails, otherwise it returns nil.
func (*LogisticService) CreateShipmentFeedback ¶
func (s *LogisticService) CreateShipmentFeedback(data *models.ShipmentFeedback) error
CreateShipmentFeedback creates a new shipment feedback record in the database.
It takes a ShipmentFeedback as input and attempts to save it to the database. The function returns an error if the operation fails, otherwise it returns nil.
func (*LogisticService) CreateShipmentLeg ¶
func (s *LogisticService) CreateShipmentLeg(data *models.ShipmentLegModel) error
CreateShipmentLeg creates a new shipment leg record in the database.
It takes a ShipmentLegModel as input and attempts to save it to the database. The function returns an error if the operation fails, otherwise it returns nil.
func (*LogisticService) DeleteDistributionEvent ¶
func (s *LogisticService) DeleteDistributionEvent(eventID string) error
func (*LogisticService) DeleteItemShipment ¶
func (s *LogisticService) DeleteItemShipment(shipmentID string, itemID string) error
DeleteItemShipment deletes an item from the shipment record in the database.
It takes a shipment ID and an item ID as input and attempts to delete the item from the shipment. The function returns an error if the operation fails, otherwise it returns nil.
func (*LogisticService) DeleteShipment ¶
func (s *LogisticService) DeleteShipment(shipmentID string) error
DeleteShipment deletes a shipment record in the database.
It takes a shipment ID as input and attempts to delete the shipment and its associated records. The function returns an error if the operation fails, otherwise it returns nil.
func (*LogisticService) GenerateDistributionEventReport ¶
func (s *LogisticService) GenerateDistributionEventReport(distributionEventID string) (*models.DistributionEventReport, error)
GenerateDistributionEventReport generates a distribution event report based on the distribution event ID.
It takes a distribution event ID as input and retrieves the distribution event and its associated shipments, items, shipment legs, tracking events, incident events, and feedbacks from the database. The function returns a pointer to a DistributionEventReport and an error. If the distribution event is found, it is returned along with a nil error. If not found, or in case of a query error, the function returns a non-nil error.
func (*LogisticService) GenerateShipmentReport ¶
func (s *LogisticService) GenerateShipmentReport(shipmentID string) (*models.ShipmentModel, error)
GenerateShipmentReport generates a shipment report based on the shipment ID.
It takes a shipment ID as input and retrieves the shipment and its associated shipment legs, items, and incident events from the database. The function returns a pointer to a ShipmentModel and an error. If the shipment is found, it is returned along with a nil error. If not found, or in case of a query error, the function returns a non-nil error.
func (*LogisticService) GetAllShipments ¶
func (*LogisticService) GetDistributionEvent ¶
func (s *LogisticService) GetDistributionEvent(eventID string) (*models.DistributionEventModel, error)
GetDistributionEvent retrieves a distribution event and its associated shipments from the database.
It takes an event ID as input and returns a pointer to a DistributionEventModel and an error. The function preloads the associated shipments, items, shipment legs, and from/to locations. If the distribution event is found, it is returned along with a nil error. If not found, or in case of a query error, the function returns a non-nil error.
func (*LogisticService) GetDistributionEventReport ¶
func (s *LogisticService) GetDistributionEventReport(distributionEventID string) (*models.DistributionEventReport, error)
GetDistributionEventReport retrieves a distribution event report from the database.
It takes a distribution event ID as input and returns a pointer to a DistributionEventReport and an error. The function preloads the associated shipments, items, shipment legs, tracking events, and incident events. If the distribution event is found, it is returned along with a nil error. If not found, or in case of a query error, the function returns a non-nil error.
func (*LogisticService) GetShipment ¶
func (s *LogisticService) GetShipment(shipmentID string) (*models.ShipmentModel, error)
GetShipment retrieves a shipment and its associated shipment legs, items, and distribution event from the database.
It takes a shipment ID as input and returns a pointer to a ShipmentModel and an error. The function preloads the associated shipment legs, items, and distribution event. If the shipment is found, it is returned along with a nil error. If not found, or in case of a query error, the function returns a non-nil error.
func (*LogisticService) ListDistributionEvents ¶
func (s *LogisticService) ListDistributionEvents(request http.Request, search string) (paginate.Page, error)
ListDistributionEvents retrieves a paginated list of distribution events from the database.
It takes an HTTP request and a search query string as input. The search query is applied to the notes and name fields of the distribution events. If the request contains a company ID header, the method filters results by company ID. Pagination is applied to manage the result set, and any necessary request modifications are made using the utils.FixRequest utility.
The function returns a paginated page of DistributionEventModel and an error if the operation fails.
func (*LogisticService) ListShipments ¶
func (*LogisticService) ProcessShipment ¶
func (*LogisticService) ReadyToShip ¶
ReadyToShip marks a shipment as READY_TO_SHIP. It takes a shipment ID, a date, and an optional notes string as input. It first checks if the shipment status is PENDING. If not, it returns an error. If the notes string is not nil, it appends the string to the shipment notes. Finally, it saves the shipment with the new status and returns an error if the operation fails.
func (*LogisticService) ReportLostOrDamage ¶
func (s *LogisticService) ReportLostOrDamage(shipmentID string, shipmentLegID string, date time.Time, data *models.IncidentEventModel, movementType models.MovementType, wasteWarehouseID *string, ) error
func (*LogisticService) StartShipmentLegDelivery ¶
func (s *LogisticService) StartShipmentLegDelivery(shipmentLegID string, date time.Time, notes string) error
StartShipmentLegDelivery marks a shipment leg as IN_DELIVERY. It takes a shipment leg ID, a date, and an optional notes string as input. It first checks if the shipment leg status is PENDING. If not, it returns an error. If the notes string is not nil, it appends the string to the shipment leg notes. Finally, it saves the shipment leg with the new status and updates the current shipment leg ID of the associated shipment. The function returns an error if the operation fails, otherwise it returns nil.
func (*LogisticService) UpdateIsDelayedForShipment ¶
func (s *LogisticService) UpdateIsDelayedForShipment(shipmentID string) error
UpdateIsDelayedForShipment updates the shipment's is_delayed flag to true if its expected_finish_at is less than the current time and the flag is currently false.
func (*LogisticService) UpdateStatusShipment ¶
func (s *LogisticService) UpdateStatusShipment(shipmentID string, status string) error
UpdateStatusShipment updates the status of a shipment in the database.
It takes a shipment ID and a status string as input and attempts to update the shipment record with the new status. If the shipment is found, the function returns a nil error. Otherwise, it returns a non-nil error.