Skip to content

Commit

Permalink
Validate(cd *popbill.CloseDown)
Browse files Browse the repository at this point in the history
  • Loading branch information
theorders committed Jul 6, 2020
1 parent 4f9bb4f commit 153b5c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pb_cashbill/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Issue struct {
OrgTradeDate string `json:"orgTradeDate,omitempty" firestore:"orgTradeDate,omitempty"`
}

func (i *Issue) Validate() error {
func (i *Issue) Validate(cd *popbill.CloseDown) error {
if i.TradeUsage == "" {
return errors.New("발급용도가 지정되지 않았습니다")
}
Expand All @@ -60,6 +60,10 @@ func (i *Issue) Validate() error {
return errors.New("거래금액이 숫자가 아닙니다")
}

if cd.TaxType != popbill.TaxTypeNormal {
i.TaxationType = TaxationTypeNoTax
}

if i.TaxationType == TaxationTypeWithTax && totalAmount > 10 {
var supply, tax int
supply = (totalAmount / 11) * 10
Expand Down
6 changes: 5 additions & 1 deletion popbill.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ func (c *Client) Request(method, service, path string, body interface{}, headers


if res.Response().StatusCode / 100 == 4 || defaultResponse.Code < 0 {
return res, echo.NewHTTPError(400, defaultResponse.Message)
if defaultResponse.Code == -14000003 {
return res, echo.NewHTTPError(404, defaultResponse.Message)
} else {
return res, echo.NewHTTPError(400, defaultResponse.Message)
}
}

return res, nil
Expand Down

0 comments on commit 153b5c3

Please sign in to comment.