# DOCTEMPLATE

NAME: Закрытие документа
CODE: 0000000001
SCRIPTDATA:
  function printHeader(print)
  {
      print.printLRStringLF("РМ №" + frontol.codeWorkplace, frontol.currentUser.text, " ");

      var documentNumber = " №" + print.addCharLeft(frontol.currentDocument.number, "0", 8);
      var sessionNumber = "Смена №"+print.addCharLeft(frontol.sessionNumber, "0", 4);
      print.printLRStringLF(frontol.currentDocument.type.name + documentNumber, sessionNumber, " ");

      print.printLRStringLF("Откр. " + frontol.currentDocument.timeOpen, "Закр. " + frontol.currentDocument.timeClose, " ");
      print.printLRStringLF("=","=","=");
  }

  function printPosition(print)
  {
      if (frontol.currentDocument.position.storno == 1)
          return;

      // Серия товара
      var series = frontol.currentDocument.position.ware.series; 
      if (series != "")
          print.printStringWordWrap("  " + "Серия " + series);

      // Разделитель
      if (frontol.currentDocument.position.number != frontol.currentDocument.position.count)
          print.printLRStringLF("-","-","-")
  }

  function printFooter(print)
  {
      // Карта
      var card = frontol.currentDocument.cardValues
      if(card != "")
          print.printStringWordWrap("Карта: " + card);

      // Скидки на документ
      if(frontol.currentDocument.discountDoc.count > 0)
      {
          print.printLRStringLF("-","-","-");
          print.printStringWordWrap("Скидки на документ");
      }

      var count = frontol.currentDocument.discountDoc.count;
      for (var index = 1; index <= count; index++)
      {
          frontol.currentDocument.discountDoc.index = index;
          if (frontol.currentDocument.discountDoc.sum != 0)
          {
              // Текст акции
              if (frontol.currentDocument.discountDoc.marketingAction.text != "")
                  print.printStringWordWrap(frontol.currentDocument.discountDoc.marketingAction.text);
              
              // Сумма скидки
              var type = '';
              type += frontol.currentDocument.discountDoc.valueType != 0 ? '1' : '0';
              type += frontol.currentDocument.discountDoc.sum < 0 ? '1' : '0';
              var value = frontol.currentDocument.discountDoc.value;
              var sum = frontol.currentDocument.discountDoc.sum;
              switch(type)
              {
              case '00':
                  print.printLRStringLF("    -" + print.formatPercent(value) + "%", print.formatCurrency(sum), "_");
                  break;
              case '10':
                  print.printLRStringLF("    -" + print.formatCurrency(value) + 'руб.', print.formatCurrency(sum), "_");
                  break;
              case '01':
                  print.printLRStringLF("    +" + print.formatPercent(-value) + "%", print.formatCurrency(-sum), "_");
                  break;
              case '11':
                  print.printLRStringLF("    +" + print.formatCurrency(-value) + 'руб.', print.formatCurrency(-sum), "_");
                  break;
              }
          }
      }

      if (frontol.currentDocument.discountDoc.count > 0)
      {
          if (frontol.currentDocument.discountDoc.totalSum != 0)
          {
              if (frontol.currentDocument.discountDoc.totalSum < 0)
              {
                  var value = print.formatPercent(-frontol.currentDocument.discountDoc.totalPercent);
                  var currency = print.formatCurrency(-frontol.currentDocument.discountDoc.totalSum);
                  print.printLRStringLF("+" + value + "%", currency, "_");
              }
              else
              {
                  var value = print.formatPercent(frontol.currentDocument.discountDoc.totalPercent);
                  var currency = print.formatCurrency(frontol.currentDocument.discountDoc.totalSum);
                  print.printLRStringLF("-" + value + "%", currency, "_");
              }
          }
      }

      if (frontol.currentDocument.totalSumDiscount != 0)
      {
          if (frontol.currentDocument.totalSumDiscount < 0)
          {  
              var value = print.formatPercent(frontol.currentDocument.totalPercentDiscount);
              var currency = print.formatCurrency(-frontol.currentDocument.totalSumDiscount);
              print.printLRString("Сумма итоговой скидки", currency, "_");
              print.printLRString("+" + value +"%", currency, "_");
          }
          else
          {
              var value = print.formatPercent(frontol.currentDocument.totalPercentDiscount);
              var currency = print.formatCurrency(frontol.currentDocument.totalSumDiscount);
              print.printLRString("Сумма итоговой скидки", currency, "_");
              print.printLRString("-" + value + "%", currency, "_");
          }
      }

      if (frontol.currentDocument.sum != frontol.currentDocument.totalSum )
          print.printLRStringLF("Итоговая сумма", print.formatCurrency(frontol.currentDocument.totalSum), "_");

      if (frontol.currentDocument.sum != frontol.currentDocument.totalSum )
          print.printCenterString("Скидки документа", " ");

      print.printLRStringLF("-","-","-");
      
      print.printStringWordWrap("Оплата");
      var count = frontol.currentDocument.payment.count;
      for(var index = 1; index <= count; index++)
      {
          frontol.currentDocument.payment.index = index;
      
          if (frontol.currentDocument.payment.sumInBaseCurrency <= 0)
          {
              print.printStringWordWrap("Сдача");
              var typetext = frontol.currentDocument.payment.type.text;
              var currency = print.formatCurrency(-frontol.currentDocument.payment.sumInBaseCurrency);
              print.printLRStringLF(typetext, currency, '_');
          }
          else
          {
              var typetext = frontol.currentDocument.payment.type.text;
              var currency = print.formatCurrency(frontol.currentDocument.payment.sumInBaseCurrency);
              print.printLRStringLF(typetext, currency, '_');
          }
      }
  }


