Показать сообщение отдельно
  #3 (permalink)  
Старый 08.12.2019, 10:03
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,109

vandalv,
function randomValueBetween(min, max) {
    return Math.random() * (max - min) + min;
}
function randomDate(date1 = '01-01-2017', date2 = new Date().toLocaleDateString()) {
  date1 = new Date(date1).getTime();
  date2 = new Date(date2).getTime();
  return new Date(randomValueBetween(date2, date1)).toLocaleDateString()
}
function getElem(arr)
{
  return arr[randomValueBetween(0, arr.length)|0]
}
var sellern = "Dogserf";
var sellernip = "2254913384";
var selleradr = "2592  Davis Place";
var sellerpost = "87918997";
var selleracc = "85090922712148335820";
var firmString="Justsurf,DietyElephant,MetaHound,CuteOx,SweetFrank,PonyMice,BoarsAndInu,KrazyRat,GlumCats,ManedPie,ZipperPuppy,AKCStew,FoxFlock,NerdyLion,SnipeSkull,KittenFur,SilentRabbit,Pupski,BearSide,Mouse17C";
var firms = firmString.split(",");
var adressString="3118  Palmer Road,4996  Watson Lane,504  Hawks Nest Lane,3432  Glory Road,157  Crosswind Drive,3063  New York Avenue,997  Jadewood Drive,1630  Mulberry Lane,1710  Jehovah Drive,409  Monroe Street,3538  Hickman Street,68  Powder House Road,2449  Eagle Drive,1143  Collins Avenue,2848  Snyder Avenue,3797  Willis Avenue,4008  Alexander Avenue,3406  Wines Lane,1610  Gorby Lane";
var adress = adressString.split(",");
var numGen = function(length) {
return Array.from({length}, _=> Math.floor(Math.random()*10)).join("");
};
var vegString=["Apple","Apricots","Avocado","Banana","Blackberries"];
var bases = [];
for (var i = 0; i < 100; )
{
  var base = new Object();
  base.pref = (++i).toString().padStart(5, "0");
  base.sellern = sellern;
  base.sellernip = sellernip;
  base.selleradr = selleradr;
  base.sellerpost = sellerpost;
  base.selleracc = selleracc;
  base.repeated = getElem(firms);
  base.repeated1 = getElem(adress);
  base.account=numGen(20);
  base.postal=numGen(8);
  base.produkt = Array.from({length : 10}, _ => `Produkt ${randomValueBetween(100, 999)|0} ${getElem(vegString)} ${randomValueBetween(1, 100).toFixed(2)}$ ${randomValueBetween(1, 100)|0}p.`).join('\n')
  bases.push(base);
}
for (var k = 0; k < bases.length; k++)
{
  console.log("№ FAKTURY  " + bases[k].pref + "  " + " ---------------------------------------------------------------------------------------------------------- " + "  " + randomDate() + "\n" + "SELLER:     " + bases[k].sellern + "  " + "NIP:  " + bases[k].sellernip + "     " + "ADRESS:  " + bases[k].selleradr + "     " + "ACCOUNT:  " + bases[k].selleracc + "     " + "POSTAL:  " + bases[k].sellerpost + "\n" + "CUSTOMER:  " + bases[k].repeated+ "   ADRESS:  " + bases[k].repeated1+"  ACCOUNT№  "+": "+bases[k].account+"    POSTAL  "+": "+ bases[k].postal+ "\n"+bases[k].produkt);
}
Ответить с цитированием