Skip to content

Commit

Permalink
Shipment updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcameron committed Jul 15, 2022
1 parent 97dfe7c commit 3ba9229
Show file tree
Hide file tree
Showing 21 changed files with 421 additions and 248 deletions.
21 changes: 15 additions & 6 deletions client/src/i18n/en/shipment.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"SHIPMENT" : {
"AUTHORIZED": "Authorized",
"ANTICIPATED_DELIVERY_DATE": "Anticipated delivery date",
"BARCODE": "Shipment Barcode",
"COMPLETE_SHIPMENT" : "Mark shipment as complete",
Expand All @@ -18,11 +19,13 @@
"DESTINATION_DEPOT": "Destination depot",
"DOES_SHIPMENT_EXIST": "Do you have a shipment ready?",
"DOES_SHIPMENT_EXIST_HELP": "Please provide the reference of a shipment that is ready to ship.",
"DUELY_RECEIVED_BY": "Duely received by",
"EDIT": "Edit",
"EDIT_SHIPMENT": "Edit Shipment",
"ENTER_SHIPMENT_PROGRESS": "Please enter the shipment progress status. Include the current shipment location if it has changed.",
"ENTER_SHIPMENT_PROGRESS_HELP_TEXT": "Ex. RECEPTION - IMA GOMA WAREHOUSE, GOMA",
"ENTER_STOCK_FOR_SHIPMENT" : "Enter stock for this shipment",
"EXECUTED_BY": "Executed by",
"EXISTING_ASSETS_IN_OTHER_SHIPMENT": "You have the following assets in ongoing shipments. Please send or cancel these shipments so that you can reassign those assets",
"EXISTING_SHIPMENT_AT_DEPOT": "Current shipment in the depot ({{number}})",
"EXIT_STOCK_FOR_SHIPMENT" : "Exit stock for this shipment",
Expand All @@ -45,6 +48,7 @@
"MARK_READY_TO_SHIP_MESSAGE":"You confirm that this shipment is ready to leave the depot.",
"MARK_READY_TO_SHIP_MESSAGE2": "(You will no longer be able to make changes to it.)",

"NAME_FUNCTION_SIGNATURE": "(name, function, signature)",
"NEW_LOCATION": "New Location",
"NEW_SHIPMENT": "New Shipment",
"NOT_DEFINED": "Not Defined",
Expand All @@ -66,28 +70,33 @@
"SHIPMENT_REFERENCE": "Shipment Reference",
"SHIPMENT_REGISTRY": "Shipment Registry",
"SHIPMENT_STATUS": "Shipment Status",
"SHIPPER": "Shipper",
"STOCK_ENTRY_COMPLETE": "Stock entry for shipment completed",
"STOCK_ENTRY_PARTIAL": "Partial stock entry for shipment performed",
"STOCK_EXITED_DONE": "Stock exit performed for the shipment",
"STOCK_REFERENCE": "Stock Reference",
"TITLE" : "Shipment",
"TOTAL_COST": "Total cost",
"TOTAL_QUANTITY": "Total quantity",
"TOTAL_WEIGHT": "Total weight",
"TRACKING_LOG": "Tracking Log",
"TRANSPORTER": "Transporter",
"TRANSPORT_MODE": "Mode of Transport",
"UPDATED": "Shipment successfully updated",
"UPDATE_LOCATION": "Update Location",
"UPDATE_LOCATION_MESSAGE": "You are about to change the location of this shipment, this information will be saved in the history of this shipment",
"UPDATE_LOCATION_WARNING": "You cannot change the location because only shipments with an IN-TRANSIT status can allow the change of location",
"UPDATE_PACKING_LIST": "Update Packing List",
"UPDATE_STATUS": "Update Status",
"STATUS" : {
"EMPTY" : "Empty",
"PARTIAL" : "Partial",
"AT_DEPOT" : "At Origin Depot",
"COMPLETE" : "Complete",
"IN_TRANSIT" : "In Transit",
"DELIVERED" : "Delivered",
"AT_DEPOT" : "At Depot",
"EMPTY" : "Empty",
"IN_TRANSIT" : "In Transit",
"LOST" : "Lost",
"PARTIAL" : "Partial",
"READY_FOR_SHIPMENT" : "Ready for shipment",
"LOST" : "Lost"
"RECEIVED" : "Received"
}
}
}
2 changes: 1 addition & 1 deletion client/src/i18n/en/stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"LEGEND" : "Legend",
"LIFETIME" : "Lifetime",
"LOSS" : "Stock Loss",
"LOT" : "Lot / Batch number",
"LOT" : "Lot",
"LOT_ID" : "Lot ID",
"LOTS" : "Lots",
"LOT_LIFETIME" : "Lifetime by Usage",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/en/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
"TYPE": "Type",
"UNIT": "Unit",
"UNIT_PRICE": "Unit Price",
"UNIT_WEIGHT": "Unit Weight",
"UNPAID_INVOICE_1": "This invoice has not been balanced in ",
"UNPAID_INVOICE_2": " days. Please make sure that the debtor has not made a payment and schedule a recovery ",
"USER": "User",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@
"FOR": "Pour",
"FROM_ACCOUNT": "Du compte",
"FROM": "De",
"FUNCTION": "Fonction",
"FUNCTION_BONUS":"Prime sur la responsabilité",
"GAIN_ACCOUNT": "Compte excedant",
"GENDER": "Genre",
Expand Down
21 changes: 15 additions & 6 deletions client/src/i18n/fr/shipment.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"SHIPMENT" : {
"AUTHORIZED": "Autorisé",
"ANTICIPATED_DELIVERY_DATE": "Date de livraison previsionnelle",
"BARCODE": "Code-barre de l'expédition",
"COMPLETE_SHIPMENT" : "Marquez l'expédition comme complète",
Expand All @@ -18,11 +19,13 @@
"DESTINATION_DEPOT": "Dépôt de destination",
"DOES_SHIPMENT_EXIST": "Avez-vous une expédition prête ?",
"DOES_SHIPMENT_EXIST_HELP": "Veuillez renseigner la référence de l'expédition prête",
"DUELY_RECEIVED_BY": "Pour réception conformé",
"EDIT": "Editer",
"EDIT_SHIPMENT": "Modifier expédition",
"ENTER_SHIPMENT_PROGRESS": "Veuillez entrer l'etat de progression de l'expédition avec sa localisation actuelle",
"ENTER_SHIPMENT_PROGRESS_HELP_TEXT": "Ex. RECEPTION - IMA GOMA WAREHOUSE, GOMA",
"ENTER_STOCK_FOR_SHIPMENT" : "Entrer le stock pour cette expédition",
"EXECUTED_BY": "Executé par",
"EXISTING_ASSETS_IN_OTHER_SHIPMENT": "Vous avez les actifs suivants dans des expéditions en cours. Veuillez envoyer ou annuler ces expéditions afin de pouvoir re-affecter ces actifs",
"EXISTING_SHIPMENT_AT_DEPOT": "Les expéditions en cours dans le dépôt ({{number}})",
"EXIT_STOCK_FOR_SHIPMENT" : "Sortir du stock pour cette expédition",
Expand All @@ -45,6 +48,7 @@
"MARK_READY_TO_SHIP_MESSAGE":"Vous confirmez que cette expédition est prête à quitter le dépôt.",
"MARK_READY_TO_SHIP_MESSAGE2": "(Vous ne pourrez plus y effectuer de modifications.)",

"NAME_FUNCTION_SIGNATURE": "(nom, fonction, signature)",
"NEW_LOCATION": "Nouvelle localisation",
"NEW_SHIPMENT": "Nouvelle expédition",
"NOT_DEFINED": "Non-défini",
Expand All @@ -66,28 +70,33 @@
"SHIPMENT_REFERENCE": "Référence Expédition",
"SHIPMENT_REGISTRY": "Registre des expéditions",
"SHIPMENT_STATUS": "Etat de l'expédition",
"SHIPPER": "Transporteur",
"STOCK_ENTRY_COMPLETE": "Entrée en stock pour l'expédition terminée",
"STOCK_ENTRY_PARTIAL": "Entrée en stock partielle pour l'expédition effectuée",
"STOCK_EXITED_DONE": "Sortie de stock effectuée pour l'expédition",
"STOCK_REFERENCE": "Stock Reférence",
"TITLE" : "Expedition",
"TOTAL_COST": "Côut total",
"TOTAL_QUANTITY": "Quantité totale",
"TOTAL_WEIGHT": "Poids total",
"TRACKING_LOG": "Journal de suivi",
"TRANSPORTER": "Transporteur",
"TRANSPORT_MODE": "Mode de transport",
"UPDATED": "Expédition mis à jour avec succès",
"UPDATE_LOCATION": "Mise à jour localisation",
"UPDATE_LOCATION_MESSAGE": "Vous êtes sur le point de changer la localisation de cette expédition, cette information sera enregistrée dans l'historique de cette expédition",
"UPDATE_LOCATION_WARNING": "Vous ne pouvez pas changer la localisation car seul les expéditions ayant un statut EN-TRANSIT peuvent bénéficier du changement de localisation",
"UPDATE_PACKING_LIST": "Mise à jour colisage",
"UPDATE_STATUS": "Mise à jour statut",
"STATUS" : {
"EMPTY" : "Vide",
"PARTIAL" : "En partie",
"AT_DEPOT" : "Au dépôt d'origine",
"COMPLETE" : "Complète",
"IN_TRANSIT" : "En transit",
"DELIVERED" : "Livré",
"AT_DEPOT" : "Au dépôt",
"EMPTY" : "Vide",
"IN_TRANSIT" : "En transit",
"LOST" : "Perdu",
"PARTIAL" : "En partie",
"READY_FOR_SHIPMENT" : "Prêt pour l'expédition",
"LOST" : "Perdu"
"RECEIVED" : "Récu"
}
}
}
1 change: 1 addition & 0 deletions client/src/i18n/fr/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
"TYPE": "Type",
"UNIT": "Unité",
"UNIT_PRICE": "Prix unitaire",
"UNIT_WEIGHT": "Poids unitaire",
"UNPAID_INVOICE_1": "Cette facture n'a pas été compensée en ",
"UNPAID_INVOICE_2": " jours. Veuillez vous rassuré que le débiteur n'a pas encore effectué un paiement ni même planifié une reprise.",
"USER": "Utilisateur",
Expand Down
1 change: 0 additions & 1 deletion client/src/i18n/fr/tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"FISCAL_YEAR":"Année Fiscale",
"FORMS_CONFIGURATION": "Configuration des formulaires",
"FORMS_MANAGEMENT": "Gestion des formulaires",
"FUNCTION": "Fonction",
"FUNCTION_BONUS_MANAGEMENT":"Gestion des primes sur la responsabilté",
"GENERAL_LEDGER":"Grand Livre",
"GRADES" : "Gestion des Grades",
Expand Down
33 changes: 31 additions & 2 deletions client/src/modules/shipment/create-shipment.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,42 @@
class="form-control"
name="description"
ng-model="CreateShipCtrl.shipment.description"
placeholder="{{ 'FORM.PLACEHOLDERS.NOTES' | translate }}"
ng-maxlength="CreateShipCtrl.maxLength">
placeholder="{{ 'FORM.PLACEHOLDERS.NOTES' | translate }}">
</textarea>
<div class="help-block" ng-messages="ShipmentForm.description.$error" ng-show="ShipmentForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>

