service

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAccountService

func NewAccountService(
	accountRepo domain.AccountRepository,
	userRepo domain.UserRepository,
	auditRepo domain.AuditRepository,
) domain.AccountService

NewAccountService creates a new instance of AccountService.

func NewAdminService

func NewAdminService(
	tenantRepo domain.AdminTenantRepository,
	userRepo domain.AdminUserRepository,
	adminAudit domain.AdminAuditRepository,
	auditRepo domain.AuditRepository,
) domain.AdminService

NewAdminService creates a new system-wide administrative service.

func NewAuthService

func NewAuthService(
	authRepo domain.AuthRepository,
	userRepo domain.UserRepository,
	auditRepo domain.AuditRepository,
	mailer domain.Mailer,
	pasetoKey paseto.V4SymmetricKey,
) domain.AuthService

NewAuthService creates a new authentication service.

func NewCategoryService

func NewCategoryService(categoryRepo domain.CategoryRepository, auditRepo domain.AuditRepository) domain.CategoryService

NewCategoryService creates a new instance of CategoryService.

func NewInvestmentService added in v1.14.0

NewInvestmentService creates a new instance of InvestmentServiceImpl with the provided repositories and services.

func NewMasterPurchaseService added in v1.10.0

func NewMasterPurchaseService(
	mpRepo domain.MasterPurchaseRepository,
	accountRepo domain.AccountRepository,
	catRepo domain.CategoryRepository,
) domain.MasterPurchaseService

NewMasterPurchaseService creates a new MasterPurchaseService implementation.

func NewTenantService

func NewTenantService(
	tenantRepo domain.TenantRepository,
	userRepo domain.UserRepository,
	auditRepo domain.AuditRepository,
) domain.TenantService

NewTenantService creates a new instance of TenantService.

func NewTransactionService

func NewTransactionService(
	txRepo domain.TransactionRepository,
	accountRepo domain.AccountRepository,
	categoryRepo domain.CategoryRepository,
	auditRepo domain.AuditRepository,
) domain.TransactionService

NewTransactionService creates a new instance of TransactionService.

Types

type InvestmentService added in v1.14.0

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

InvestmentService provides business logic for managing investment-related operations such as positions, assets, and portfolio summaries. It interacts with various repositories to perform CRUD operations and also handles audit logging for all actions.

func (*InvestmentService) CancelIncome added in v1.14.0

func (s *InvestmentService) CancelIncome(ctx context.Context, tenantID, eventID string) (*domain.PositionIncomeEvent, error)

CancelIncome marks a position income event as cancelled, preventing it from being processed as received, and logs the update action in the audit trail. It validates that the event is in a state that can be cancelled before performing the update.

func (*InvestmentService) CreateAsset added in v1.14.0

func (s *InvestmentService) CreateAsset(ctx context.Context, input domain.CreateAssetInput) (*domain.Asset, error)

CreateAsset adds a new asset to the global asset catalogue, ensuring that the asset details are valid. It also logs the creation action in the audit trail.

func (*InvestmentService) CreatePosition added in v1.14.0

func (s *InvestmentService) CreatePosition(ctx context.Context, tenantID string, in domain.CreatePositionInput) (*domain.Position, error)

CreatePosition creates a new investment position for the specified tenant, ensuring that the associated account is of type investment and that the referenced asset exists. It also logs the creation action in the audit trail.

func (*InvestmentService) DeleteAsset added in v1.14.0

func (s *InvestmentService) DeleteAsset(ctx context.Context, id string) error

DeleteAsset performs a soft delete of an asset from the global catalogue, and logs the deletion action in the audit trail. It first checks if the asset exists before attempting deletion.

func (*InvestmentService) DeletePosition added in v1.14.0

func (s *InvestmentService) DeletePosition(ctx context.Context, tenantID, id string) error

DeletePosition performs a soft delete of the position, and logs the deletion action in the audit trail. It first checks if the position exists before attempting deletion.

func (*InvestmentService) DeleteTenantAssetConfig added in v1.14.0

func (s *InvestmentService) DeleteTenantAssetConfig(ctx context.Context, tenantID, assetID string) error

DeleteTenantAssetConfig performs a soft delete of a tenant-specific asset configuration, and logs the deletion action in the audit trail. It first checks if the configuration exists before attempting deletion.

func (*InvestmentService) GetAssetByID added in v1.14.0

func (s *InvestmentService) GetAssetByID(ctx context.Context, id string) (*domain.Asset, error)

GetAssetByID retrieves an asset by its ID. It returns domain.ErrNotFound if the asset does not exist.

func (*InvestmentService) GetAssetWithTenantConfig added in v1.14.0

