ЛК ЕСИА Финанс: портфель ДЕПО из DEPO — сверка каждые 10 с в проходе опроса, отправка только при изменении; настройки и «Синхронизировать сейчас»

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FsEKyJrYF69Cj9ZXzFLRi
This commit is contained in:
zuevav
2026-09-29 16:54:43 +03:00
parent 98e17a8cb7
commit e47e6cfbdc
10 changed files with 500 additions and 0 deletions
@@ -0,0 +1,41 @@
//go:build live
package lkgateway
import (
"context"
"encoding/json"
"fmt"
"os"
"strings"
"testing"
)
// Портфель ДЕПО в ЛК ЕСИА Финанс. PF_CONTRACT=ДД-816 PF_PORT=БР-859 PF_ISIN=RU0009029540[,…] [PF_GO=1 — отправить]
func TestLKPortfolioLive(t *testing.T) {
rc, err := NewRuntimeConfig("/var/lib/bj/.bj/setup.json")
if err != nil {
t.Fatal(err)
}
only := map[string]bool{}
for _, i := range strings.Split(os.Getenv("PF_ISIN"), ",") {
if i = strings.ToUpper(strings.TrimSpace(i)); i != "" {
only[i] = true
}
}
lines, skipped, err := lkPortfolioLines(context.Background(), rc, os.Getenv("PF_PORT"), only)
if err != nil {
t.Fatal(err)
}
body, _ := json.MarshalIndent(map[string]any{"data": map[string]any{os.Getenv("PF_CONTRACT"): lines}}, "", " ")
fmt.Println("запрос: POST /portfolio/import?import_type=depo_portfolio")
fmt.Println(string(body))
for _, s := range skipped {
fmt.Println("пропущено:", s)
}
if os.Getenv("PF_GO") != "1" {
return
}
code, resp, err := lkPortfolioPush(context.Background(), rc, os.Getenv("PF_CONTRACT"), lines)
fmt.Println("ответ HTTP", code, resp, err)
}