NAME: Шаблон РКО для кассовой ленты для заполнения вручную
CODE: 0000000002
SCRIPTDATA:
  function printHeader(print)
  {
  	var rmNo = frontol.codeWorkplace;
  	var userName = frontol.currentUser.text;
  	
  	print.printLRStringLF("РМ №" + rmNo, userName, " ");
  	print.printLRStringLF("=","=","=");
  	nextLine(print);
  	printFormLine(print, "РАСХОДНЫЙ КАССОВЫЙ ОРДЕР №");
  	printFormLine(print, "                     от");
  	printFormLine(print, "Код структ. подразделения");
  	printFormLine(print, "Корр. счет");
  	printFormLine(print, "Код анал. учета");
  	printFormLine(print, "Кредит");
  	printFormLine(print, "Сумма");
  	printFormLine(print, "Выдать (ФИО)");
  	printFormLine(print, "_");
  	printFormLine(print, "_");
  	print.printLRStringLF("Основание", "ЗАЯВЛЕНИЕ", " ");
  	nextLine(print, " ");
  	printFormLine(print, "Сумма _________ РУБ ___ КОП (");
  	printFormLine(print, "_");
  	print.printLRStringLF("_", "_)", "_");
  	nextLine(print, " ");
  	printFormLine(print, "Рук. орг.");
  	printFormLine(print, "Гл. бух.");
  	printFormLine(print, "Получил _________ РУБ ___ КОП (");
  	printFormLine(print, "_");
  	print.printLRStringLF("_", "_)", "_");
  	nextLine(print, " ");
  	printFormLine(print, "\"__\" _____ 20__г. Подпись");
  	print.printLRStringLF("По", "_", "_");
  	print.printCenterString("(наимен., номер, дата", " ");
  	nextLine(print, " ");
  	print.printLRStringLF("_", "_", "_");
  	print.printCenterString("и место выдачи документа,", " ");
  	nextLine(print, " ");
  	print.printLRStringLF("_", "_", "_");
  	print.printCenterString("удостоверяющего личность)", " ");
  	nextLine(print, " ");
  	printFormLine(print, "_");
  	printFormLine(print, "_");
  	printFormLine(print, "Кассир");
  }

  function printPosition(print)
  {
  }

  function printFooter(print)
  {
  }

  function nextLine(print)
  {
  	print.printString(" ");
  }

  function printFormLine(print, l)
  {
  	print.printLRStringLF(l, "_", "_");
  	nextLine(print, " ");
  }


NAME: Шаблон заявления для кассовой ленты для заполнения вручную
CODE: 0000000003
SCRIPTDATA:
  function printHeader(print)
  {
  	var rmNo = frontol.codeWorkplace;
  	var userName = frontol.currentUser.text;
  	
  	print.printLRStringLF("РМ №" + rmNo, userName, " ");
  	print.printLRStringLF("=","=","=");
  	nextLine(print);
  	printFormLine(print, "В");
  	printFormLine(print, "От покупателя");
  	print.printLRStringLF("_", "_", "_");
  	print.printCenterString("(Ф.И.О.)", " ");
  	nextLine(print, " ");
  	printFormLine(print, "_");
  	printFormLine(print, "Паспорт серии_____ номер");
  	printFormLine(print, "Кем и когда выдан");
  	printFormLine(print, "_");
  	printFormLine(print, "_");
  	printFormLine(print, "Телефон:");
  	print.printCenterString("ЗАЯВЛЕНИЕ", " ");
  	nextLine(print, " ");	
  	print.printString("Прошу принять возврат товара ");
  	nextLine(print, " ");	
  	print.printLRStringLF("(чек № __________ от", ") на", "_");
  	nextLine(print, " ");
  	print.printLRStringLF("сумму", "руб.____коп., сумма ", "_");
  	nextLine(print, " ");
  	printFormLine(print, "прописью (");
  	printFormLine(print, "_");
  	print.printLRStringLF("_", "),", "_");
  	nextLine(print, " ");
  	print.printLRStringLF("дата оплаты ", ", и вернуть", "_");
  	print.printString("уплаченные за него денежные");
  	print.printString("средства.");
  	nextLine(print, " ");
  	printFormLine(print, "Наименование товаров:");
  	printFormLine(print, "_");
  	printFormLine(print, "Причина возврата:");
  	printFormLine(print, "_");
  	printFormLine(print, "     Дата:");
  	printFormLine(print, "  Подпись:");
  }

  function printPosition(print)
  {
  }

  function printFooter(print)
  {
  }

  function nextLine(print)
  {
  	print.printString(" ");
  }

  function printFormLine(print, l)
  {
  	print.printLRStringLF(l, "_", "_");
  	nextLine(print, " ");
  }


