Documentation ¶
Index ¶
- Constants
- type Crop
- func (c *Crop) AddNewNote(content string) error
- func (c *Crop) AddPhoto(filename, mimeType string, size, width, height int, description string) error
- func (c Crop) CalculateDaysSinceSeeding() int
- func (c *Crop) ChangeContainer(quantity int, containerType CropContainerType) error
- func (c *Crop) ChangeCropStatus(cropStatus string) error
- func (c *Crop) ChangeCropType(cropType string) error
- func (c *Crop) ChangeInventory(cropService CropService, inventoryUID uuid.UUID) error
- func (c *Crop) Dump(cropService CropService, sourceAreaUID uuid.UUID, quantity int, notes string) error
- func (c *Crop) Fertilize() error
- func (c *Crop) Harvest(cropService CropService, sourceAreaUID uuid.UUID, harvestType string, ...) error
- func (c *Crop) MoveToArea(cropService CropService, sourceAreaUID uuid.UUID, destinationAreaUID uuid.UUID, ...) error
- func (c *Crop) Pesticide() error
- func (c *Crop) Prune() error
- func (c *Crop) RemoveNote(uid uuid.UUID) error
- func (state *Crop) TrackChange(event interface{})
- func (state *Crop) Transition(event interface{})
- func (c *Crop) Water(cropService CropService, sourceAreaUID uuid.UUID, wateringDate time.Time) error
- type CropBatchContainerChanged
- type CropBatchCreated
- type CropBatchDumped
- type CropBatchHarvested
- type CropBatchInventoryChanged
- type CropBatchMoved
- type CropBatchNoteCreated
- type CropBatchNoteRemoved
- type CropBatchPhotoCreated
- type CropBatchTypeChanged
- type CropBatchWatered
- type CropContainer
- type CropContainerType
- type CropError
- type CropNote
- type CropPhoto
- type CropService
- type CropStatus
- type CropType
- type HarvestType
- type HarvestedStorage
- type InitialArea
- type MovedArea
- type Pot
- type ProducedUnit
- type ServiceResult
- type Trash
- type Tray
Constants ¶
View Source
const ( CropActive = "ACTIVE" CropArchived = "ARCHIVED" )
We just recorded two crop status because other activities are recurring and parallel. So we can't have crop batch with a status, for example `HARVESTED`, because not all the crop has harvested
View Source
const ( CropTypeSeeding = "SEEDING" CropTypeGrowing = "GROWING" )
View Source
const ( HarvestTypeAll = "ALL" HarvestTypePartial = "PARTIAL" )
View Source
const ( Kg = "Kg" Gr = "Gr" )
View Source
const ( CropErrorInvalidArea = iota CropErrorInvalidCropType CropErrorInvalidCropStatus // Crop move to area errors CropMoveToAreaErrorInvalidSourceArea CropMoveToAreaErrorSourceAreaNotFound CropMoveToAreaErrorInvalidDestinationArea CropMoveToAreaErrorDestinationAreaNotFound CropMoveToAreaErrorInvalidQuantity CropMoveToAreaErrorInvalidAreaRules CropMoveToAreaErrorInvalidExistingSourceArea CropMoveToAreaErrorCannotBeSame CropMoveToAreaErrorInvalidExistingArea // Crop harvest errors CropHarvestErrorInvalidSourceArea CropHarvestErrorSourceAreaNotFound CropHarvestErrorInvalidQuantity CropHarvestErrorNotEnoughQuantity CropHarvestErrorInvalidHarvestType // Crop dump errors CropDumpErrorInvalidSourceArea CropDumpErrorSourceAreaNotFound CropDumpErrorInvalidQuantity CropDumpErrorNotEnoughQuantity // Crop water errors CropWaterErrorInvalidWateringDate CropWaterErrorInvalidSourceArea CropWaterErrorSourceAreaNotFound // Crop Batch ID errors CropErrorInvalidBatchID CropErrorBatchIDAlreadyCreated // Crop Photo errros CropErrorPhotoInvalidFilename CropErrorPhotoInvalidMimeType CropErrorPhotoInvalidSize CropErrorPhotoInvalidDescription CropContainerErrorInvalidType CropContainerErrorInvalidQuantity CropContainerErrorInvalidTrayCell CropContainerErrorCropHasBeenMoved CropMaterialErrorInvalidMaterial CropMaterialErrorNotFound CropNoteErrorInvalidContent CropNoteErrorNotFound )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Crop ¶
type Crop struct { UID uuid.UUID BatchID string Status CropStatus Type CropType Container CropContainer InventoryUID uuid.UUID FarmUID uuid.UUID Photos []CropPhoto // Fields to track crop's movement InitialArea InitialArea MovedArea []MovedArea HarvestedStorage []HarvestedStorage Trash []Trash // Fields to track care crop LastFertilized time.Time LastPruned time.Time LastPesticided time.Time // Notes Notes map[uuid.UUID]CropNote // Events Version int UncommittedChanges []interface{} }
func CreateCropBatch ¶
func CreateCropBatch( cropService CropService, areaUID uuid.UUID, cropType string, inventoryUID uuid.UUID, quantity int, containerType CropContainerType) (*Crop, error)
func (*Crop) AddNewNote ¶
func (Crop) CalculateDaysSinceSeeding ¶
CalculateDaysSinceSeeding will find how long since its been seeded It basically tell use the days since this crop is created.
func (*Crop) ChangeContainer ¶
func (c *Crop) ChangeContainer(quantity int, containerType CropContainerType) error
func (*Crop) ChangeCropStatus ¶
func (*Crop) ChangeCropType ¶
func (*Crop) ChangeInventory ¶
func (c *Crop) ChangeInventory(cropService CropService, inventoryUID uuid.UUID) error
func (*Crop) Harvest ¶
func (c *Crop) Harvest( cropService CropService, sourceAreaUID uuid.UUID, harvestType string, producedQuantity float32, producedUnit ProducedUnit, notes string) error
func (*Crop) MoveToArea ¶
func (*Crop) TrackChange ¶
func (state *Crop) TrackChange(event interface{})
func (*Crop) Transition ¶
func (state *Crop) Transition(event interface{})
type CropBatchContainerChanged ¶
type CropBatchContainerChanged struct { UID uuid.UUID Container CropContainer }
type CropBatchCreated ¶
type CropBatchDumped ¶
type CropBatchHarvested ¶
type CropBatchHarvested struct { UID uuid.UUID CropStatus string // Values: ACTIVE / ARCHIVED HarvestType string HarvestedQuantity int ProducedGramQuantity float32 UpdatedHarvestedStorage HarvestedStorage HarvestedArea interface{} HarvestedAreaCode string // Values: INITIAL_AREA / MOVED_AREA HarvestDate time.Time Notes string }
type CropBatchMoved ¶
type CropBatchNoteCreated ¶
type CropBatchNoteRemoved ¶
type CropBatchPhotoCreated ¶
type CropBatchTypeChanged ¶
type CropBatchWatered ¶
type CropContainer ¶
type CropContainer struct { Quantity int Type CropContainerType }
type CropContainerType ¶
type CropContainerType interface {
Code() string
}
CropContainerType defines the type of a container
type CropError ¶
type CropError struct {
Code int
}
CropError is a custom error from Go built-in error
type CropService ¶
type CropService interface { FindMaterialByID(uid uuid.UUID) ServiceResult FindByBatchID(batchID string) ServiceResult FindAreaByID(uid uuid.UUID) ServiceResult }
CropService handles crop behaviours that needs external interaction to be worked
type CropStatus ¶
func CropStatuses ¶
func CropStatuses() []CropStatus
func GetCropStatus ¶
func GetCropStatus(code string) CropStatus
type CropType ¶
func GetCropType ¶
type HarvestType ¶
func GetHarvestType ¶
func GetHarvestType(code string) HarvestType
func HarvestTypes ¶
func HarvestTypes() []HarvestType
type HarvestedStorage ¶
type InitialArea ¶
type InitialArea struct { AreaUID uuid.UUID `json:"area_id"` InitialQuantity int `json:"initial_quantity"` CurrentQuantity int `json:"current_quantity"` CreatedDate time.Time `json:"created_date"` LastUpdated time.Time `json:"last_updated"` LastWatered time.Time `json:"last_watered"` LastFertilized time.Time `json:"last_fertilized"` LastPruned time.Time `json:"last_pruned"` LastPesticided time.Time `json:"last_pesticided"` }
type MovedArea ¶
type MovedArea struct { AreaUID uuid.UUID `json:"area_id"` SourceAreaUID uuid.UUID `json:"source_area_id"` InitialQuantity int `json:"initial_quantity"` CurrentQuantity int `json:"current_quantity"` CreatedDate time.Time `json:"created_date"` LastUpdated time.Time `json:"last_updated"` LastWatered time.Time `json:"last_watered"` LastFertilized time.Time `json:"last_fertilized"` LastPruned time.Time `json:"last_pruned"` LastPesticided time.Time `json:"last_pesticided"` }
type ProducedUnit ¶
func GetProducedUnit ¶
func GetProducedUnit(code string) ProducedUnit
func ProducedUnits ¶
func ProducedUnits() []ProducedUnit
type ServiceResult ¶
type ServiceResult struct { Result interface{} Error error }
ServiceResult is the container for service result
Click to show internal directories.
Click to hide internal directories.