Remove nomenclature type from monthly orders approval text #174

Merged
romanskijdev merged 1 commits from fix-permissions into main 2026-10-12 10:41:42 +03:00
2 changed files with 32 additions and 6 deletions

31
code2text.py Normal file
View File

@ -0,0 +1,31 @@
import os
def generate_codebase(root_dir, output_file):
# Папки, которые мы игнорируем
ignore_dirs = {'.git', 'vendor', '__pycache__', 'node_modules', '.idea', '.vscode'}
# Расширения файлов, которые нам не нужны (бинарники и контрольные суммы)
ignore_exts = {'.pyc', '.sum', '.exe', '.dll', '.so', '.pdf', '.png', '.jpg'}
with open(output_file, 'w', encoding='utf-8') as outfile:
for root, dirs, files in os.walk(root_dir):
# Исключаем игнорируемые директории, модифицируя список dirs на месте
dirs[:] = [d for d in dirs if d not in ignore_dirs]
for file in files:
# Пропускаем сам выходной файл, этот скрипт и файлы с ненужными расширениями
if file == output_file or file == "code2text.py" or any(file.endswith(ext) for ext in ignore_exts):
continue
filepath = os.path.join(root, file)
try:
with open(filepath, 'r', encoding='utf-8') as infile:
outfile.write(f"\n\n=== ФАЙЛ: {filepath} ===\n")
outfile.write(infile.read())
except Exception as e:
# Если файл нельзя прочитать как текст (например, это картинка без расширения), просто запишем ошибку и пойдем дальше
outfile.write(f"\n\n=== ПРОПУЩЕН БИНАРНЫЙ ФАЙЛ ИЛИ ОШИБКА ЧТЕНИЯ: {filepath} ===\n")
if __name__ == "__main__":
# Меняем '.' на './service/telegram_service' (или как у вас называется эта папка)
generate_codebase('./service/telegram_service', 'telegram_codebase.txt')
print("Готово! Код собран в файл telegram_codebase.txt")

View File

@ -404,17 +404,12 @@ func (s *MonthlyOrderService) SubmitOrdersToTelegram(ctx context.Context, manage
nomName = *item.NomenclatureName
}
nomType := ""
if item.NomenclatureType != nil && *item.NomenclatureType != "" {
nomType = fmt.Sprintf(" (%s)", *item.NomenclatureType)
}
qty := 0
if item.Quantity != nil {
qty = *item.Quantity
}
contentBuilder.WriteString(fmt.Sprintf("- %s%s: %d шт.\n", nomName, nomType, qty))
contentBuilder.WriteString(fmt.Sprintf("- %s: %d шт.\n", nomName, qty))
order.Items = append(order.Items, *item)
}