mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 21:41:55 +00:00
fix get search keuangan; add bank name to supplier and customer
This commit is contained in:
@@ -91,7 +91,7 @@ func (s transactionService) GetAll(c *fiber.Ctx, params *validation.Query) ([]en
|
||||
if params.Search != "" {
|
||||
like := "%" + strings.ToLower(strings.TrimSpace(params.Search)) + "%"
|
||||
db = db.Where(
|
||||
`LOWER(payment_code) LIKE ? OR
|
||||
`(LOWER(payment_code) LIKE ? OR
|
||||
LOWER(COALESCE(reference_number, '')) LIKE ? OR
|
||||
LOWER(COALESCE(payment_method, '')) LIKE ? OR
|
||||
LOWER(COALESCE(transaction_type, '')) LIKE ? OR
|
||||
@@ -100,7 +100,7 @@ func (s transactionService) GetAll(c *fiber.Ctx, params *validation.Query) ([]en
|
||||
LOWER(COALESCE(suppliers.name, '')) LIKE ? OR
|
||||
LOWER(COALESCE(banks.name, '')) LIKE ? OR
|
||||
CAST(payments.nominal AS TEXT) LIKE ? OR
|
||||
TO_CHAR(payments.payment_date, 'YYYY-MM-DD') LIKE ?`,
|
||||
TO_CHAR(payments.payment_date, 'YYYY-MM-DD') LIKE ?)`,
|
||||
like, like, like, like, like, like, like, like, like, like,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ type CustomerRelationDTO struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
AccountNumber string `json:"account_number"`
|
||||
BankName string `json:"bank_name"`
|
||||
Address string `json:"address,omitempty"`
|
||||
Balance float64 `json:"balance"`
|
||||
Pic *userDTO.UserRelationDTO `json:"pic,omitempty"`
|
||||
@@ -28,6 +29,7 @@ type CustomerListDTO struct {
|
||||
Phone string `json:"phone"`
|
||||
Email string `json:"email"`
|
||||
AccountNumber string `json:"account_number"`
|
||||
BankName string `json:"bank_name"`
|
||||
Balance float64 `json:"balance"`
|
||||
Pic userDTO.UserRelationDTO `json:"pic"`
|
||||
CreatedUser userDTO.UserRelationDTO `json:"created_user"`
|
||||
@@ -53,6 +55,7 @@ func ToCustomerRelationDTO(e entity.Customer) CustomerRelationDTO {
|
||||
Name: e.Name,
|
||||
Type: e.Type,
|
||||
AccountNumber: e.AccountNumber,
|
||||
BankName: e.BankName,
|
||||
Address: e.Address,
|
||||
Balance: e.Balance,
|
||||
Pic: pic,
|
||||
@@ -81,6 +84,7 @@ func ToCustomerListDTO(e entity.Customer) CustomerListDTO {
|
||||
Phone: e.Phone,
|
||||
Email: e.Email,
|
||||
AccountNumber: e.AccountNumber,
|
||||
BankName: e.BankName,
|
||||
Pic: pic,
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
|
||||
@@ -133,6 +133,7 @@ func (s *customerService) CreateOne(c *fiber.Ctx, req *validation.Create) (*enti
|
||||
Phone: req.Phone,
|
||||
Email: req.Email,
|
||||
AccountNumber: req.AccountNumber,
|
||||
BankName: req.BankName,
|
||||
CreatedBy: actorID,
|
||||
}
|
||||
|
||||
@@ -193,6 +194,10 @@ func (s customerService) UpdateOne(c *fiber.Ctx, req *validation.Update, id uint
|
||||
updateBody["account_number"] = *req.AccountNumber
|
||||
}
|
||||
|
||||
if req.BankName != nil {
|
||||
updateBody["bank_name"] = *req.BankName
|
||||
}
|
||||
|
||||
if len(updateBody) == 0 {
|
||||
return s.GetOne(c, id)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ type Create struct {
|
||||
Phone string `json:"phone" validate:"required_strict,max=20"`
|
||||
Email string `json:"email" validate:"required_strict,email,max=50"`
|
||||
AccountNumber string `json:"account_number" validate:"required_strict,max=50"`
|
||||
BankName string `json:"bank_name" validate:"required_strict,max=100"`
|
||||
}
|
||||
|
||||
type Update struct {
|
||||
@@ -18,6 +19,7 @@ type Update struct {
|
||||
Phone *string `json:"phone,omitempty" validate:"omitempty,max=20"`
|
||||
Email *string `json:"email,omitempty" validate:"omitempty,max=50"`
|
||||
AccountNumber *string `json:"account_number,omitempty" validate:"omitempty,max=50"`
|
||||
BankName *string `json:"bank_name,omitempty" validate:"omitempty,max=100"`
|
||||
}
|
||||
|
||||
type Query struct {
|
||||
|
||||
@@ -26,6 +26,7 @@ type SupplierListDTO struct {
|
||||
Address string `json:"address"`
|
||||
Npwp *string `json:"npwp,omitempty"`
|
||||
AccountNumber *string `json:"account_number,omitempty"`
|
||||
BankName *string `json:"bank_name,omitempty"`
|
||||
Balance float64 `json:"balance"`
|
||||
DueDate int `json:"due_date"`
|
||||
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
|
||||
@@ -66,6 +67,7 @@ func ToSupplierListDTO(e entity.Supplier) SupplierListDTO {
|
||||
Address: e.Address,
|
||||
Npwp: e.Npwp,
|
||||
AccountNumber: e.AccountNumber,
|
||||
BankName: e.BankName,
|
||||
Balance: e.Balance,
|
||||
DueDate: e.DueDate,
|
||||
SupplierRelationDTO: ToSupplierRelationDTO(e),
|
||||
|
||||
@@ -160,6 +160,7 @@ func (s *supplierService) CreateOne(c *fiber.Ctx, req *validation.Create) (*enti
|
||||
Address: req.Address,
|
||||
Npwp: req.Npwp,
|
||||
AccountNumber: req.AccountNumber,
|
||||
BankName: req.BankName,
|
||||
DueDate: req.DueDate,
|
||||
CreatedBy: actorID,
|
||||
}
|
||||
@@ -243,6 +244,10 @@ func (s supplierService) UpdateOne(c *fiber.Ctx, req *validation.Update, id uint
|
||||
updateBody["account_number"] = *req.AccountNumber
|
||||
}
|
||||
|
||||
if req.BankName != nil {
|
||||
updateBody["bank_name"] = *req.BankName
|
||||
}
|
||||
|
||||
if req.DueDate != nil {
|
||||
updateBody["due_date"] = *req.DueDate
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ type Create struct {
|
||||
Address string `json:"address" validate:"required_strict"`
|
||||
Npwp *string `json:"npwp,omitempty" validate:"omitempty,max=50"`
|
||||
AccountNumber *string `json:"account_number,omitempty" validate:"omitempty,max=50"`
|
||||
BankName *string `json:"bank_name,omitempty" validate:"omitempty,max=100"`
|
||||
DueDate int `json:"due_date" validate:"required_strict,number,gt=0"`
|
||||
}
|
||||
|
||||
@@ -27,6 +28,7 @@ type Update struct {
|
||||
Address *string `json:"address,omitempty" validate:"omitempty"`
|
||||
Npwp *string `json:"npwp,omitempty" validate:"omitempty,max=50"`
|
||||
AccountNumber *string `json:"account_number,omitempty" validate:"omitempty,max=50"`
|
||||
BankName *string `json:"bank_name,omitempty" validate:"omitempty,max=100"`
|
||||
DueDate *int `json:"due_date,omitempty" validate:"omitempty,number,gt=0"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user