parent
9a90f18d58
commit
3fc2004190
|
@ -7,23 +7,23 @@ import (
|
|||
|
||||
// GlBalanceParams is a parameter struct
|
||||
type GlBalanceParams struct {
|
||||
glAccountID string
|
||||
periodID string
|
||||
principal *User
|
||||
GlAccountID string
|
||||
PeriodID string
|
||||
Principal *User
|
||||
}
|
||||
|
||||
// GetGlBalanceByParams is a GL balance helper function
|
||||
func GetGlBalanceByParams(params GlBalanceParams) *ledger_models.GlBalance {
|
||||
sugar.Debug("ops.getGlBalanceByParams: 📥")
|
||||
obj, ok := glBalanceCache.get(params.periodID, params.glAccountID)
|
||||
obj, ok := glBalanceCache.get(params.PeriodID, params.GlAccountID)
|
||||
if ok {
|
||||
sugar.Debug("ops.getGlBalanceByParams: 👍 📤 🎯")
|
||||
return obj
|
||||
}
|
||||
ledgerParams := gl_balance.NewGetGlBalancesParamsWithTimeout(getTimeout)
|
||||
ledgerParams.GlAccountID = ¶ms.glAccountID
|
||||
ledgerParams.PeriodID = ¶ms.periodID
|
||||
response, restErr := ledgerClient.GlBalance.GetGlBalances(ledgerParams, params.principal.Auth)
|
||||
ledgerParams.GlAccountID = ¶ms.GlAccountID
|
||||
ledgerParams.PeriodID = ¶ms.PeriodID
|
||||
response, restErr := ledgerClient.GlBalance.GetGlBalances(ledgerParams, params.Principal.Auth)
|
||||
if restErr != nil {
|
||||
sugar.Errorf("ops.getGlBalanceByParams: 💣 ⛔ %s", restErr.Error())
|
||||
return nil
|
||||
|
@ -32,7 +32,7 @@ func GetGlBalanceByParams(params GlBalanceParams) *ledger_models.GlBalance {
|
|||
for _, itm := range response.Payload.Data {
|
||||
theGlBalance = itm // singleton
|
||||
}
|
||||
glBalanceCache.put(params.periodID, params.glAccountID, theGlBalance)
|
||||
glBalanceCache.put(params.PeriodID, params.GlAccountID, theGlBalance)
|
||||
sugar.Debugf("ops.getGlBalanceByParams: 👍 📤")
|
||||
return theGlBalance
|
||||
}
|
||||
|
|
|
@ -5,8 +5,33 @@ import (
|
|||
"time"
|
||||
|
||||
"code.tnxs.net/taxnexus/lib/api/ledger/ledger_client/period"
|
||||
"code.tnxs.net/taxnexus/lib/api/ledger/ledger_models"
|
||||
)
|
||||
|
||||
// GetPeriodByID is a first class object retrieval method
|
||||
func GetPeriodByID(recordID *string, principal *User) (*ledger_models.Period, error) {
|
||||
ledgerParams := period.NewGetPeriodsParams()
|
||||
ledgerParams.PeriodID = recordID
|
||||
periodResponse, restErr := ledgerClient.Period.GetPeriods(ledgerParams, principal.Auth)
|
||||
if restErr != nil {
|
||||
return nil, fmt.Errorf("devops.getPeriodByID: 💣 ⛔ getPeriod error: %w", restErr)
|
||||
}
|
||||
return periodResponse.Payload.Data[0], nil
|
||||
}
|
||||
|
||||
// GetPeriodByDate is a first class object retrieval method
|
||||
func GetPeriodByDate(accountID *string, theDate time.Time, principal *User) (*ledger_models.Period, error) {
|
||||
ledgerParams := period.NewGetPeriodsParams()
|
||||
ledgerParams.AccountID = accountID
|
||||
dateString := theDate.Format(dateFormat)
|
||||
ledgerParams.Date = &dateString
|
||||
periodResponse, restErr := ledgerClient.Period.GetPeriods(ledgerParams, principal.Auth)
|
||||
if restErr != nil {
|
||||
return nil, fmt.Errorf("devops.getPeriodByDate: 💣 ⛔ getPeriod error: %w", restErr)
|
||||
}
|
||||
return periodResponse.Payload.Data[0], nil
|
||||
}
|
||||
|
||||
// CalendarPeriod is a parameter type
|
||||
type CalendarPeriod struct {
|
||||
ID string
|
||||
|
|
Loading…
Reference in New Issue