51 lines
930 B
Go
51 lines
930 B
Go
package vchasno
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"gitea.jeezft.xyz/jeezft/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,
|
|
}
|
|
}
|