@@ -272,10 +272,10 @@
-
+
-
+
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts
index 8eebd8b22..3aca4522f 100755
--- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts
+++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/financial-info/financial-info.component.ts
@@ -205,9 +205,6 @@ export class FinancialInfoComponent implements OnInit {
// }
-
-
-
/** CREATING financial Statement ( financial_year AutoGenerate ) */
createDate(date) {
return this.fb.group({
@@ -418,7 +415,7 @@ export class FinancialInfoComponent implements OnInit {
let array = this.financialForm.controls['date_per_financial'];
let prev_annual_sale = array.value[index-1].financial_annual_sale;
let annual_sale_variation = (( annual_sale - prev_annual_sale)/prev_annual_sale) * 100 ;
- detail.controls.financial_annualsales_variation.setValue(annual_sale_variation.toFixed(2));
+ detail.controls.financial_annualsales_variation.setValue(annual_sale_variation!= Infinity ? annual_sale_variation.toFixed(2):0);
}
}
@@ -429,7 +426,7 @@ export class FinancialInfoComponent implements OnInit {
let array = this.financialForm.controls['estimated_value'];
let prev_annual_sale = array.value[index-1].estimate_annual_sale;
let annual_sale_variation = (( annual_sale - prev_annual_sale)/prev_annual_sale) * 100 ;
- detail.controls.estimate_annualsales_variation.setValue(annual_sale_variation.toFixed(2));
+ detail.controls.estimate_annualsales_variation.setValue(annual_sale_variation!= Infinity ? annual_sale_variation.toFixed(2):0);
}
}
@@ -464,7 +461,7 @@ export class FinancialInfoComponent implements OnInit {
let variation = (((profit != '' ? profit : loss ) - (prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? Math.abs(prev_profit) : Math.abs(prev_loss))) * 100;
- detail.controls.financial_variation.setValue(variation.toFixed(2));
+ detail.controls.financial_variation.setValue(variation!= Infinity ? variation.toFixed(2):0);
}
}
}
@@ -508,7 +505,7 @@ export class FinancialInfoComponent implements OnInit {
}
else{
profit_margin = (profit / salary) * 100;
- detail.controls.financial_margin_of_profit.setValue(profit_margin.toFixed(2));
+ detail.controls.financial_margin_of_profit.setValue(profit_margin!= Infinity ? profit_margin.toFixed(2):0);
}
}
@@ -528,7 +525,7 @@ export class FinancialInfoComponent implements OnInit {
}
else{
loss_margin = (loss / salary) * 100 * (-1);
- detail.controls.financial_margin_of_loss.setValue(loss_margin.toFixed(2));
+ detail.controls.financial_margin_of_loss.setValue(loss_margin != Infinity ? loss_margin.toFixed(2): 0);
// detail.controls.financial_margin.disable()
}
}
@@ -582,7 +579,7 @@ export class FinancialInfoComponent implements OnInit {
let variation = (((profit != '' ? profit : loss ) - ( prev_profit != '' ? prev_profit : prev_loss ))/ (prev_profit != '' ? Math.abs(prev_profit) : Math.abs(prev_loss))) * 100;
- detail.controls.estimate_variation.setValue(variation.toFixed(2));
+ detail.controls.estimate_variation.setValue(variation!= Infinity ? variation.toFixed(2) : 0);
}
}
@@ -598,7 +595,7 @@ export class FinancialInfoComponent implements OnInit {
if (salary != '' && profit != '') {
let margin = profit / salary * 100;
- detail.controls.estimate_margin_of_profit.setValue(margin.toFixed(2));
+ detail.controls.estimate_margin_of_profit.setValue(margin!= Infinity ? margin.toFixed(2):0);
}
}
else if (detail.value.estimate_profit_or_loss == 2){
@@ -606,7 +603,7 @@ export class FinancialInfoComponent implements OnInit {
let loss = detail.value.estimate_net_loss;
if (salary != '' && loss != '') {
let margin = (loss / salary) * 100 * (-1);
- detail.controls.estimate_margin_of_loss.setValue(margin.toFixed(2));
+ detail.controls.estimate_margin_of_loss.setValue(margin!= Infinity ? margin.toFixed(2):0);
}
}
@@ -619,7 +616,7 @@ export class FinancialInfoComponent implements OnInit {
let margin_profit = detail.value.estimate_margin_of_profit;
if (salary != '' && margin_profit != '') {
let profit = (margin_profit/100)*salary;
- detail.controls.estimate_net_profit.setValue(profit.toFixed(2));
+ detail.controls.estimate_net_profit.setValue(profit!= Infinity ? profit.toFixed(2):0);
this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(profit);
}
@@ -628,7 +625,7 @@ export class FinancialInfoComponent implements OnInit {
let margin_loss = detail.value.estimate_margin_of_loss;
if (salary != '' && margin_loss != '') {
let loss = (margin_loss/100)*salary*(-1);
- detail.controls.estimate_net_loss.setValue(loss.toFixed(2));
+ detail.controls.estimate_net_loss.setValue(loss!= Infinity ? loss.toFixed(2):0);
this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(loss);
}
}
@@ -640,6 +637,13 @@ export class FinancialInfoComponent implements OnInit {
let estimate_sales_to = +details.value.estimate_sales_to;
if (estimate_sales_from != null && estimate_sales_to != null){
+
+ if(+estimate_sales_from>+estimate_sales_to){
+ alert("Given To value is lower than From Value");
+ details.controls.estimate_sales_to.setValue('');
+ details.controls.estimate_sales_average.setValue('');
+ return;
+ }
let C = (estimate_sales_to - estimate_sales_from)
let D = (C / estimate_sales_from) * 100;
@@ -648,46 +652,46 @@ export class FinancialInfoComponent implements OnInit {
if(D >= 20){
var r = confirm("Given Sales Range is greater than 20%");
if (r == true) {
- details.controls.estimate_sales_to.setValue(estimate_sales_to);
+ details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0);
}else{
details.controls.estimate_sales_to.setValue('');
return;
}
}
else{
- details.controls.estimate_sales_to.setValue(estimate_sales_to);
+ details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0);
}
}
else if(estimate_sales_from > 5000000 || estimate_sales_from <= 10000000){
if(D >= 15){
var r = confirm("Given Sales Range is greater than 15%");
if (r == true) {
- details.controls.estimate_sales_to.setValue(estimate_sales_to);
+ details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0);
}else{
details.controls.estimate_sales_to.setValue('');
return;
}
}
else{
- details.controls.estimate_sales_to.setValue(estimate_sales_to);
+ details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0);
}
}
else if(estimate_sales_from > 10000000){
if(D >= 10){
var r = confirm("Given Sales Range is greater than 10%");
if (r == true) {
- details.controls.estimate_sales_to.setValue(estimate_sales_to);
+ details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0);
}else{
details.controls.estimate_sales_to.setValue('');
return;
}
}
else{
- details.controls.estimate_sales_to.setValue(estimate_sales_to);
+ details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0);
}
}
else{
- details.controls.estimate_sales_to.setValue(estimate_sales_to);
+ details.controls.estimate_sales_to.setValue(estimate_sales_to!= Infinity ? estimate_sales_to:0);
}
// if(D >= 30){
@@ -719,11 +723,11 @@ export class FinancialInfoComponent implements OnInit {
let higer = ((+estimate_sales_to + +estimate_sales_from) / 2);
if(lower > higer){
- details.controls.estimate_sales_average.setValue(higer.toFixed(2));
+ details.controls.estimate_sales_average.setValue(higer!= Infinity ? higer.toFixed(2):0);
this.AV_SalesInwords[i] = this._pd.convertNumberToWords(Math.round(higer));
}
else{
- details.controls.estimate_sales_average.setValue(lower.toFixed(2));
+ details.controls.estimate_sales_average.setValue(lower!= Infinity ? lower.toFixed(2):0);
this.AV_SalesInwords[i] = this._pd.convertNumberToWords(Math.round(lower));
}
@@ -737,19 +741,55 @@ export class FinancialInfoComponent implements OnInit {
calculateMarginProfit( i, details){
let sales_average = details.value.estimate_sales_average;
+ if(sales_average == ''){
+ alert("Considered Sales Average is Empty");
+ details.controls.estimate_profit_range_from.setValue('');
+ details.controls.estimate_profit_range_to.setValue('');
+ details.controls.estimate_profit_margin.setValue('');
+ details.controls.estimate_profit_margin_percent.setValue('');
+ return;
+ }
let estimate_profit_range_from = details.value.estimate_profit_range_from;
+ if(+estimate_profit_range_from > 100){
+ alert('Given Profit percent is More Than 100');
+ details.controls.estimate_profit_range_from.setValue('');
+ details.controls.estimate_profit_range_to.setValue('');
+ details.controls.estimate_profit_margin.setValue('');
+ details.controls.estimate_profit_margin_percent.setValue('');
+ return;
+
+ }
+
let estimate_profit_range_to = details.value.estimate_profit_range_to;
+
+ if(+estimate_profit_range_to > 100){
+ alert('Given Profit percent is More Than 100');
+ details.controls.estimate_profit_range_to.setValue('');
+ details.controls.estimate_profit_margin.setValue('');
+ details.controls.estimate_profit_margin_percent.setValue('');
+ return;
+
+ }
if (sales_average != '' && estimate_profit_range_from != '' && estimate_profit_range_to != ''){
+ if(+estimate_profit_range_from>+estimate_profit_range_to){
+ alert("Given To value is lower than From Value");
+ details.controls.estimate_profit_range_to.setValue('');
+ details.controls.estimate_profit_margin.setValue('');
+ details.controls.estimate_profit_margin_percent.setValue('');
+ return;
+ }
+
let profit_percent = (estimate_profit_range_to + estimate_profit_range_from)/2;
let Profit_Average = (profit_percent*sales_average)/100;
+ let difference = (estimate_profit_range_to - estimate_profit_range_from);
- if(Profit_Average >= 3){
- var r = confirm("Given Profit Range is greater than 3%");
+ if(difference > 3){
+ var r = confirm("Given Profit Percent Range is greater than 3");
if (r == true) {
- details.controls.estimate_profit_margin.setValue(Math.round(Profit_Average));
- details.controls.estimate_profit_margin_percent.setValue(profit_percent.toFixed(2));
+ details.controls.estimate_profit_margin.setValue(Profit_Average!= Infinity ? Math.round(Profit_Average):0);
+ details.controls.estimate_profit_margin_percent.setValue(profit_percent!= Infinity ? profit_percent.toFixed(2):0);
this.AV_marginProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(Profit_Average));
}else{
details.controls.estimate_profit_range_to.setValue('');
@@ -758,10 +798,10 @@ export class FinancialInfoComponent implements OnInit {
return;
}
}
- else{
- alert('else part');
- }
-
+
+ details.controls.estimate_profit_margin.setValue(Profit_Average!= Infinity ? Math.round(Profit_Average):0);
+ details.controls.estimate_profit_margin_percent.setValue(profit_percent!= Infinity ? profit_percent.toFixed(2):0);
+ this.AV_marginProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(Profit_Average));
// details.controls.estimate_profit_margin.setValue(Math.round(Profit_Average));
// details.controls.estimate_profit_margin_percent.setValue(profit_percent.toFixed(2));
@@ -774,65 +814,214 @@ export class FinancialInfoComponent implements OnInit {
calculateProfitAmount( i, details){
let sales_average = details.value.estimate_sales_average;
+ if(sales_average == ''){
+ alert("Considered Sales Average is Empty");
+ details.controls.estimate_net_profit_from.setValue('');
+ details.controls.estimate_net_profit_to.setValue('');
+ details.controls.estimate_net_profit.setValue('');
+ details.controls.estimate_net_profit_percent.setValue('');
+ return;
+ }
let estimate_net_profit_from = details.value.estimate_net_profit_from;
let estimate_net_profit_to = details.value.estimate_net_profit_to;
+ if(+estimate_net_profit_to>+sales_average){
+
+ alert("Given Profit is Greater than Sales");
+ details.controls.estimate_net_profit_from.setValue('');
+ details.controls.estimate_net_profit_to.setValue('');
+ details.controls.estimate_net_profit.setValue('');
+ details.controls.estimate_net_profit_percent.setValue('');
+ return;
+ }
+
+
if (sales_average != '' && estimate_net_profit_from != '' && estimate_net_profit_to != ''){
-
- let profit_amount = (estimate_net_profit_to + estimate_net_profit_from)/2;
- let Profit_percent = (profit_amount/sales_average)*100;
+ if(+estimate_net_profit_from>+estimate_net_profit_to){
+ alert("Given To value is lower than From Value");
+ details.controls.estimate_net_profit_to.setValue('');
+ details.controls.estimate_net_profit.setValue('');
+ details.controls.estimate_net_profit_percent.setValue('');
+ return;
+ }
+
+ let C = (estimate_net_profit_to - estimate_net_profit_from)
+ let D = (C / estimate_net_profit_from) * 100;
+
+ let range1 = +estimate_net_profit_from/10;
+
+ let lower = (+estimate_net_profit_from)+range1;
+ let higer = ((+estimate_net_profit_to + +estimate_net_profit_from) / 2);
- // details.controls.estimate_net_profit.setValue(Math.round(profit_amount));
- // details.controls.estimate_net_profit_percent.setValue(Profit_percent.toFixed(2));
-
- // this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(profit_amount));
- if(Profit_percent >= 3){
- var r = confirm("Given Profit Percentage is greater than 3%");
+ if(estimate_net_profit_from <= 5000000){
+ if(D >= 20){
+ var r = confirm("Given Profit Range is greater than 20%");
if (r == true) {
-
- details.controls.estimate_net_profit.setValue(Math.round(profit_amount));
- details.controls.estimate_net_profit_percent.setValue(Profit_percent.toFixed(2));
- this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(profit_amount));
-
+ details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0);
}else{
-
details.controls.estimate_net_profit_to.setValue('');
details.controls.estimate_net_profit.setValue('');
details.controls.estimate_net_profit_percent.setValue('');
return;
-
}
+ }
+ else{
+ details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0);
+ }
+
+ if(lower > higer){
+ details.controls.estimate_net_profit.setValue(higer!= Infinity ? higer.toFixed(2):0);
+ let Profit_percent = (higer/sales_average)*100;
+ details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0);
+ this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer));
+ }
+ else{
+ details.controls.estimate_net_profit.setValue(lower!= Infinity ? lower.toFixed(2):0);
+ let Profit_percent = (lower/sales_average)*100;
+ details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0);
+ this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower));
+ }
+ }
+ else if(estimate_net_profit_from > 5000000 || estimate_net_profit_from <= 10000000){
+ if(D >= 15){
+ var r = confirm("Given Sales Range is greater than 15%");
+ if (r == true) {
+ details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0);
+
+ }else{
+ details.controls.estimate_net_profit_to.setValue('');
+ details.controls.estimate_net_profit.setValue('');
+ details.controls.estimate_net_profit_percent.setValue('');
+ return;
+ }
+ }
+ else{
+ details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0);
+ }
+
+ if(lower > higer){
+ details.controls.estimate_net_profit.setValue(higer!= Infinity ? higer.toFixed(2):0);
+ let Profit_percent = (higer/sales_average)*100;
+ details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0);
+ this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer));
+ }
+ else{
+ details.controls.estimate_net_profit.setValue(lower!= Infinity ? lower.toFixed(2):0);
+ let Profit_percent = (lower/sales_average)*100;
+ details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0);
+ this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower));
+ }
+
+ }
+ else if(estimate_net_profit_from > 10000000){
+ if(D >= 10){
+ var r = confirm("Given Sales Range is greater than 10%");
+ if (r == true) {
+ details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0);
+ }else{
+ details.controls.estimate_net_profit_to.setValue('');
+ details.controls.estimate_net_profit.setValue('');
+ details.controls.estimate_net_profit_percent.setValue('');
+ return;
+ }
+ }
+ else{
+ details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0);
+ }
+
+ if(lower > higer){
+ details.controls.estimate_net_profit.setValue(higer!= Infinity ? higer.toFixed(2):0);
+ let Profit_percent = (higer/sales_average)*100;
+ details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0);
+ this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer));
+ }
+ else{
+ details.controls.estimate_net_profit.setValue(lower!= Infinity ? lower.toFixed(2):0);
+ let Profit_percent = (lower/sales_average)*100;
+ details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0);
+ this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower));
+ }
}
else{
- alert('else part');
+ details.controls.estimate_net_profit_to.setValue(estimate_net_profit_to!= Infinity ? estimate_net_profit_to:0);
+ if(lower > higer){
+ details.controls.estimate_net_profit.setValue(higer!= Infinity ? higer.toFixed(2):0);
+ let Profit_percent = (higer/sales_average)*100;
+ details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0);
+ this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer));
+ }
+ else{
+ details.controls.estimate_net_profit.setValue(lower!= Infinity ? lower.toFixed(2):0);
+ let Profit_percent = (lower/sales_average)*100;
+ details.controls.estimate_net_profit_percent.setValue(Profit_percent!= Infinity ? Profit_percent.toFixed(2):0);
+ this.AV_netProfitAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower));
+ }
}
}
-
+
}
calculateMarginLoss( i, details){
let sales_average = details.value.estimate_sales_average;
+ if(sales_average == ''){
+ alert("Considered Sales Average is Empty");
+ details.controls.estimate_loss_range_from.setValue('');
+ details.controls.estimate_loss_range_to.setValue('');
+ details.controls.estimate_loss_margin.setValue('');
+ details.controls.estimate_loss_margin_percent.setValue('');
+ return;
+ }
+ // else{
let estimate_loss_range_from = details.value.estimate_loss_range_from;
+ if(+estimate_loss_range_from > 100){
+ alert('Given Loss Percent is more than 100');
+ details.controls.estimate_loss_range_from.setValue('');
+ details.controls.estimate_loss_range_to.setValue('');
+ details.controls.estimate_loss_margin.setValue('');
+ details.controls.estimate_loss_margin_percent.setValue('');
+ return;
+
+ }
+
let estimate_loss_range_to = details.value.estimate_loss_range_to;
+ if(+estimate_loss_range_to > 100){
+ alert('Given Loss Percent is more than 100');
+ details.controls.estimate_loss_range_from.setValue('');
+ details.controls.estimate_loss_range_to.setValue('');
+ details.controls.estimate_loss_margin.setValue('');
+ details.controls.estimate_loss_margin_percent.setValue('');
+ return;
+
+ }
+
if (sales_average != '' && estimate_loss_range_from != '' && estimate_loss_range_to != ''){
+
+ if(+estimate_loss_range_from>+estimate_loss_range_to){
+ alert("Given To value is lower than From Value");
+ details.controls.estimate_loss_range_to.setValue('');
+ details.controls.estimate_loss_margin.setValue('');
+ details.controls.estimate_loss_margin_percent.setValue('');
+ return;
+ }
let loss_percent = (estimate_loss_range_to + estimate_loss_range_from)/2;
let loss_Average = (loss_percent*sales_average)/100;
+ let difference = (estimate_loss_range_to - estimate_loss_range_from)
// details.controls.estimate_loss_margin.setValue(Math.round(loss_Average));
// details.controls.estimate_loss_margin_percent.setValue(loss_percent.toFixed(2));
// this.AV_marginLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_Average));
- if(loss_Average >= 3){
- var r = confirm("Given Profit Range is greater than 3%");
+ if(difference > 3){
+ var r = confirm("Given Loss Percent Range is greater than 3");
if (r == true) {
- details.controls.estimate_loss_margin.setValue(Math.round(loss_Average));
- details.controls.estimate_loss_margin_percent.setValue(loss_percent.toFixed(2));
+ details.controls.estimate_loss_margin.setValue(loss_Average!= Infinity ? Math.round(loss_Average):0);
+ details.controls.estimate_loss_margin_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
this.AV_marginLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_Average));
}else{
@@ -841,71 +1030,235 @@ export class FinancialInfoComponent implements OnInit {
details.controls.estimate_loss_margin_percent.setValue('');
return;
}
- }
- else{
- alert('else part');
- }
+ }
+ details.controls.estimate_loss_margin.setValue(loss_Average!= Infinity ? Math.round(loss_Average):0);
+ details.controls.estimate_loss_margin_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
+ this.AV_marginLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_Average));
}
}
+
calculateLossAmount( i, details){
let sales_average = details.value.estimate_sales_average;
+ if(sales_average == ''){
+ alert("Considered Sales Average is Empty");
+ details.controls.estimate_net_loss_from.setValue('');
+ details.controls.estimate_net_loss_to.setValue('');
+ details.controls.estimate_net_loss.setValue('');
+ details.controls.estimate_net_loss_percent.setValue('');
+ return;
+ }
let estimate_net_loss_from = details.value.estimate_net_loss_from;
let estimate_net_loss_to = details.value.estimate_net_loss_to;
- if (sales_average != '' && estimate_net_loss_from != '' && estimate_net_loss_to != ''){
+ if(+estimate_net_loss_to > +sales_average){
+
+ alert("Given Loss is Greater than Sales");
+ details.controls.estimate_net_loss_from.setValue('');
+ details.controls.estimate_net_loss_to.setValue('');
+ details.controls.estimate_net_loss.setValue('');
+ details.controls.estimate_net_loss_percent.setValue('');
+ return;
+ }
+
- // let profit_percent = (estimate_net_profit_to - estimate_net_profit_from)/estimate_net_profit_from * 100;
- // let Profit_Average = (profit_percent*sales_average)/100;
- let loss_amount = (estimate_net_loss_to + estimate_net_loss_from)/2;
- let loss_percent = (loss_amount/sales_average)*100;
+ if (sales_average != '' && estimate_net_loss_from != '' && estimate_net_loss_to != ''){
+ if(+estimate_net_loss_from > +estimate_net_loss_to){
+ alert("Given To value is Lower than From Value");
+ details.controls.estimate_net_loss_to.setValue('');
+ details.controls.estimate_net_loss.setValue('');
+ details.controls.estimate_net_loss_percent.setValue('');
+ return;
+ }
+
+
+
+ // if(+estimate_net_loss_to > +estimate_net_loss_from){
+ // alert("loss is greater than sales");
+ // details.controls.estimate_net_loss_to.setValue('');
+ // details.controls.estimate_net_loss.setValue('');
+ // details.controls.estimate_net_loss_percent.setValue('');
+ // return;
+ // }
+
+
+ let C = (estimate_net_loss_to - estimate_net_loss_from)
+ let D = (C / estimate_net_loss_from) * 100;
+
+ let range1 = +estimate_net_loss_from/10;
+
+ let lower = (+estimate_net_loss_from)+range1;
+ let higer = ((+estimate_net_loss_to + +estimate_net_loss_from) / 2);
- // details.controls.estimate_net_loss.setValue(Math.round(loss_amount));
- // details.controls.estimate_net_loss_percent.setValue(loss_percent.toFixed(2));
-
- // this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_amount));
- if(loss_percent >= 3){
- var r = confirm("Given Loss Percentage is greater than 3%");
+ if(estimate_net_loss_from <= 5000000){
+ if(D >= 20){
+ var r = confirm("Given Profit Range is greater than 20%");
if (r == true) {
-
- details.controls.estimate_net_loss.setValue(Math.round(loss_amount));
- details.controls.estimate_net_loss_percent.setValue(loss_percent.toFixed(2));
-
- this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_amount));
-
+ details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0);
+
}else{
-
details.controls.estimate_net_loss_to.setValue('');
details.controls.estimate_net_loss.setValue('');
details.controls.estimate_net_loss_percent.setValue('');
return;
-
}
+ }
+ else{
+ details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0);
+ }
+
+ if(lower > higer){
+ details.controls.estimate_net_loss.setValue(higer!= Infinity ? higer.toFixed(2):0);
+ let loss_percent = (higer/sales_average)*100;
+ details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
+ this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer));
+ }
+ else{
+ details.controls.estimate_net_loss.setValue(lower!= Infinity ? lower.toFixed(2):0);
+ let loss_percent = (lower/sales_average)*100;
+ details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
+ this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower));
+ }
+
+ }
+ else if(estimate_net_loss_from > 5000000 || estimate_net_loss_from <= 10000000){
+ if(D >= 15){
+ var r = confirm("Given Sales Range is greater than 15%");
+ if (r == true) {
+ details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0);
+ }else{
+ details.controls.estimate_net_loss_to.setValue('');
+ details.controls.estimate_net_loss.setValue('');
+ details.controls.estimate_net_loss_percent.setValue('');
+ return;
+ }
+ }
+ else{
+ details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0);
+ }
+
+ if(lower > higer){
+ details.controls.estimate_net_loss.setValue(higer!= Infinity ? higer.toFixed(2):0);
+ let loss_percent = (higer/sales_average)*100;
+ details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
+ this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer));
+ }
+ else{
+ details.controls.estimate_net_loss.setValue(lower!= Infinity ? lower.toFixed(2):0);
+ let loss_percent = (lower/sales_average)*100;
+ details.controls.estimate_net_profit_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
+ this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower));
+ }
+ }
+ else if(estimate_net_loss_from > 10000000){
+ if(D >= 10){
+ var r = confirm("Given Sales Range is greater than 10%");
+ if (r == true) {
+ details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0);
+ }else{
+ details.controls.estimate_net_loss_to.setValue('');
+ details.controls.estimate_net_loss.setValue('');
+ details.controls.estimate_net_loss_percent.setValue('');
+ return;
+ }
+ }
+ else{
+ details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0);
+
+ }
+ if(lower > higer){
+ details.controls.estimate_net_loss.setValue(higer!= Infinity ? higer.toFixed(2):0);
+ let loss_percent = (higer/sales_average)*100;
+ details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
+ this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer));
+ }
+ else{
+ details.controls.estimate_net_loss.setValue(lower!= Infinity ? lower.toFixed(2):0);
+ let loss_percent = (lower/sales_average)*100;
+ details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
+ this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower));
+ }
+
}
else{
- alert('else part');
+ details.controls.estimate_net_loss_to.setValue(estimate_net_loss_to!= Infinity ? estimate_net_loss_to:0);
+ if(lower > higer){
+ details.controls.estimate_net_loss.setValue(higer!= Infinity ? higer.toFixed(2):0);
+ let loss_percent = (higer/sales_average)*100;
+ details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
+ this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(higer));
+ }
+ else{
+ details.controls.estimate_net_loss.setValue(lower!= Infinity ? lower.toFixed(2):0);
+ let loss_percent = (lower/sales_average)*100;
+ details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
+ this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(lower));
+ }
}
}
-
- // let estimate_net_profit_from = details.value.estimate_net_profit_from;
- // let estimate_net_profit_to = details.value.estimate_net_profit_to;
-
- // if (estimate_net_profit_from != '' && estimate_net_profit_to != ''){
- // let AB = (estimate_net_profit_to + estimate_net_profit_from)/2;
- // let C = (estimate_net_profit_to - estimate_net_profit_from);
- // let D = (C / estimate_net_profit_from);
- // let E = D*100;
-
- // details.controls.estimate_net_profit_percent.setValue(E);
- // details.controls.estimate_net_profit.setValue(AB);
-
- // }
+
}
+ // calculateLossAmount( i, details){
+
+ // let sales_average = details.value.estimate_sales_average;
+
+ // let estimate_net_loss_from = details.value.estimate_net_loss_from;
+ // let estimate_net_loss_to = details.value.estimate_net_loss_to;
+
+ // if (sales_average != '' && estimate_net_loss_from != '' && estimate_net_loss_to != ''){
+
+ // // let profit_percent = (estimate_net_profit_to - estimate_net_profit_from)/estimate_net_profit_from * 100;
+ // // let Profit_Average = (profit_percent*sales_average)/100;
+ // let loss_amount = (estimate_net_loss_to + estimate_net_loss_from)/2;
+ // let loss_percent = (loss_amount/sales_average)*100;
+
+ // // details.controls.estimate_net_loss.setValue(Math.round(loss_amount));
+ // // details.controls.estimate_net_loss_percent.setValue(loss_percent.toFixed(2));
+
+ // // this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_amount));
+ // if(loss_percent >= 3){
+ // var r = confirm("Given Loss Percentage is greater than 3%");
+ // if (r == true) {
+
+ // details.controls.estimate_net_loss.setValue(loss_amount!= Infinity ? Math.round(loss_amount):0);
+ // details.controls.estimate_net_loss_percent.setValue(loss_percent!= Infinity ? loss_percent.toFixed(2):0);
+
+ // this.AV_netLossAmtInwords[i] = this._pd.convertNumberToWords(Math.round(loss_amount));
+
+ // }else{
+
+ // details.controls.estimate_net_loss_to.setValue('');
+ // details.controls.estimate_net_loss.setValue('');
+ // details.controls.estimate_net_loss_percent.setValue('');
+ // return;
+
+ // }
+ // }
+ // else{
+ // alert('else part');
+ // }
+
+ // }
+
+ // // let estimate_net_profit_from = details.value.estimate_net_profit_from;
+ // // let estimate_net_profit_to = details.value.estimate_net_profit_to;
+
+ // // if (estimate_net_profit_from != '' && estimate_net_profit_to != ''){
+ // // let AB = (estimate_net_profit_to + estimate_net_profit_from)/2;
+ // // let C = (estimate_net_profit_to - estimate_net_profit_from);
+ // // let D = (C / estimate_net_profit_from);
+ // // let E = D*100;
+
+ // // details.controls.estimate_net_profit_percent.setValue(E);
+ // // details.controls.estimate_net_profit.setValue(AB);
+
+ // // }
+ // }
submitDetails() {
diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html
index 1dac6787f..cf0bcf0c9 100755
--- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html
+++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/general-info/general-info.component.html
@@ -19,7 +19,8 @@
Name
- {{details.value.applicant_name | titlecase}}
+
+
@@ -61,11 +62,11 @@
-
-