Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $scope.recalculateSettlementCurrences = function() {
- $rootScope.doc.settlementsCurrencesReturn = {};
- $rootScope.doc.settlementsCurrencesPayment = {};
- if(!($rootScope.initialized) || $rootScope.delegationsVariables == undefined) {
- // Nic nie robimy bo nie jest zainicjowane
- } else {
- if($rootScope.delegationsVariables.currences == undefined) {
- } else {
- //Leci po wszystkich walutach które są dostępne w dokumencie
- for(var i =0; i < $rootScope.delegationsVariables.currences.length; i++) {
- //Sprawdza czy w zaliczkach jest uzyta taka waluta
- if($rootScope.doc.advenceAmounts.hasOwnProperty($rootScope.delegationsVariables.currences[i])) {
- //var tmpAdvence = $rootScope.doc.advenceAmounts[$rootScope.delegationsVariables.currences[i]];
- var tmpAdvence = $rootScope.singleDelegations.getAdvenceAmountsToSettlementByCurrency($rootScope.delegationsVariables.currences[i]);
- //Sprawdza czy w kosztach jest użyta taka waluta
- if($rootScope.doc.totalValues.hasOwnProperty($rootScope.delegationsVariables.currences[i])) {
- //var tmpCost = $rootScope.doc.totalValues[$rootScope.delegationsVariables.currences[i]];
- var tmpCost = $rootScope.singleDelegations.getCostsAmountsToSettlementByCurrency($rootScope.delegationsVariables.currences[i]);
- if(tmpAdvence > tmpCost) {
- var substraction = tmpAdvence - tmpCost;
- $rootScope.doc.settlementsCurrencesReturn[$rootScope.delegationsVariables.currences[i]] = substraction;
- } else {
- var substraction = tmpCost - tmpAdvence;
- $rootScope.doc.settlementsCurrencesPayment[$rootScope.delegationsVariables.currences[i]] = substraction;
- }
- } else {
- //Jeśli ta waluta była tylko w zaliczkach to wrzuca do zwrotów
- //var tmpAdvence = $rootScope.doc.advenceAmounts[$rootScope.delegationsVariables.currences[i]];
- var tmpAdvence = $rootScope.singleDelegations.getAdvenceAmountsToSettlementByCurrency($rootScope.delegationsVariables.currences[i]);
- $rootScope.doc.settlementsCurrencesReturn[$rootScope.delegationsVariables.currences[i]] = tmpAdvence;
- }
- }
- else {
- //Jeśli nie było w zaliczkach to sprawdza w kosztach
- if($rootScope.doc.totalValues.hasOwnProperty($rootScope.delegationsVariables.currences[i])) {
- //Jeśli jest tylko w kosztach to wrzuca do kosztów do wypłaty
- //var tmpCost = $rootScope.doc.totalValues[$rootScope.delegationsVariables.currences[i]];
- var tmpCost = $rootScope.singleDelegations.getCostsAmountsToSettlementByCurrency($rootScope.delegationsVariables.currences[i]);
- $rootScope.doc.settlementsCurrencesPayment[$rootScope.delegationsVariables.currences[i]] = tmpCost;
- }
- }
- }
- //}
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement