mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'development' of https://gitlab.com/mbugroup/lti-api into feat/BE/sso-adjustment
This commit is contained in:
@@ -98,6 +98,8 @@ func (c *RepportController) GetMarketing(ctx *fiber.Ctx) error {
|
||||
ProductId: int64(ctx.QueryInt("product_id", 0)),
|
||||
WarehouseId: int64(ctx.QueryInt("warehouse_id", 0)),
|
||||
SalesPersonId: int64(ctx.QueryInt("sales_person_id", 0)),
|
||||
AreaId: int64(ctx.QueryInt("area_id", 0)),
|
||||
LocationId: int64(ctx.QueryInt("location_id", 0)),
|
||||
MarketingType: ctx.Query("marketing_type", ""),
|
||||
FilterBy: ctx.Query("filter_by", ""),
|
||||
StartDate: ctx.Query("start_date", ""),
|
||||
@@ -278,6 +280,65 @@ func (c *RepportController) GetHppPerKandang(ctx *fiber.Ctx) error {
|
||||
return ctx.Status(fiber.StatusOK).JSON(resp)
|
||||
}
|
||||
|
||||
func (c *RepportController) GetCustomerPayment(ctx *fiber.Ctx) error {
|
||||
var customerIDs []uint
|
||||
if customerIDsStr := ctx.Query("customer_ids"); customerIDsStr != "" {
|
||||
ids := strings.Split(customerIDsStr, ",")
|
||||
for _, idStr := range ids {
|
||||
idStr = strings.TrimSpace(idStr)
|
||||
if idStr != "" {
|
||||
if id, err := strconv.ParseUint(idStr, 10, 32); err == nil {
|
||||
customerIDs = append(customerIDs, uint(id))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query := &validation.CustomerPaymentQuery{
|
||||
Page: ctx.QueryInt("page", 1),
|
||||
Limit: ctx.QueryInt("limit", 10),
|
||||
CustomerIDs: customerIDs,
|
||||
StartDate: ctx.Query("start_date", ""),
|
||||
EndDate: ctx.Query("end_date", ""),
|
||||
}
|
||||
|
||||
// Validate pagination
|
||||
if len(customerIDs) == 0 && (query.Page < 1 || query.Limit < 1) {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "page and limit must be greater than 0 when customer_ids is not provided")
|
||||
}
|
||||
|
||||
result, totalResults, err := c.RepportService.GetCustomerPayment(ctx, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If single customer mode (only 1 customer ID), return without pagination
|
||||
if len(customerIDs) == 1 {
|
||||
return ctx.Status(fiber.StatusOK).
|
||||
JSON(response.Success{
|
||||
Code: fiber.StatusOK,
|
||||
Status: "success",
|
||||
Message: "Get customer payment report successfully",
|
||||
Data: result,
|
||||
})
|
||||
}
|
||||
|
||||
// Multiple customers mode with pagination
|
||||
return ctx.Status(fiber.StatusOK).
|
||||
JSON(response.SuccessWithPaginate[dto.CustomerPaymentReportItem]{
|
||||
Code: fiber.StatusOK,
|
||||
Status: "success",
|
||||
Message: "Get customer payment report successfully",
|
||||
Meta: response.Meta{
|
||||
Page: query.Page,
|
||||
Limit: query.Limit,
|
||||
TotalPages: int64(math.Ceil(float64(totalResults) / float64(query.Limit))),
|
||||
TotalResults: totalResults,
|
||||
},
|
||||
Data: result,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *RepportController) GetProductionResult(ctx *fiber.Ctx) error {
|
||||
idParam := ctx.Params("idProjectFlockKandang")
|
||||
if idParam == "" {
|
||||
|
||||
Reference in New Issue
Block a user