initial commit
This commit is contained in:
50
vchasno.go
Normal file
50
vchasno.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package vchasno
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.jeezft.xyz/rk/go-vchasno-kassa/api"
|
||||
)
|
||||
|
||||
type Vchasno struct {
|
||||
api *api.Kasa
|
||||
}
|
||||
|
||||
const (
|
||||
PayTypeCash = 0
|
||||
PayTypeCard = 2
|
||||
)
|
||||
|
||||
type SellParams struct {
|
||||
PayType int
|
||||
Sum float64
|
||||
Comment string
|
||||
Cardmask string
|
||||
BankID string
|
||||
Name string
|
||||
Cnt int
|
||||
Price float64
|
||||
Disc float64
|
||||
Taxgrp string
|
||||
}
|
||||
|
||||
func NewVchasno(token string) *Vchasno {
|
||||
return &Vchasno{
|
||||
api: api.NewKasaInstance(token),
|
||||
}
|
||||
}
|
||||
|
||||
func (v *Vchasno) NewSell(params SellParams) (*api.KasaResponse, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
return v.api.NewSell(ctx, params.PayType, params.Sum, params.Comment, params.Cardmask, params.BankID, params.Name, params.Cnt, params.Price, params.Disc, params.Taxgrp)
|
||||
}
|
||||
|
||||
func SetDefaultParams() SellParams {
|
||||
return SellParams{
|
||||
PayType: PayTypeCard,
|
||||
Taxgrp: "1",
|
||||
Cnt: 1,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user