initial commit

This commit is contained in:
daniel
2025-09-30 14:39:08 +03:00
parent 85292a94ba
commit 830b63e701
7 changed files with 472 additions and 0 deletions

50
vchasno.go Normal file
View 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,
}
}