package constants // A cash advance is money handed to a team so it can go shopping. Its status is // about the document only — whether the money may leave the drawer. How much of it // has been accounted for is a separate axis, derived from the spending charged to // the advance rather than stored, so the two never have to be kept in step. const ( CashAdvanceStatusDraft = "draft" CashAdvanceStatusApproved = "approved" CashAdvanceStatusRejected = "rejected" CashAdvanceStatusCancelled = "cancelled" ) // Settlement states come out of the amount, the spending charged to the advance, and // the cash handed back. An advance the team overspent still counts as settled: the // shortfall is owed back to the team and shows up as a negative remaining amount. const ( CashAdvanceSettlementOpen = "open" CashAdvanceSettlementPartial = "partial" CashAdvanceSettlementSettled = "settled" ) func GetAllCashAdvanceStatuses() []string { return []string{ CashAdvanceStatusDraft, CashAdvanceStatusApproved, CashAdvanceStatusRejected, CashAdvanceStatusCancelled, } } func IsValidCashAdvanceStatus(status string) bool { for _, valid := range GetAllCashAdvanceStatuses() { if status == valid { return true } } return false } func GetAllCashAdvanceSettlementStatuses() []string { return []string{ CashAdvanceSettlementOpen, CashAdvanceSettlementPartial, CashAdvanceSettlementSettled, } } func IsValidCashAdvanceSettlementStatus(status string) bool { for _, valid := range GetAllCashAdvanceSettlementStatuses() { if status == valid { return true } } return false } // Settlement entries name where a piece of spending was recorded. const ( CashAdvanceSettlementTypePurchaseOrder = "purchase_order" CashAdvanceSettlementTypeExpense = "expense" )