mysql

package
v0.0.0-...-79ac43c Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchRepository

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

func NewBranchRepository

func NewBranchRepository(db *Store) *BranchRepository

func (*BranchRepository) CreateBranch

func (r *BranchRepository) CreateBranch(
	ctx context.Context,
	branch *repository.Branch,
) (repository.Branch, error)

func (*BranchRepository) GetBranchByID

func (r *BranchRepository) GetBranchByID(
	ctx context.Context,
	id uint32,
) (repository.Branch, error)

func (*BranchRepository) GetReportBranchData

func (*BranchRepository) ListBranches

func (r *BranchRepository) ListBranches(
	ctx context.Context,
	search *string,
	pgData *pkg.PaginationMetadata,
) ([]repository.Branch, pkg.PaginationMetadata, error)

func (*BranchRepository) UpdateBranch

func (r *BranchRepository) UpdateBranch(
	ctx context.Context,
	name string,
	id uint32,
) (repository.Branch, error)

type ClientRepository

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

func NewClientRepository

func NewClientRepository(db *Store) *ClientRepository

func (*ClientRepository) CreateClient

func (r *ClientRepository) CreateClient(
	ctx context.Context,
	client *repository.Client,
) (repository.ClientFullData, error)

func (*ClientRepository) GetClientAdminsReportData

func (*ClientRepository) GetClientClientsReportData

func (*ClientRepository) GetClientFullData

func (r *ClientRepository) GetClientFullData(
	ctx context.Context,
	id uint32,
) (repository.ClientFullData, error)

func (*ClientRepository) GetClientIDByPhoneNumber

func (r *ClientRepository) GetClientIDByPhoneNumber(
	ctx context.Context,
	phoneNumber string,
) (uint32, error)

func (*ClientRepository) GetReportClientAdminData

func (*ClientRepository) GetReportClientClientsData

func (r *ClientRepository) GetReportClientClientsData(
	ctx context.Context,
	id uint32,
	filters services.ReportFilters,
) (services.ClientClientsReportData, error)

func (*ClientRepository) ListClients

func (*ClientRepository) ListClientsByActiveStatus

func (r *ClientRepository) ListClientsByActiveStatus(
	ctx context.Context,
	active bool,
	pgData *pkg.PaginationMetadata,
) ([]repository.Client, error)

func (*ClientRepository) ListClientsByBranch

func (r *ClientRepository) ListClientsByBranch(
	ctx context.Context,
	branchID uint32,
	pgData *pkg.PaginationMetadata,
) ([]repository.Client, error)

func (*ClientRepository) UpdateClient

func (r *ClientRepository) UpdateClient(
	ctx context.Context,
	client *repository.UpdateClient,
) error

func (*ClientRepository) UpdateClientOverpayment

func (r *ClientRepository) UpdateClientOverpayment(
	ctx context.Context,
	phoneNumber string,
	overpayment float64,
) error

used during transactions

type GetClientAdminsReportDataParams

type GetClientAdminsReportDataParams struct {
	EndDate   time.Time `json:"end_date"`
	StartDate time.Time `json:"start_date"`
}

type GetClientAdminsReportDataRow

type GetClientAdminsReportDataRow struct {
	Name           string         `json:"name"`
	BranchName     sql.NullString `json:"branch_name"`
	TotalLoanGiven int64          `json:"total_loan_given"`
	DefaultedLoans int64          `json:"defaulted_loans"`
	ActiveLoans    int64          `json:"active_loans"`
	CompletedLoans int64          `json:"completed_loans"`
	InactiveLoans  int64          `json:"inactive_loans"`
	Overpayment    float64        `json:"overpayment"`
	PhoneNumber    string         `json:"phone_number"`
	TotalPaid      interface{}    `json:"total_paid"`
	TotalDisbursed interface{}    `json:"total_disbursed"`
	TotalOwed      interface{}    `json:"total_owed"`
	RateScore      interface{}    `json:"rate_score"`
	DefaultRate    interface{}    `json:"default_rate"`
}

