Documentation ¶
Overview ¶
Package domain provides the operation that farm holder can do to their farm
Index ¶
- Constants
- func GetCurrencyCode(currencyCode string) (string, error)
- type Area
- func (a *Area) AddNewNote(content string) error
- func (a *Area) ChangeLocation(locationCode string) error
- func (a *Area) ChangeName(name string) error
- func (a *Area) ChangePhoto(photo AreaPhoto) error
- func (a *Area) ChangeReservoir(reservoirUID uuid.UUID) error
- func (a *Area) ChangeSize(size AreaSize) error
- func (a *Area) ChangeType(areaService AreaService, areaType string) error
- func (a *Area) RemoveNote(uid uuid.UUID) error
- func (a *Area) TrackChange(event interface{})
- func (a *Area) Transition(event interface{})
- type AreaCreated
- type AreaError
- type AreaFarmServiceResult
- type AreaLocation
- type AreaLocationChanged
- type AreaNameChanged
- type AreaNote
- type AreaNoteAdded
- type AreaNoteRemoved
- type AreaPhoto
- type AreaPhotoAdded
- type AreaReservoirChanged
- type AreaReservoirServiceResult
- type AreaService
- type AreaSize
- type AreaSizeChanged
- type AreaType
- type AreaTypeChanged
- type AreaUnit
- type Bucket
- type ChemicalType
- type ContainerType
- type Farm
- func (f *Farm) ChangeGeoLocation(latitude, longitude string) error
- func (f *Farm) ChangeName(name string) error
- func (f *Farm) ChangeRegion(country, city string) error
- func (f *Farm) ChangeType(farmType string) error
- func (f *Farm) TrackChange(event interface{})
- func (f *Farm) Transition(event interface{})
- type FarmCountry
- type FarmCreated
- type FarmError
- type FarmGeolocationChanged
- type FarmNameChanged
- type FarmRegionChanged
- type FarmService
- type FarmType
- type FarmTypeChanged
- type InventoryMaterialError
- type Material
- func (m *Material) ChangeExpirationDate(expDate time.Time) error
- func (m *Material) ChangeName(name string) error
- func (m *Material) ChangeNotes(notes string) error
- func (m *Material) ChangePricePerUnit(price, priceUnit string) error
- func (m *Material) ChangeProducedBy(producedBy string) error
- func (m *Material) ChangeQuantityUnit(quantity float32, quantityUnit string, materialType MaterialType) error
- func (m *Material) ChangeType(materialType MaterialType) error
- func (m *Material) TrackChange(event interface{})
- func (m *Material) Transition(event interface{})
- type MaterialCreated
- type MaterialError
- type MaterialExpirationDateChanged
- type MaterialNameChanged
- type MaterialNotesChanged
- type MaterialPriceChanged
- type MaterialProducedByChanged
- type MaterialQuantity
- type MaterialQuantityChanged
- type MaterialQuantityUnit
- type MaterialType
- type MaterialTypeAgrochemical
- type MaterialTypeChanged
- type MaterialTypeGrowingMedium
- type MaterialTypeLabelAndCropSupport
- type MaterialTypeOther
- type MaterialTypePlant
- type MaterialTypePostHarvestSupply
- type MaterialTypeSeed
- type MaterialTypeSeedingContainer
- type PlantType
- type PricePerUnit
- type Reservoir
- func (r *Reservoir) AddNewNote(content string) error
- func (r *Reservoir) ChangeName(name string) error
- func (r *Reservoir) ChangeWaterSource(waterSourceType string, capacity float32) error
- func (r *Reservoir) RemoveNote(uid uuid.UUID) error
- func (r *Reservoir) TrackChange(event interface{})
- func (r *Reservoir) Transition(event interface{})
- type ReservoirCreated
- type ReservoirError
- type ReservoirFarmServiceResult
- type ReservoirNameChanged
- type ReservoirNote
- type ReservoirNoteAdded
- type ReservoirNoteRemoved
- type ReservoirService
- type ReservoirWaterSourceChanged
- type Tap
- type WaterSource
Constants ¶
const ( AreaTypeSeeding = "SEEDING" AreaTypeGrowing = "GROWING" )
const ( AreaLocationOutdoor = "OUTDOOR" AreaLocationIndoor = "INDOOR" )
const ( SquareMeter = "m2" Hectare = "Ha" )
const ( AreaErrorNameEmptyCode = iota AreaErrorNameNotEnoughCharacterCode AreaErrorNameExceedMaximunCharacterCode AreaErrorNameAlphanumericOnlyCode AreaErrorFarmNotFound AreaErrorReservoirNotFound AreaErrorSizeEmptyCode AreaErrorInvalidSizeUnitCode AreaErrorTypeEmptyCode AreaErrorInvalidAreaTypeCode AreaErrorCropAlreadyCreated AreaErrorLocationEmptyCode AreaErrorInvalidAreaLocationCode AreaNoteErrorInvalidContent AreaNoteErrorInvalidID AreaNoteErrorNotFound )
const ( FarmErrorInvalidFarmTypeCode = iota FarmErrorReservoirAlreadyAdded FarmErrorReservoirNotFound FarmErrorAreaAlreadyAdded FarmErrorAreaNotFound FarmErrorNameEmptyCode FarmErrorNameNotEnoughCharacterCode FarmErrorNameExceedMaximunCharacterCode FarmErrorNameAlphanumericOnlyCode FarmErrorInvalidLatitudeValueCode FarmErrorInvalidLongitudeValueCode FarmErrorInvalidCountry FarmErrorInvalidCity )
const ( FarmTypeOrganic = "organic" FarmTypeHydroponic = "hydroponic" FarmTypeAquaponic = "aquaponic" FarmTypeMushroom = "mushroom" FarmTypeLiveStock = "livestock" FarmTypeFisheries = "fisheries" FarmTypePermaculture = "permaculture" )
const ( InventoryMaterialInvalidPlantType = iota InventoryMaterialInvalidVariety InventoryMaterialErrorWrongType )
const ( MoneyEUR = "EUR" MoneyIDR = "IDR" )
const ( MaterialUnitSeeds = "SEEDS" MaterialUnitPackets = "PACKETS" MaterialUnitGram = "GRAM" MaterialUnitKilogram = "KILOGRAM" MaterialUnitBags = "BAGS" MaterialUnitBottles = "BOTTLES" MaterialUnitCubicMetre = "CUBIC_METRE" MaterialUnitPieces = "PIECES" MaterialUnitUnits = "UNITS" )
const ( MaterialTypeSeedCode = "SEED" MaterialTypePlantCode = "PLANT" MaterialTypeGrowingMediumCode = "GROWING_MEDIUM" MaterialTypeAgrochemicalCode = "AGROCHEMICAL" MaterialTypeLabelAndCropSupportCode = "LABEL_AND_CROP_SUPPORT" MaterialTypeSeedingContainerCode = "SEEDING_CONTAINER" MaterialTypePostHarvestSupplyCode = "POST_HARVEST_SUPPLY" MaterialTypeOtherCode = "OTHER" )
const ( PlantTypeVegetable = "VEGETABLE" PlantTypeFruit = "FRUIT" PlantTypeHerb = "HERB" PlantTypeFlower = "FLOWER" PlantTypeTree = "TREE" )
const ( ChemicalTypeDisinfectant = "DISINFECTANT" ChemicalTypeFertilizer = "FERTILIZER" ChemicalTypeHormone = "HORMONE" ChemicalTypeManure = "MANURE" ChemicalTypePesticide = "PESTICIDE" )
const ( ContainerTypeTray = "TRAY" ContainerTypePot = "POT" )
const ( BucketType = "BUCKET" TapType = "TAP" )
const ( ReservoirErrorNameEmptyCode = iota ReservoirErrorNameNotEnoughCharacterCode ReservoirErrorNameExceedMaximunCharacterCode ReservoirErrorNameAlphanumericOnlyCode ReservoirErrorFarmNotFound ReservoirErrorPHInvalidCode ReservoirErrorECInvalidCode ReservoirErrorBucketCapacityInvalidCode ReservoirErrorBucketVolumeInvalidCode ReservoirErrorWaterSourceAlreadyAttachedCode ReservoirNoteErrorInvalidContent ReservoirNoteErrorNotFound )
const (
MaterialErrorInvalidMaterialType = iota
)
Variables ¶
This section is empty.
Functions ¶
func GetCurrencyCode ¶
Types ¶
type Area ¶
type Area struct { UID uuid.UUID `json:"uid"` Name string `json:"name"` Size AreaSize `json:"size"` Type AreaType `json:"type"` Location AreaLocation `json:"location"` Photo AreaPhoto `json:"photo"` CreatedDate time.Time `json:"created_date"` Notes map[uuid.UUID]AreaNote `json:"-"` ReservoirUID uuid.UUID `json:"-"` FarmUID uuid.UUID `json:"-"` // Events Version int UncommittedChanges []interface{} }
func CreateArea ¶
func CreateArea( areaService AreaService, farmUID uuid.UUID, reservoirUID uuid.UUID, name string, areaType string, size AreaSize, locationCode string) (*Area, error, )
CreateArea registers a new area to a farm.
func (*Area) AddNewNote ¶
func (*Area) ChangeLocation ¶
ChangeLocation changes an area location.
func (*Area) ChangeName ¶
func (*Area) ChangePhoto ¶
TODO: Do file type validation here.
func (*Area) ChangeSize ¶
ChangeSize changes an area size.
func (*Area) ChangeType ¶
func (a *Area) ChangeType(areaService AreaService, areaType string) error
func (*Area) TrackChange ¶
func (a *Area) TrackChange(event interface{})
func (*Area) Transition ¶
func (a *Area) Transition(event interface{})
type AreaCreated ¶
type AreaError ¶
type AreaError struct {
Code int
}
AreaError is a custom error from Go built-in error
type AreaFarmServiceResult ¶
type AreaLocation ¶
func AreaLocations ¶
func AreaLocations() []AreaLocation
func GetAreaLocation ¶
func GetAreaLocation(code string) AreaLocation
type AreaLocationChanged ¶
type AreaLocationChanged struct { AreaUID uuid.UUID Location AreaLocation }
type AreaNameChanged ¶
type AreaNoteAdded ¶
type AreaPhotoAdded ¶
type AreaReservoirChanged ¶
type AreaService ¶
type AreaSizeChanged ¶
type AreaType ¶
func GetAreaType ¶
type AreaTypeChanged ¶
type AreaUnit ¶
func GetAreaUnit ¶
type Bucket ¶
type Bucket struct {
Capacity float32
}
Bucket is value object attached to the Reservoir.waterSource.
func CreateBucket ¶
CreateBucket registers a new Bucket.
type ChemicalType ¶
func ChemicalTypes ¶
func ChemicalTypes() []ChemicalType
func GetChemicalType ¶
func GetChemicalType(code string) ChemicalType
type ContainerType ¶
func ContainerTypes ¶
func ContainerTypes() []ContainerType
func GetContainerType ¶
func GetContainerType(code string) ContainerType
type Farm ¶
type Farm struct { UID uuid.UUID `json:"uid"` Name string `json:"name"` Latitude string `json:"latitude"` Longitude string `json:"longitude"` Type string `json:"type"` Country string `json:"country"` City string `json:"city"` IsActive bool `json:"is_active"` CreatedDate time.Time `json:"created_date"` // Events Version int UncommittedChanges []interface{} }
func CreateFarm ¶
CreateFarm registers a new farm to Tania
func (*Farm) ChangeGeoLocation ¶
ChangeGeoLocation changes the geolocation of a farm
func (*Farm) ChangeName ¶
func (*Farm) ChangeRegion ¶
ChangeRegion changes country and city of a farm
func (*Farm) ChangeType ¶
func (*Farm) TrackChange ¶
func (f *Farm) TrackChange(event interface{})
func (*Farm) Transition ¶
func (f *Farm) Transition(event interface{})
type FarmCountry ¶
type FarmCreated ¶
type FarmError ¶
type FarmError struct {
Code int
}
FarmError is a custom error from Go built-in error
type FarmGeolocationChanged ¶
type FarmNameChanged ¶
type FarmRegionChanged ¶
type FarmService ¶
type FarmService interface {
GetCountryNameByCode() string
}
type FarmType ¶
func FindAllFarmTypes ¶
func FindAllFarmTypes() []FarmType
func FindFarmTypeByCode ¶
type FarmTypeChanged ¶
type InventoryMaterialError ¶
type InventoryMaterialError struct {
Code int
}
InventoryMaterialError is a custom error from Go built-in error
func (InventoryMaterialError) Error ¶
func (e InventoryMaterialError) Error() string
type Material ¶
type Material struct { UID uuid.UUID `json:"uid"` Name string `json:"name"` PricePerUnit PricePerUnit `json:"price_per_unit"` Type MaterialType `json:"type"` Quantity MaterialQuantity `json:"quantity"` ExpirationDate *time.Time `json:"expiration_date"` Notes *string `json:"notes"` ProducedBy *string `json:"produced_by"` CreatedDate time.Time `json:"created_date"` // Events Version int UncommittedChanges []interface{} }
func CreateMaterial ¶
func (*Material) ChangeExpirationDate ¶
func (*Material) ChangeName ¶
func (*Material) ChangeNotes ¶
func (*Material) ChangePricePerUnit ¶
func (*Material) ChangeProducedBy ¶
func (*Material) ChangeQuantityUnit ¶
func (m *Material) ChangeQuantityUnit(quantity float32, quantityUnit string, materialType MaterialType) error
func (*Material) ChangeType ¶
func (m *Material) ChangeType(materialType MaterialType) error
func (*Material) TrackChange ¶
func (m *Material) TrackChange(event interface{})
func (*Material) Transition ¶
func (m *Material) Transition(event interface{})
type MaterialCreated ¶
type MaterialCreated struct { UID uuid.UUID Name string PricePerUnit PricePerUnit Type MaterialType Quantity MaterialQuantity ExpirationDate *time.Time Notes *string ProducedBy *string CreatedDate time.Time }
type MaterialError ¶
type MaterialError struct {
Code int
}
MaterialError is a custom error from Go built-in error
func (MaterialError) Error ¶
func (e MaterialError) Error() string
type MaterialNameChanged ¶
type MaterialNotesChanged ¶
type MaterialPriceChanged ¶
type MaterialPriceChanged struct { MaterialUID uuid.UUID Price PricePerUnit }
type MaterialQuantity ¶
type MaterialQuantity struct { Value float32 `json:"value"` Unit MaterialQuantityUnit `json:"unit"` }
type MaterialQuantityChanged ¶
type MaterialQuantityChanged struct { MaterialUID uuid.UUID MaterialTypeCode string Quantity MaterialQuantity }
type MaterialQuantityUnit ¶
func GetMaterialQuantityUnit ¶
func GetMaterialQuantityUnit(materialTypeCode string, code string) MaterialQuantityUnit
func MaterialQuantityUnits ¶
func MaterialQuantityUnits(materialTypeCode string) []MaterialQuantityUnit
type MaterialType ¶
type MaterialType interface {
Code() string
}
type MaterialTypeAgrochemical ¶
type MaterialTypeAgrochemical struct {
ChemicalType ChemicalType
}
func CreateMaterialTypeAgrochemical ¶
func CreateMaterialTypeAgrochemical(chemicalType string) (MaterialTypeAgrochemical, error)
func (MaterialTypeAgrochemical) Code ¶
func (mt MaterialTypeAgrochemical) Code() string
type MaterialTypeChanged ¶
type MaterialTypeChanged struct { MaterialUID uuid.UUID MaterialType MaterialType }
type MaterialTypeGrowingMedium ¶
type MaterialTypeGrowingMedium struct{}
func (MaterialTypeGrowingMedium) Code ¶
func (mt MaterialTypeGrowingMedium) Code() string
type MaterialTypeLabelAndCropSupport ¶
type MaterialTypeLabelAndCropSupport struct{}
func (MaterialTypeLabelAndCropSupport) Code ¶
func (mt MaterialTypeLabelAndCropSupport) Code() string
type MaterialTypeOther ¶
type MaterialTypeOther struct{}
func (MaterialTypeOther) Code ¶
func (mt MaterialTypeOther) Code() string
type MaterialTypePlant ¶
type MaterialTypePlant struct {
PlantType PlantType
}
func CreateMaterialTypePlant ¶
func CreateMaterialTypePlant(plantType string) (MaterialTypePlant, error)
func (MaterialTypePlant) Code ¶
func (mt MaterialTypePlant) Code() string
type MaterialTypePostHarvestSupply ¶
type MaterialTypePostHarvestSupply struct{}
func (MaterialTypePostHarvestSupply) Code ¶
func (mt MaterialTypePostHarvestSupply) Code() string
type MaterialTypeSeed ¶
type MaterialTypeSeed struct {
PlantType PlantType
}
func CreateMaterialTypeSeed ¶
func CreateMaterialTypeSeed(plantType string) (MaterialTypeSeed, error)
func (MaterialTypeSeed) Code ¶
func (mt MaterialTypeSeed) Code() string
type MaterialTypeSeedingContainer ¶
type MaterialTypeSeedingContainer struct {
ContainerType ContainerType
}
func CreateMaterialTypeSeedingContainer ¶
func CreateMaterialTypeSeedingContainer(containerType string) (MaterialTypeSeedingContainer, error)
func (MaterialTypeSeedingContainer) Code ¶
func (mt MaterialTypeSeedingContainer) Code() string
type PricePerUnit ¶
func CreatePricePerUnit ¶
func CreatePricePerUnit(amount, currencyCode string) (PricePerUnit, error)
func (PricePerUnit) Symbol ¶
func (p PricePerUnit) Symbol() string
type Reservoir ¶
type Reservoir struct { UID uuid.UUID Name string WaterSource WaterSource FarmUID uuid.UUID Notes map[uuid.UUID]ReservoirNote CreatedDate time.Time // Events Version int UncommittedChanges []interface{} }
Reservoir is entity that provides the operation that farm owner or his/her staff can do with the reservoir in a farm.
func CreateReservoir ¶
func CreateReservoir(rs ReservoirService, farmUID uuid.UUID, name, waterSourceType string, capacity float32) (*Reservoir, error)
CreateReservoir registers a new Reservoir.
func (*Reservoir) AddNewNote ¶
func (*Reservoir) ChangeName ¶
ChangeName is used to change Reservoir Name.
func (*Reservoir) ChangeWaterSource ¶
func (*Reservoir) TrackChange ¶
func (r *Reservoir) TrackChange(event interface{})
func (*Reservoir) Transition ¶
func (r *Reservoir) Transition(event interface{})
type ReservoirCreated ¶
type ReservoirError ¶
type ReservoirError struct {
Code int
}
ReservoirError is a custom error from Go built-in error
func (ReservoirError) Error ¶
func (e ReservoirError) Error() string
type ReservoirNameChanged ¶
type ReservoirNote ¶
type ReservoirNoteAdded ¶
type ReservoirNoteRemoved ¶
type ReservoirService ¶
type ReservoirService interface {
FindFarmByID(farmUID uuid.UUID) (ReservoirFarmServiceResult, error)
}
type ReservoirWaterSourceChanged ¶
type ReservoirWaterSourceChanged struct { ReservoirUID uuid.UUID WaterSource WaterSource }
type WaterSource ¶
type WaterSource interface {
Type() string
}