<div class="form-group" ng-class="{ 'has-error' : ShipmentForm.$submitted && ShipmentForm.receiver.$invalid }">
<label class="control-label" translate>SHIPMENT.RECEIVER</label>
<div>
<input
name="receiver"
ng-model="CreateShipCtrl.shipment.receiver"
autocomplete="off"
ng-maxlength="100"
class="form-control">
<div class="help-block" ng-messages="ShipmentForm.receiver.$error" ng-show="ShipmentForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<div class="form-group" ng-class="{ 'has-error' : ShipmentForm.$submitted && ShipmentForm.transport_mode.$invalid }">
<label class="control-label" translate>SHIPMENT.TRANSPORT_MODE</label>
<div>
<input
name="transport_mode"
ng-model="CreateShipCtrl.shipment.transport_mode"
autocomplete="off"
ng-maxlength="100"
class="form-control">
<div class="help-block" ng-messages="ShipmentForm.transport_mode.$error" ng-show="ShipmentForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
</div>
</div>

<div class="col-md-4">
Expand Down
60 changes: 51 additions & 9 deletions client/src/modules/shipment/create-shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ angular.module('bhima.controllers')

// dependencies injections
CreateShipmentController.$inject = [
'$state', 'NotifyService', 'util',
'$state', 'NotifyService', 'util', '$translate',
'StockExitFormService', 'uiGridConstants', 'BarcodeService',
'ShipmentService', 'DepotService', '$timeout', 'ShipmentModalService',
'bhConstants',
];

