mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-22 22:35:43 +00:00
add export laporang keuangan hutang ke supplier
This commit is contained in:
@@ -392,6 +392,13 @@ func (c *RepportController) GetDebtSupplier(ctx *fiber.Ctx) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if isDebtSupplierExcelExportRequest(ctx) {
|
||||
return exportDebtSupplierExcel(ctx, result)
|
||||
}
|
||||
if isDebtSupplierExcelAllExportRequest(ctx) {
|
||||
return exportDebtSupplierExcelAll(ctx, result)
|
||||
}
|
||||
|
||||
supplierIDs = query.SupplierIDs
|
||||
if supplierIDs == nil {
|
||||
supplierIDs = []int64{}
|
||||
@@ -505,6 +512,83 @@ func (c *RepportController) GetCustomerPayment(ctx *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
type BalanceMonitoringResponse struct {
|
||||
Code int `json:"code"`
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Meta response.Meta `json:"meta"`
|
||||
Data []dto.BalanceMonitoringRowDTO `json:"data"`
|
||||
Totals dto.BalanceMonitoringTotalsDTO `json:"totals"`
|
||||
}
|
||||
|
||||
func (c *RepportController) GetBalanceMonitoring(ctx *fiber.Ctx) error {
|
||||
customerIDs, err := parseUintCSV(ctx.Query("customer_ids"))
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "customer_ids must be comma separated positive integers")
|
||||
}
|
||||
salesIDs, err := parseUintCSV(ctx.Query("sales_ids"))
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "sales_ids must be comma separated positive integers")
|
||||
}
|
||||
|
||||
query := &validation.BalanceMonitoringQuery{
|
||||
Page: ctx.QueryInt("page", 1),
|
||||
Limit: ctx.QueryInt("limit", 10),
|
||||
CustomerIDs: customerIDs,
|
||||
SalesIDs: salesIDs,
|
||||
FilterBy: strings.ToLower(ctx.Query("filter_by", "")),
|
||||
SortBy: ctx.Query("sort_by", ""),
|
||||
SortOrder: ctx.Query("sort_order", ""),
|
||||
StartDate: ctx.Query("start_date", ""),
|
||||
EndDate: ctx.Query("end_date", ""),
|
||||
}
|
||||
|
||||
result, totals, totalResults, err := c.RepportService.GetBalanceMonitoring(ctx, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
limit := query.Limit
|
||||
if limit < 1 {
|
||||
limit = 10
|
||||
}
|
||||
|
||||
return ctx.Status(fiber.StatusOK).JSON(BalanceMonitoringResponse{
|
||||
Code: fiber.StatusOK,
|
||||
Status: "success",
|
||||
Message: "Get balance monitoring report successfully",
|
||||
Meta: response.Meta{
|
||||
Page: query.Page,
|
||||
Limit: limit,
|
||||
TotalPages: int64(math.Ceil(float64(totalResults) / float64(limit))),
|
||||
TotalResults: totalResults,
|
||||
},
|
||||
Data: result,
|
||||
Totals: totals,
|
||||
})
|
||||
}
|
||||
|
||||
func parseUintCSV(raw string) ([]uint, error) {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
return nil, nil
|
||||
}
|
||||
parts := strings.Split(raw, ",")
|
||||
result := make([]uint, 0, len(parts))
|
||||
for _, part := range parts {
|
||||
part = strings.TrimSpace(part)
|
||||
if part == "" {
|
||||
continue
|
||||
}
|
||||
id, err := strconv.ParseUint(part, 10, 32)
|
||||
if err != nil || id == 0 {
|
||||
return nil, fmt.Errorf("invalid id: %s", part)
|
||||
}
|
||||
result = append(result, uint(id))
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *RepportController) GetProductionResult(ctx *fiber.Ctx) error {
|
||||
idParam := ctx.Params("idProjectFlockKandang")
|
||||
if idParam == "" {
|
||||
|
||||
Reference in New Issue
Block a user