merge changes: kms

This commit is contained in:
gandhimathi 2018-12-21 10:42:18 +05:30
parent 2f7f36bbab
commit 412a8d956a
4 changed files with 1010 additions and 543 deletions

View File

@ -68,7 +68,7 @@
</span> </span>
<mat-form-field *ngIf="i != 0" style="width:65%"> <mat-form-field *ngIf="i != 0" style="width:65%">
<input matInput [ngClass]="{'highlight': (details.controls['financial_variation'].value > 40) || (details.controls['financial_variation'].value < -40)}" placeholder="Variation from Previous Year" formControlName="financial_variation" (keypress)="keyPress($event)"> <input matInput [ngClass]="{'highlight': (details.controls['financial_variation'].value > 40) || (details.controls['financial_variation'].value < -40)}" placeholder="Variation from Previous Year" formControlName="financial_variation" (keypress)="keyPress($event)">
<mat-hint align="end" *ngIf="i != 0" [ngClass]="{'highlight': (details.controls['financial_variation'].value > 40) || (details.controls['financial_variation'].value < -40)}" >{{SalesStatement[i]}}</mat-hint> <!-- <mat-hint align="end" *ngIf="i != 0" [ngClass]="{'highlight': (details.controls['financial_variation'].value > 40) || (details.controls['financial_variation'].value < -40)}" >{{SalesStatement[i]}}</mat-hint> -->
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="customerCommentsFlag" style="width:65%"> <mat-form-field *ngIf="customerCommentsFlag" style="width:65%">

View File