NAME: Шаблон РКО для кассовой ленты с автоматическим заполнением
CODE: 0000000004
SCRIPTDATA:
  function printHeader(print)
  {
  	var rmNo = frontol.codeWorkplace;
  	var userName = frontol.currentUser.text;

  	print.printLRStringLF("РМ №" + rmNo, userName, " ");
  	print.printLRStringLF("=","=","=");
  	nextLine(print);
  	printFormLine(print, "РАСХОДНЫЙ КАССОВЫЙ ОРДЕР №");
  	print.printLRStringLF("", "от " + frontol.currentDate, " ");
  	nextLine(print);
  	printFormLine(print, "Код структ. подразделения");
  	printFormLine(print, "Корр. счет");
  	printFormLine(print, "Код анал. учета");
  	printFormLine(print, "Кредит");
  	print.printLRStringLF("Сумма", print.formatCurrency(frontol.currentDocument.totalSum), " ");
  	nextLine(print, " ");
  	printFormLine(print, "Выдать (ФИО)");
  	printFormLine(print, "_");
  	printFormLine(print, "_");
  	print.printLRStringLF("Основание", "ЗАЯВЛЕНИЕ", " ");
  	nextLine(print);
  	printFormLine(print, "Сумма " + print.formatCurrency(frontol.currentDocument.totalSum, "РУБ", "КОП ") + "(");
  	printFormLine(print, "_");	
  	print.printLRStringLF("_","_)","_");
  	nextLine(print);
  	printFormLine(print, "Рук. орг.");
  	printFormLine(print, "Гл. бух.");
  	printFormLine(print, "Получил ________ РУБ ____ КОП (");
  	printFormLine(print, "_");
  	print.printLRStringLF("_", ")", "_");
  	nextLine(print, " ");
  	printFormLine(print, "\"__\" _____ 20__г. Подпись");
  	print.printLRStringLF("По", "_", "_");
  	print.printCenterString("(наимен., номер, дата", " ");
  	nextLine(print, " ");
  	print.printLRStringLF("_", "_", "_");
  	print.printCenterString("и место выдачи документа,", " ");
  	nextLine(print, " ");
  	print.printLRStringLF("_", "_", "_");
  	print.printCenterString("удостоверяющего личность)", " ");
  	nextLine(print, " ");
  	printFormLine(print, "_");
  	printFormLine(print, "_");
  	print.printLRStringLF("Кассир", frontol.currentUser.text, " ");
  	nextLine(print, " ");
  }

  function printPosition(print)
  {
  }

  function printFooter(print)
  {
  }

  function nextLine(print)
  {
  	print.printString(" ");
  }

  function printFormLine(print, l)
  {
  	print.printLRStringLF(l, "_", "_");
  	nextLine(print, " ");
  }


