mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
feat: refactor module adjusment stock, adjust constant, adjust table migration and create command reflow and delete module adjusment stock
This commit is contained in:
@@ -198,6 +198,136 @@ const (
|
||||
TransactionTypeSaldoAwal TransactionType = "SALDO_AWAL"
|
||||
)
|
||||
|
||||
type AdjustmentTransactionType string
|
||||
|
||||
const (
|
||||
AdjustmentTransactionTypePembelian AdjustmentTransactionType = "PEMBELIAN"
|
||||
AdjustmentTransactionTypeRecording AdjustmentTransactionType = "RECORDING"
|
||||
AdjustmentTransactionTypePenjualan AdjustmentTransactionType = "PENJUALAN"
|
||||
)
|
||||
|
||||
type AdjustmentTransactionSubtype string
|
||||
|
||||
const (
|
||||
AdjustmentTransactionSubtypePurchaseIn AdjustmentTransactionSubtype = "PURCHASE_IN"
|
||||
AdjustmentTransactionSubtypeRecordingDepletionOut AdjustmentTransactionSubtype = "RECORDING_DEPLETION_OUT"
|
||||
AdjustmentTransactionSubtypeMarketingOut AdjustmentTransactionSubtype = "MARKETING_OUT"
|
||||
AdjustmentTransactionSubtypeRecordingDepletionIn AdjustmentTransactionSubtype = "RECORDING_DEPLETION_IN"
|
||||
AdjustmentTransactionSubtypeRecordingStockOut AdjustmentTransactionSubtype = "RECORDING_STOCK_OUT"
|
||||
AdjustmentTransactionSubtypeRecordingEggIn AdjustmentTransactionSubtype = "RECORDING_EGG_IN"
|
||||
)
|
||||
|
||||
var adjustmentSubtypesByType = map[AdjustmentTransactionType][]string{
|
||||
AdjustmentTransactionTypePembelian: {
|
||||
string(AdjustmentTransactionSubtypePurchaseIn),
|
||||
},
|
||||
AdjustmentTransactionTypeRecording: {
|
||||
string(AdjustmentTransactionSubtypeRecordingStockOut),
|
||||
string(AdjustmentTransactionSubtypeRecordingDepletionOut),
|
||||
string(AdjustmentTransactionSubtypeRecordingDepletionIn),
|
||||
string(AdjustmentTransactionSubtypeRecordingEggIn),
|
||||
},
|
||||
AdjustmentTransactionTypePenjualan: {
|
||||
string(AdjustmentTransactionSubtypeMarketingOut),
|
||||
},
|
||||
}
|
||||
|
||||
var hiddenAdjustmentSubtypesForFrontend = map[string]struct{}{
|
||||
string(AdjustmentTransactionSubtypeRecordingDepletionIn): {},
|
||||
}
|
||||
|
||||
var adjustmentSubtypeToType = func() map[string]AdjustmentTransactionType {
|
||||
out := make(map[string]AdjustmentTransactionType)
|
||||
for txType, subtypes := range adjustmentSubtypesByType {
|
||||
for _, subtype := range subtypes {
|
||||
code := strings.ToUpper(strings.TrimSpace(subtype))
|
||||
if code == "" {
|
||||
continue
|
||||
}
|
||||
out[code] = txType
|
||||
}
|
||||
}
|
||||
return out
|
||||
}()
|
||||
|
||||
func AdjustmentTransactionTypes() []string {
|
||||
return []string{
|
||||
string(AdjustmentTransactionTypePembelian),
|
||||
string(AdjustmentTransactionTypeRecording),
|
||||
string(AdjustmentTransactionTypePenjualan),
|
||||
}
|
||||
}
|
||||
|
||||
func AdjustmentTransactionSubtypesByType() map[string][]string {
|
||||
out := make(map[string][]string, len(adjustmentSubtypesByType))
|
||||
for _, txType := range []AdjustmentTransactionType{
|
||||
AdjustmentTransactionTypePembelian,
|
||||
AdjustmentTransactionTypeRecording,
|
||||
AdjustmentTransactionTypePenjualan,
|
||||
} {
|
||||
src := adjustmentSubtypesByType[txType]
|
||||
dup := make([]string, len(src))
|
||||
copy(dup, src)
|
||||
out[string(txType)] = dup
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func AdjustmentTransactionSubtypes() []string {
|
||||
result := make([]string, 0)
|
||||
for _, txType := range []AdjustmentTransactionType{
|
||||
AdjustmentTransactionTypePembelian,
|
||||
AdjustmentTransactionTypeRecording,
|
||||
AdjustmentTransactionTypePenjualan,
|
||||
} {
|
||||
result = append(result, adjustmentSubtypesByType[txType]...)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func AdjustmentTransactionSubtypesByTypeForFrontend() map[string][]string {
|
||||
out := make(map[string][]string, len(adjustmentSubtypesByType))
|
||||
for txType, subtypes := range AdjustmentTransactionSubtypesByType() {
|
||||
filtered := make([]string, 0, len(subtypes))
|
||||
for _, subtype := range subtypes {
|
||||
if _, hidden := hiddenAdjustmentSubtypesForFrontend[subtype]; hidden {
|
||||
continue
|
||||
}
|
||||
filtered = append(filtered, subtype)
|
||||
}
|
||||
out[txType] = filtered
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func AdjustmentTransactionSubtypesForFrontend() []string {
|
||||
result := make([]string, 0)
|
||||
for _, subtype := range AdjustmentTransactionSubtypes() {
|
||||
if _, hidden := hiddenAdjustmentSubtypesForFrontend[subtype]; hidden {
|
||||
continue
|
||||
}
|
||||
result = append(result, subtype)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func ResolveAdjustmentTransactionType(functionCode string) string {
|
||||
code := strings.ToUpper(strings.TrimSpace(functionCode))
|
||||
if txType, ok := adjustmentSubtypeToType[code]; ok {
|
||||
return string(txType)
|
||||
}
|
||||
switch {
|
||||
case strings.HasPrefix(code, "PURCHASE_"):
|
||||
return string(AdjustmentTransactionTypePembelian)
|
||||
case strings.HasPrefix(code, "MARKETING_"):
|
||||
return string(AdjustmentTransactionTypePenjualan)
|
||||
case strings.HasPrefix(code, "RECORDING_"):
|
||||
return string(AdjustmentTransactionTypeRecording)
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Payment Party
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user