warehouse

package
v1.0.49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB) error

Migrate creates the database tables for the warehouse module if they do not exist.

This function is intended to be used for database migrations and should be called during the application's setup process.

Parameters:

db - a pointer to the Gorm DB instance

Returns:

an error if the migration failed

Types

type WarehouseService

type WarehouseService struct {
	// contains filtered or unexported fields
}

func NewWarehouseService

func NewWarehouseService(db *gorm.DB, ctx *context.ERPContext) *WarehouseService

func (*WarehouseService) CreateWarehouse

func (s *WarehouseService) CreateWarehouse(data *models.WarehouseModel) error

CreateWarehouse adds a new warehouse record to the database.

This method receives a pointer to a WarehouseModel containing the warehouse details to be added. It uses GORM to insert the warehouse data into the warehouses table.

Returns:

  • nil if the operation is successful.
  • an error if the operation fails.

func (*WarehouseService) DeleteWarehouse

func (s *WarehouseService) DeleteWarehouse(id string) error

DeleteWarehouse deletes a warehouse in the database.

It takes an ID as input and attempts to delete the warehouse with the given ID from the database. If the deletion is successful, the function returns nil. If the deletion operation fails, the function returns an error.

func (*WarehouseService) GetWarehouseByCode

func (s *WarehouseService) GetWarehouseByCode(code string) (*models.WarehouseModel, error)

GetWarehouseByCode retrieves a warehouse record from the database by its code.

It takes a code string as input and returns a pointer to a WarehouseModel containing the warehouse details if the record is found. If the record is not found, the function returns an error.

func (*WarehouseService) GetWarehouseByID

func (s *WarehouseService) GetWarehouseByID(id string) (*models.WarehouseModel, error)

GetWarehouseByID retrieves a warehouse record from the database by its ID.

It takes an ID string as input and returns a pointer to a WarehouseModel containing the warehouse details if the record is found. If the record is not found, the function returns an error.

func (*WarehouseService) GetWarehouses

func (s *WarehouseService) GetWarehouses(request http.Request, search string) (paginate.Page, error)

GetWarehouses retrieves a paginated list of warehouses from the database.

It takes an HTTP request and a search query string as input. The search query is applied to the warehouse name, code and description fields. If the request contains a company ID header, the method also filters the result by the company ID. The function utilizes pagination to manage the result set and applies any necessary request modifications using the utils.FixRequest utility.

The function returns a paginated page of WarehouseModel and an error if the operation fails.

func (*WarehouseService) UpdateWarehouse

func (s *WarehouseService) UpdateWarehouse(id string, data *models.WarehouseModel) error

UpdateWarehouse updates an existing warehouse record in the database.

It takes an ID and a pointer to a WarehouseModel as input and returns an error if the operation fails. The function uses GORM to update the warehouse data in the warehouses table where the ID matches.

If the update is successful, the error is nil. Otherwise, the error contains information about what went wrong.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL