Update Product List

This commit is contained in:
aditya.siregar 2024-08-22 03:07:40 +07:00
parent 67d3529980
commit 031c36897f
2 changed files with 17 additions and 1 deletions

View File

@ -80,10 +80,26 @@ func (e *ProductDB) ToProduct() *Product {
func (b *ProductList) ToProductList() []*Product {
var Products []*Product
for _, p := range *b {
if p.Status == "Available" {
Products = append(Products, p.ToProduct())
}
}
return Products
}
func (b *ProductList) ToProductListPOS() []*Product {
var Products []*Product
today := time.Now().Weekday()
isWeekend := today == time.Saturday || today == time.Sunday
for _, p := range *b {
if p.Status != "Available" {
continue
}
if isWeekend && p.IsWeekendTicket {
Products = append(Products, p.ToProduct())
} else {

View File

@ -77,7 +77,7 @@ func (s *ProductService) GetProductPOS(ctx context.Context, search entity.Produc
return nil, err
}
return products.ToProductList(), nil
return products.ToProductListPOS(), nil
}
func (s *ProductService) Delete(ctx mycontext.Context, id int64) error {