type GetClientClientsReportDataParams

type GetClientClientsReportDataParams struct {
	StartDate time.Time `json:"start_date"`
	EndDate   time.Time `json:"end_date"`
	ID        uint32    `json:"id"`
}

type GetClientClientsReportDataRow

type GetClientClientsReportDataRow struct {
	Name          string         `json:"name"`
	PhoneNumber   string         `json:"phone_number"`
	IDNumber      sql.NullString `json:"id_number"`
	Dob           sql.NullTime   `json:"dob"`
	BranchName    sql.NullString `json:"branch_name"`
	AssignedStaff sql.NullString `json:"assigned_staff"`
	Active        bool           `json:"active"`
	Loans         interface{}    `json:"loans"`
	Payments      interface{}    `json:"payments"`
}

type GetLoanEventsRow

type GetLoanEventsRow struct {
	LoanID        uint32          `json:"loan_id"`
	DisbursedDate sql.NullTime    `json:"disbursed_date"`
	DueDate       sql.NullTime    `json:"due_date"`
	ClientName    string          `json:"client_name"`
	LoanAmount    float64         `json:"loan_amount"`
	PaymentDue    sql.NullFloat64 `json:"payment_due"`
}

type GetLoanReportDataByIdRow

type GetLoanReportDataByIdRow struct {
	LoanID                uint32      `json:"loan_id"`
	ClientName            string      `json:"client_name"`
	LoanAmount            float64     `json:"loan_amount"`
	RepayAmount           float64     `json:"repay_amount"`
	PaidAmount            float64     `json:"paid_amount"`
	Status                string      `json:"status"`
	TotalInstallments     int64       `json:"total_installments"`
	PaidInstallments      int64       `json:"paid_installments"`
	RemainingInstallments int64       `json:"remaining_installments"`
	InstallmentDetails    interface{} `json:"installment_details"`
}

type GetLoansReportDataParams

type GetLoansReportDataParams struct {
	StartDate time.Time `json:"start_date"`
	EndDate   time.Time `json:"end_date"`
}

type GetLoansReportDataRow

type GetLoansReportDataRow struct {
	LoanID            uint32       `json:"loan_id"`
	ClientName        string       `json:"client_name"`
	BranchName        string       `json:"branch_name"`
	LoanOfficer       string       `json:"loan_officer"`
	LoanAmount        float64      `json:"loan_amount"`
	RepayAmount       float64      `json:"repay_amount"`
	PaidAmount        float64      `json:"paid_amount"`
	OutstandingAmount interface{}  `json:"outstanding_amount"`
	Status            string       `json:"status"`
	TotalInstallments uint32       `json:"total_installments"`
	PaidInstallments  int64        `json:"paid_installments"`
	DueDate           sql.NullTime `json:"due_date"`
	DisbursedDate     sql.NullTime `json:"disbursed_date"`
	DefaultRisk       interface{}  `json:"default_risk"`
}

type GetProductReportDataParams

type GetProductReportDataParams struct {
	StartDate time.Time `json:"start_date"`
	EndDate   time.Time `json:"end_date"`
}

type GetProductReportDataRow

type GetProductReportDataRow struct {
	ProductName            string      `json:"product_name"`
	TotalLoansIssued       int64       `json:"total_loans_issued"`
	TotalAmountDisbursed   interface{} `json:"total_amount_disbursed"`
	TotalAmountRepaid      interface{} `json:"total_amount_repaid"`
	TotalOutstandingAmount interface{} `json:"total_outstanding_amount"`
	ActiveLoans            int64       `json:"active_loans"`
	CompletedLoans         int64       `json:"completed_loans"`
	DefaultedLoans         int64       `json:"defaulted_loans"`
	DefaultRate            interface{} `json:"default_rate"`
}

type GetUserAdminsReportDataParams

