Ai changes
This commit is contained in:
parent
05b64e4a5d
commit
87acb19edf
@ -13,52 +13,95 @@
|
||||
<mat-card-content formArrayName="sales_product">
|
||||
<mat-card *ngFor="let sales of salesItemForm.controls.sales_product['controls']; let s = index;" [formGroupName]="s">
|
||||
<mat-card-content>
|
||||
<mat-form-field style="width: 35%">
|
||||
<mat-form-field style="width: 87%">
|
||||
<input type="text" matInput placeholder="Product/Services" formControlName="sales_item" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 20%" *ngIf="data.margin_calculation_status===true">
|
||||
<input matInput OnlyNumber type="text" placeholder="Magin Percetage %" formControlName="margin_per" (keyup)="salesCalculation(s,sales.value)">
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 25%" *ngIf="data.margin_calculation_status===true">
|
||||
<input matInput OnlyNumber type="text" placeholder="Margin Value" formControlName="margin_value" readonly>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="sales.value.margin_value != ''">{{"₹"}} {{sales.value.margin_value | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeProducts(s)" *ngIf="salesItemForm.value.sales_product.length>1"
|
||||
matTooltip="Remove" matTooltipPosition="above">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
<mat-form-field style="width: 88%">
|
||||
<textarea matInput type="text" placeholder="Remarks" formControlName="comments"></textarea>
|
||||
</mat-form-field>
|
||||
<div formArrayName="child">
|
||||
<mat-radio-group class="example-radio-group" formControlName="sales_type" (change)="changeOptions(s,$event)">
|
||||
<mat-radio-button class="example-radio-button" color="primary" [value]="types.type_id" *ngFor="let types of check_type; let t = index">{{types.type_name}}</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
<!-- switch case date/frequency information section -->
|
||||
<div [ngSwitch]="sales.value.sales_type">
|
||||
<!-- date info -->
|
||||
<div *ngSwitchCase="1" formArrayName="child">
|
||||
<div class="item-margin" fxLayout="row wrap" *ngFor="let childItem of sales.get('child').controls; let c = index" [formGroupName]="c">
|
||||
<div fxFlex="100" *ngIf="childItem.value.isactive===true">
|
||||
<mat-form-field style="width: 33%;">
|
||||
<input matInput [max]="maxDate" [matDatepicker]="picker" formControlName="sales_date" (dateChange)="salesCalculation(s,sales.value)" placeholder="Sales Date" required>
|
||||
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #picker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 50%">
|
||||
<input OnlyNumber type="text" matInput placeholder="Bill Value" (keyup)="salesCalculation(s,sales.value)" formControlName="sales_value" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="childItem.value.sales_value != ''">{{"₹"}} {{childItem.value.sales_value | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeDailyItems(s,c,childItem.value)" *ngIf="sales.value.child.length>1"
|
||||
matTooltip="Remove" matTooltipPosition="above">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div align="center" style="margin-top: 3%;">
|
||||
<button type="button" mat-flat-button (click)="addMoreDailySales(s,sales.value)"
|
||||
matTooltip="Add More" matTooltipPosition="above" color="primary">
|
||||
<strong>Add More Daily Sales</strong>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- frequency info -->
|
||||
<div *ngSwitchCase="2" formArrayName="child">
|
||||
<div class="item-margin" fxLayout="row wrap" *ngFor="let childItem of sales.get('child').controls; let c = index" [formGroupName]="c">
|
||||
<div fxFlex="100" *ngIf="childItem.value.isactive===true">
|
||||
<mat-form-field style="width: 33%;">
|
||||
<input matInput [max]="maxDate" [matDatepicker]="picker" formControlName="sales_date" (dateChange)="salesCalculation(s,sales.value)" placeholder="Sales Date" required>
|
||||
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #picker></mat-datepicker>
|
||||
<mat-form-field style="width: 40%">
|
||||
<mat-select placeholder="Frequency" formControlName="fk_frequency_id" (selectionChange)="salesCalculation(s,sales.value)" required>
|
||||
<mat-option *ngFor="let frq of frequencyData" [value]="frq.frequency_id">{{frq.name}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 50%">
|
||||
<input OnlyNumber type="text" matInput placeholder="Value" (keyup)="salesCalculation(s,sales.value,sales.value.child)" formControlName="sales_value" required>
|
||||
<mat-form-field style="width: 44%">
|
||||
<input OnlyNumber type="text" matInput placeholder="Value" (keyup)="salesCalculation(s,sales.value)" formControlName="frequency_value" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="childItem.value.frequency_value != ''">{{"₹"}} {{childItem.value.frequency_value | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 88%">
|
||||
<input OnlyNumber type="text" matInput placeholder="Annual Value" (keyup)="salesCalculation(s,sales.value)" formControlName="sales_value" readonly required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="childItem.value.sales_value != ''">{{"₹"}} {{childItem.value.sales_value | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeDailyItems(s,c,childItem.value)" *ngIf="sales.value.child.length>1"
|
||||
<!-- <button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeDailyItems(s,c,childItem.value)" *ngIf="sales.value.child.length>1"
|
||||
matTooltip="Remove" matTooltipPosition="above">
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</button> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top:3%;margin-bottom:2%; ">
|
||||
<mat-form-field style="width: 40%" *ngIf="data.margin_calculation_status===true">
|
||||
<input matInput OnlyNumber type="text" placeholder="Magin Percetage %" formControlName="margin_per" (keyup)="salesCalculation(s,sales.value)">
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 44%" *ngIf="data.margin_calculation_status===true">
|
||||
<input matInput OnlyNumber type="text" placeholder="Margin Value" formControlName="margin_value" readonly>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="sales.value.margin_value != ''">{{"₹"}} {{sales.value.margin_value | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
|
||||
<mat-form-field style="width: 88%">
|
||||
<textarea matInput type="text" placeholder="Remarks" formControlName="comments" [required]="sales.value.sales_type=='2' ? true : false"></textarea>
|
||||
</mat-form-field>
|
||||
|
||||
</mat-card-content>
|
||||
<mat-card-actions align="center">
|
||||
<!-- <mat-card-actions align="center">
|
||||
<button type="button" mat-flat-button (click)="addMoreDailySales(s,sales.value)"
|
||||
matTooltip="Add More" matTooltipPosition="above" color="primary">
|
||||
<strong>Add More Daily Sales</strong>
|
||||
</button>
|
||||
|
||||
</mat-card-actions>
|
||||
</mat-card-actions> -->
|
||||
</mat-card>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
@ -20,3 +20,12 @@
|
||||
margin-left:4%;
|
||||
margin-top:2%;
|
||||
}
|
||||
.example-radio-group {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.example-radio-button {
|
||||
margin: 0 2%;
|
||||
color: #000 !important
|
||||
}
|
||||
@ -20,9 +20,11 @@ export class ManageDailySalesComponent implements OnInit {
|
||||
frequencyData: any[]=[];
|
||||
marginAmtInwords: any[]=[];
|
||||
private notifier: NotifierService;
|
||||
check_type:any=[{'type_id':"1",'type_name':'Date Information'},{'type_id':"2",'type_name':'Frequency Information'}]
|
||||
constructor(notifier: NotifierService,private _fb: FormBuilder, private _pd: PdTrigerService, @Inject(MAT_DIALOG_DATA) public data: any, private dialogRef: MatDialogRef<ManageDailySalesComponent>) {
|
||||
this.pageTitle = this.data.manage_status==1 ? 'Add Daily Sales Item' : 'Update Daily Sales Item';
|
||||
this.notifier = notifier;
|
||||
this.frequencyData=this.data.masterData.frequencyList;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@ -39,10 +41,27 @@ export class ManageDailySalesComponent implements OnInit {
|
||||
sales_product: this._fb.array([this.createSalesItemWithData(this.data.editData)]),
|
||||
});
|
||||
let control: any = <FormArray>this.salesItemForm.controls['sales_product'];
|
||||
control = control.controls[0].get('child') as FormArray;
|
||||
let innercontrol: any = control.controls[0].get('child') as FormArray;
|
||||
this.data.editData.values.forEach((elementVal,inx) => {
|
||||
control.push(this.createDailySalesWithData(elementVal,this.data.editData.sim_id))
|
||||
});
|
||||
innercontrol.push(this.createDailySalesWithData(elementVal,this.data.editData))
|
||||
});
|
||||
|
||||
if(this.data.editData.sales_type=="2"){
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_date'].setValue("");
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_date'].clearValidators();
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_date'].updateValueAndValidity();
|
||||
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['fk_frequency_id'].setValidators([Validators.required]);
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['fk_frequency_id'].updateValueAndValidity();
|
||||
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['frequency_value'].setValidators([Validators.required]);
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['frequency_value'].updateValueAndValidity();
|
||||
|
||||
control.controls[control.value.length-1].controls['comments'].setValidators([Validators.required]);
|
||||
control.controls[control.value.length-1].controls['comments'].updateValueAndValidity();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
this.salesItemForm = this._fb.group({
|
||||
@ -64,7 +83,8 @@ export class ManageDailySalesComponent implements OnInit {
|
||||
margin_per: [''],
|
||||
margin_value: [''],
|
||||
comments: [''],
|
||||
isactive:[true]
|
||||
sales_type:["1"],
|
||||
isactive:[true],
|
||||
});
|
||||
}
|
||||
// create daily list empty
|
||||
@ -74,6 +94,8 @@ createDailySalesData(sim_id: string) {
|
||||
fk_sim_id: [sim_id],
|
||||
sales_date: [''],
|
||||
sales_value: ['', Validators.compose([Validators.required])],
|
||||
fk_frequency_id:[''],
|
||||
frequency_value:[''],
|
||||
isactive:[true],
|
||||
})
|
||||
}
|
||||
@ -89,16 +111,19 @@ createSalesItemWithData(values: any) {
|
||||
margin_per: [this.data.margin_calculation_status===true ? values.margin_per: ''],
|
||||
margin_value: [this.data.margin_calculation_status===true ? values.margin_value: ''],
|
||||
comments: [values.comments],
|
||||
isactive:[true]
|
||||
sales_type:[values.sales_type],
|
||||
isactive:[true],
|
||||
});
|
||||
}
|
||||
// create daily list
|
||||
createDailySalesWithData(values: any, sim_id: string) {
|
||||
createDailySalesWithData(values: any, parent: any) {
|
||||
return this._fb.group({
|
||||
simc_id: [values.simc_id],
|
||||
fk_sim_id: [sim_id],
|
||||
sales_date: [new Date(this.pipe.transform(values.sales_date, 'yyyy-MM-dd')), Validators.compose([Validators.required])],
|
||||
fk_sim_id: [parent.sim_id],
|
||||
sales_date: [parent.sales_type=='2' ? '' :new Date(this.pipe.transform(values.sales_date, 'yyyy-MM-dd')), Validators.compose([Validators.required])],
|
||||
sales_value: [values.sales_value, Validators.compose([Validators.required])],
|
||||
fk_frequency_id:[values.fk_frequency_id],
|
||||
frequency_value:[values.frequency_value],
|
||||
isactive:[true]
|
||||
})
|
||||
}
|
||||
@ -148,7 +173,7 @@ closeDialogue(){
|
||||
}
|
||||
|
||||
salesCalculation(indexVal: number,values: any): void {
|
||||
if(this.data.margin_calculation_status===true){
|
||||
if(this.data.margin_calculation_status===true && values.sales_type=="1"){
|
||||
let control:any = <FormArray>this.salesItemForm.controls['sales_product'];
|
||||
if(values.child.length>0 && values.margin_per!=''){
|
||||
let transformData = values.child.filter(val=>val.sales_date!='' && val.sales_date!=null && val.sales_date!=undefined && val.sales_value!='' && val.isactive===true).map(mval=>{
|
||||
@ -165,7 +190,7 @@ salesCalculation(indexVal: number,values: any): void {
|
||||
control.controls[indexVal].controls['margin_value'].setValue(parseInt(getTotalValueCounts) * (parseInt(values.margin_per)/100) * (12 / parseInt(getUniqueMonthCounts.length)));
|
||||
}
|
||||
else{
|
||||
control.controls[indexVal].controls['margin_value'].setValue('');
|
||||
control.controls[indexVal].controls['margin_value'].setValue("");
|
||||
}
|
||||
|
||||
}
|
||||
@ -174,8 +199,88 @@ salesCalculation(indexVal: number,values: any): void {
|
||||
|
||||
}
|
||||
}
|
||||
else if(this.data.margin_calculation_status===true && values.sales_type=="2"){
|
||||
let control:any = <FormArray>this.salesItemForm.controls['sales_product'];
|
||||
let innercontrol: any = control.controls[indexVal].get('child') as FormArray;
|
||||
|
||||
if(values.child[values.child.length-1].fk_frequency_id!='' && values.child[values.child.length-1].frequency_value!=''){
|
||||
let filterFrequencyValue: any = this.frequencyData.filter(val =>val.frequency_id==values.child[values.child.length-1].fk_frequency_id);
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_value'].setValue(parseInt(filterFrequencyValue[0].mutiple_factor) * parseInt(values.child[values.child.length-1].frequency_value));
|
||||
|
||||
let getTotalValueCounts =parseInt(filterFrequencyValue[0].mutiple_factor) * parseInt(values.child[values.child.length-1].frequency_value)
|
||||
values.margin_per!='' ? control.controls[indexVal].controls['margin_value'].setValue( getTotalValueCounts * (parseInt(values.margin_per)/100)) : '';
|
||||
}
|
||||
else {
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_value'].setValue("");
|
||||
control.controls[indexVal].controls['margin_value'].setValue("");
|
||||
|
||||
}
|
||||
}
|
||||
else if(this.data.margin_calculation_status===false && values.sales_type=="2"){
|
||||
let control:any = <FormArray>this.salesItemForm.controls['sales_product'];
|
||||
let innercontrol: any = control.controls[indexVal].get('child') as FormArray;
|
||||
|
||||
if(values.child[values.child.length-1].fk_frequency_id!='' && values.child[values.child.length-1].frequency_value!=''){
|
||||
let filterFrequencyValue: any = this.frequencyData.filter(val =>val.frequency_id==values.child[values.child.length-1].fk_frequency_id);
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_value'].setValue(parseInt(filterFrequencyValue[0].mutiple_factor) * parseInt(values.child[values.child.length-1].frequency_value));
|
||||
}
|
||||
else {
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_value'].setValue("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// change options for either Date/Frequency Information
|
||||
changeOptions(indexVal: any,event: any): void{
|
||||
let control: any = <FormArray>this.salesItemForm.controls['sales_product'];
|
||||
let innercontrol: any = control.controls[indexVal].get('child') as FormArray;
|
||||
if(event.value==1){
|
||||
for (let i = 0; i < innercontrol.value.length-1; i++) {
|
||||
innercontrol.removeAt(i);
|
||||
}
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_date'].setValidators([Validators.required]);
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_date'].updateValueAndValidity();
|
||||
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['fk_frequency_id'].setValue("");
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['fk_frequency_id'].clearValidators();
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['fk_frequency_id'].updateValueAndValidity();
|
||||
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['frequency_value'].setValue("");
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['frequency_value'].clearValidators();
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['frequency_value'].updateValueAndValidity();
|
||||
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_value'].setValue("");
|
||||
|
||||
control.controls[indexVal].controls['comments'].setValue("");
|
||||
control.controls[indexVal].controls['comments'].clearValidators();
|
||||
control.controls[indexVal].controls['comments'].updateValueAndValidity();
|
||||
}
|
||||
else if(event.value==2){
|
||||
for (let i = 0; i < innercontrol.value.length-1; i++) {
|
||||
innercontrol.removeAt(i);
|
||||
}
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_date'].setValue("");
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_date'].clearValidators();
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_date'].updateValueAndValidity();
|
||||
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['fk_frequency_id'].setValidators([Validators.required]);
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['fk_frequency_id'].updateValueAndValidity();
|
||||
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['frequency_value'].setValidators([Validators.required]);
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['frequency_value'].updateValueAndValidity();
|
||||
|
||||
innercontrol.controls[innercontrol.value.length-1].controls['sales_value'].setValue("");
|
||||
|
||||
control.controls[indexVal].controls['comments'].setValue("");
|
||||
control.controls[indexVal].controls['comments'].setValidators([Validators.required]);
|
||||
control.controls[indexVal].controls['comments'].updateValueAndValidity();
|
||||
|
||||
}
|
||||
control.controls[indexVal].controls['margin_per'].setValue("");
|
||||
control.controls[indexVal].controls['margin_value'].setValue("");
|
||||
|
||||
}
|
||||
// save sales details
|
||||
submitDetails(records) {
|
||||
if (this.salesItemForm.invalid) {
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<mat-card-content formArrayName="salesCalItemwise">
|
||||
<div fxLayout="row wrap" *ngFor="let sales of salesItemForm.controls.salesCalItemwise['controls']; let s = index;" [formGroupName]="s" style="margin-top: 4%;">
|
||||
<div fxFlex="100">
|
||||
<mat-form-field style="width: 90%">
|
||||
<mat-form-field style="width: 87%">
|
||||
<input type="text" matInput placeholder="Product/Services" formControlName="sales_item" required>
|
||||
</mat-form-field>
|
||||
<button type="button" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button (click)="removeItem(s)" *ngIf="salesItemForm.value.salesCalItemwise.length>1"
|
||||
@ -21,11 +21,17 @@
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="item-margin" fxFlex="100">
|
||||
|
||||
<div fxFlex="100">
|
||||
<mat-radio-group formControlName="sales_type" class="example-radio-group" (change)="changeOptions(s,$event)">
|
||||
<mat-radio-button class="example-radio-button" color="primary" [value]="types.type_id" *ngFor="let types of check_type; let t = index">{{types.type_name}}</mat-radio-button>
|
||||
</mat-radio-group>
|
||||
</div>
|
||||
<div class="item-margin" fxFlex="100" *ngIf="sales.value.sales_type=='1'">
|
||||
<mat-form-field style="width: 25%">
|
||||
<input OnlyNumber type="text" matInput placeholder="Sale Quantity" (keyup)="salesCalculation(s,sales.value);" formControlName="sales_qty" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 25%">
|
||||
<mat-form-field style="width: 25%" *ngIf="sales.value.sales_type=='1'">
|
||||
<mat-select placeholder="UOM" formControlName="fk_uom_id" required (selectionChange)="generateOtherUOM(s,sales.value)">
|
||||
<mat-option *ngFor="let uom of UOMData" [value]="uom.uom_id">{{uom.name}}</mat-option>
|
||||
</mat-select>
|
||||
@ -35,31 +41,55 @@
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
<!-- switch case for swap the frequency and value field -->
|
||||
<div [ngSwitch]="sales.value.sales_type" fxFlex="100">
|
||||
<!-- Case 1 -->
|
||||
<div *ngSwitchCase="1" class="item-margin" fxFlex="100">
|
||||
<mat-form-field style="width: 25%">
|
||||
<input OnlyNumber type="text" matInput placeholder="Rate/Unit of Sale" formControlName="rate_per_unit" (keyup)="salesCalculation(s,sales.value)" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="sales.value.rate_per_unit != ''">{{"₹"}} {{sales.value.rate_per_unit | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 25%">
|
||||
<mat-select placeholder="Frequency" formControlName="fk_frequency_id" (selectionChange)="salesCalculation(s,sales.value)" required>
|
||||
<mat-option *ngFor="let frq of frequencyData" [value]="frq.frequency_id">{{frq.name}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 30%">
|
||||
<input matInput OnlyNumber type="text" placeholder="Annual Sales" formControlName="annual_sale_value" readonly>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="sales.value.annual_sale_value != ''">{{"₹"}} {{sales.value.annual_sale_value | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<!-- case 2 -->
|
||||
<div *ngSwitchCase="2" class="item-margin" fxFlex="100">
|
||||
<mat-form-field style="width: 25%">
|
||||
<mat-select placeholder="Frequency" formControlName="fk_frequency_id" (selectionChange)="salesCalculation(s,sales.value)" required>
|
||||
<mat-option *ngFor="let frq of frequencyData" [value]="frq.frequency_id">{{frq.name}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 25%">
|
||||
<input OnlyNumber type="text" matInput [placeholder]="sales.value.fk_frequency_id=='1' ? 'Other Sale' : sales.value.fk_frequency_id=='2' ? 'Yearly Sale' : sales.value.fk_frequency_id=='3' ? 'Half Yearly Sale' : sales.value.fk_frequency_id=='4' ? 'Fortnightly Sale' : sales.value.fk_frequency_id=='5' ? 'Daily Sale' : sales.value.fk_frequency_id=='6' ? 'Quarterly Sale' : sales.value.fk_frequency_id=='7' ? 'Monthly Sale' : ''" formControlName="rate_per_unit" (keyup)="salesCalculation(s,sales.value)" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="sales.value.rate_per_unit != ''">{{"₹"}} {{sales.value.rate_per_unit | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field style="width: 30%">
|
||||
<input matInput OnlyNumber type="text" placeholder="Annual Sales" formControlName="annual_sale_value" readonly>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="sales.value.annual_sale_value != ''">{{"₹"}} {{sales.value.annual_sale_value | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end -->
|
||||
|
||||
|
||||
<div class="item-margin" fxFlex="100">
|
||||
<mat-form-field style="width: 25%">
|
||||
<input OnlyNumber type="text" matInput placeholder="Rate/Unit of Sale" formControlName="rate_per_unit" (keyup)="salesCalculation(s,sales.value)" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="sales.value.rate_per_unit != ''">{{"₹"}} {{sales.value.rate_per_unit | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 25%">
|
||||
<mat-select placeholder="Frequency" formControlName="fk_frequency_id" (selectionChange)="salesCalculation(s,sales.value)" required>
|
||||
<mat-option *ngFor="let frq of frequencyData" [value]="frq.frequency_id">{{frq.name}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 30%">
|
||||
<input matInput OnlyNumber type="text" placeholder="Annual Sales" formControlName="annual_sale_value" readonly>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="sales.value.annual_sale_value != ''">{{"₹"}} {{sales.value.annual_sale_value | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div class="item-margin" fxFlex="100" *ngIf="data.margin_calculation_status===true">
|
||||
<mat-form-field style="width: 25%">
|
||||
<input matInput OnlyNumber type="text" placeholder="Margin Percentage %" formControlName="margin_per" (keyup)="salesMarginPerCalculation(s,sales.value)">
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 25%">
|
||||
<mat-form-field style="width: 25%" *ngIf="sales.value.sales_type=='1'">
|
||||
<input matInput OnlyNumber type="text" placeholder="Margin Per Unit" formControlName="margin_per_uom" (keyup)="salesMarginAmtCalculation(s,sales.value)">
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="sales.value.margin_per_uom != ''">{{"₹"}} {{sales.value.margin_per_uom | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 25%">
|
||||
<mat-form-field style="width: 30%">
|
||||
<input matInput OnlyNumber type="text" placeholder="Considered Margin Amount" formControlName="margin_final_value" readonly>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="sales.value.margin_final_value != ''">{{"₹"}} {{sales.value.margin_final_value | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
@ -21,3 +21,13 @@
|
||||
margin-top:2%;
|
||||
}
|
||||
|
||||
.example-radio-group {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.example-radio-button {
|
||||
margin: 0 2%;
|
||||
color: #000 !important
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@ang
|
||||
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA , DialogPosition} from '@angular/material';
|
||||
import { PdTrigerService } from './../../../../../../../pd-service/pd-triger.service';
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
import { AnyAaaaRecord } from 'dns';
|
||||
|
||||
@Component({
|
||||
selector: 'app-manage-sales',
|
||||
@ -21,6 +22,7 @@ export class ManageSalesComponent implements OnInit {
|
||||
marginAmtInwords: any[]=[];
|
||||
marginFinalAmtInwords: any[]=[];
|
||||
ratePerUnitAmtInwords: any[]=[];
|
||||
check_type:any=[{'type_id':"1",'type_name':'Quantity and Rate Information'},{'type_id':"2",'type_name':'Value Information'}]
|
||||
|
||||
private notifier: NotifierService;
|
||||
constructor(notifier: NotifierService,private _fb: FormBuilder, private _pd: PdTrigerService, @Inject(MAT_DIALOG_DATA) public data: any, private dialogRef: MatDialogRef<ManageSalesComponent>) {
|
||||
@ -37,7 +39,17 @@ export class ManageSalesComponent implements OnInit {
|
||||
});
|
||||
let control: any = <FormArray>this.salesItemForm.controls['salesCalItemwise'];
|
||||
this.data.editData.fk_uom_id=="1" ? control.controls[0].addControl('uom_other', new FormControl(this.data.editData.uom_other ? this.data.editData.uom_other : '', Validators.required)) : control.controls[0].removeControl('uom_other');
|
||||
|
||||
if(this.data.editData.sales_type && this.data.editData.sales_type=="2"){
|
||||
control.controls[0].controls['sales_qty'].setValue("");
|
||||
control.controls[0].controls['sales_qty'].clearValidators();
|
||||
control.controls[0].controls['sales_qty'].updateValueAndValidity();
|
||||
|
||||
control.controls[0].controls['fk_uom_id'].setValue("");
|
||||
control.controls[0].controls['fk_uom_id'].clearValidators();
|
||||
control.controls[0].controls['fk_uom_id'].updateValueAndValidity();
|
||||
control.controls[0].controls['margin_per_uom'].setValue("");
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.salesItemForm = this._fb.group({
|
||||
@ -64,6 +76,7 @@ export class ManageSalesComponent implements OnInit {
|
||||
margin_per_uom:[''],
|
||||
margin_final_value:[''],
|
||||
comments:[],
|
||||
sales_type:["1"]
|
||||
});
|
||||
}
|
||||
|
||||
@ -83,6 +96,7 @@ createSalesItemWithData(values: any) {
|
||||
margin_per_uom:[this.data.margin_calculation_status===true ? values.margin_per_uom :''],
|
||||
margin_final_value:[this.data.margin_calculation_status===true ? values.margin_final_value: ''],
|
||||
comments:[values.comments],
|
||||
sales_type:[values.sales_type]
|
||||
|
||||
});
|
||||
}
|
||||
@ -100,11 +114,14 @@ closeDialogue(){
|
||||
|
||||
salesCalculation(indexVal: number,values: any): void {
|
||||
let control:any = <FormArray>this.salesItemForm.controls['salesCalItemwise'];
|
||||
if(values.sales_qty!='' && values.rate_per_unit!='' && values.fk_frequency_id!='') {
|
||||
if(values.sales_type=="1" && values.sales_qty!='' && values.rate_per_unit!='' && values.fk_frequency_id!='') {
|
||||
let filterFrequencyValue: any = this.frequencyData.filter(val =>val.frequency_id==values.fk_frequency_id);
|
||||
let AnnualSalesValue = parseInt(values.sales_qty) * parseInt(values.rate_per_unit) * parseInt(filterFrequencyValue[0].mutiple_factor)
|
||||
control.controls[indexVal].controls['annual_sale_value'].setValue(parseInt(values.sales_qty) * parseInt(values.rate_per_unit) * parseInt(filterFrequencyValue[0].mutiple_factor));
|
||||
}
|
||||
else if(values.sales_type=="2" && values.rate_per_unit!='' && values.fk_frequency_id!='') {
|
||||
let filterFrequencyValue: any = this.frequencyData.filter(val =>val.frequency_id==values.fk_frequency_id);
|
||||
control.controls[indexVal].controls['annual_sale_value'].setValue(parseInt(values.rate_per_unit) * parseInt(filterFrequencyValue[0].mutiple_factor));
|
||||
}
|
||||
else {
|
||||
control.controls[indexVal].controls['annual_sale_value'].setValue('');
|
||||
}
|
||||
@ -125,16 +142,48 @@ salesMarginPerCalculation(indexVal: number,values: any): void {
|
||||
salesMarginAmtCalculation(indexVal: number,values: any): void {
|
||||
let control:any = <FormArray>this.salesItemForm.controls['salesCalItemwise'];
|
||||
control.controls[indexVal].controls['margin_per'].setValue('');
|
||||
|
||||
|
||||
if(values.margin_per_uom!='' && values.sales_qty!='') {
|
||||
let MarginFinalValue = parseInt(values.sales_qty) * parseInt(values.margin_per_uom);
|
||||
|
||||
if(values.sales_type=="1" && values.margin_per_uom!='' && values.sales_qty!='') {
|
||||
control.controls[indexVal].controls['margin_final_value'].setValue(parseInt(values.sales_qty) * parseInt(values.margin_per_uom));
|
||||
}
|
||||
else if(values.sales_type=="2" && values.margin_per_uom!='' && values.rate_per_unit!='') {
|
||||
control.controls[indexVal].controls['margin_final_value'].setValue(parseInt(values.rate_per_unit) * parseInt(values.margin_per_uom));
|
||||
}
|
||||
else {
|
||||
control.controls[indexVal].controls['margin_final_value'].setValue('');
|
||||
}
|
||||
}
|
||||
// generate other UOM
|
||||
generateOtherUOM(index: number, values: any): void {
|
||||
let control: any = <FormArray>this.salesItemForm.controls['salesCalItemwise'];
|
||||
values.fk_uom_id=="1" ? control.controls[index].addControl('uom_other', new FormControl('', Validators.required)) : control.controls[index].removeControl('uom_other');
|
||||
}
|
||||
|
||||
// change options for either Quantity and Rate Information / Value Information
|
||||
changeOptions(indexVal: any,event: any): void{
|
||||
let control: any = <FormArray>this.salesItemForm.controls['salesCalItemwise'];
|
||||
if(event.value==1){
|
||||
control.controls[indexVal].controls['sales_qty'].setValidators([Validators.required]);
|
||||
control.controls[indexVal].controls['sales_qty'].updateValueAndValidity();
|
||||
|
||||
control.controls[indexVal].controls['fk_uom_id'].setValidators([Validators.required]);
|
||||
control.controls[indexVal].controls['fk_uom_id'].updateValueAndValidity();
|
||||
this.salesCalculation(indexVal,control.controls[indexVal].value);
|
||||
}
|
||||
else if(event.value==2){
|
||||
control.controls[indexVal].controls['sales_qty'].setValue("");
|
||||
control.controls[indexVal].controls['sales_qty'].clearValidators();
|
||||
control.controls[indexVal].controls['sales_qty'].updateValueAndValidity();
|
||||
|
||||
control.controls[indexVal].controls['fk_uom_id'].setValue("");
|
||||
control.controls[indexVal].controls['fk_uom_id'].clearValidators();
|
||||
control.controls[indexVal].controls['fk_uom_id'].updateValueAndValidity();
|
||||
|
||||
control.controls[indexVal].controls['margin_per_uom'].setValue("");
|
||||
|
||||
this.salesCalculation(indexVal,control.controls[indexVal].value);
|
||||
}
|
||||
}
|
||||
|
||||
removeItem(indexVal: number) : void {
|
||||
let control = <FormArray>this.salesItemForm.controls['salesCalItemwise'];
|
||||
@ -158,11 +207,7 @@ submitDetails(records) {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
});
|
||||
}
|
||||
// generate other UOM
|
||||
generateOtherUOM(index: number, values: any): void {
|
||||
let control: any = <FormArray>this.salesItemForm.controls['salesCalItemwise'];
|
||||
values.fk_uom_id=="1" ? control.controls[index].addControl('uom_other', new FormControl('', Validators.required)) : control.controls[index].removeControl('uom_other');
|
||||
}
|
||||
|
||||
|
||||
// validate all form group and form array fields
|
||||
validateAllFormFields(formGroup: any) {
|
||||
|
||||
@ -46,12 +46,12 @@ public businessExpenseList: any=[];
|
||||
public businessIncomeList: any=[];
|
||||
public grossProfitTypeList: any=[];
|
||||
public salesDeclaredCustomer: any=[];
|
||||
public getCustomValues:any = { UOMList: this.UOMList,frequencyList: this.frequencyList,businessExpenseList: this.businessExpenseList,businessIncomeList:this.businessIncomeList,pdid:'',company_id:'',grossProfitTypeList:this.grossProfitTypeList};
|
||||
public getCustomValues:any = { UOMList: this.UOMList,frequencyList: this.frequencyList,businessExpenseList: this.businessExpenseList,businessIncomeList:this.businessIncomeList,pdid:'',company_id:'',grossProfitTypeList:this.grossProfitTypeList,salesDeclaredCustomer:this.salesDeclaredCustomer};
|
||||
//public finalData: any;
|
||||
constructor(notifier: NotifierService, private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private _pd: PdTrigerService, private dialog: MatDialog,
|
||||
@Inject(MAT_DIALOG_DATA) public pd_all_details: any) {
|
||||
@Inject(MAT_DIALOG_DATA) public pd_all_details: any, private dialogRef: MatDialogRef<AssessedIncomeComponent>,) {
|
||||
this.pdid = this.pd_all_details.pdmaster_details.pd_id;
|
||||
this.company_id = this.pd_all_details.company_id;
|
||||
this.notifier = notifier;
|
||||
@ -105,6 +105,8 @@ public viewerOptions: any = {
|
||||
}
|
||||
if(value.records.sales_declared_by_customer){
|
||||
this.salesDeclaredCustomer = value.records.sales_declared_by_customer;
|
||||
this.getCustomValues.salesDeclaredCustomer=this.salesDeclaredCustomer;
|
||||
|
||||
}
|
||||
if(value.records.sales_calculated_by_itemwise){
|
||||
this.salesCaluatedItem = value.records.sales_calculated_by_itemwise;
|
||||
@ -119,7 +121,7 @@ public viewerOptions: any = {
|
||||
listItems.push({items:expnadElement, itemsTotal:calculateItems})
|
||||
})
|
||||
let calculateAllItemsTotal:number=listItems.reduce((racc, rcalculate) => racc + Number(rcalculate.itemsTotal), 0);
|
||||
|
||||
|
||||
let convertYear : number = 12 / listItems.length;
|
||||
let footerMessage: any=[];
|
||||
footerMessage.push({
|
||||
@ -132,7 +134,7 @@ public viewerOptions: any = {
|
||||
// message: ' Yearly ' + itemElement.sales_item + ' Sales Arrived',
|
||||
// value: calculateAllItemsTotal * convertYear,
|
||||
// })
|
||||
this.salesMonthWiseExpandedItems.push({sim_id:itemElement.sim_id,salesItem:itemElement.sales_item,comments:itemElement.comments,margin_per:itemElement.margin_per,margin_value:itemElement.margin_value, expandElements:expandBodyContent, footerMessage: footerMessage});
|
||||
this.salesMonthWiseExpandedItems.push({sim_id:itemElement.sim_id,salesItem:itemElement.sales_item,sales_type:itemElement.sales_type,comments:itemElement.comments,margin_per:itemElement.margin_per,margin_value:itemElement.margin_value, expandElements:expandBodyContent, footerMessage: footerMessage});
|
||||
});
|
||||
}
|
||||
if(value.records.purchase_details){
|
||||
@ -310,16 +312,19 @@ public viewerOptions: any = {
|
||||
|
||||
// complete AI detailscomplete AI details
|
||||
completeAI(): void{
|
||||
const dialogRef = this.dialog.open(ConfirmAiDetailsComponent, {
|
||||
const completeDialogRef = this.dialog.open(ConfirmAiDetailsComponent, {
|
||||
data: { pdid: this.pdid, company_id: this.company_id ,calc_type_id:this.grossProfitTypeList.length > 0 ? this.grossProfitTypeList[0].calc_type_id : ''},
|
||||
disableClose: true,
|
||||
minWidth:'30%',
|
||||
maxWidth:'40%',
|
||||
});
|
||||
dialogRef.afterClosed()
|
||||
completeDialogRef.afterClosed()
|
||||
.subscribe(dataresult => {
|
||||
if(dataresult.update_status==true){
|
||||
this.loadAIDetails();
|
||||
// this.loadAIDetails();
|
||||
setTimeout(() =>{
|
||||
this.dialogRef.close();
|
||||
},3000);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<mat-card>
|
||||
<mat-card *ngIf="enableDailySalesSection">
|
||||
<!-- <mat-card-header>
|
||||
<mat-card-title>Sales Calculate Month Wise</mat-card-title>
|
||||
|
||||
@ -16,44 +16,91 @@
|
||||
</div>
|
||||
</div>
|
||||
<mat-card *ngFor="let expandDetails of salesMonthWiseExpandedItems">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
<small class="expan_table_header">{{expandDetails.salesItem}}</small>
|
||||
<small class="expan_table_header" *ngIf="activateMariginCalculation===true"> ( Margin Percentage : {{expandDetails.margin_per}} % Margin Value : {{expandDetails.margin_value}} )</small>
|
||||
</mat-card-title>
|
||||
<mat-card-subtitle *ngFor="let footer of expandDetails.footerMessage">
|
||||
|
||||
<div fxFlex="100" class="subtitle_message">
|
||||
{{footer.month_message}} {{footer.year_message}}
|
||||
</div>
|
||||
</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
|
||||
<mat-divider></mat-divider>
|
||||
<mat-card-content style="display: flex;margin-top: -20px;">
|
||||
|
||||
<div fxFlex="50" *ngFor="let eachItem of expandDetails.expandElements" class="m-gap p-gap">
|
||||
|
||||
<h4 align="center" class="h4_font">{{eachItem.header}}</h4>
|
||||
<table mat-table [dataSource]="eachItem.value" class="mat-elevation-z8">
|
||||
<ng-container matColumnDef="Date">
|
||||
<th mat-header-cell *matHeaderCellDef>Date</th>
|
||||
<td mat-cell *matCellDef="let itemValue">{{itemValue.sales_date | date: 'dd-MM-yyyy'}} </td>
|
||||
<td mat-footer-cell *matFooterCellDef> Total </td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="Amount">
|
||||
<th mat-header-cell *matHeaderCellDef>Amount</th>
|
||||
<td mat-cell *matCellDef="let itemValue">{{itemValue.sales_value}}</td>
|
||||
<td mat-footer-cell *matFooterCellDef> {{getTotalCost(eachItem.value)}} </td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="salesMonthItemColumns; sticky: true"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: salesMonthItemColumns;"></tr>
|
||||
<tr mat-footer-row *matFooterRowDef="salesMonthItemColumns; sticky: true"></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
<div [ngSwitch]="expandDetails.sales_type">
|
||||
<!-- date info -->
|
||||
<div *ngSwitchCase="1">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
<small class="expan_table_header">{{expandDetails.salesItem}}</small>
|
||||
<small class="expan_table_header" *ngIf="activateMariginCalculation===true"> ( Margin Percentage : {{expandDetails.margin_per}} % Margin Value : {{expandDetails.margin_value}} )</small>
|
||||
</mat-card-title>
|
||||
<mat-card-subtitle *ngFor="let footer of expandDetails.footerMessage">
|
||||
|
||||
<div fxFlex="100" class="subtitle_message">
|
||||
{{footer.month_message}} {{footer.year_message}}
|
||||
</div>
|
||||
</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
|
||||
<mat-divider></mat-divider>
|
||||
<mat-card-content style="display: flex;margin-top: -20px;">
|
||||
|
||||
<div fxFlex="50" *ngFor="let eachItem of expandDetails.expandElements" class="m-gap p-gap">
|
||||
|
||||
<h4 align="center" class="h4_font">{{eachItem.header}}</h4>
|
||||
<table mat-table [dataSource]="eachItem.value" class="mat-elevation-z8">
|
||||
<ng-container matColumnDef="Date">
|
||||
<th mat-header-cell *matHeaderCellDef>Date</th>
|
||||
<td mat-cell *matCellDef="let itemValue">{{itemValue.sales_date | date: 'dd-MM-yyyy'}} </td>
|
||||
<td mat-footer-cell *matFooterCellDef> Total </td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="Amount">
|
||||
<th mat-header-cell *matHeaderCellDef>Amount</th>
|
||||
<td mat-cell *matCellDef="let itemValue">{{itemValue.sales_value}}</td>
|
||||
<td mat-footer-cell *matFooterCellDef> {{getTotalCost(eachItem.value)}} </td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="salesMonthItemColumns; sticky: true"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: salesMonthItemColumns;"></tr>
|
||||
<tr mat-footer-row *matFooterRowDef="salesMonthItemColumns; sticky: true"></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
</div>
|
||||
<!-- frequency info -->
|
||||
<div *ngSwitchCase="2">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
<small class="expan_table_header">{{expandDetails.salesItem}}</small>
|
||||
<small class="expan_table_header" *ngIf="activateMariginCalculation===true"> ( Margin Percentage : {{expandDetails.margin_per}} % Margin Value : {{expandDetails.margin_value}} )</small>
|
||||
</mat-card-title>
|
||||
<!-- <mat-card-subtitle *ngFor="let footer of expandDetails.footerMessage">
|
||||
|
||||
<div fxFlex="100" class="subtitle_message">
|
||||
{{footer.month_message}} {{footer.year_message}}
|
||||
</div>
|
||||
</mat-card-subtitle> -->
|
||||
</mat-card-header>
|
||||
|
||||
<mat-divider></mat-divider>
|
||||
<mat-card-content style="display: flex;">
|
||||
|
||||
<div fxFlex="50" *ngFor="let eachItem of expandDetails.expandElements" class="m-gap p-gap">
|
||||
|
||||
<!-- <h4 align="center" class="h4_font">{{eachItem.header}}</h4> -->
|
||||
<table mat-table [dataSource]="eachItem.value" class="mat-elevation-z8">
|
||||
<ng-container matColumnDef="Date">
|
||||
<th mat-header-cell *matHeaderCellDef>Frequency</th>
|
||||
<td mat-cell *matCellDef="let itemValue">{{itemValue.frequency_name ? itemValue.frequency_name : '' }} </td>
|
||||
<td mat-footer-cell *matFooterCellDef> Total </td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="Amount">
|
||||
<th mat-header-cell *matHeaderCellDef>Amount</th>
|
||||
<td mat-cell *matCellDef="let itemValue">{{itemValue.frequency_value}}</td>
|
||||
<td mat-footer-cell *matFooterCellDef> {{getTotalCost(eachItem.value)}} </td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="salesMonthItemColumns; sticky: true"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: salesMonthItemColumns;"></tr>
|
||||
<tr mat-footer-row *matFooterRowDef="salesMonthItemColumns; sticky: true"></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<mat-card-actions>
|
||||
<div fxFlex="75" align="left">
|
||||
|
||||
@ -14,13 +14,15 @@ export class DailySalesDetailsComponent implements OnInit, DoCheck {
|
||||
public salesMonthItemColumns = ['Date','Amount'];
|
||||
public salesMonthWiseExpandedItems: any[]=[];
|
||||
@Input() parentData: any;
|
||||
@Input() masterData: { UOMList: any; frequencyList: any; pdid:number,company_id:number, grossProfitTypeList:any};
|
||||
@Input() masterData: { UOMList: any; frequencyList: any; pdid:number,company_id:number, grossProfitTypeList:any,salesDeclaredCustomer: any};
|
||||
@Output() loadAssessedForms = new EventEmitter<string>();
|
||||
activateMariginCalculation: boolean;
|
||||
private notifier:NotifierService;
|
||||
enableDailySalesSection: boolean;
|
||||
constructor(notifier:NotifierService, private _pd: PdTrigerService, private dialog: MatDialog) {
|
||||
this.activateMariginCalculation=false;
|
||||
this.notifier = notifier;
|
||||
this.enableDailySalesSection = false;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@ -59,10 +61,11 @@ editSalesItem(value:any) {
|
||||
"fk_pd_id":this.masterData.pdid,
|
||||
"sim_id":value.sim_id,
|
||||
"salesItem":value.salesItem,
|
||||
"sales_type":value.sales_type,
|
||||
"comments":value.comments,
|
||||
"margin_value":value.margin_value,
|
||||
"margin_per":value.margin_per,
|
||||
"values":transformData
|
||||
"values":transformData,
|
||||
}
|
||||
let passValues: any = {
|
||||
manage_status:2,
|
||||
@ -109,6 +112,8 @@ ngDoCheck() {
|
||||
|
||||
if(this.masterData.grossProfitTypeList.length>0){
|
||||
this.activateMariginCalculation = this.masterData.grossProfitTypeList[this.masterData.grossProfitTypeList.length-1].margin==2 && this.masterData.grossProfitTypeList[this.masterData.grossProfitTypeList.length-1].mode==2 ? true : false;
|
||||
this.enableDailySalesSection = this.masterData.salesDeclaredCustomer.length>0 ? true : false;
|
||||
|
||||
}}
|
||||
|
||||
// detect chnges from parent
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
<form [formGroup]="salesCalculationForm" novalidate>
|
||||
<form [formGroup]="salesCalculationForm" novalidate *ngIf="enableCalculationSection">
|
||||
|
||||
<mat-card>
|
||||
<mat-card-header>
|
||||
<mat-card-title>Sales Calculation</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<mat-form-field style="width: 82%">
|
||||
<mat-form-field style="width: 85%">
|
||||
<input matInput OnlyNumber type="text" placeholder="Sales Declared by the Customer as the Annual Sales Actually Done" formControlName="sales_declared_by_customer" (keyup)="salesCalculation(salesCalculationForm.value)" required>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="salesCalculationForm.value.sales_declared_by_customer != ''">{{"₹"}} {{SaleAmtInwords}} Only</mat-hint>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="salesCalculationForm.value.sales_declared_by_customer != ''">{{"₹"}} {{salesCalculationForm.value.sales_declared_by_customer | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
<!-- {{salesCalculationForm.value.sales_declared_by_customer}} -->
|
||||
<mat-form-field style="width: 40%" *ngIf="activateMariginCalculation">
|
||||
<input matInput OnlyNumber type="text" placeholder="Margin Percentage %" formControlName="margin_per" (keyup)="salesCalculation(salesCalculationForm.value)" required>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 40%" *ngIf="activateMariginCalculation">
|
||||
<mat-form-field style="width: 41%" *ngIf="activateMariginCalculation">
|
||||
<input matInput OnlyNumber type="text" placeholder="Margin Value" formControlName="margin_value" readonly>
|
||||
<mat-hint align="start" style="font-size:90%" *ngIf="salesCalculationForm.value.margin_value != ''">{{"₹"}} {{salesCalculationForm.value.margin_value | numberToWords}} Only</mat-hint>
|
||||
</mat-form-field>
|
||||
<mat-form-field style="width: 82%">
|
||||
<mat-form-field style="width: 85%">
|
||||
<textarea matInput type="text" placeholder="Remarks" formControlName="comments"></textarea>
|
||||
</mat-form-field>
|
||||
<button type="submit" class="mr-1 mb-1 hover-icon" mat-raised-button mat-icon-button matTooltip="Save" matTooltipPosition="above" (click)="submitDetails(salesCalculationForm.value)"><mat-icon>save</mat-icon>
|
||||
|
||||
@ -15,16 +15,17 @@ export class SalesCalculationComponent implements OnInit, OnChanges, DoCheck {
|
||||
salesCalculationForm:FormGroup;
|
||||
activateMariginCalculation: boolean;
|
||||
private notifier: NotifierService;
|
||||
SaleAmtInwords : any;
|
||||
enableCalculationSection: boolean;
|
||||
constructor(notifier:NotifierService,private _fb: FormBuilder, private _pd: PdTrigerService) {
|
||||
this.activateMariginCalculation=false;
|
||||
this.notifier = notifier;
|
||||
this.enableCalculationSection=false;
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
salesCalculation(values): void {
|
||||
if(values.sales_declared_by_customer !=''){this.SaleAmtInwords = this._pd.convertNumberToWords(values.sales_declared_by_customer);}
|
||||
if(values.margin_per !='' && values.sales_declared_by_customer !='')
|
||||
{
|
||||
|
||||
@ -63,15 +64,12 @@ validateAllFormFields(formGroup: any) {
|
||||
|
||||
// do check component bases
|
||||
ngDoCheck() {
|
||||
// console.log('ngDoCheck this.activateMariginCalculation',this.activateMariginCalculation);
|
||||
// console.log('ngDoCheck this.masterData.grossProfitTypeList',this.masterData.grossProfitTypeList);
|
||||
// console.log('69',this.masterData.grossProfitTypeList[this.masterData.grossProfitTypeList.length-1].margin);
|
||||
if(this.masterData.grossProfitTypeList.length>0){
|
||||
this.activateMariginCalculation = this.masterData.grossProfitTypeList[this.masterData.grossProfitTypeList.length-1].margin==2 && this.masterData.grossProfitTypeList[this.masterData.grossProfitTypeList.length-1].mode==2 ? true : false;
|
||||
this.enableCalculationSection=true;
|
||||
}
|
||||
this.activateMariginCalculation===true ? this.salesCalculationForm.controls['margin_per'].setValidators([Validators.required]) : this.salesCalculationForm.controls['margin_per'].clearValidators();
|
||||
this.salesCalculationForm.controls['margin_per'].updateValueAndValidity();
|
||||
|
||||
}
|
||||
|
||||
//detect chnges from parent
|
||||
@ -86,7 +84,6 @@ ngOnChanges(changes: SimpleChanges) {
|
||||
}
|
||||
if(changes.parentData){
|
||||
if(changes.parentData.currentValue.length>0){
|
||||
this.SaleAmtInwords = this._pd.convertNumberToWords(changes.parentData.currentValue[changes.parentData.currentValue.length-1].sales_declared_by_customer);
|
||||
this.salesCalculationForm = this._fb.group({
|
||||
sdc_id:[changes.parentData.currentValue[changes.parentData.currentValue.length-1].sdc_id],
|
||||
sales_declared_by_customer:[changes.parentData.currentValue[changes.parentData.currentValue.length-1].sales_declared_by_customer, Validators.compose([Validators.required])],
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<mat-card>
|
||||
<mat-card *ngIf="enableSalesItemSection">
|
||||
<!-- <mat-card-header>
|
||||
<mat-card-title>Sales Calculate Item Wise</mat-card-title>
|
||||
</mat-card-header> -->
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
<ng-container matColumnDef="sale_quantity">
|
||||
<th mat-header-cell *matHeaderCellDef> Sale Quantity </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.sales_qty}} </td>
|
||||
<td mat-cell *matCellDef="let element"> {{element.sales_type=="1" ? element.sales_qty : ''}} </td>
|
||||
<td mat-footer-cell *matFooterCellDef> </td>
|
||||
|
||||
</ng-container>
|
||||
@ -38,7 +38,7 @@
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="rate_per_unit_sale">
|
||||
<th mat-header-cell *matHeaderCellDef> Rate/Unit of Sale </th>
|
||||
<th mat-header-cell *matHeaderCellDef> Rate/Unit or Value of Sale </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.rate_per_unit}} </td>
|
||||
<td mat-footer-cell *matFooterCellDef> </td>
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="margin_amount" *ngIf="activateMariginCalculation===true">
|
||||
<th mat-header-cell *matHeaderCellDef> Margin Amount </th>
|
||||
<td mat-cell *matCellDef="let element">{{element.margin_per_uom}}
|
||||
<td mat-cell *matCellDef="let element">{{element.sales_type=="1" ? element.margin_per_uom : ''}}
|
||||
</td>
|
||||
<td mat-footer-cell *matFooterCellDef> </td>
|
||||
|
||||
|
||||
@ -13,13 +13,15 @@ export class SalesDetailsComponent implements OnInit, DoCheck {
|
||||
displayedColumns = ['product_services','sale_quantity','UOM','rate_per_unit_sale','frequency','annual_sales','comments','action'];
|
||||
public salesItemSource= new MatTableDataSource();
|
||||
@Input() parentData: any;
|
||||
@Input() masterData: { UOMList: any; frequencyList: any;businessExpenseList:any,businessIncomeList: any, pdid:number,company_id:number, grossProfitTypeList:any};
|
||||
@Input() masterData: { UOMList: any; frequencyList: any;businessExpenseList:any,businessIncomeList: any, pdid:number,company_id:number, grossProfitTypeList:any, salesDeclaredCustomer: any};
|
||||
@Output() loadAssessedForms = new EventEmitter<string>();
|
||||
activateMariginCalculation: boolean;
|
||||
enableSalesItemSection: boolean;
|
||||
private notifier :NotifierService
|
||||
constructor(notifier:NotifierService, private _pd: PdTrigerService, private dialog: MatDialog) {
|
||||
this.activateMariginCalculation=false;
|
||||
this.notifier = notifier;
|
||||
this.enableSalesItemSection=false;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@ -98,6 +100,8 @@ ngDoCheck() {
|
||||
this.displayedColumns = ['product_services','sale_quantity','UOM','rate_per_unit_sale','frequency','annual_sales','comments','action'];
|
||||
|
||||
}
|
||||
|
||||
this.enableSalesItemSection = this.masterData.salesDeclaredCustomer.length>0 ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -48,13 +48,13 @@ export class NumberToWordsPipe implements PipeTransform {
|
||||
words_string += words[value] + " ";
|
||||
}
|
||||
if ((i == 1 && value != 0) || (i == 0 && value != 0 && n_array[i + 1] == 0)) {
|
||||
words_string += "Crores ";
|
||||
words_string += "Crores, ";
|
||||
}
|
||||
if ((i == 3 && value != 0) || (i == 2 && value != 0 && n_array[i + 1] == 0)) {
|
||||
words_string += "Lakhs ";
|
||||
words_string += "Lakhs, ";
|
||||
}
|
||||
if ((i == 5 && value != 0) || (i == 4 && value != 0 && n_array[i + 1] == 0)) {
|
||||
words_string += "Thousand ";
|
||||
words_string += "Thousand, ";
|
||||
}
|
||||
if (i == 6 && value != 0 && (n_array[i + 1] != 0 && n_array[i + 2] != 0)) {
|
||||
words_string += "Hundred and ";
|
||||
@ -63,6 +63,7 @@ export class NumberToWordsPipe implements PipeTransform {
|
||||
}
|
||||
}
|
||||
words_string = words_string.split(" ").join(" ");
|
||||
words_string=(words_string.length > 2 && words_string.charAt(words_string.length-2)==',') ? words_string.slice(0, -2) : words_string;
|
||||
}
|
||||
return words_string;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user