Skip to content

Commit

Permalink
Renaming tags to barcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbayopanda committed Feb 3, 2022
1 parent 9d2b915 commit c1804a3
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 41 deletions.
8 changes: 4 additions & 4 deletions client/src/js/services/LotService.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
angular.module('bhima.services')
.service('LotService', LotService);

LotService.$inject = ['PrototypeApiService', '$http', 'util'];
LotService.$inject = ['PrototypeApiService', '$http', 'util', '$window'];

function LotService(Api, $http, util) {
function LotService(Api, $http, util, $window) {
const lots = new Api('/lots/');

lots.read = (uuid) => {
Expand Down Expand Up @@ -82,8 +82,8 @@ function LotService(Api, $http, util) {
.then(util.unwrapHttpResponse);
};

lots.generateTags = (number) => {
return window.open(`/lots/generate_barcodes/${number}`);
lots.generateAssetTags = (number) => {
return $window.open(`/lots/generate_barcodes/${number}`);
};

/**
Expand Down
6 changes: 3 additions & 3 deletions client/src/modules/stock/StockModal.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function StockModalService(Modal) {
service.openLotScheduleModal = openLotScheduleModal;
service.openAMCCalculationModal = openAMCCalculationModal;
service.openConsumptionByLots = openConsumptionByLots;
service.openGenerateTagNumbers = openGenerateTagNumbers;
service.openGenerateAssetBarcodes = openGenerateAssetBarcodes;

// generate tag numbers
function openGenerateTagNumbers(request) {
function openGenerateAssetBarcodes(request) {
const params = angular.extend(modalParameters, {
templateUrl : 'modules/stock/entry/modals/generateTags.modal.html',
templateUrl : 'modules/stock/entry/modals/generateAssetTags.modal.html',
controller : 'GenerateTagsModalController',
controllerAs : '$ctrl',
resolve : { data : () => request },
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/stock/entry/entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</a>
</bh-dropdown-menu-item>
<bh-dropdown-menu-item>
<a href="" ng-click="StockCtrl.generateTagNumbers()">
<a href="" ng-click="StockCtrl.generateAssetBarcodes()">
<i class="fa fa-barcode"></i> <span translate>STOCK.GENERATE_TAG_NUMBERS</span>
</a>
</bh-dropdown-menu-item>
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/stock/entry/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function StockEntryController(
vm.reset = reset;
vm.onDateChange = onDateChange;
vm.$loading = false;
vm.generateTagNumbers = StockModal.openGenerateTagNumbers;
vm.generateAssetBarcodes = StockModal.openGenerateAssetBarcodes;

vm.gridOptions = {
appScopeProvider : vm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
name="totalTags"
type="number"
step="1"
max="500"
ng-max="500"
class="form-control"
ng-model="$ctrl.totalTags"
translate-attr="{ 'placeholder' : 'FORM.PLACEHOLDERS.TAG_NUMBER_TO_GENERATE' }">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ function GenerateTagsModalController(Instance, Lots) {

vm.cancel = cancel;

vm.submit = () => {
if (!vm.totalTags || vm.totalTags > 500) { return null; }
vm.submit = form => {
if (form.$invalid) { return null; }

return Lots.generateTags(vm.totalTags);
return Lots.generateAssetTags(vm.totalTags);
};

// cancel
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
"express-handlebars": "^6.0.2",
"express-session": "^1.17.2",
"font-awesome": "^4.7.0",
"fs-extra": "^10.0.0",
"handlebars": "^4.7.7",
"helmet": "^5.0.1",
"inline-source": "^7.1.0",
Expand All @@ -136,7 +135,6 @@
"nodemailer": "^6.7.1",
"p-retry": "^4.6.1",
"pako": "^2.0.4",
"pdf-merge": "^1.2.0",
"pdf-merger-js": "^3.3.2",
"q": "^1.5.1",
"qrcode": "^1.5.0",
Expand Down
20 changes: 10 additions & 10 deletions server/controllers/stock/lots.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,29 +457,29 @@ function assignments(req, res, next) {
}

/**
* GET /lots/generate_tags/:number
* GET /lots/generate_barcodes/:number
*
* @description
* Returns generated barcodes in a zip file
*/
async function generateBarcodes(req, res, next) {

try {
const totalTags = req.params.number;
const totalBarcodes = req.params.number;
const { key } = identifiers.LOT;
const tagNumbers = [];
const barcodeList = [];

for (let i = 0; i < totalTags; i++) {
tagNumbers.push({ barcode : barcode.generate(key, util.uuid()) });
for (let i = 0; i < totalBarcodes; i++) {
barcodeList.push({ barcode : barcode.generate(key, util.uuid()) });
}

// create the csv file of tag numbers
const data = await converter.json2csvAsync(tagNumbers, { trimHeaderFields : true, trimFieldValues : true });
const data = await converter.json2csvAsync(barcodeList, { trimHeaderFields : true, trimFieldValues : true });
const tmpCsvFile = tempy.file({ name : 'barcodes.csv' });
await fs.promises.writeFile(tmpCsvFile, data);

// create the pdf file of tag numbers
const pdfTickets = await genPdfTickets(tagNumbers);
const pdfTickets = await genPdfTickets(barcodeList);
const tmpPdfFile = path.join(pdfTickets.path);

// create a zip file for the csv and pdf files
Expand All @@ -491,10 +491,10 @@ async function generateBarcodes(req, res, next) {

}

async function genPdfTickets(tagNumbers) {
const context = { tagNumbers };
async function genPdfTickets(barcodeList) {
const context = { barcodeList };
const tmpDocumentsFile = tempy.file({ name : `barcodes.pdf` });
const template = './server/controllers/stock/reports/tag_numbers.handlebars';
const template = './server/controllers/stock/reports/asset_barcodes.handlebars';

const options = {
path : tmpDocumentsFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</style>

<div class="container">
{{#each tagNumbers as | tagNumber |}}
{{#each barcodeList as | tagNumber |}}
<div class="label ticket">
<svg
class="barcode"
Expand Down
16 changes: 1 addition & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6668,15 +6668,6 @@ pathval@^1.1.1:
resolved "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d"
integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==

pdf-merge@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/pdf-merge/-/pdf-merge-1.2.0.tgz#a15d155e6e6fcff2e34148c6b8960119c5273593"
integrity sha512-/2QygIR3Q/p0SxUhj64LvUzYFVzFL8DQGV8GOpG3I44uXwSTiMS7tAd3dHvxLrnGYLzom2IPdlhnxqLyOC41VQ==
dependencies:
bluebird "^3.5.1"
shell-escape "^0.2.0"
tmp "0.0.33"

pdf-merger-js@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/pdf-merger-js/-/pdf-merger-js-3.3.2.tgz#32f0f0b0c56375f2c3557f52cda1b43b1d1cca8b"
Expand Down Expand Up @@ -7870,11 +7861,6 @@ shebang-regex@^3.0.0:
resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==

shell-escape@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/shell-escape/-/shell-escape-0.2.0.tgz#68fd025eb0490b4f567a027f0bf22480b5f84133"
integrity sha1-aP0CXrBJC09WegJ/C/IkgLX4QTM=

shelljs@0.8.5:
version "0.8.5"
resolved "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c"
Expand Down Expand Up @@ -8614,7 +8600,7 @@ tmp@0.0.30:
dependencies:
os-tmpdir "~1.0.1"

tmp@0.0.33, tmp@^0.0.33:
tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
Expand Down

0 comments on commit c1804a3

Please sign in to comment.