type GetUserAdminsReportDataParams struct {
	StartDate time.Time `json:"start_date"`
	EndDate   time.Time `json:"end_date"`
}

type GetUserAdminsReportDataRow

type GetUserAdminsReportDataRow struct {
	Name              string         `json:"name"`
	Role              string         `json:"role"`
	BranchName        sql.NullString `json:"branch_name"`
	ApprovedLoans     int64          `json:"approved_loans"`
	ActiveLoans       int64          `json:"active_loans"`
	CompletedLoans    int64          `json:"completed_loans"`
	DefaultRate       interface{}    `json:"default_rate"`
	ClientsRegistered int64          `json:"clients_registered"`
	PaymentsAssigned  int64          `json:"payments_assigned"`
}

type GetUserUsersReportDataParams

type GetUserUsersReportDataParams struct {
	StartDate time.Time `json:"start_date"`
	EndDate   time.Time `json:"end_date"`
	ID        uint32    `json:"id"`
}

type GetUserUsersReportDataRow

type GetUserUsersReportDataRow struct {
	Name                   string         `json:"name"`
	Role                   string         `json:"role"`
	Branch                 sql.NullString `json:"branch"`
	TotalClientsHandled    int64          `json:"total_clients_handled"`
	LoansApproved          int64          `json:"loans_approved"`
	TotalLoanAmountManaged interface{}    `json:"total_loan_amount_managed"`
	TotalCollectedAmount   interface{}    `json:"total_collected_amount"`
	DefaultRate            interface{}    `json:"default_rate"`
	AssignedPayments       int64          `json:"assigned_payments"`
	AssignedLoans          interface{}    `json:"assigned_loans"`
	AssignedPaymentsList   interface{}    `json:"assigned_payments_list"`
}

type HelperRepository

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

func NewHelperRepository

func NewHelperRepository(db *Store) *HelperRepository

func (*HelperRepository) GetBranchData

func (r *HelperRepository) GetBranchData(ctx context.Context) ([]repository.BranchData, error)

func (*HelperRepository) GetClientData

func (r *HelperRepository) GetClientData(ctx context.Context) ([]repository.ClientData, error)

func (*HelperRepository) GetClientNonPayments

func (r *HelperRepository) GetClientNonPayments(
	ctx context.Context,
	id uint32,
	phoneNumber string,
	pgData *pkg.PaginationMetadata,
) ([]repository.NonPostedShort, pkg.PaginationMetadata, error)

func (*HelperRepository) GetDashboardData

func (r *HelperRepository) GetDashboardData(ctx context.Context) (repository.DashboardData, error)

func (*HelperRepository) GetLoanData

func (r *HelperRepository) GetLoanData(ctx context.Context) ([]repository.LoanData, error)

func (*HelperRepository) GetLoanOfficerData

func (r *HelperRepository) GetLoanOfficerData(
	ctx context.Context,
) ([]repository.LoanOfficerData, error)

func (*HelperRepository) GetProductData

func (r *HelperRepository) GetProductData(ctx context.Context) ([]repository.ProductData, error)

func (*HelperRepository) GetUserFullname

func (r *HelperRepository) GetUserFullname(ctx context.Context, id uint32) (string, error)

type LoanRepository

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

func NewLoanRepository

func NewLoanRepository(db *Store) *LoanRepository

func (*LoanRepository) CreateLoan

func (r *LoanRepository) CreateLoan(
	ctx context.Context,
	loan *repository.Loan,
) (repository.LoanFullData, error)

func (*LoanRepository) DeleteLoan

func (r *LoanRepository) DeleteLoan(ctx context.Context, id uint32) error

func (*LoanRepository) DisburseLoan

func (r *LoanRepository) DisburseLoan(
	ctx context.Context,
	disburseLoan *repository.DisburseLoan,
) (uint32, error)

func (*LoanRepository) GetClientActiceLoan

func (t *LoanRepository) GetClientActiceLoan(ctx context.Context, clientID uint32) (uint32, error)