@ -459,7 +459,10 @@ export class FinancialInfoComponent implements OnInit {
} }
calAmount(index, detail) {
calAmount(i, detail) {
console.log(detail);
let salary = detail.value.estimate_annual_sale; let salary = detail.value.estimate_annual_sale;
@ -468,7 +471,6 @@ export class FinancialInfoComponent implements OnInit {
// let profit = detail.value.estimate_net_profit; // let profit = detail.value.estimate_net_profit;
let margin_profit = detail.value.estimate_margin_of_profit; let margin_profit = detail.value.estimate_margin_of_profit;
if (salary != '' && margin_profit != '') { if (salary != '' && margin_profit != '') {
@ -480,7 +482,6 @@ export class FinancialInfoComponent implements OnInit {
//detail.controls.estimate_margin_of_profit.setValue(margin.toFixed(2)); //detail.controls.estimate_margin_of_profit.setValue(margin.toFixed(2));
detail.controls.estimate_net_profit.setValue(profit.toFixed(2)); detail.controls.estimate_net_profit.setValue(profit.toFixed(2));
} }
} }
// else if (detail.value.estimate_profit_or_loss == 2){ // else if (detail.value.estimate_profit_or_loss == 2){
@ -498,7 +499,7 @@ export class FinancialInfoComponent implements OnInit {
} }
submitDetails() { submitDetails() {
console.log(this.financialForm.value.date_per_financial['financial_variation']);
if(this.financialForm.value.date_per_financial['finanical_profit_or_loss'] == 1){ if(this.financialForm.value.date_per_financial['finanical_profit_or_loss'] == 1){
this.financialForm.value.date_per_financial['financial_net_profit'].setValidators([Validators.required]); this.financialForm.value.date_per_financial['financial_net_profit'].setValidators([Validators.required]);
@ -527,9 +528,9 @@ export class FinancialInfoComponent implements OnInit {
this.financialForm.value.date_per_financial['financial_margin_of_loss'].setValidators([Validators.required]); this.financialForm.value.date_per_financial['financial_margin_of_loss'].setValidators([Validators.required]);
this.financialForm.value.date_per_financial['financial_margin_of_loss'].updateValueAndValidity(); this.financialForm.value.date_per_financial['financial_margin_of_loss'].updateValueAndValidity();
} }
if (!this.financialForm.valid) { // if (!this.financialForm.valid) {
return; // return;
} // }
let records = this.financialForm.value; let records = this.financialForm.value;
console.log('data', records); console.log('data', records);
this._pd.saveForm(records).subscribe(data => { this._pd.saveForm(records).subscribe(data => {

View File

@ -1,43 +1,41 @@
<form [formGroup]="stockForm" class="address"> <h2 mat-dialog-title class="paragraph_change">
<h2 mat-dialog-title class="paragraph_change">
<div fxFlex="70" align="left" style="padding: 10px !important;"> <div fxFlex="70" align="left" style="padding: 10px !important;">
{{pageTitle}} {{pageTitle}}
</div> </div>
<div fxFlex="30" align="end" style="padding: 10px !important;"> <div fxFlex="30" align="end" style="padding: 10px !important;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Close" matTooltipPosition="right" mat-dialog-close><mat-icon>close</mat-icon></button> <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Close" matTooltipPosition="right" mat-dialog-close><mat-icon>close</mat-icon></button>
</div> </div>
</h2> </h2>
<div *ngIf="noRecordsFound" style="max-width: 100vw !important;width: 100% !important;height: 95% !important;">
<!-- <form [formGroup]="" class="address"> -->
<form [formGroup]="stockForms" (submit)="submitDetails($event); false;">
<mat-dialog-content> <mat-dialog-content>
<mat-tab-group> <mat-tab-group>
<mat-tab label="Questions"> <mat-tab label="Questions">
<ng-template matTabContent> <ng-template matTabContent>
<div fxLayout="row wrap"> <div fxLayout="row wrap">
<div fxFlex="100"> <div fxFlex="100">
<!-- start main applicant --> <mat-card *ngIf="manufacturingForm">
<mat-card *ngIf="rawMaterialAccess">
<mat-card-header> <mat-card-header>
<p>Raw Materials<p> <p> Manufacturing Details</p>
</mat-card-header> </mat-card-header>
<div formArrayName="raw_materials"> <div formArrayName="manufacturing_details">
<div *ngFor="let details of stockForm.controls.raw_materials['controls']; let i=index" <div *ngFor="let md of stockForms.controls.manufacturing_details['controls']; let i=index" [formGroupName]="i">
[formGroupName]="i"> <div formArrayName="manufacturing_raw_materials">
<div *ngFor="let mrm of md.controls.manufacturing_raw_materials['controls']; let a=index" [formGroupName]="a">
<mat-card-title> <p>{{a+1}} . Raw Material </p> </mat-card-title>
<mat-card-content class="matcard"> <mat-card-content class="matcard">
<mat-form-field style="width:30%"> <mat-form-field style="width:30%">
<input matInput placeholder="Name" formControlName="raw_name" required> <input matInput placeholder="Name" formControlName="raw_name" required>
</mat-form-field> </mat-form-field>
<mat-form-field style="width:30%"> <mat-form-field style="width:30%">
<mat-select placeholder="is the Stock is Observed ?" <mat-select placeholder="is the Stock is Observed ?" formControlName="stock_observed" required>
formControlName="stock_observed" required
(selectionChange)="RawMaterialValidation($event)">
<mat-option value="yes" >Yes</mat-option> <mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option> <mat-option value="no" >No</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<span *ngIf="details.get('stock_observed').value == 'no'" > <span *ngIf="mrm.get('stock_observed').value == 'no'" >
<mat-form-field style="width:30%"> <mat-form-field style="width:30%">
<input matInput placeholder="Estimated Quantity" formControlName="raw_quantity" required> <input matInput placeholder="Estimated Quantity" formControlName="raw_quantity" required>
</mat-form-field> </mat-form-field>
@ -47,137 +45,107 @@
<mat-option value="{{uom.uom_id}}" *ngFor="let uom of uomData">{{uom.name}}</mat-option> <mat-option value="{{uom.uom_id}}" *ngFor="let uom of uomData">{{uom.name}}</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="details.get('raw_uom').value == 61" style="width:30%"> <mat-form-field *ngIf="mrm.get('raw_uom').value == 61" style="width:30%">
<input matInput placeholder="Specify Other UOM" formControlName="other_uom" required> <input matInput placeholder="Specify Other UOM" formControlName="other_uom" required>
</mat-form-field> </mat-form-field>
<mat-form-field style="width:76%"> <mat-form-field style="width:76%">
<input matInput placeholder="Estimated Value of Stock Observed" formControlName="raw_value" (keypress)="keyPress($event)" (keyup)="inWords($event,1)" required> <input matInput placeholder="Estimated Value of Stock Observed" formControlName="raw_value" (keypress)="keyPress($event)" required>
<mat-hint align="end" *ngIf="details.get('raw_value').value != ''">{{"&#8377;"}} {{rawValueInWords}} Only</mat-hint> <!-- <mat-hint align="end" *ngIf="mrm.get('raw_value').value != ''">{{"&#8377;"}} {{rawValueInWords}} Only</mat-hint> (keyup)="inWords($event,1)" -->
</mat-form-field> </mat-form-field>
<mat-form-field style="width:76%"> <mat-form-field style="width:76%">
<input matInput placeholder="Value of raw materials as per latest financial Statements" formControlName="rawmaterial_value" (keypress)="keyPress($event)" required> <input matInput placeholder="Value of raw materials as per latest financial Statements" formControlName="rawmaterial_value" (keypress)="keyPress($event)" required>
</mat-form-field> </mat-form-field>
<mat-form-field style="width:90%"> <mat-form-field style="width:90%">
<!-- <input matInput placeholder="Is the stock of raw materials observed ?" formControlName="is_sufficiant_raw" required> -->
<mat-select placeholder="Is the stock of Raw Materials observed, sufficient considering the size of operations" formControlName="is_sufficiant_raw" required> <mat-select placeholder="Is the stock of Raw Materials observed, sufficient considering the size of operations" formControlName="is_sufficiant_raw" required>
<mat-option value="yes" >Yes</mat-option> <mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option> <mat-option value="no" >No</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="details.get('is_sufficiant_raw').value == 'no'" appearance="outline" style="width: 90%"> <mat-form-field *ngIf="mrm.get('is_sufficiant_raw').value == 'no'" appearance="outline" style="width: 90%">
<mat-label>Please comment on the stock level observed?</mat-label> <mat-label>Please comment on the stock level observed?</mat-label>
<textarea matInput placeholder="Please comment on the stock level observed" formControlName="rawmaterial_remarks"></textarea> <textarea matInput placeholder="Please comment on the stock level observed" formControlName="rawmaterial_remarks"></textarea>
</mat-form-field> </mat-form-field>
</span> </span>
<button type="button" mat-raised-button mat-icon-button (click)="addRawMaterials(1)"
<button type="button" mat-raised-button mat-icon-button (click)="addRawMaterials()" matTooltip="Add More Raw Materials" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="a==0">
matTooltip="Add More Raw Materials" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="i==0">
<mat-icon>add</mat-icon> <mat-icon>add</mat-icon>
</button> </button>
<button type="button" mat-raised-button mat-icon-button (click)="deleteRawMaterials(i)" <button type="button" mat-raised-button mat-icon-button (click)="deleteRawMaterials(a,1)"
matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="i>0"> matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="a>0">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>
</mat-card-content> </mat-card-content>
</div> </div>
</div> </div>
</mat-card>
<!-- end main applicant --> <div formArrayName="manufacturing_finished_goods">
</div> <div *ngFor="let mfg of md.controls.manufacturing_finished_goods['controls']; let b=index" [formGroupName]="b">
</div> <mat-card-title> <p> {{b+1}} Finished Goods </p> </mat-card-title>
<div fxLayout="row wrap">
<div fxFlex="100">
<!-- start co applicant form details -->
<mat-card *ngIf="finishedGoodsAccess">
<mat-card-header>
<p>Finished Goods<p>
</mat-card-header>
<div formArrayName="finished_goods">
<div *ngFor="let details of stockForm.controls.finished_goods['controls']; let i=index"
[formGroupName]="i">
<mat-card-content class="matcard"> <mat-card-content class="matcard">
<mat-form-field style="width:30%"> <mat-form-field style="width:30%">
<input matInput placeholder="Name" formControlName="goods_name" required> <input matInput placeholder="Name" formControlName="goods_name" required>
</mat-form-field> </mat-form-field>
<mat-form-field style="width:30%"> <mat-form-field style="width:30%">
<mat-select placeholder="is the Goods is Observed ?" <mat-select placeholder="is the Goods is Observed ?" formControlName="goods_observed" required>
formControlName="goods_observed" required
(selectionChange)="GoodsValidation($event)">
<mat-option value="yes" >Yes</mat-option> <mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option> <mat-option value="no" >No</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<span *ngIf="details.get('goods_observed').value == 'no'" > <span *ngIf="mfg.get('goods_observed').value == 'no'" >
<mat-form-field style="width:30%"> <mat-form-field style="width:30%">
<input matInput placeholder="Estimated Quantity" formControlName="goods_quantity" required> <input matInput placeholder="Estimated Quantity" formControlName="goods_quantity" required>
</mat-form-field> </mat-form-field>
<mat-form-field style="width:76%"> <mat-form-field style="width:76%">
<input matInput placeholder="Estimated Value of Stock Observed" formControlName="goods_value" (keypress)="keyPress($event)" (keyup)="inWords($event,2)" required> <input matInput placeholder="Estimated Value of Stock Observed" formControlName="goods_value" (keypress)="keyPress($event)" required>
<mat-hint align="end" *ngIf="details.get('goods_value').value != ''">{{"&#8377;"}} {{goodsValueInWords}} Only</mat-hint> <!-- <mat-hint align="end" *ngIf="mfg.get('goods_value').value != ''">{{"&#8377;"}} {{goodsValueInWords}} Only</mat-hint> (keyup)="inWords($event,2)" -->
</mat-form-field> </mat-form-field>
<mat-form-field style="width:76%"> <mat-form-field style="width:76%">
<input matInput placeholder="Value of finished goods as per latest financial statements" formControlName="finished_goods_value" (keypress)="keyPress($event)" required> <input matInput placeholder="Value of finished goods as per latest financial statements" formControlName="finished_goods_value" (keypress)="keyPress($event)" required>
</mat-form-field> </mat-form-field>
<mat-form-field style="width:90%"> <mat-form-field style="width:90%">
<!-- <input matInput placeholder="Is the stock of finished goods observed ?" formControlName="is_sufficiant_goods" required> -->
<mat-select placeholder="Is the stock of finished goods observed ?" formControlName="is_sufficiant_goods" required> <mat-select placeholder="Is the stock of finished goods observed ?" formControlName="is_sufficiant_goods" required>
<mat-option value="yes" >Yes</mat-option> <mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option> <mat-option value="no" >No</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="details.get('is_sufficiant_goods').value == 'no'" appearance="outline" style="width: 90%"> <mat-form-field *ngIf="mfg.get('is_sufficiant_goods').value == 'no'" appearance="outline" style="width: 90%">
<mat-label>Please comment on the finished goods stock level observed?</mat-label> <mat-label>Please comment on the finished goods stock level observed?</mat-label>
<textarea matInput placeholder="Please comment on the finished goods observed" formControlName="finishedgoods_remarks"></textarea> <textarea matInput placeholder="Please comment on the finished goods observed" formControlName="finishedgoods_remarks"></textarea>
</mat-form-field> </mat-form-field>
</span> </span>
<button type="button" mat-raised-button mat-icon-button (click)="addGoods()" <button type="button" mat-raised-button mat-icon-button (click)="addGoods(1)"
matTooltip="Add More Finished Goods" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="i==0"> matTooltip="Add More Finished Goods" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="b==0">
<mat-icon>add</mat-icon> <mat-icon>add</mat-icon>
</button> </button>
<button type="button" mat-raised-button mat-icon-button (click)="deleteGoods(i)" <button type="button" mat-raised-button mat-icon-button (click)="deleteGoods(b,1)"
matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="i>0"> matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="b>0">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>
</mat-card-content> </mat-card-content>
</div> </div>
</div> </div>
</mat-card>
<!-- end co apllicant -->
</div> <div formArrayName="manufacturing_traded_goods">
</div> <div *ngFor="let mtg of md.controls.manufacturing_traded_goods['controls']; let c=index" [formGroupName]="c">
<mat-card-title> <p>{{c+1}} Traded Goods </p> </mat-card-title>
<div fxLayout="row wrap">
<div fxFlex="100">
<mat-card *ngIf="tradeConcernAccess">
<mat-card-header>
<p>Stock of Goods Traded<p>
</mat-card-header>
<div formArrayName="traded_goods">
<div *ngFor="let details of stockForm.controls.traded_goods['controls']; let i=index"
[formGroupName]="i">
<mat-card-content class="matcard"> <mat-card-content class="matcard">
<mat-form-field style="width:30%"> <mat-form-field style="width:30%">
<input matInput placeholder="Name" formControlName="traded_goods_name" required> <input matInput placeholder="Name" formControlName="traded_goods_name" required>
</mat-form-field> </mat-form-field>
<mat-form-field style="width:30%"> <mat-form-field style="width:30%">
<mat-select placeholder="is the Traded Goods is Observed ?" <mat-select placeholder="is the Traded Goods is Observed ?" formControlName="traded_goods_observed" required >
formControlName="traded_goods_observed" required
(selectionChange)="TradedGoodsValidation($event)">
<mat-option value="yes" >Yes</mat-option> <mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option> <mat-option value="no" >No</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<span *ngIf="details.get('traded_goods_observed').value == 'no'" > <span *ngIf="mtg.get('traded_goods_observed').value == 'no'" >
<mat-form-field style="width:30%"> <mat-form-field style="width:30%">
<input matInput placeholder="Estimated Quantity" formControlName="traded_goods_quantity" required> <input matInput placeholder="Estimated Quantity" formControlName="traded_goods_quantity" required>
</mat-form-field> </mat-form-field>
<mat-form-field style="width:76%"> <mat-form-field style="width:76%">
<input matInput placeholder="Estimated Value of Stock Observed" formControlName="estimated_traded_goods_value" (keypress)="keyPress($event)" (keyup)="inWords($event,3)" required> <input matInput placeholder="Estimated Value of Stock Observed" formControlName="estimated_traded_goods_value" (keypress)="keyPress($event)" required>
<mat-hint align="end" *ngIf="details.get('estimated_traded_goods_value').value != ''">{{"&#8377;"}} {{tradedGoodsValueInWords}} Only</mat-hint> <!-- <mat-hint align="end" *ngIf="mtg.get('estimated_traded_goods_value').value != ''">{{"&#8377;"}} {{tradedGoodsValueInWords}} Only</mat-hint>(keyup)="inWords($event,3)" -->
</mat-form-field> </mat-form-field>
<mat-form-field style="width:76%"> <mat-form-field style="width:76%">
<input matInput placeholder="Value of traded goods as per latest financial statements" formControlName="traded_goods_value" (keypress)="keyPress($event)" required> <input matInput placeholder="Value of traded goods as per latest financial statements" formControlName="traded_goods_value" (keypress)="keyPress($event)" required>
@ -189,30 +157,254 @@
<mat-option value="no" >No</mat-option> <mat-option value="no" >No</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="details.get('is_sufficiant_traded_goods').value == 'no'" appearance="outline" style="width: 90%"> <mat-form-field *ngIf="mtg.get('is_sufficiant_traded_goods').value == 'no'" appearance="outline" style="width: 90%">
<mat-label>Please comment on the Traded Goods stock level observed?</mat-label> <mat-label>Please comment on the Traded Goods stock level observed?</mat-label>
<textarea matInput placeholder="Please comment on the traded goods stock level observed" formControlName="traded_goods_remarks"></textarea> <textarea matInput placeholder="Please comment on the traded goods stock level observed" formControlName="traded_goods_remarks"></textarea>
</mat-form-field> </mat-form-field>
</span> </span>
<button type="button" mat-raised-button mat-icon-button (click)="addTradedGoods()" <button type="button" mat-raised-button mat-icon-button (click)="addTradedGoods(1)"
matTooltip="Add More Traded Goods" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="i==0"> matTooltip="Add More Traded Goods" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="c==0">
<mat-icon>add</mat-icon> <mat-icon>add</mat-icon>
</button> </button>
<button type="button" mat-raised-button mat-icon-button (click)="deleteTradedGoods(i)" <button type="button" mat-raised-button mat-icon-button (click)="deleteTradedGoods(c,1)"
matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="i>0"> matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="c>0">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
</button> </button>
</mat-card-content> </mat-card-content>
</div> </div>
</div> </div>
</div>
</div>
</mat-card> </mat-card>
<mat-card *ngIf="retailForm">
<mat-card-header>
<p>Retail Details</p>
</mat-card-header>
<div formArrayName="retail_details">
<div *ngFor="let rd of stockForms.controls.retail_details['controls']; let j=index" [formGroupName]="j">
<div formArrayName="retail_finished_goods">
<div *ngFor="let retailfg of rd.controls.retail_finished_goods['controls']; let d=index" [formGroupName]="d">
<mat-card-title> <p>{{d+1}} Finished Goods </p> </mat-card-title>
<mat-card-content class="matcard">
<mat-form-field style="width:30%">
<input matInput placeholder="Name" formControlName="goods_name" required>
</mat-form-field>
<mat-form-field style="width:30%">
<mat-select placeholder="is the Goods is Observed ?" formControlName="goods_observed" required>
<mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option>
</mat-select>
</mat-form-field>
<span *ngIf="retailfg.get('goods_observed').value == 'no'" >
<mat-form-field style="width:30%">
<input matInput placeholder="Estimated Quantity" formControlName="goods_quantity" required>
</mat-form-field>
<mat-form-field style="width:76%">
<input matInput placeholder="Estimated Value of Stock Observed" formControlName="goods_value" (keypress)="keyPress($event)" required>
<!-- <mat-hint align="end" *ngIf="retailfg.get('goods_value').value != ''">{{"&#8377;"}} {{goodsValueInWords}} Only</mat-hint>(keyup)="inWords($event,2)" -->
</mat-form-field>
<mat-form-field style="width:76%">
<input matInput placeholder="Value of finished goods as per latest financial statements" formControlName="finished_goods_value" (keypress)="keyPress($event)" required>
</mat-form-field>
<mat-form-field style="width:90%">
<mat-select placeholder="Is the stock of finished goods observed ?" formControlName="is_sufficiant_goods" required>
<mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field *ngIf="retailfg.get('is_sufficiant_goods').value == 'no'" appearance="outline" style="width: 90%">
<mat-label>Please comment on the finished goods stock level observed?</mat-label>
<textarea matInput placeholder="Please comment on the finished goods observed" formControlName="finishedgoods_remarks"></textarea>
</mat-form-field>
</span>
<button type="button" mat-raised-button mat-icon-button (click)="addGoods(2)"
matTooltip="Add More Finished Goods" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="d==0">
<mat-icon>add</mat-icon>
</button>
<button type="button" mat-raised-button mat-icon-button (click)="deleteGoods(d,2)"
matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="d>0">
<mat-icon>delete</mat-icon>
</button>
</mat-card-content>
</div>
</div>
<div formArrayName="retail_traded_goods">
<div *ngFor="let item of rd.controls.retail_traded_goods['controls']; let e=index" [formGroupName]="e">
<mat-card-title> <p>{{e+1}} Traded Goods </p> </mat-card-title>
<mat-card-content class="matcard">
<mat-form-field style="width:30%">
<input matInput placeholder="Name" formControlName="traded_goods_name" required>
</mat-form-field>
<mat-form-field style="width:30%">
<mat-select placeholder="is the Traded Goods is Observed ?" formControlName="traded_goods_observed" required>
<mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option>
</mat-select>
</mat-form-field>
<span *ngIf="item.get('traded_goods_observed').value == 'no'" >
<mat-form-field style="width:30%">
<input matInput placeholder="Estimated Quantity" formControlName="traded_goods_quantity" required>
</mat-form-field>
<mat-form-field style="width:76%">
<input matInput placeholder="Estimated Value of Stock Observed" formControlName="estimated_traded_goods_value" (keypress)="keyPress($event)" required>
<!-- <mat-hint align="end" *ngIf="item.get('estimated_traded_goods_value').value != ''">{{"&#8377;"}} {{tradedGoodsValueInWords}} Only</mat-hint>(keyup)="inWords($event,3)" -->
</mat-form-field>
<mat-form-field style="width:76%">
<input matInput placeholder="Value of traded goods as per latest financial statements" formControlName="traded_goods_value" (keypress)="keyPress($event)" required>
</mat-form-field>
<mat-form-field style="width:90%">
<mat-select placeholder="Is the stock of Traded goods observed ?" formControlName="is_sufficiant_traded_goods" required>
<mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field *ngIf="item.get('is_sufficiant_traded_goods').value == 'no'" appearance="outline" style="width: 90%">
<mat-label>Please comment on the Traded Goods stock level observed?</mat-label>
<textarea matInput placeholder="Please comment on the traded goods stock level observed" formControlName="traded_goods_remarks"></textarea>
</mat-form-field>
</span>
<button type="button" mat-raised-button mat-icon-button (click)="addTradedGoods(2)"
matTooltip="Add More Traded Goods" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="e==0">
<mat-icon>add</mat-icon>
</button>
<button type="button" mat-raised-button mat-icon-button (click)="deleteTradedGoods(e,2)"
matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="e>0">
<mat-icon>delete</mat-icon>
</button>
</mat-card-content>
</div>
</div>
</div>
</div>
</mat-card>
<mat-card *ngIf="tradingForm">
<mat-card-header>
<p>Trading Details</p>
</mat-card-header>
<div formArrayName="trade_details">
<div *ngFor="let td of stockForms.controls.trade_details['controls']; let k=index" [formGroupName]="k">
<div formArrayName="trading_finished_goods">
<div *ngFor="let tradesubdetail of td.controls.trading_finished_goods['controls']; let f=index" [formGroupName]="f">
<mat-card-title> <p>{{f+1}} Finished Goods </p> </mat-card-title>
<mat-card-content class="matcard">
<mat-form-field style="width:30%">
<input matInput placeholder="Name" formControlName="goods_name" required>
</mat-form-field>
<mat-form-field style="width:30%">
<mat-select placeholder="is the Goods is Observed ?" formControlName="goods_observed" required >
<mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option>
</mat-select>
</mat-form-field>
<span *ngIf="tradesubdetail.get('goods_observed').value == 'no'" >
<mat-form-field style="width:30%">
<input matInput placeholder="Estimated Quantity" formControlName="goods_quantity" required>
</mat-form-field>
<mat-form-field style="width:76%">
<input matInput placeholder="Estimated Value of Stock Observed" formControlName="goods_value" (keypress)="keyPress($event)" required>
<!-- <mat-hint align="end" *ngIf="tradesubdetail.get('goods_value').value != ''">{{"&#8377;"}} {{goodsValueInWords}} Only</mat-hint>(keyup)="inWords($event,2)" -->
</mat-form-field>
<mat-form-field style="width:76%">
<input matInput placeholder="Value of finished goods as per latest financial statements" formControlName="finished_goods_value" (keypress)="keyPress($event)" required>
</mat-form-field>
<mat-form-field style="width:90%">
<mat-select placeholder="Is the stock of finished goods observed ?" formControlName="is_sufficiant_goods" required>
<mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field *ngIf="tradesubdetail.get('is_sufficiant_goods').value == 'no'" appearance="outline" style="width: 90%">
<mat-label>Please comment on the finished goods stock level observed?</mat-label>
<textarea matInput placeholder="Please comment on the finished goods observed" formControlName="finishedgoods_remarks"></textarea>
</mat-form-field>
</span>
<button type="button" mat-raised-button mat-icon-button (click)="addGoods(3)"
matTooltip="Add More Finished Goods" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="f==0">
<mat-icon>add</mat-icon>
</button>
<button type="button" mat-raised-button mat-icon-button (click)="deleteGoods(f,3)"
matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="f>0">
<mat-icon>delete</mat-icon>
</button>
</mat-card-content>
</div>
</div>
<div formArrayName="trading_traded_goods">
<div *ngFor="let tradetg of td.controls.trading_traded_goods['controls']; let g=index" [formGroupName]="g">
<mat-card-title> <p>{{g+1}} Traded Goods </p> </mat-card-title>
<mat-card-content class="matcard">
<mat-form-field style="width:30%">
<input matInput placeholder="Name" formControlName="traded_goods_name" required>
</mat-form-field>
<mat-form-field style="width:30%">
<mat-select placeholder="is the Traded Goods is Observed ?" formControlName="traded_goods_observed" required>
<mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option>
</mat-select>
</mat-form-field>
<span *ngIf="tradetg.get('traded_goods_observed').value == 'no'" >
<mat-form-field style="width:30%">
<input matInput placeholder="Estimated Quantity" formControlName="traded_goods_quantity" required>
</mat-form-field>
<mat-form-field style="width:76%">
<input matInput placeholder="Estimated Value of Stock Observed" formControlName="estimated_traded_goods_value" (keypress)="keyPress($event)" required>
<!-- <mat-hint align="end" *ngIf="tradetg.get('estimated_traded_goods_value').value != ''">{{"&#8377;"}} {{tradedGoodsValueInWords}} Only</mat-hint> (keyup)="inWords($event,3)" -->
</mat-form-field>
<mat-form-field style="width:76%">
<input matInput placeholder="Value of traded goods as per latest financial statements" formControlName="traded_goods_value" (keypress)="keyPress($event)" required>
</mat-form-field>
<mat-form-field style="width:90%">
<!-- <input matInput placeholder="Is the stock of finished goods observed ?" formControlName="is_sufficiant_goods" required> -->
<mat-select placeholder="Is the stock of Traded goods observed ?" formControlName="is_sufficiant_traded_goods" required>
<mat-option value="yes" >Yes</mat-option>
<mat-option value="no" >No</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field *ngIf="tradetg.get('is_sufficiant_traded_goods').value == 'no'" appearance="outline" style="width: 90%">
<mat-label>Please comment on the Traded Goods stock level observed?</mat-label>
<textarea matInput placeholder="Please comment on the traded goods stock level observed" formControlName="traded_goods_remarks"></textarea>
</mat-form-field>
</span>
<button type="button" mat-raised-button mat-icon-button (click)="addTradedGoods(3)"
matTooltip="Add More Traded Goods" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" *ngIf="g==0">
<mat-icon>add</mat-icon>
</button>
<button type="button" mat-raised-button mat-icon-button (click)="deleteTradedGoods(g,3)"
matTooltip="Delete" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" *ngIf="g>0">
<mat-icon>delete</mat-icon>
</button>
</mat-card-content>
</div>
</div>
</div>
</div>
</mat-card>
</div> </div>
</div> </div>
</ng-template> </ng-template>
</mat-tab> </mat-tab>
<mat-tab label="Docs"> <mat-tab label="Docs">
<ng-template matTabContent> <ng-template matTabContent>
<div ngxViewer> <div ngxViewer>
@ -311,8 +503,8 @@
</mat-tab> </mat-tab>
</mat-tab-group> </mat-tab-group>
</mat-dialog-content> </mat-dialog-content>
<mat-dialog-actions> <mat-dialog-actions>
<div fxFlex="60" class="pb-0 text-sm-left" align="left"> <div fxFlex="60" class="pb-0 text-sm-left" align="left">
<mat-form-field appearance="outline" style="width: 100%"> <mat-form-field appearance="outline" style="width: 100%">
@ -321,25 +513,18 @@
</mat-form-field> </mat-form-field>
</div> </div>
<div fxFlex="40" align="end"> <div fxFlex="40" align="end">
<button type="submit" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button matTooltip="Submit" matTooltipPosition="above" (click)="submitDetails()"><mat-icon>save</mat-icon> <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
</button>
</div> </div>
</mat-dialog-actions> </mat-dialog-actions>
</form> </form>
<notifier-container></notifier-container> </div>
<notifier-container></notifier-container>
<!-- <mat-card style="padding: 12px;"> <!-- <mat-card style="padding: 12px;">
<p>Stock Details</p> <p>Stock Details</p>
<form [formGroup]="stockForm" class="address"> --> <form [formGroup]="stockForms" class="address"> -->
<!-- {{uomData | json}} --> <!-- {{uomData | json}} -->
<!-- <mat-card> <!-- <mat-card>
======= =======
<!-- {{uomData | json}} --> <!-- {{uomData | json}} -->
<mat-card>

View File

@ -35,7 +35,7 @@ export class StockComponent implements OnInit {
pageTitle: string ="Stock Details"; pageTitle: string ="Stock Details";
pdid: number; pdid: number;
form_id: number; form_id: number;
public stockForm: FormGroup; public stockForms: FormGroup;
private notifier: NotifierService; private notifier: NotifierService;
public uomData : any = []; public uomData : any = [];
@ -46,6 +46,8 @@ export class StockComponent implements OnInit {
rawMaterialAccess: boolean; rawMaterialAccess: boolean;
finishedGoodsAccess: boolean; finishedGoodsAccess: boolean;
tradeConcernAccess: boolean; tradeConcernAccess: boolean;
public submitted = false;
noRecordsFound: Boolean = false;
constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute,
private router: Router, private router: Router,
@ -74,154 +76,310 @@ export class StockComponent implements OnInit {
} }
}; };
ngOnInit() { ngOnInit() {
this.initstockForm();
// this._pd.stockFormsAccess({pd_id:this.pdid}).subscribe(data => {
// if(data.status == 200){
// this.initstockForms(data.record.type_of_activity);
// }
// }, err => {
// this.notifier.notify('warning', 'There is No Type Of Activity Please Check Bussiness Information.!');
// })
this._pd.getTypeofActivityForSuppliedInfoForm(this.pdid).subscribe(data => {
// if(data.dataStatus === undefined){
let datas = {
"profession_name": "Others",
"type_of_activity": [
{
"type_of_activity_id": 1,
"name": "Manufacturing Details"
},
{
"type_of_activity_id": 2,
"name": "Retail trading"
},
{
"type_of_activity_id": 3,
"name": "Trading Concern"
},
{
"type_of_activity_id": 4,
"name": "Service Provider"
}
]
};
this.initstockForms(datas.type_of_activity);
// }else {
// this.notifier.notify('warning', 'No Category Records Found.!');
// this.noRecordsFound = false;
// }
}, err => {
this.notifier.notify('warning', 'There is No Type Of Activity Please Check Bussiness Information.!');
this.noRecordsFound = false;
})
this.getUOM(); this.getUOM();
//this.setSku('data',0); }
public initstockForms(record){
let params: any = {}; let params: any = {};
let activityArray : any = [];
params.pd_id = this.pdid; params.pd_id = this.pdid;
params.pd_form_id = this.form_id; params.pd_form_id = this.form_id;
this._pd.stockFormAccess({pd_id:this.pdid}).subscribe(value => {
console.log(value);
const rawMaterial = <FormArray>this.stockForm.controls['raw_materials'];
const finishedGoods = <FormArray>this.stockForm.controls['finished_goods'];
const tradedGoods = <FormArray>this.stockForm.controls['traded_goods'];
if (value.status == 200) {
console.log('value.records',value.records);
value.records.type_of_activity.forEach(val => {
//console.log(val);
//console.log(val.type_of_activity_id);
this.rawMaterialAccess = true;
this.finishedGoodsAccess = true;
this.tradeConcernAccess = true;
if(val.type_of_activity_id == 1){
rawMaterial.push(this.createRawmaterial());
finishedGoods.push(this.createGoods());
tradedGoods.push(this.createTradedGoods());
}
else if(val.type_of_activity_id == 2){
rawMaterial.push(this.createRawmaterial());
finishedGoods.push(this.createGoods());
}
else if(val.type_of_activity_id == 3){
rawMaterial.push(this.createRawmaterial());
finishedGoods.push(this.createGoods());
}
// else if(val.type_of_activity_id == 4){
// }
});
this._pd.retriveForm({pd_id:this.pdid,pd_form_id:'1'}).subscribe(value => {
//console.log('Raw material Name',value.records.main_raw_materials);
// const faControl = (<FormArray>this.stockForm.controls['raw_materials']).at(1);
//const control = (<FormArray>this.stockForm.controls['raw_materials']).at(0);
//console.log(control);
// this.stockForm.controls['raw_materials'].setValue(value.records.main_raw_materials);
// if (value.status == 200) {
// this.rawmaterial = value.records.main_raw_materials;
// }else{ this.rawmaterial = ''; }
})
this._pd.retriveForm(params).subscribe(value => { this._pd.retriveForm(params).subscribe(value => {
//console.log('value', value);
if (value.status == 200) { if (value.status == 200) {
console.log('data',value); let dataForm = value.records;
// Raw Material Access is True means., Data have to load,
if(this.rawMaterialAccess == true){
let result = Object.keys(value.records.raw_materials).map(function(key) { if(dataForm !== undefined) {
return value.records.raw_materials[key]; console.log('dtaForm',dataForm);
this.stockForms = this.fb.group({
pdid: [this.pdid],
formid: [this.form_id],
stock_remarks: [''],
manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]),
retail_details : this.fb.array([this.retailFormCreation(record)]),
trade_details: this.fb.array([this.tradingFormCreation(record)]),
}); });
let arr = record.filter(data => data.type_of_activity_id === 1);
if (result.length > 0) { if(arr.length > 0) {
let retail_finished_goods;
result.forEach(val => { let manufacturing_raw_materials;
let manufacturing_finished_goods;
//this.RawMaterialValidation(val.stock_observed); let manufacturing_traded_goods;
rawMaterial.push(this.createRawmaterial()); if(dataForm.manufacturing_raw_materials !==undefined){
if(val.raw_value != '' && val.raw_value != null ){ this.rawValueInWords = this._pd.convertNumberToWords(val.raw_value); } manufacturing_raw_materials = Object.keys(dataForm.manufacturing_raw_materials).map(function (key) {
return dataForm.manufacturing_raw_materials[key];
}); });
this.stockForm.controls['raw_materials'].setValue(result);
} else {
rawMaterial.push(this.createRawmaterial());
} }
} if(dataForm.manufacturing_finished_goods !==undefined){
manufacturing_finished_goods = Object.keys(dataForm.manufacturing_finished_goods).map(function (key) {
// Finished Goods Access is TRUE Means., data have to load., return dataForm.manufacturing_finished_goods[key];
if(this.finishedGoodsAccess == true){
let result_Goods = Object.keys(value.records.finished_goods).map(function(key) {
return value.records.finished_goods[key];
}); });
}
if (result_Goods.length > 0) { if(dataForm.manufacturing_traded_goods !==undefined){
manufacturing_traded_goods = Object.keys(dataForm.manufacturing_traded_goods).map(function (key) {
result_Goods.forEach(val => { return dataForm.manufacturing_traded_goods[key];
//this.GoodsValidation(val.goods_observed);
finishedGoods.push(this.createGoods());
if(val.goods_value != '' && val.goods_value != null ){ this.goodsValueInWords = this._pd.convertNumberToWords(val.goods_value); }
}); });
this.stockForm.controls['finished_goods'].setValue(result_Goods);
} else {
finishedGoods.push(this.createGoods());
}
}
//TradeConcern Access is TRUE Means., data have to load.,
if(this.tradeConcernAccess == true){
let result_Traded_Goods = Object.keys(value.records.finished_goods).map(function(key) {
return value.records.traded_goods[key];
});
if (result_Traded_Goods.length > 0) {
result_Traded_Goods.forEach(val => {
tradedGoods.push(this.createTradedGoods());
if(val.traded_goods_value != '' && val.traded_goods_value != null )
{ this.tradedGoodsValueInWords = this._pd.convertNumberToWords(val.traded_goods_value); }
});
this.stockForm.controls['traded_goods'].setValue(result_Traded_Goods);
} else {
tradedGoods.push(this.createTradedGoods());
}
}
this.stockForm.controls['stock_remarks'].setValue(value.records.stock_remarks);
} else {
// rawMaterial.push(this.createRawmaterial());
// finishedGoods.push(this.createGoods());
// tradedGoods.push(this.createTradedGoods());
} }
if(dataForm.retail_finished_goods !==undefined)
{
retail_finished_goods = Object.keys(dataForm.retail_finished_goods).map(function(key)
{
return dataForm.retail_finished_goods[key];
}) })
} }
}); //console.log(retail_finished_goods,manufacturing_traded_goods);
} let manufacturing_temparr = [];
manufacturing_temparr['manufacturing_traded_goods'] = manufacturing_traded_goods;manufacturing_temparr['manufacturing_finished_goods'] = manufacturing_finished_goods;manufacturing_temparr['manufacturing_raw_materials'] = manufacturing_raw_materials;
this.initManufacturingDetails(manufacturing_temparr);
}
let arr1 = record.filter(data => data.type_of_activity_id === 2);
if(arr1.length > 0) {
let retail_finished_goods;
let retail_traded_goods;
public initstockForm(): void {
this.stockForm = this.fb.group({ if(dataForm.retail_traded_goods !==undefined){
stock_remarks: ['', Validators.compose([Validators.required])], retail_traded_goods = Object.keys(dataForm.retail_traded_goods).map(function (key) {
raw_materials: this.fb.array([]), return dataForm.retail_traded_goods[key];
finished_goods: this.fb.array([]),
traded_goods: this.fb.array([])
}); });
} }
if(dataForm.retail_finished_goods !==undefined)
{
retail_finished_goods = Object.keys(dataForm.retail_finished_goods).map(function(key)
{
return dataForm.retail_finished_goods[key];
})
}
let retail_temparr = [];
retail_temparr['retail_traded_goods'] = retail_traded_goods;
retail_temparr['retail_finished_goods'] = retail_finished_goods;
this.initRetailDetails(retail_temparr);
}
let arr2 = record.filter(data => data.type_of_activity_id === 3);
if(arr2.length > 0) {
let trading_finished_goods;
let trading_traded_goods;
if(dataForm.trading_finished_goods !==undefined){
trading_finished_goods = Object.keys(dataForm.trading_finished_goods).map(function (key) {
return dataForm.trading_finished_goods[key];
});
}
if(dataForm.trading_traded_goods !==undefined)
{
trading_traded_goods = Object.keys(dataForm.trading_traded_goods).map(function(key)
{
return dataForm.trading_traded_goods[key];
})
}
let trading_temparr = [];
trading_temparr['trading_finished_goods'] = trading_finished_goods;
trading_temparr['trading_traded_goods'] = trading_traded_goods;
this.initTradingDetails(trading_temparr);
}
this.noRecordsFound = true;
}
else{
console.log('dataForm',dataForm);
this.stockForms = this.fb.group({
pdid: [this.pdid],
formid: [this.form_id],
stock_remarks: [''],
manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]),
retail_details : this.fb.array([this.retailFormCreation(record)]),
trade_details: this.fb.array([this.tradingFormCreation(record)]),
});
let arr = record.filter(data => data.type_of_activity_id === 1);
if(arr.length > 0) {
this.initManufacturingDetails(null);
}
let arr1 = record.filter(data => data.type_of_activity_id === 2);
if(arr1.length > 0) {
this.initRetailDetails(null);
}
let arr2 = record.filter(data => data.type_of_activity_id === 3);
if(arr2.length > 0) {
this.initTradingDetails(null);
}
let arr3 = record.filter(data => data.type_of_activity_id === 4);
if(arr3.length > 0) {
//this.serviceProviderForm = true;
}
this.noRecordsFound = true;
}
}
else {
this.stockForms = this.fb.group({
pdid: [this.pdid],
formid: [this.form_id],
stock_remarks: [''],
manufacturing_details: this.fb.array([this.manufacturingFormCreation(record)]),
retail_details : this.fb.array([this.retailFormCreation(record)]),
trade_details: this.fb.array([this.tradingFormCreation(record)]),
});
let arr = record.filter(data => data.type_of_activity_id === 1);
if(arr.length > 0) {
this.initManufacturingDetails(null);
}
let arr1 = record.filter(data => data.type_of_activity_id === 2);
if(arr1.length > 0) {
this.initRetailDetails(null);
}
let arr2 = record.filter(data => data.type_of_activity_id === 3);
if(arr2.length > 0) {
this.initTradingDetails(null);
}
let arr3 = record.filter(data => data.type_of_activity_id === 4);
if(arr3.length > 0) {
//this.serviceProviderForm = true;
}
this.noRecordsFound = true;
}
})
// this.stockForms = this.fb.group({
// stock_remarks: ['', Validators.compose([Validators.required])],
// raw_materials: this.fb.array([]),
// finished_goods: this.fb.array([]),
// traded_goods: this.fb.array([])
// });
}
manufacturingForm: Boolean = false;
manufacturingFormCreation(val) {
let arr = val.filter(data => data.type_of_activity_id === 1);
if (arr.length > 0) {
this.manufacturingForm = true;
return this.fb.group({
manufacturing_raw_materials: this.fb.array([]),
manufacturing_finished_goods: this.fb.array([]),
manufacturing_traded_goods: this.fb.array([])
})
// }
} else {
return;
}
}
retailForm: Boolean = false;
retailFormCreation(val) {
let arr = val.filter(data => data.type_of_activity_id === 2);
if (arr.length > 0) {
this.retailForm = true;
return this.fb.group({
retail_finished_goods: this.fb.array([]),
retail_traded_goods: this.fb.array([])
})
// }
} else {
return;
}
}
tradingForm: Boolean = false;
tradingFormCreation(val) {
let arr = val.filter(data => data.type_of_activity_id === 3);
if (arr.length > 0) {
this.tradingForm = true;
return this.fb.group({
trading_finished_goods: this.fb.array([]),
trading_traded_goods: this.fb.array([])
});
} else {
return;
}
}
//setSku(sku: string, index: number) { //setSku(sku: string, index: number) {
// const faControl = // const faControl =
// (<FormArray>this.stockForm.controls['raw_materials']).at(index); // (<FormArray>this.stockForms.controls['raw_materials']).at(index);
// faControl['controls'].raw_name.setValue(sku); // faControl['controls'].raw_name.setValue(sku);
// } // }
createRawmaterial() {
initManufacturingDetails(datas) {
const rawMaterial = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_raw_materials'];
const finishedGoods = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods'];
const tradedGoods = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_traded_goods'];
const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['main_raw_materials'];
if(datas === null){
console.log(299,'if');
// rawMaterial.push(this.createRawmaterial(null));
// finishedGoods.push(this.createGoods(null));
// tradedGoods.push(this.createTradedGoods(null));
} else {
console.log(305,'else')
for (let val of datas.manufacturing_raw_materials) {
console.log(val);
rawMaterial.push(this.createRawmaterial(val));
}
for (let val of datas.manufacturing_finished_goods) {
console.log(val);
finishedGoods.push(this.createGoods(val));
}
for (let val of datas.manufacturing_traded_goods) {
console.log(val);
tradedGoods.push(this.createTradedGoods(val));
}
console.log(310,rawMaterial);
}
}
createRawmaterial2() {
return this.fb.group({ return this.fb.group({
raw_name: ['', Validators.compose([Validators.required])], raw_name: ['', Validators.compose([Validators.required])],
stock_observed:['', Validators.compose([Validators.required])], stock_observed:['', Validators.compose([Validators.required])],
@ -234,7 +392,67 @@ export class StockComponent implements OnInit {
rawmaterial_remarks:[''] rawmaterial_remarks:['']
}); });
} }
createGoods() {
createRawmaterial(records) {
// console.log(330,'function in');
if(records === null) {
// console.log(331,'fif');
return this.fb.group({
raw_name: [''],
stock_observed:[''],
raw_quantity: [''],
raw_uom: [''],
other_uom : [''],
raw_value: [''],
rawmaterial_value: [''],
is_sufficiant_raw: [''],
rawmaterial_remarks:['']
})
} else {
// console.log(343,'else');
return this.fb.group({
manufacturing_raw_material_name: [records.manufacturing_raw_material_name || null],
raw_name: [records.raw_name],
stock_observed:[records.stock_observed],
raw_quantity: [records.raw_quantity],
raw_uom: [records.raw_uom],
other_uom : [records.other_uom],
raw_value: [records.raw_value],
rawmaterial_value: [records.rawmaterial_value],
is_sufficiant_raw: [records.is_sufficiant_raw],
rawmaterial_remarks:[records.rawmaterial_remarks]
})
}
}
initRetailDetails(datas) {
const finishedGoods = <FormArray>this.stockForms.controls['retail_details']['controls'][0].controls['retail_finished_goods'];
const tradedGoods = <FormArray>this.stockForms.controls['retail_details']['controls'][0].controls['retail_traded_goods'];
if(datas === null){
finishedGoods.push(this.createGoods(null));
tradedGoods.push(this.createTradedGoods(null));
} else {
for (let val of datas.retail_finished_goods) {
console.log(val);
finishedGoods.push(this.createGoods(val));
}
for (let val of datas.retail_traded_goods) {
console.log(val);
tradedGoods.push(this.createTradedGoods(val));
}
}
}
createGoods2() {
return this.fb.group({ return this.fb.group({
goods_name: ['', Validators.compose([Validators.required])], goods_name: ['', Validators.compose([Validators.required])],
goods_observed: ['', Validators.compose([Validators.required])], goods_observed: ['', Validators.compose([Validators.required])],
@ -246,7 +464,33 @@ export class StockComponent implements OnInit {
}); });
} }
createTradedGoods() { createGoods(records) {
if(records === null) {
return this.fb.group({
goods_name: [''],
goods_observed: [''],
goods_quantity: [''],
goods_value: [''],
finished_goods_value: [''],
is_sufficiant_goods: [''],
finishedgoods_remarks:['']
});
}
else {
return this.fb.group({
goods_name: [records.goods_name],
goods_observed: [records.goods_observed],
goods_quantity: [records.goods_quantity],
goods_value: [records.goods_value],
finished_goods_value: [records.finished_goods_value],
is_sufficiant_goods: [records.is_sufficiant_goods],
finishedgoods_remarks:[records.finishedgoods_remarks]
})
}
}
createTradedGoods2() {
return this.fb.group({ return this.fb.group({
traded_goods_name: ['', Validators.compose([Validators.required])], traded_goods_name: ['', Validators.compose([Validators.required])],
traded_goods_observed: ['', Validators.compose([Validators.required])], traded_goods_observed: ['', Validators.compose([Validators.required])],
@ -257,64 +501,231 @@ export class StockComponent implements OnInit {
traded_goods_remarks:[''] traded_goods_remarks:['']
}); });
} }
addRawMaterials() {
const control = <FormArray>this.stockForm.controls['raw_materials']; initTradingDetails(datas) {
control.push(this.createRawmaterial());
const finishedGoods = <FormArray>this.stockForms.controls['trade_details']['controls'][0].controls['trading_finished_goods'];
const tradedGoods = <FormArray>this.stockForms.controls['trade_details']['controls'][0].controls['trading_traded_goods'];
if(datas === null){
finishedGoods.push(this.createGoods(null));
tradedGoods.push(this.createTradedGoods(null));
} else {
// for (let val of datas) {
// finishedGoods.push(this.createGoods(val.trading_finished_goods));
// tradedGoods.push(this.createTradedGoods(val.trading_traded_goods));
// }
for (let val of datas.trading_finished_goods) {
console.log(val);
finishedGoods.push(this.createGoods(val));
} }
deleteRawMaterials(index) { for (let val of datas.trading_traded_goods) {
const control = <FormArray>this.stockForm.controls['raw_materials']; console.log(val);
control.removeAt(index); tradedGoods.push(this.createTradedGoods(val));
}
addGoods() {
const control = <FormArray>this.stockForm.controls['finished_goods'];
control.push(this.createGoods());
}
deleteGoods(index) {
const control = <FormArray>this.stockForm.controls['finished_goods'];
control.removeAt(index);
}
addTradedGoods() {
const control = <FormArray>this.stockForm.controls['traded_goods'];
control.push(this.createTradedGoods());
}
deleteTradedGoods(index) {
const control = <FormArray>this.stockForm.controls['traded_goods'];
control.removeAt(index);
} }
submitDetails() {
if (!this.stockForm.valid) {
return;
} }
let records: any = {};
records.pdid = this.pdid;
records.formid = this.form_id;
records.fk_createdby = this.pdid;
if(this.rawMaterialAccess == true){
records.raw_materials = this.stockForm.controls['raw_materials'].value; }
if(this.finishedGoodsAccess == true){
records.finished_goods = this.stockForm.controls['finished_goods'].value;}
if(this.tradeConcernAccess == true){
records.traded_goods = this.stockForm.controls['traded_goods'].value; }
records.stock_remarks = this.stockForm.controls['stock_remarks'].value;
//console.log('data', records);
this._pd.saveForm(records).subscribe(data => {
//console.log('data', data);
this.notifier.notify('success', 'Saved Successfully.');
}, error => {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
})
}
validateAllFormFields(formGroup: FormGroup) {
Object.keys(formGroup.controls).forEach(field => {
const control = formGroup.get(field);
if (control instanceof FormControl) {
control.markAsTouched({onlySelf: true});
} else if (control instanceof FormGroup) {
this.validateAllFormFields(control);
} }
createTradedGoods(records) {
if(records === null) {
return this.fb.group({
traded_goods_name: [''],
traded_goods_observed: [''],
traded_goods_quantity: [''],
estimated_traded_goods_value: [''],
traded_goods_value: [''],
is_sufficiant_traded_goods: [''],
traded_goods_remarks:['']
}); });
} }
else {
return this.fb.group({
traded_goods_name: [records.traded_goods_name],
traded_goods_observed: [records.traded_goods_observed],
traded_goods_quantity: [records.traded_goods_quantity],
estimated_traded_goods_value: [records.estimated_traded_goods_value],
traded_goods_value: [records.traded_goods_value],
is_sufficiant_traded_goods: [records.is_sufficiant_traded_goods],
traded_goods_remarks:[records.traded_goods_remarks]
})
}
}
addRawMaterials(flag) {
if(flag==1){
const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_raw_materials'];
control.push(this.createRawmaterial(null));
}
}
deleteRawMaterials(index,flag) {
if(flag==1){
const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_raw_materials'];
// const control = <FormArray>this.stockForms.controls['raw_materials'];
control.removeAt(index);
}
}
addGoods(flag) {
//const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods'];
//const control = <FormArray>this.stockForms.controls['finished_goods'];
//control.push(this.createGoods(null));
switch(flag){
case 1: {
const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods'];
control.push(this.createGoods(null));
break;
}
case 2: {
const control = <FormArray>this.stockForms.controls['retail_details']['controls'][0].controls['retail_finished_goods'];
control.push(this.createGoods(null));
break;
}
case 3: {
const control = <FormArray>this.stockForms.controls['trade_details']['controls'][0].controls['trading_finished_goods'];
control.push(this.createGoods(null));
break;
}
default: {
break;
}
}
}
deleteGoods(index,flag) {
switch(flag){
case 1: {
const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods'];
control.removeAt(index);
break;
}
case 2: {
const control = <FormArray>this.stockForms.controls['retail_details']['controls'][0].controls['retail_finished_goods'];
control.removeAt(index);
break;
}
case 3: {
const control = <FormArray>this.stockForms.controls['trade_details']['controls'][0].controls['trading_finished_goods'];
control.removeAt(index);
break;
}
default: {
break;
}
}
//const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_finished_goods'];
//const control = <FormArray>this.stockForms.controls['finished_goods'];
}
addTradedGoods(flag) {
// const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_traded_goods'];
// //const control = <FormArray>this.stockForms.controls['traded_goods'];
// control.push(this.createTradedGoods(null));
switch(flag){
case 1: {
const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_traded_goods'];
control.push(this.createTradedGoods(null));
break;
}
case 2: {
const control = <FormArray>this.stockForms.controls['retail_details']['controls'][0].controls['retail_traded_goods'];
control.push(this.createTradedGoods(null));
break;
}
case 3: {
const control = <FormArray>this.stockForms.controls['trade_details']['controls'][0].controls['trading_traded_goods'];
control.push(this.createTradedGoods(null));
break;
}
default: {
break;
}
}
}
deleteTradedGoods(index,flag) {
switch(flag){
case 1: {
const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_traded_goods'];
control.removeAt(index);
break;
}
case 2: {
const control = <FormArray>this.stockForms.controls['retail_details']['controls'][0].controls['retail_traded_goods'];
control.removeAt(index);
break;
}
case 3: {
const control = <FormArray>this.stockForms.controls['trade_details']['controls'][0].controls['trading_traded_goods'];
control.removeAt(index);
break;
}
default: {
break;
}
}
//const control = <FormArray>this.stockForms.controls['manufacturing_details']['controls'][0].controls['manufacturing_traded_goods'];
//const control = <FormArray>this.stockForms.controls['traded_goods'];
}
/** To Save/Edited Popup Data */
submitDetails(e) {
this.submitted = true;
// stop here if form is invalid
// if (this.stockForms.invalid) {
// return;
// } else {
var answerFormValues = this.stockForms.value;
//To Remove The "Null" With Key also
Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]);
this._pd.savePDFormDetailsWithID(answerFormValues).subscribe(
dataresult => {
if (dataresult.status == 200) {
this.notifier.notify('success', 'Record Saved Successfully.!');
}
else {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
}
}, error => {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
});
//}
}
// validateAllFormFields(formGroup: FormGroup) {
// Object.keys(formGroup.controls).forEach(field => {
// const control = formGroup.get(field);
// if (control instanceof FormControl) {
// control.markAsTouched({onlySelf: true});
// } else if (control instanceof FormGroup) {
// this.validateAllFormFields(control);
// }
// });
// }
getUOM() { getUOM() {
this._pd.getAllMasterDatas('UOM').subscribe(data => { this._pd.getAllMasterDatas('UOM').subscribe(data => {
@ -352,134 +763,4 @@ export class StockComponent implements OnInit {
break; break;
} }
} }
// Validation Dynamically Add And Remove
GoodsValidation(event: any){
// console.log('First Time',event);
// console.log('First Time Value',event.value);
const control = <FormArray>this.stockForm.controls['finished_goods'];
if(event.value == 'no') {
control.controls[0].get('goods_quantity').setValidators([Validators.required]);
control.controls[0].get('goods_quantity').updateValueAndValidity();
control.controls[0].get('goods_value').setValidators([Validators.required]);
control.controls[0].get('goods_value').updateValueAndValidity();
control.controls[0].get('finished_goods_value').setValidators([Validators.required]);
control.controls[0].get('finished_goods_value').updateValueAndValidity();
control.controls[0].get('is_sufficiant_goods').setValidators([Validators.required]);
control.controls[0].get('is_sufficiant_goods').updateValueAndValidity();
}
else
if(event.value == 'yes') {
control.controls[0].get('goods_quantity').clearValidators();
control.controls[0].get('goods_quantity').updateValueAndValidity();
control.controls[0].get('goods_value').clearValidators();
control.controls[0].get('goods_value').updateValueAndValidity();
control.controls[0].get('finished_goods_value').clearValidators();
control.controls[0].get('finished_goods_value').updateValueAndValidity();
control.controls[0].get('is_sufficiant_goods').clearValidators();
control.controls[0].get('is_sufficiant_goods').updateValueAndValidity();
}
}
RawMaterialValidation(event: any){
// console.log('First Time',event);
// console.log('First Time Value',event.value);
const control = <FormArray>this.stockForm.controls['raw_materials'];
if(event.value == 'no') {
control.controls[0].get('raw_quantity').setValidators([Validators.required]);
control.controls[0].get('raw_quantity').updateValueAndValidity();
control.controls[0].get('raw_uom').setValidators([Validators.required]);
control.controls[0].get('raw_uom').updateValueAndValidity();
control.controls[0].get('raw_value').setValidators([Validators.required]);
control.controls[0].get('raw_value').updateValueAndValidity();
control.controls[0].get('rawmaterial_value').setValidators([Validators.required]);
control.controls[0].get('rawmaterial_value').updateValueAndValidity();
control.controls[0].get('is_sufficiant_raw').setValidators([Validators.required]);
control.controls[0].get('is_sufficiant_raw').updateValueAndValidity();
}
else
if(event.value == 'yes') {
control.controls[0].get('raw_quantity').clearValidators();
control.controls[0].get('raw_quantity').updateValueAndValidity();
control.controls[0].get('raw_uom').clearValidators();
control.controls[0].get('raw_uom').updateValueAndValidity();
control.controls[0].get('raw_value').clearValidators();
control.controls[0].get('raw_value').updateValueAndValidity();
control.controls[0].get('rawmaterial_value').clearValidators();
control.controls[0].get('rawmaterial_value').updateValueAndValidity();
control.controls[0].get('is_sufficiant_raw').clearValidators();
control.controls[0].get('is_sufficiant_raw').updateValueAndValidity();
}
}
TradedGoodsValidation(event: any){
console.log('First Time',event);
console.log('First Time Value',event.value);
const control = <FormArray>this.stockForm.controls['tradeded_goods'];
if(event.value == 'no') {
control.controls[0].get('traded_goods_quantity').setValidators([Validators.required]);
control.controls[0].get('traded_goods_quantity').updateValueAndValidity();
control.controls[0].get('estimated_traded_goods_value').setValidators([Validators.required]);
control.controls[0].get('estimated_traded_goods_value').updateValueAndValidity();
control.controls[0].get('traded_goods_value').setValidators([Validators.required]);
control.controls[0].get('traded_goods_value').updateValueAndValidity();
control.controls[0].get('is_sufficiant_traded_goods').setValidators([Validators.required]);
control.controls[0].get('is_sufficiant_traded_goods').updateValueAndValidity();
}
else
if(event.value == 'yes') {
control.controls[0].get('traded_goods_quantity').clearValidators();
control.controls[0].get('traded_goods_quantity').updateValueAndValidity();
control.controls[0].get('estimated_traded_goods_value').clearValidators();
control.controls[0].get('estimated_traded_goods_value').updateValueAndValidity();
control.controls[0].get('traded_goods_value').clearValidators();
control.controls[0].get('traded_goods_value').updateValueAndValidity();
control.controls[0].get('is_sufficiant_traded_goods').clearValidators();
control.controls[0].get('is_sufficiant_traded_goods').updateValueAndValidity();
}
}
} }