create supplier cashflow

This commit is contained in:
Sinh 2022-10-26 17:56:15 +07:00
parent e3d80ab251
commit 20f460b4ef
5 changed files with 41 additions and 0 deletions

View File

@ -136,3 +136,22 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh
} }
return nil return nil
} }
// CreateCashflow ...
func (s Supplier) CreateCashflow(p model.SupplierCashflowCreatePayload) (*model.SupplierCashflowCreateResponse, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.CreateCashflow, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Error string `json:"error"`
Data *model.SupplierCashflowCreateResponse `json:"data"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return nil, err
}
if r.Error != "" {
return nil, errors.New(r.Error)
}
return r.Data, nil
}

View File

@ -20,3 +20,9 @@ type ActionBy struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
} }
// ClickAction ...
type ClickAction struct {
Type string `json:"type"`
Value string `json:"value"`
}

View File

@ -38,3 +38,13 @@ type UpdateSupplierWarehousePayload struct {
DistrictCode int `json:"districtCode"` DistrictCode int `json:"districtCode"`
WardCode int `json:"wardCode"` WardCode int `json:"wardCode"`
} }
// SupplierCashflowCreatePayload ...
type SupplierCashflowCreatePayload struct {
Supplier string `json:"supplier"`
Action string `json:"action"`
Name string `json:"name"`
TargetID string `json:"targetId"`
Value float64 `json:"value"`
ClickAction *ClickAction `json:"clickAction"`
}

View File

@ -29,3 +29,7 @@ type SupplierAll struct {
Suppliers []SupplierBrief `json:"suppliers"` Suppliers []SupplierBrief `json:"suppliers"`
Total int64 `json:"total"` Total int64 `json:"total"`
} }
type SupplierCashflowCreateResponse struct {
ID string `json:"id"`
}

View File

@ -10,8 +10,10 @@ var Supplier = struct {
GetListSupplierInfo string GetListSupplierInfo string
GetSupplierContractBySupplierID string GetSupplierContractBySupplierID string
FindAll string FindAll string
CreateCashflow string
}{ }{
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
FindAll: getSupplierValue("find_all"), FindAll: getSupplierValue("find_all"),
CreateCashflow: getSupplierValue("create_cashflow"),
} }