Documentation
¶
Index ¶
- type ContactService
- func (s *ContactService) CountContactByTag(companyID string) ([]models.CountByTag, error)
- func (s *ContactService) CreateContact(data *models.ContactModel) error
- func (s *ContactService) CreateContactFromUser(user *models.UserModel, code string, isCustomer, isVendor, isSupplier bool, ...) (*models.ContactModel, error)
- func (s *ContactService) DB() *gorm.DB
- func (s *ContactService) DeleteContact(id string) error
- func (s *ContactService) GetContactByID(id string) (*models.ContactModel, error)
- func (s *ContactService) GetContactByPhone(phone string, companyID string) (*models.ContactModel, error)
- func (s *ContactService) GetContactByTagIDs(tagIDs []string) ([]models.ContactModel, error)
- func (s *ContactService) GetContacts(request http.Request, search string, isCustomer, isVendor, isSupplier *bool) (paginate.Page, error)
- func (s *ContactService) GetContactsByRole(isCustomer, isVendor, isSupplier bool) ([]models.ContactModel, error)
- func (s *ContactService) GetTotalDebt(contact *models.ContactModel) float64
- func (s *ContactService) GetTotalReceivable(contact *models.ContactModel) float64
- func (s *ContactService) Migrate() error
- func (s *ContactService) UpdateContact(id string, data *models.ContactModel) (*models.ContactModel, error)
- func (s *ContactService) UpdateContactRoles(id string, isCustomer, isVendor, isSupplier bool) (*models.ContactModel, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContactService ¶
type ContactService struct {
CompanyService *company.CompanyService
// contains filtered or unexported fields
}
func NewContactService ¶
func NewContactService(ctx *context.ERPContext, companyService *company.CompanyService) *ContactService
func (*ContactService) CountContactByTag ¶
func (s *ContactService) CountContactByTag(companyID string) ([]models.CountByTag, error)
CountContactByTag returns a list of tags with the number of contacts associated with each tag, filtered by the given company ID.
The returned list is grouped by tag ID, name, and color. The count of contacts associated with each tag is included in the response.
If the query encounters an error, it will return that error. Otherwise, it will return the list of tags with contact counts.
func (*ContactService) CreateContact ¶
func (s *ContactService) CreateContact(data *models.ContactModel) error
CreateContact creates a new contact.
It checks if a contact with the same phone number already exists in the same company. If it does, it returns an error.
If the contact does not exist, it creates a new contact with the given data.
func (*ContactService) CreateContactFromUser ¶
func (s *ContactService) CreateContactFromUser(user *models.UserModel, code string, isCustomer, isVendor, isSupplier bool, companyID *string) (*models.ContactModel, error)
CreateContactFromUser creates a new contact from a user if no contact with the same email exists.
If the contact does not exist, it creates a new contact with the given data. If the contact does exist, it returns the existing contact.
func (*ContactService) DB ¶
func (s *ContactService) DB() *gorm.DB
DB returns the underlying database connection.
The method returns the GORM database connection that is used by the service for CRUD (Create, Read, Update, Delete) operations.
func (*ContactService) DeleteContact ¶
func (s *ContactService) DeleteContact(id string) error
DeleteContact removes a contact based on the given ID.
func (*ContactService) GetContactByID ¶
func (s *ContactService) GetContactByID(id string) (*models.ContactModel, error)
GetContactByID retrieves a contact by ID.
It returns an error if the contact is not found.
func (*ContactService) GetContactByPhone ¶
func (s *ContactService) GetContactByPhone(phone string, companyID string) (*models.ContactModel, error)
GetContactByPhone retrieves a contact by phone number.
It returns an error if the contact is not found.
func (*ContactService) GetContactByTagIDs ¶
func (s *ContactService) GetContactByTagIDs(tagIDs []string) ([]models.ContactModel, error)
GetContactByTagIDs returns a list of contacts associated with the given tag IDs.
The returned list is filtered by the given tag IDs. If the query encounters an error, it will return that error. Otherwise, it will return the list of contacts.
func (*ContactService) GetContacts ¶
func (s *ContactService) GetContacts(request http.Request, search string, isCustomer, isVendor, isSupplier *bool) (paginate.Page, error)
GetContacts mengambil semua contact dengan pagination
func (*ContactService) GetContactsByRole ¶
func (s *ContactService) GetContactsByRole(isCustomer, isVendor, isSupplier bool) ([]models.ContactModel, error)
GetContactsByRole retrieves all contacts based on the specified roles (customer, vendor, supplier).
func (*ContactService) GetTotalDebt ¶
func (s *ContactService) GetTotalDebt(contact *models.ContactModel) float64
GetTotalDebt returns the total debt that a contact has.
It takes in a contact and returns the total debt that the contact has. The total debt is calculated by summing up all the unpaid invoices of the contact. If the contact does not have any unpaid invoices, it returns 0.
func (*ContactService) GetTotalReceivable ¶
func (s *ContactService) GetTotalReceivable(contact *models.ContactModel) float64
func (*ContactService) Migrate ¶
func (s *ContactService) Migrate() error
func (*ContactService) UpdateContact ¶
func (s *ContactService) UpdateContact(id string, data *models.ContactModel) (*models.ContactModel, error)
UpdateContact updates the information of a contact.
func (*ContactService) UpdateContactRoles ¶
func (s *ContactService) UpdateContactRoles(id string, isCustomer, isVendor, isSupplier bool) (*models.ContactModel, error)
UpdateContactRoles updates the roles (is_customer, is_vendor, is_supplier) of a contact.