Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/.nextRelease/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ class Generator {
NL: "Netherlands",
NO: "Norway",
NZ: "New Zealand",
PL: "Poland",
RS: "Serbia",
TR: "Turkey",
UA: "Ukraine",
Expand Down
44 changes: 44 additions & 0 deletions api/.nextRelease/data/PL/inject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { transliterate } = require('transliteration');
const { random, include, pad, randomItem } = require('../../api');

module.exports = (inc, contents, datasets) => {
const lastName = contents.gender === 'male' ? randomItem(datasets['PL'].male_last) : randomItem(datasets['PL'].female_last);

include(inc, contents, 'phone', `+48 ${random(3, 3)} ${random(3, 3)} ${random(3, 3)}`);

include(inc, contents, 'cell', `+48 ${random(3, 3)} ${random(3, 3)} ${random(3, 3)}`);

include(inc, contents, 'id', () => {
const dobDate = new Date(contents.dob.date);
const generatePesel = () => {
const pesel = `${dobDate.getFullYear().toString().slice(-2)
}${pad(dobDate.getMonth() + 1, 2)
}${pad(dobDate.getDate(), 2)
}${random(3, 3)
}${contents.gender === 'male' ? randomItem([1, 3, 5, 7, 9]) : randomItem([0, 2, 4, 6, 8]) // odd number for man, even number for woman
}`
const checksum = 10 - ((pesel[0] * 1 + pesel[1] * 3 + pesel[2] * 7 + pesel[3] * 9 + pesel[4] * 1 + pesel[5] * 3 +
pesel[6] * 7 + pesel[7] * 9 + pesel[8] * 1 + pesel[9] * 3) % 10) % 10;

return `${pesel}${checksum}`;
};
contents.id = {
name: 'PESEL',
value: generatePesel()
}
});

include(inc, contents, 'location', () => {
contents.location.postcode = `${random(3, 2)}-${random(3, 3)}`;
});

include(inc, contents, 'name', () => {
contents.name.title = contents.gender === 'male' ? 'Pan' : 'Pani';
contents.name.last = lastName;
});

include(inc, contents, 'email', () => {
contents.email = transliterate(`${contents.name.first}.${lastName}`).replace(/ /g, '').toLowerCase() + '@example.com';
});

};
Loading