NAME: Шаблон заявления для кассовой ленты с автоматическим заполнением
CODE: 0000000005
SCRIPTDATA:
  function printHeader(print)
  {
  	var rmNo = frontol.codeWorkplace;
  	var userName = frontol.currentUser.text;
  	
  	print.printLRStringLF("РМ №" + rmNo, userName, " ");
  	print.printLRStringLF("=","=","=");
  	nextLine(print);
  	print.printString("В ОАО \"Императорский фарфоровый ");
  	print.printString("завод\"");
  	print.printString("От покупателя");
  	nextLine(print)
  	print.printLRStringLF("_", "_", "_");
  	print.printCenterString("(Ф.И.О.)", " ");
  	nextLine(print)
  	printFormLine(print, "_");
  	printFormLine(print, "Паспорт серии_____ номер");
  	printFormLine(print, "Кем и когда выдан");
  	printFormLine(print, "_");
  	printFormLine(print, "_");
  	printFormLine(print, "Телефон:");
  	print.printCenterString("ЗАЯВЛЕНИЕ", " ");
  	nextLine(print)
  	print.printString("Прошу принять возврат товара");
  	nextLine(print);
  	print.printString("(чек № " + frontol.currentDocument.baseDocumentNumber + " от " +
  		frontol.currentDocument.baseDocumentDateClose + ") на");
  	nextLine(print);

     print.printString("сумму " + print.formatCurrency(frontol.currentDocument.totalSum, "руб., ", "коп., ") + "сумма прописью");
  	nextLine(print);		
  	print.printLRStringLF("(_", "_", "_");
     nextLine(print);	
  	print.printLRStringLF("_", "_)", "_");
  	nextLine(print);
     print.printString("дата оплаты " + frontol.currentDocument.dateClose + ", и вернуть");
  	print.printString("уплаченные за него денежные");
  	print.printString("средства.");
  	nextLine(print);
  	print.printString("Наименование товаров:");
  	nextLine(print);
  }

  function printPosition(print)
  {
  	var number = frontol.currentDocument.position.number;
  	var text = frontol.currentDocument.position.ware.text;
  	var quantity = frontol.currentDocument.position.quantity;
  	var price = print.formatCurrency(frontol.currentDocument.position.price);
  	var sum = print.formatCurrency(frontol.currentDocument.position.sum);
  	print.printLRStringLF(number + ". " + text, 
  		(frontol.currentDocument.position.ware.fracSale ? print.formatQuantity(quantity) : quantity) + " * " + price + " = " + sum, " ");
  }

  function printFooter(print)
  {
  	printFormLine(print, "Причина возврата:");
  	printFormLine(print, "_");
  	print.printLRStringLF(" ","   Дата: ___________________"," ");
  	nextLine(print);
  	print.printLRStringLF(" ","Подпись: ___________________"," ");
  	nextLine(print);
  }

  function nextLine(print)
  {
  	print.printString(" ");
  }

  function printFormLine(print, l)
  {
  	print.printLRStringLF(l, "_", "_");
  	nextLine(print, " ");
  }


NAME: Инвентаризация
CODE: 0000000006
SCRIPTDATA:
  function printHeader(print)
  {
      print.printLRStringLF("РМ №" + frontol.codeWorkplace, frontol.currentUser.text, " ");

      var documentNumber = " №" + print.addCharLeft(frontol.currentDocument.number, "0", 8);
      var sessionNumber = "Смена №"+print.addCharLeft(frontol.sessionNumber, "0", 4);
      print.printLRStringLF(frontol.currentDocument.type.name + documentNumber, sessionNumber, " ");

      print.printLRStringLF("Откр. " + frontol.currentDocument.timeOpen, "Закр. " + frontol.currentDocument.timeClose, " ");
      print.printLRStringLF("=","=","=");
  }

  function printPosition(print)
  {
      if (frontol.currentDocument.position.storno == 1)
          return;

      // Заголовок позиции
      var number = frontol.currentDocument.position.number;
      var text = frontol.currentDocument.position.ware.text;
      print.printString(number + ". " + text);

      // Описание позиции
      var quantity = frontol.currentDocument.position.quantity;
      var price = print.formatCurrency(frontol.currentDocument.position.price);
      var sum = print.formatCurrency(frontol.currentDocument.position.sum);
      print.printLRStringLF("   Было:", frontol.currentDocument.position.ware.initialRemain, " ");
      print.printLRStringLF("   Стало:", frontol.currentDocument.position.ware.remain, " ");

      // Серия товара
      var series = frontol.currentDocument.position.ware.series; 
      if (series != "")
          print.printStringWordWrap("  " + "Серия " + series);

      // Разделитель
      if (frontol.currentDocument.position.number != frontol.currentDocument.position.count)
          print.printLRStringLF("-","-","-")
  }

  function printFooter(print)
  {
      // Количество позиций
      var positionCount = frontol.currentDocument.position.count;
      print.printLRStringLF("Позиций: ", positionCount, " ");
      print.printLRStringLF("=","=","=");
  }


NAME: Постановка/снятие кега
CODE: 0000000007
SCRIPTDATA:
  function printHeader(print)
  {
      print.printLRStringLF("РМ №" + frontol.codeWorkplace, frontol.currentUser.text, " ");

      var documentNumber = " №" + print.addCharLeft(frontol.currentDocument.number, "0", 8);
      var sessionNumber = "Смена №"+print.addCharLeft(frontol.sessionNumber, "0", 4);
      print.printLRStringLF(frontol.currentDocument.type.name + documentNumber, sessionNumber, " ");

      print.printLRStringLF("Откр. " + frontol.currentDocument.timeOpen, "Закр. " + frontol.currentDocument.timeClose, " ");
      print.printLRStringLF("=","=","=");
  }

  function printPosition(print)
  {
  }

  function printFooter(print)
  {
  }


