Documentation
¶
Overview ¶
Copyright © 2019 zhijie wang
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and
Copyright © 2019 zhijie wang ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- type Inventory
- func (db *Inventory) AddItem(pCode string, cost float32, status ItemStatus) error
- func (db *Inventory) AddItems(pCode string, cost float32, num int) error
- func (db *Inventory) AddProduct(pName string, code string) error
- func (db *Inventory) CostOfGoodsSold(month time.Time) int
- func (db *Inventory) ListInventory(pCode string) *[]Item
- func (db *Inventory) ListProduct() *[]Product
- func (db *Inventory) ShipItem(pCode string, date time.Time) error
- func (db *Inventory) ShipItems(pCode string, number int, date time.Time) error
- type Item
- type ItemStatus
- type Product
Constants ¶
const ( Available ItemStatus = 1 Reserved = 2 Shipped = 3 Lost = 4 )
Available means the item is in inventory, can be sold Reserved means the item is marked for an order. If the order is canceld, the item becomes available again. If the item is shipped, the item becomes shipped. Shipped means the item is shipped and the order is fullfiled. This marks the item can now be consider as part of cost of goods sold. Lost means the item is either damaged or no longer possible for sale. This can be added to either cost of goods sold or to expense for write off.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Inventory ¶
func OpenInventory ¶
func (*Inventory) AddItem ¶
func (db *Inventory) AddItem(pCode string, cost float32, status ItemStatus) error
AddItem function performs the operation adding the Item instance to the database. If there is any issue, the operation will throw an error. The argument db points to a db connection, the argument pCode points to a productCode, should be randomly generated, either UUID or user defined, the status argument is the enumeration represent item status.
func (*Inventory) AddItems ¶
AddItems add many items to that of same product code to the database, the serial number is generated automatically. This operation does not check whether the item is already in the database or not. This operation implies bulk intake of product, thus all item status will set to default Availabel
func (*Inventory) ListInventory ¶
func (*Inventory) ListProduct ¶
type Item ¶
type Item struct {
gorm.Model
Status ItemStatus `gorm:"not null;default:0"`
ProductCode string `gorm:"not null"`
UnitCost float32
ShippedDate time.Time
}
Item represent each individual goods to be sold, assume discrete and concrete item.
type ItemStatus ¶
type ItemStatus int
ItemStatus denotes the current status of the individual item. Default to 0, denoting the item is available.
func (*ItemStatus) Scan ¶
func (u *ItemStatus) Scan(value interface{}) error