Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b70e95ac5c | ||
| ac4f4670bb | |||
| 4a8b5cf0c5 | |||
| b33620f629 | |||
| 8006fd0935 | |||
| 4f9ca56157 |
@@ -8,10 +8,16 @@ import (
|
||||
)
|
||||
|
||||
func (c *Client) executeRequest(ctx context.Context, request FiscalRequest, response interface{}) error {
|
||||
//execute request with json body in request
|
||||
reqJson, err := json.Marshal(request)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal request: %w", err)
|
||||
}
|
||||
|
||||
resp, err := c.resty.R().
|
||||
SetContext(ctx).
|
||||
SetHeader("Authorization", c.token).
|
||||
SetBody(request).
|
||||
SetBody(reqJson).
|
||||
Post(c.apiBaseURL + "/fiscal/execute")
|
||||
|
||||
if err != nil {
|
||||
|
||||
31
vchasno.go
31
vchasno.go
@@ -247,11 +247,12 @@ func (c *Client) Sell(ctx context.Context, params SellParams) (*api.SellResponse
|
||||
}
|
||||
|
||||
return c.api.Sell(ctx, api.SellParams{
|
||||
Cashier: c.cashier,
|
||||
Source: c.source,
|
||||
Rows: []api.ReceiptRow{row},
|
||||
Pays: []api.ReceiptPay{pay},
|
||||
Userinfo: params.Userinfo,
|
||||
Cashier: c.cashier,
|
||||
Source: c.source,
|
||||
Rows: []api.ReceiptRow{row},
|
||||
Pays: []api.ReceiptPay{pay},
|
||||
Userinfo: params.Userinfo,
|
||||
CommentUP: params.CommentUP,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -273,3 +274,23 @@ func (c *Client) QuickSellNamed(ctx context.Context, name string, price float64)
|
||||
Price: price,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Client) ZeroReceipt(ctx context.Context) (*api.SellResponse, error) {
|
||||
return c.api.Sell(ctx, api.SellParams{
|
||||
Cashier: c.cashier,
|
||||
Source: c.source,
|
||||
Rows: []api.ReceiptRow{},
|
||||
Pays: []api.ReceiptPay{},
|
||||
CommentUP: "Нульовий чек",
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Client) ZeroReceiptWithTimeout(timeout time.Duration) (*api.SellResponse, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
return c.ZeroReceipt(ctx)
|
||||
}
|
||||
|
||||
func (c *Client) ZeroReceiptDefault() (*api.SellResponse, error) {
|
||||
return c.ZeroReceiptWithTimeout(c.defaults.DefaultTimeout)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user