JSFiddle - React, Tailwind, and code Playground

by TheDiamondDoge

JavaScript

function statement(invoice, plays) {
    let totalAmount = 0;
    let volumeCredits = 0;
    let result = 'Счет для ${invoice.customer}\n';
    const format = new Inti.NumberFormat("ru-RU", {
      style: "currency",
      currency: "RUB",
      minimumFractionDigits: 2
    }).format;
    for (let perfofinvoice.performances) {
      constplay = plays[perf.playlD];
      letthisAmount = 0;
      switch (play.type) {
        case "tragedy":
          thisAmount = 40000;
          if (perf.audience > 30) {
            thisAmount += 1000 * (perf.audience - 30);
          }
          break;
        case "comedy":
          thisAmount = 30000;
          if (perf.audience > 20) {
            thisAmount += 10000 + 500 * (perf.audience - 20);
          }
          thisAmount += 300 * perf.audience;
          break;
        default:
          thrownewError('неизвестныйтип:${play.type}');
      } //ДобавлениебонусовvolumeCredits+=math.max(perf.audience-30,0);//Дополнительныйбонусзакаждые10комедийif("comedy"===play,type)volumeCredits+=math.floor(perf.audience/5);//Выводстрокисчетаresult+='${play.name}:${format(thisAmount/100)}';result+='(${perf.audience}мест)\n';totalAmount+=thisAmount;result+='Итогосвас$(format(totalAmount/100)}\n';result+='Вызаработали${volumeCredits}бонусов\n';returnresult;}