93 lines
4.9 KiB
Go
93 lines
4.9 KiB
Go
package contract
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type CreateCashAdvanceRequest struct {
|
|
// OutletID falls back to the caller's outlet when omitted; an advance is cash out
|
|
// of one drawer, so one of the two has to be known.
|
|
OutletID *uuid.UUID `json:"outlet_id,omitempty" validate:"omitempty"`
|
|
CodeNumber string `json:"code_number" validate:"required,min=1,max=50"`
|
|
TeamScope string `json:"team_scope" validate:"required,oneof=category central"`
|
|
TeamCategoryID *uuid.UUID `json:"team_category_id,omitempty" validate:"omitempty"`
|
|
Amount float64 `json:"amount" validate:"required,gt=0"`
|
|
IssuedDate string `json:"issued_date" validate:"required"` // Format: YYYY-MM-DD
|
|
DueDate *string `json:"due_date,omitempty" validate:"omitempty"` // Format: YYYY-MM-DD
|
|
Status *string `json:"status,omitempty" validate:"omitempty,oneof=draft approved rejected cancelled"`
|
|
Description *string `json:"description,omitempty" validate:"omitempty"`
|
|
}
|
|
|
|
type UpdateCashAdvanceRequest struct {
|
|
CodeNumber *string `json:"code_number,omitempty" validate:"omitempty,min=1,max=50"`
|
|
// An advance always belongs to a team, so team_scope can be moved but not cleared.
|
|
TeamScope *string `json:"team_scope,omitempty" validate:"omitempty,oneof=category central"`
|
|
TeamCategoryID *uuid.UUID `json:"team_category_id,omitempty" validate:"omitempty"`
|
|
Amount *float64 `json:"amount,omitempty" validate:"omitempty,gt=0"`
|
|
ReturnedAmount *float64 `json:"returned_amount,omitempty" validate:"omitempty,gte=0"`
|
|
IssuedDate *string `json:"issued_date,omitempty" validate:"omitempty"`
|
|
DueDate *string `json:"due_date,omitempty" validate:"omitempty"`
|
|
Status *string `json:"status,omitempty" validate:"omitempty,oneof=draft approved rejected cancelled"`
|
|
Description *string `json:"description,omitempty" validate:"omitempty"`
|
|
}
|
|
|
|
type CashAdvanceResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
OrganizationID uuid.UUID `json:"organization_id"`
|
|
OutletID uuid.UUID `json:"outlet_id"`
|
|
CodeNumber string `json:"code_number"`
|
|
TeamScope string `json:"team_scope"`
|
|
TeamCategoryID *uuid.UUID `json:"team_category_id"`
|
|
Amount float64 `json:"amount"`
|
|
SettledAmount float64 `json:"settled_amount"`
|
|
ReturnedAmount float64 `json:"returned_amount"`
|
|
RemainingAmount float64 `json:"remaining_amount"`
|
|
SettlementStatus string `json:"settlement_status"`
|
|
IssuedDate time.Time `json:"issued_date"`
|
|
DueDate *time.Time `json:"due_date"`
|
|
Status string `json:"status"`
|
|
Description *string `json:"description"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Team *PurchaseTeamResponse `json:"team,omitempty"`
|
|
Settlements []CashAdvanceSettlementResponse `json:"settlements,omitempty"`
|
|
}
|
|
|
|
// CashAdvanceSettlementResponse is one purchase order or expense paid out of the
|
|
// advance.
|
|
type CashAdvanceSettlementResponse struct {
|
|
Type string `json:"type"`
|
|
ID uuid.UUID `json:"id"`
|
|
Number string `json:"number"`
|
|
Date time.Time `json:"date"`
|
|
Amount float64 `json:"amount"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
type ListCashAdvancesRequest struct {
|
|
Page int `json:"page" validate:"min=1"`
|
|
Limit int `json:"limit" validate:"min=1,max=100"`
|
|
Search string `json:"search,omitempty"`
|
|
Status string `json:"status,omitempty" validate:"omitempty,oneof=draft approved rejected cancelled"`
|
|
// SettlementStatus filters on how much of the cash has been accounted for,
|
|
// which is derived from the spending charged to the advance rather than stored.
|
|
SettlementStatus string `json:"settlement_status,omitempty" validate:"omitempty,oneof=open partial settled"`
|
|
// Team is the single-value form of the two filters below, so the team picker can
|
|
// send back what it was given: a parent category id or "central" for Pusat.
|
|
Team string `json:"team,omitempty"`
|
|
TeamScope string `json:"team_scope,omitempty" validate:"omitempty,oneof=category central"`
|
|
TeamCategoryID *uuid.UUID `json:"team_category_id,omitempty"`
|
|
StartDate *time.Time `json:"start_date,omitempty"`
|
|
EndDate *time.Time `json:"end_date,omitempty"`
|
|
}
|
|
|
|
type ListCashAdvancesResponse struct {
|
|
CashAdvances []CashAdvanceResponse `json:"cash_advances"`
|
|
TotalCount int `json:"total_count"`
|
|
Page int `json:"page"`
|
|
Limit int `json:"limit"`
|
|
TotalPages int `json:"total_pages"`
|
|
}
|