func (s *InvestmentService) GetAssetWithTenantConfig(ctx context.Context, tenantID, id string) (*domain.Asset, error)

GetAssetWithTenantConfig retrieves an asset by its ID and applies any tenant-specific configuration overrides to the asset details. This allows tenants to have customized views of assets in their portfolio based on their specific configurations.

func (*InvestmentService) GetPortfolioSummary added in v1.14.0

func (s *InvestmentService) GetPortfolioSummary(ctx context.Context, tenantID string) (*domain.PortfolioSummary, error)

GetPortfolioSummary generates a real-time summary of the tenant's portfolio, including allocation by asset type and individual position summaries. It aggregates data from all positions to calculate total value and gain/loss information for each position.

func (*InvestmentService) GetPosition added in v1.14.0

func (s *InvestmentService) GetPosition(ctx context.Context, tenantID, id string) (*domain.Position, error)

GetPosition retrieves a position by its ID and tenant ID. It returns domain.ErrNotFound if the position does not exist.

func (*InvestmentService) GetTenantAssetConfig added in v1.14.0

func (s *InvestmentService) GetTenantAssetConfig(ctx context.Context, tenantID, assetID string) (*domain.TenantAssetConfig, error)

GetTenantAssetConfig retrieves a tenant-specific asset configuration by asset ID. It returns domain.ErrAssetConfigNotFound if the configuration does not exist for the given tenant and asset ID.

func (*InvestmentService) ListAssets added in v1.14.0

func (s *InvestmentService) ListAssets(ctx context.Context, params domain.ListAssetsParams) ([]domain.Asset, error)

ListAssets returns a list of assets from the global catalogue, with optional filtering by ticker symbol. It supports pagination through limit and offset parameters.

func (*InvestmentService) ListPositions added in v1.14.0

func (s *InvestmentService) ListPositions(ctx context.Context, tenantID string) ([]domain.Position, error)

ListPositions returns all positions for a given tenant.

func (*InvestmentService) ListTenantAssetConfigs added in v1.14.0

func (s *InvestmentService) ListTenantAssetConfigs(ctx context.Context, tenantID string) ([]domain.TenantAssetConfig, error)

ListTenantAssetConfigs returns all tenant-specific asset configurations for a given tenant, allowing the tenant to view and manage their customizations for assets in their portfolio.

func (*InvestmentService) MarkIncomeReceived added in v1.14.0

func (s *InvestmentService) MarkIncomeReceived(ctx context.Context, tenantID, eventID string) (*domain.PositionIncomeEvent, error)

MarkIncomeReceived marks a position income event as received, creates a corresponding transaction for the income, and logs the update action in the audit trail. It validates that the event is in a state that can be marked as received before performing the update.

func (*InvestmentService) TakeSnapshot added in v1.14.0

func (s *InvestmentService) TakeSnapshot(ctx context.Context, tenantID string) (*domain.PortfolioSnapshot, error)

TakeSnapshot captures the current state of the tenant's portfolio and saves it as a snapshot for historical reference. It retrieves the latest portfolio summary to populate the snapshot data, including total value and allocation by asset type.

func (*InvestmentService) UpdatePosition added in v1.14.0

func (s *InvestmentService) UpdatePosition(ctx context.Context, tenantID, id string, in domain.UpdatePositionInput) (*domain.Position, error)

UpdatePosition modifies an existing position's details, and logs the update action in the audit trail, including the old and new values of the changed fields.

func (*InvestmentService) UpsertTenantAssetConfig added in v1.14.0

func (s *InvestmentService) UpsertTenantAssetConfig(ctx context.Context, tenantID string, input domain.UpsertTenantAssetConfigInput) (*domain.TenantAssetConfig, error)

UpsertTenantAssetConfig creates or updates a tenant-specific asset configuration, allowing tenants to override global asset details such as name, currency, and additional information. It ensures that the referenced asset exists before upserting the configuration, and logs the action in the audit trail.

type InvoiceCloser added in v1.10.0

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

InvoiceCloser materializes installment transactions at invoice-close time.

func NewInvoiceCloser added in v1.10.0

NewInvoiceCloser creates a new InvoiceCloser.

func (*InvoiceCloser) CloseInvoice added in v1.10.0

func (c *InvoiceCloser) CloseInvoice(
	ctx context.Context,
	tenantID string,
	accountID string,
	closingDate time.Time,
) (domain.CloseInvoiceResult, error)

CloseInvoice finds all open master purchases for the account due on or before closingDate, materializes the current installment as a transaction, and advances paid_installments. Runs each master purchase in its own DB transaction.

Jump to

Keyboard shortcuts

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