cib

package
v0.0.0-...-6c93a1e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TermTypeUnSpecified termType = iota
	TermTypeCL
	TermTypeL
	TermTypePL
	TermTypeOD
	TermTypeCC
	TermTypeRL
	TermTypeOther
)
View Source
const (
	StatusUnSpecified status = iota
	StatusActive
	StatusClosed
)

Variables

View Source
var ErrCIBFileNotFound = errors.New("cib file not found")
View Source
var ErrCalculationNotFound = errors.New("calculation not found")
View Source
var ErrUnsupportedFileType = errors.New("unsupported file type")

ErrUnsupportedFileType is returned when the file type is not supported.

Functions

func ParseDDMMYYYY

func ParseDDMMYYYY(layout, s string) (yyyymmdd, error)

Types

type AggregateByBankCode

type AggregateByBankCode struct {
	BankCode string          `json:"bankCode"`
	Quantity decimal.Decimal `json:"quantity"`
}

type AggregateQuantity

type AggregateQuantity struct {
	Total  decimal.Decimal `json:"total"`
	Closed decimal.Decimal `json:"closed"`
	Active decimal.Decimal `json:"active"`
}

type CIBFile

type CIBFile struct {
	ID           int64     `json:"-"`
	Location     string    `json:"-"`
	OriginalName string    `json:"originalName"`
	Name         string    `json:"name"`
	CreatedBy    string    `json:"createdBy"`
	CreatedAt    time.Time `json:"createdAt"`

	// Public URL is the signed url to download the file.
	// For output at first time only, not save to DB.
	PublicURL string `json:"publicUrl,omitempty"`
}

type CIBFileReq

type CIBFileReq struct {
	OriginalName string
	ReadSeeker   io.ReadSeeker
}

type CalculateReq

type CalculateReq struct {
	Number      string `json:"number"`
	CIBFileName string `json:"cibFileName"`
	// contains filtered or unexported fields
}

func (*CalculateReq) Validate

func (r *CalculateReq) Validate() error

type Calculation

type Calculation struct {
	ID                    int64                 `json:"id"`
	CIBFileName           string                `json:"cibFileName"`
	Number                string                `json:"number"`
	Customer              Customer              `json:"customer"`
	TotalInstallmentInLAK decimal.Decimal       `json:"totalInstallmentInLAK"`
	AggregateQuantity     AggregateQuantity     `json:"aggregateQuantity"`
	AggregateByBankCode   []AggregateByBankCode `json:"aggregateByBankCode"`
	Contracts             []Contract            `json:"contracts"`
	CreatedBy             string                `json:"createdBy"`
	UpdatedBy             string                `json:"updatedBy"`
	CreatedAt             time.Time             `json:"createdAt"`
	UpdatedAt             time.Time             `json:"updatedAt"`
}

func (Calculation) BytesFromAggregateByBankCode

func (c Calculation) BytesFromAggregateByBankCode() []byte

func (Calculation) BytesFromContracts

func (c Calculation) BytesFromContracts() []byte

type CalculationQuery

type CalculationQuery struct {
	ID                  int64     `query:"id"`
	Number              string    `query:"number"`
	CustomerDisplayName string    `query:"customerDisplayName"`
	CreatedAfter        time.Time `query:"createdAfter"`
	CreatedBefore       time.Time `query:"createdBefore"`
	PageSize            uint64    `query:"pageSize"`
	PageToken           string    `query:"pageToken"`
}

func (*CalculationQuery) ToSQL

func (q *CalculationQuery) ToSQL() (string, []any, error)

type Contract

type Contract struct {
	Number               string   `json:"number"`
	BankCode             string   `json:"bankCode"`
	Type                 string   `json:"type"`
	Currency             string   `json:"currency"`
	GradeCIB             string   `json:"gradeCIB"`
	Term                 string   `json:"term"`
	GradeCIBLast12Months []string `json:"gradeCIBLast12months"`
	Status               status   `json:"status"`

	TermType string `json:"termType"`

	LastedAt           yyyymmdd        `json:"lastedAt"`
	FirstInstallment   yyyymmdd        `json:"firstInstallment"`
	LastInstallment    yyyymmdd        `json:"lastInstallment"`
	InterestRate       decimal.Decimal `json:"interestRate"`
	FinanceAmount      decimal.Decimal `json:"financeAmount"`
	OutstandingBalance decimal.Decimal `json:"outstandingBalance"`
	OverdueInDay       decimal.Decimal `json:"overdueInDay"`
	Period             decimal.Decimal `json:"period"`
	Installment        decimal.Decimal `json:"installment"`
	InstallmentInLAK   decimal.Decimal `json:"installmentInLAK"`
	ExchangeRate       decimal.Decimal `json:"exchangeRate"`
	// contains filtered or unexported fields
}

type Customer

type Customer struct {
	DisplayName string   `json:"displayName"`
	PhoneNumber string   `json:"phoneNumber"`
	DateOfBirth yyyymmdd `json:"dateOfBirth"`
}

type ListCalculationsResult

type ListCalculationsResult struct {
	Calculations  []*Calculation `json:"calculations"`
	NextPageToken string         `json:"nextPageToken"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(_ context.Context, db *sql.DB, currency *currency.Service, gemini *gemini.Service, zlog *zap.Logger) (*Service, error)

func (*Service) CalculateCIB

func (s *Service) CalculateCIB(ctx context.Context, in *CalculateReq) (*Calculation, error)

func (*Service) GetCIBFile

func (s *Service) GetCIBFile(ctx context.Context, fileName string, signature string) (*CIBFile, error)

func (*Service) GetCalculationByNumber

func (s *Service) GetCalculationByNumber(ctx context.Context, number string) (*Calculation, error)

func (*Service) ListCalculations

func (s *Service) ListCalculations(ctx context.Context, in *CalculationQuery) (*ListCalculationsResult, error)

func (*Service) SignedURL

func (s *Service) SignedURL(ctx context.Context, in *CIBFile) string

func (*Service) UploadCIB

func (s *Service) UploadCIB(ctx context.Context, in *CIBFileReq) (*CIBFile, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL