-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(price list) import items from csv file
closes #3893
- Loading branch information
1 parent
6b9d982
commit 545dfe7
Showing
17 changed files
with
342 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
{"PRICE_LIST":{"ADD_ITEMS":"Add an Item", | ||
"ADD_PRICE_LIST":"Add a Price List", | ||
"HELP_TXT_1":"Select an action on the left to edit price list properties", | ||
"HELP_TXT_2":"Edit the price list's metadata", | ||
"HELP_TXT_3":"Remove the price list", | ||
"ITEMS":"Items", | ||
"NEW_PRICE_LIST":"New Price List", | ||
"NO_RECORDS":"No Records", | ||
"NONE":"Apply no price list", | ||
"PRICE_LIST_ITEMS":"Price list items", | ||
"TITLE":"Price List Management", | ||
"UNABLE_TO_DELETE":"Price list cannot be deleted - it may currently be assigned to patient / debtor groups", | ||
"UPDATE":"Update a Price List", | ||
"ERRORS":{"HAS_NEGATIVE_PRICE":"You cannot assign a negative price to an item. Please either assign a positive percentage, a negative percentage, or a positive value."}}} | ||
{ | ||
"PRICE_LIST": { | ||
"ADD_ITEMS": "Add an Item", | ||
"ADD_PRICE_LIST": "Add a Price List", | ||
"HELP_TXT_1": "Select an action on the left to edit price list properties", | ||
"HELP_TXT_2": "Edit the price list's metadata", | ||
"HELP_TXT_3": "Remove the price list", | ||
"ITEMS": "Items", | ||
"NEW_PRICE_LIST": "New Price List", | ||
"NO_RECORDS": "No Records", | ||
"NONE": "Apply no price list", | ||
"PRICE_LIST_ITEMS": "Price list items", | ||
"TITLE": "Price List Management", | ||
"UNABLE_TO_DELETE": "Price list cannot be deleted - it may currently be assigned to patient / debtor groups", | ||
"UPDATE": "Update a Price List", | ||
"ERRORS": { | ||
"HAS_NEGATIVE_PRICE": "You cannot assign a negative price to an item. Please either assign a positive percentage, a negative percentage, or a positive value." | ||
}, | ||
"IMPORT": { | ||
"PRICE_LIST_ITEMS_DESCRIPTION": "You are about to import inventories's prices for this price list from a csv file", | ||
"PRICE_LIST_ITEMS": "Click here for downloading price list items template file" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
{"PRICE_LIST":{"ADD_ITEMS":"Ajouter un Item", | ||
"ADD_PRICE_LIST":"Ajouter une Liste", | ||
"HELP_TXT_1":"Choisir une action à gauche pour editer la liste de prix", | ||
"HELP_TXT_2":"Éditer les metadonnées de la Liste", | ||
"HELP_TXT_3":"Effacer la Liste", | ||
"ITEMS":"Items", | ||
"NEW_PRICE_LIST":"Nouvelle Liste des Prix", | ||
"NO_RECORDS":"Pas d'enregistrement", | ||
"NONE":"Appliquer aucune liste de prix", | ||
"PRICE_LIST_ITEMS":"Eléments de la liste des prix", | ||
"TITLE":"Liste des Prix", | ||
"UNABLE_TO_DELETE":"La liste de prix ne peut être supprimer - car elle peut être courament assignée à un groupe de patient / Groupes Débiteurs", | ||
"UPDATE":"Mettre à jour une liste de prix", | ||
"ERRORS":{"HAS_NEGATIVE_PRICE":"Vous ne pouvez pas assigner une valeur negatif."}}} | ||
{ | ||
"PRICE_LIST": { | ||
"ADD_ITEMS": "Ajouter un Item", | ||
"ADD_PRICE_LIST": "Ajouter une Liste", | ||
"HELP_TXT_1": "Choisir une action à gauche pour editer la liste de prix", | ||
"HELP_TXT_2": "Éditer les metadonnées de la Liste", | ||
"HELP_TXT_3": "Effacer la Liste", | ||
"ITEMS": "Items", | ||
"NEW_PRICE_LIST": "Nouvelle Liste des Prix", | ||
"NO_RECORDS": "Pas d'enregistrement", | ||
"NONE": "Appliquer aucune liste de prix", | ||
"PRICE_LIST_ITEMS": "Eléments de la liste des prix", | ||
"TITLE": "Liste des Prix", | ||
"UNABLE_TO_DELETE": "La liste de prix ne peut être supprimer - car elle peut être courament assignée à un groupe de patient / Groupes Débiteurs", | ||
"UPDATE": "Mettre à jour une liste de prix", | ||
"ERRORS": { | ||
"HAS_NEGATIVE_PRICE": "Vous ne pouvez pas assigner une valeur negatif." | ||
}, | ||
"IMPORT": { | ||
"PRICE_LIST_ITEMS_DESCRIPTION": "Vous êtes sur le point d'importer les prix des inventaires pour cette liste des prix à partir d'un fichier CSV", | ||
"PRICE_LIST_ITEMS": "Cliquez ici pour télécharger le fichier modèle pour l'importation des prix" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<form name="ActionForm" bh-submit="ModalCtrl.submit(ActionForm)" novalidate> | ||
<div class="modal-header"> | ||
<ol class="headercrumb"> | ||
<li class="static" translate>FORM.LABELS.PRICE_LIST</li> | ||
<li class="title text-capitalize"> | ||
{{ModalCtrl.priceList.description}} | ||
</li> | ||
</ol> | ||
</div> | ||
<div class="modal-body" data-import-modal> | ||
<div class="alert alert-info"> | ||
<p translate>PRICE_LIST.IMPORT.PRICE_LIST_ITEMS_DESCRIPTION</p> | ||
<a ng-click="ModalCtrl.downloadTemplate()" href> | ||
<i class="fa fa-cloud-download"></i> | ||
<span translate>PRICE_LIST.IMPORT.PRICE_LIST_ITEMS</span> | ||
</a> | ||
</div> | ||
|
||
<div class="form-group" | ||
ng-class="{ 'has-error' : ModalCtrl.noSelectedFile }"> | ||
<label translate>ACCOUNT.IMPORT.LOAD_FROM_FILE</label> | ||
<input | ||
id="import-input" | ||
accept=".csv" | ||
class="form-control" | ||
type="file" | ||
name="file" | ||
ng-model="ModalCtrl.file" | ||
ngf-select="ModalCtrl.select(ModalCtrl.file)"> | ||
<div class="help-block" data-error-message ng-show="ModalCtrl.noSelectedFile"> | ||
<i class="fa fa-warning"></i> <span translate>INVENTORY.NO_FILE_SELECTED</span> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-default" data-method="cancel" | ||
ng-click="ModalCtrl.cancel()"> | ||
<span translate>FORM.BUTTONS.CANCEL</span> | ||
</button> | ||
|
||
<bh-loading-button | ||
disabled="!ModalCtrl.file" | ||
loading-state="ActionForm.$loading"> | ||
</bh-loading-button> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
angular.module('bhima.controllers') | ||
.controller('ImportPriceListModalController', ImportPriceListModalController); | ||
|
||
ImportPriceListModalController.$inject = [ | ||
'data', '$uibModalInstance', 'InventoryService', | ||
'Upload', 'NotifyService', 'PriceListService', | ||
]; | ||
|
||
function ImportPriceListModalController(data, Instance, Inventory, Upload, Notify, PriceList) { | ||
const vm = this; | ||
|
||
vm.downloadTemplate = Inventory.downloadInventoriesTemplate; | ||
vm.cancel = Instance.close; | ||
vm.priceList = data; | ||
vm.select = (file) => { | ||
vm.noSelectedFile = !file; | ||
}; | ||
|
||
vm.downloadTemplate = PriceList.downloadTemplate; | ||
|
||
vm.submit = () => { | ||
// send data only when a file is selected | ||
if (!vm.file) { | ||
vm.noSelectedFile = true; | ||
return; | ||
} | ||
|
||
uploadFile(vm.file); | ||
}; | ||
|
||
/** upload the file to server */ | ||
function uploadFile(file) { | ||
vm.uploadState = 'uploading'; | ||
|
||
const params = { | ||
url : '/prices/item/import', | ||
data : { file, pricelist_uuid : data.uuid }, | ||
}; | ||
|
||
// upload the file to the server | ||
Upload.upload(params) | ||
.then(handleSuccess, Notify.handleError, handleProgress); | ||
|
||
// success upload handler | ||
function handleSuccess() { | ||
vm.uploadState = 'uploaded'; | ||
Notify.success('INVENTORY.UPLOAD_SUCCESS'); | ||
Instance.close(); | ||
} | ||
|
||
// progress handler | ||
function handleProgress(evt) { | ||
file.progress = Math.min(100, parseInt((100.0 * evt.loaded) / evt.total, 10)); | ||
vm.progressStyle = { width : String(file.progress).concat('%') }; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.