Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
development to staging (#126)
Browse files Browse the repository at this point in the history
Development to staging
  • Loading branch information
AriefLazuardi authored Dec 18, 2023
2 parents 89ff044 + ec8be24 commit 2897b47
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
20 changes: 18 additions & 2 deletions handler/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type TransactionHandler interface {
GetRecentTransactionsRealtimeHandler(ctx echo.Context) error
GetTransactionHandler(ctx echo.Context) error
GetTransactionsHandler(ctx echo.Context) error
PrintReceiptTransactionHandler(ctx echo.Context) error
GetRecentTransactionsHandler(ctx echo.Context) error
GetTransactionMonthlyHandler(ctx echo.Context) error
GetTransactionYearlyHandler(ctx echo.Context) error
Expand Down Expand Up @@ -119,6 +120,21 @@ func (c *TransactionHandlerImpl) GetTransactionHandler(ctx echo.Context) error {
return ctx.JSON(http.StatusOK, helpers.SuccessResponse("Successfully Get Data Transaction", response))
}

func (c *TransactionHandlerImpl) PrintReceiptTransactionHandler(ctx echo.Context) error {
transactionInvoice := ctx.Param("invoice")
result, err := c.TransactionService.FindByInvoice(transactionInvoice)
if err != nil {
if strings.Contains(err.Error(), "transaction not found") {
return ctx.JSON(http.StatusNotFound, helpers.ErrorResponse("transaction not found"))
}
logrus.Error(err.Error())
return ctx.JSON(http.StatusInternalServerError, helpers.ErrorResponse("Get transaction data error"))
}
response := res.TransactionDomainToTransactionResponse(result)

return ctx.JSON(http.StatusOK, helpers.SuccessResponse("Successfully Get Data Transaction", response))
}

func (c *TransactionHandlerImpl) GetTransactionsHandler(ctx echo.Context) error {
transactions, totalTransactions, err := c.TransactionService.FindAllTransaction()
if err != nil {
Expand Down Expand Up @@ -190,11 +206,11 @@ func (c *TransactionHandlerImpl) GetRecentTransactionsHandler(ctx echo.Context)
return ctx.JSON(http.StatusNotFound, helpers.ErrorResponse("transaction not found"))
}
logrus.Error(err.Error())
return ctx.JSON(http.StatusInternalServerError, helpers.ErrorResponse("Get all transaction error"))
return ctx.JSON(http.StatusInternalServerError, helpers.ErrorResponse("Get Recent transaction error"))
}
response := res.ConvertTransactionResponse(transactions)

return ctx.JSON(http.StatusOK, helpers.SuccessResponse("Successfully Get Data Transaction", response))
return ctx.JSON(http.StatusOK, helpers.SuccessResponse("Successfully Get Data Recent Transaction", response))

}

Expand Down
3 changes: 2 additions & 1 deletion repository/productRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ func (repository *ProductRepositoryImpl) FindBestSellingProduct() ([]domain.Best
GROUP BY
p.id, p.name, p.image, pd.price, pt.type_name, pd.size
ORDER BY
total_quantity DESC;
total_quantity DESC
LIMIT 3;
`
result := repository.DB.Raw(query).Preload("ProductDetail", "deleted_at IS NULL").Scan(&bestProduct)
if result.Error != nil {
Expand Down
1 change: 1 addition & 0 deletions routes/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TransactionRoutes(e *echo.Echo, db *gorm.DB, midtransCoreApi midtrans.Midtr
transactionGroup.GET("s/cashier", transactionHandler.GetCashierTransactionsHandler, middleware.AuthMiddleware("Cashier"))
transactionGroup.GET("s/membership/:id", transactionHandler.GetMembershipTransactionsHandler, middleware.AuthMiddleware("Cashier"))
transactionGroup.GET("/:id", transactionHandler.GetTransactionHandler)
transactionGroup.GET("/receipt/:invoice", transactionHandler.PrintReceiptTransactionHandler)
transactionGroup.GET("/realtime", transactionHandler.GetTransactionStatusRealtime)
transactionGroup.GET("s/recent/realtime", transactionHandler.GetRecentTransactionsRealtimeHandler)
transactionGroup.GET("s", transactionHandler.GetTransactionsHandler)
Expand Down
4 changes: 2 additions & 2 deletions utils/response/transactionConvertResponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TransactionDomainToTransactionResponse(transaction *domain.Transaction) *we
updatedAt := transaction.UpdatedAt
response := &web.TransactionResponse{
ID: transaction.ID,
CreatedAt: createdAt.Format("2006-01-02 15:04:05"),
CreatedAt: createdAt.Format("2006-January-02 15:04:05"),
UpdatedAt: updatedAt.Format("2006-01-02 15:04:05"),
Cashier: web.CashierTransactionResponse{
ID: transaction.Cashier.ID,
Expand Down Expand Up @@ -105,7 +105,7 @@ func TransactionDomainToTransactionResponseNoMembership(transaction *domain.Tran
createdAt := transaction.CreatedAt
response := &web.TransactionResponse{
ID: transaction.ID,
CreatedAt: createdAt.Format("2006-01-02 15:04:05"),
CreatedAt: createdAt.Format("2006-January-02 15:04:05"),
Cashier: web.CashierTransactionResponse{
ID: transaction.Cashier.ID,
Fullname: transaction.Cashier.Fullname,
Expand Down

0 comments on commit 2897b47

Please sign in to comment.