func (*LoanRepository) GetClientLoans

func (r *LoanRepository) GetClientLoans(
	ctx context.Context,
	clientID uint32,
	category *repository.Category,
	pgData *pkg.PaginationMetadata,
) ([]repository.LoanFullData, pkg.PaginationMetadata, error)

func (*LoanRepository) GetExpectedPayments

func (*LoanRepository) GetInstallment

func (r *LoanRepository) GetInstallment(
	ctx context.Context,
	id uint32,
) (repository.Installment, error)

func (*LoanRepository) GetLoan

func (*LoanRepository) GetLoanByID

func (r *LoanRepository) GetLoanByID(ctx context.Context, id uint32) (repository.Loan, error)

func (*LoanRepository) GetLoanEvents

func (r *LoanRepository) GetLoanEvents(ctx context.Context) ([]repository.LoanEvent, error)

func (*LoanRepository) GetLoanEventsHelper

func (q *LoanRepository) GetLoanEventsHelper(ctx context.Context) ([]GetLoanEventsRow, error)

func (*LoanRepository) GetLoanInstallments

func (r *LoanRepository) GetLoanInstallments(
	ctx context.Context,
	id uint32,
) ([]repository.Installment, error)

func (*LoanRepository) GetLoanReportDataById

func (q *LoanRepository) GetLoanReportDataById(ctx context.Context, id uint32) (GetLoanReportDataByIdRow, error)

func (*LoanRepository) GetLoanStatus

func (r *LoanRepository) GetLoanStatus(ctx context.Context, id uint32) (string, error)

func (*LoanRepository) GetLoansReportData

func (*LoanRepository) GetReportLoanByIdData

func (r *LoanRepository) GetReportLoanByIdData(
	ctx context.Context,
	id uint32,
) (services.LoanReportDataById, error)

func (*LoanRepository) GetReportLoanData

func (*LoanRepository) ListLoans

func (*LoanRepository) ListUnpaidInstallmentsData

func (r *LoanRepository) ListUnpaidInstallmentsData(
	ctx context.Context,
	category *repository.Category,
	pgData *pkg.PaginationMetadata,
) ([]repository.UnpaidInstallmentData, pkg.PaginationMetadata, error)

func (*LoanRepository) TransferLoan

func (r *LoanRepository) TransferLoan(
	ctx context.Context,
	officerId uint32,
	loanId uint32,
	adminId uint32,
) error

func (*LoanRepository) UpdateInstallment

func (r *LoanRepository) UpdateInstallment(
	ctx context.Context,
	installment *repository.UpdateInstallment,
) (repository.Installment, error)

type NonPostedRepository

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

func NewNonPostedRepository

func NewNonPostedRepository(db *Store) *NonPostedRepository

func (*NonPostedRepository) CreateNonPosted

func (r *NonPostedRepository) CreateNonPosted(
	ctx context.Context,
	nonPosted *repository.NonPosted,
) (repository.NonPosted, error)

func (*NonPostedRepository) DeleteNonPosted

func (r *NonPostedRepository) DeleteNonPosted(
	ctx context.Context,
	id uint32,
	description string,
) error

func (*NonPostedRepository) GetClientNonPosted

func (r *NonPostedRepository) GetClientNonPosted(
	ctx context.Context,
	id uint32,
	phoneNumber string,
	pgData *pkg.PaginationMetadata,
) (repository.ClientNonPosted, pkg.PaginationMetadata, error)

func (*NonPostedRepository) GetNonPosted

func (r *NonPostedRepository) GetNonPosted(
	ctx context.Context,
	id uint32,
) (repository.NonPosted, error)

func (*NonPostedRepository) GetReportPaymentData

func (*NonPostedRepository) ListNonPosted

func (*NonPostedRepository) ListNonPostedByTransactionSource

func (r *NonPostedRepository) ListNonPostedByTransactionSource(
	ctx context.Context,
	transactionSource string,
	pgData *pkg.PaginationMetadata,
) ([]repository.NonPosted, error)