function CreateShipmentController(
$state, Notify, util, StockForm, uiGridConstants, Barcode,
Shipment, Depot, $timeout, ShipmentModal, bhConstants,
$state, Notify, util, $translate,
StockForm, uiGridConstants, Barcode,
Shipment, Depot, $timeout, ShipmentModal,
bhConstants,
) {
const vm = this;

Expand All @@ -21,6 +23,9 @@ function CreateShipmentController(

vm.isCreateState = $state.params.isCreateState;

vm.totalQuantity = 0;
vm.totalWeight = 0;

vm.stockForm = new StockForm('ShipmentForm');
vm.stockForm.setAllowExpired(false);
vm.stockForm.setExitTypePredefined(true);
Expand Down Expand Up @@ -67,13 +72,26 @@ function CreateShipmentController(
displayName : 'TABLE.COLUMNS.QUANTITY',
headerCellFilter : 'translate',
cellTemplate : 'modules/shipment/templates/quantity.tmpl.html',
aggregationType : uiGridConstants.aggregationTypes.sum,
footerCellClass : 'text-right',
footerCellTemplate : `<div class="ui-grid-cell-contents" >
${$translate.instant('SHIPMENT.TOTAL_QUANTITY')}: {{ grid.appScope.totalQuantity }}
</div>`,
}, {
field : 'unit_weight',
width : 150,
displayName : 'TABLE.COLUMNS.UNIT_WEIGHT',
headerCellFilter : 'translate',
cellTemplate : 'modules/shipment/templates/unit_weight.tmpl.html',
footerCellClass : 'text-right',
footerCellTemplate : `<div class="ui-grid-cell-contents" >
${$translate.instant('SHIPMENT.TOTAL_WEIGHT')}: {{ grid.appScope.totalWeight }}
</div>'`,
}, {
field : 'unit_type',
width : 75,
displayName : 'TABLE.COLUMNS.UNIT',
headerCellFilter : 'translate',
cellTemplate : 'modules/stock/exit/templates/unit.tmpl.html',
cellTemplate : 'modules/stock/inventories/templates/unit.tmpl.html',
}, {
field : '_quantity_available',
width : 150,
Expand All @@ -89,10 +107,9 @@ function CreateShipmentController(
],
data : vm.stockForm.store.data,

// fastWatch to false is required for updating the grid correctly for
// inventories loaded from an invoice for patient exit
fastWatch : false,
flatEntityAccess : true,
showColumnFooter : true,
showGridFooter : true,
gridFooterTemplate,
onRegisterApi,
Expand All @@ -103,7 +120,6 @@ function CreateShipmentController(
vm.gridApi = {};
vm.ROW_ERROR_FLAG = bhConstants.grid.ROW_ERROR_FLAG;

vm.maxLength = util.maxLength;
vm.today = new Date();
vm.onChangeDepot = onChangeDepot;
vm.getOverview = getOverview;
Expand All @@ -115,7 +131,17 @@ function CreateShipmentController(
vm.stockForm.setDepotDistribution(depot);
};

function updateTotals() {
vm.totalQuantity = 0;
vm.totalWeight = 0;
vm.stockForm.store.data.forEach(row => {
vm.totalQuantity += row.quantity || 0;
vm.totalWeight += (row.quantity || 0) * (row.unit_weight || 0);
});
}

vm.validateItems = () => {
updateTotals();
vm.stockForm.validate(true);
vm.messages = vm.stockForm.messages();
};
Expand All @@ -125,6 +151,7 @@ function CreateShipmentController(
// Override default quantity for assets
lot.quantity = 1;
}
lot.unit_type = lot.unit; // We seem to handle this differently in different parts of BHIMA!
vm.stockForm.configureItem(row, lot);
vm.validateItems();
};
Expand Down Expand Up @@ -325,11 +352,14 @@ function CreateShipmentController(
}

vm.$loading = true;

vm.shipment = cleanShipment(vm.shipment);

vm.shipment.lots = vm.stockForm.store.data.map(row => ({
lot_uuid : row.lot_uuid,
quantity : row.quantity,
unit_weight : row.unit_weight,
unit_type : row.unit_type,
}));

const promise = !!(vm.isCreateState)
Expand All @@ -355,11 +385,22 @@ function CreateShipmentController(
destination_depot_uuid : shipment.destination_depot_uuid,
name : shipment.name,
description : shipment.description,
note : shipment.note,
transport_mode : shipment.transport_mode,
receiver : shipment.receiver,
anticipated_delivery_date : shipment.anticipated_delivery_date,
};
}

// Re-add any data lost by StockExitForm
// (This is necessary because StockExit does not know about unit_weight)
function updateLotsData(lots) {
vm.stockForm.store.data.forEach(row => {
const lot = lots.find(lt => lt.lot_uuid === row.lot_uuid);
row.unit_weight = lot.unit_weight;
row.unit_type = lot.unit_type;
});
}

// this function
function loadShipment() {
if (!existingShipmentUuid) {
Expand All @@ -385,6 +426,7 @@ function CreateShipmentController(
vm.stockForm.setExitType('depot');
vm.stockForm.setDepotDistribution(destDepot);
vm.stockForm.setLotsFromShipmentList(vm.shipment.lots, 'lot_uuid');
updateLotsData(vm.shipment.lots);
})
.catch(Notify.handleError)
.finally(() => {
Expand Down
Loading

0 comments on commit 3ba9229

Please sign in to comment.