journal

package
v1.0.49 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB) error

Migrate creates the database tables required for the journal service, if they do not already exist.

Types

type JournalService

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

func NewJournalService

func NewJournalService(db *gorm.DB,
	ctx *context.ERPContext,
	accountService *account.AccountService,
	transactionService *transaction.TransactionService,
) *JournalService

func (*JournalService) AddTransaction

func (js *JournalService) AddTransaction(journalID string, transaction *models.TransactionModel, amount float64) error

AddTransaction adds a transaction to a journal entry.

It takes the ID of the journal entry, a pointer to a TransactionModel containing the transaction information, and the amount of the transaction. The function sets the TransactionSecondaryRefID and TransactionSecondaryRefType fields of the transaction to the provided journal ID and "journal" respectively, and then calls the CreateTransaction method of the TransactionService to persist the transaction to the database. The function returns an error if the transaction creation fails.

func (*JournalService) CreateJournal

func (js *JournalService) CreateJournal(data *models.JournalModel) error

CreateJournal creates a new journal entry based on the provided data.

func (*JournalService) DeleteJournal

func (js *JournalService) DeleteJournal(id string) error

DeleteJournal deletes a journal entry and its associated transactions.

This function takes the ID of the journal entry to be deleted. It first removes all transactions linked to the journal entry by their reference ID and type. Then, it deletes the journal entry itself.

Returns an error if any of the delete operations fail; otherwise, nil.

func (*JournalService) DeleteTransaction

func (js *JournalService) DeleteTransaction(id string) error

DeleteTransaction deletes a transaction by its ID.

The function takes the ID of the transaction as its argument. It returns an error if the deletion operation fails.

func (*JournalService) GetJournal

func (js *JournalService) GetJournal(id string) (*models.JournalModel, error)

func (*JournalService) GetJournals

func (js *JournalService) GetJournals(request http.Request, search string) (paginate.Page, error)

GetJournals retrieves a paginated list of journals from the database.

It takes an HTTP request and a search query string as input. The method uses GORM to query the database for journals, applying the search query to the journal name and description fields. If the request contains a company ID header, the method filters the result by the company ID. The function utilizes pagination to manage the result set and applies any necessary request modifications using the utils.FixRequest utility. The function returns a paginated page of JournalModel and an error if the operation fails.

func (*JournalService) GetTransactions

func (js *JournalService) GetTransactions(journalID string, request http.Request) ([]models.TransactionModel, error)

func (*JournalService) UpdateJournal

func (js *JournalService) UpdateJournal(id string, data *models.JournalModel) error

UpdateJournal updates an existing journal entry based on the provided data.

It takes an ID of the journal entry to be updated and a pointer to a JournalModel containing the updated journal information. The function returns an error if the update operation fails.

Jump to

Keyboard shortcuts

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