func (*NonPostedRepository) ListPaymentAllocationsByNonPostedId

func (r *NonPostedRepository) ListPaymentAllocationsByNonPostedId(
	ctx context.Context,
	id uint32,
) ([]repository.PaymentAllocation, error)

func (*NonPostedRepository) ListUnassignedNonPosted

func (r *NonPostedRepository) ListUnassignedNonPosted(
	ctx context.Context,
	pgData *pkg.PaginationMetadata,
) ([]repository.NonPosted, error)

func (*NonPostedRepository) UpdateNonPosted

func (r *NonPostedRepository) UpdateNonPosted(
	ctx context.Context,
	nonPosted *repository.NonPosted,
) error

type ProductRepository

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

func NewProductRepository

func NewProductRepository(db *Store) *ProductRepository

func (*ProductRepository) CreateProduct

func (r *ProductRepository) CreateProduct(
	ctx context.Context,
	product *repository.Product,
) (repository.Product, error)

func (*ProductRepository) DeleteProduct

func (r *ProductRepository) DeleteProduct(ctx context.Context, id uint32) error

func (*ProductRepository) GetAllProducts

func (r *ProductRepository) GetAllProducts(
	ctx context.Context,
	search *string,
	pgData *pkg.PaginationMetadata,
) ([]repository.Product, pkg.PaginationMetadata, error)

func (*ProductRepository) GetProductByID

func (r *ProductRepository) GetProductByID(
	ctx context.Context,
	id uint32,
) (repository.Product, error)

func (*ProductRepository) GetProductReportData

func (*ProductRepository) GetReportProductData

func (*ProductRepository) ListProductByBranch

func (r *ProductRepository) ListProductByBranch(
	ctx context.Context,
	branchID uint32,
	pgData *pkg.PaginationMetadata,
) ([]repository.Product, error)

type Store

type Store struct {
	NewQuerierFn func(tx *sql.Tx) generated.Querier
	// contains filtered or unexported fields
}

func NewStore

func NewStore(config pkg.Config) *Store

func (*Store) CloseDB

func (s *Store) CloseDB() error

close db.

func (*Store) ExecTx

func (s *Store) ExecTx(ctx context.Context, fn func(q generated.Querier) error) error

executes transaction.

func (*Store) OpenDB

func (s *Store) OpenDB() error

open db.

type UserRepository

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

func NewUserRepository

func NewUserRepository(db *Store) *UserRepository

func (*UserRepository) CheckUserExistance

func (r *UserRepository) CheckUserExistance(ctx context.Context, email string) bool

func (*UserRepository) CreateUser

func (r *UserRepository) CreateUser(
	ctx context.Context,
	user *repository.User,
) (repository.User, error)

func (*UserRepository) GetReportUserAdminData

func (*UserRepository) GetReportUserUsersData

func (r *UserRepository) GetReportUserUsersData(
	ctx context.Context,
	id uint32,
	filters services.ReportFilters,
) (services.UserUsersReportData, error)

func (*UserRepository) GetUserAdminsReportData

func (*UserRepository) GetUserByEmail

func (r *UserRepository) GetUserByEmail(
	ctx context.Context,
	email string,
) (repository.User, error)

func (*UserRepository) GetUserByID

func (r *UserRepository) GetUserByID(ctx context.Context, id uint32) (repository.User, error)

func (*UserRepository) GetUserUsersReportData

func (*UserRepository) ListUsers

func (*UserRepository) UpdateUser

func (r *UserRepository) UpdateUser(
	ctx context.Context,
	user *repository.UpdateUser,
) (repository.User, error)

func (*UserRepository) UpdateUserPassword

func (r *UserRepository) UpdateUserPassword(
	ctx context.Context,
	email string,
	password string,
) error

Directories

Path Synopsis
Package mockdb is a generated GoMock package.
Package mockdb is a generated GoMock package.

Jump to

Keyboard shortcuts

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