Skip to content

Commit

Permalink
Merge pull request #7122 from Walkover-Web-Solution/GIDK-#2186e2-prod
Browse files Browse the repository at this point in the history
fix: GIDK-#2186e2 | Prateek | Prod | Application got hanged when user click on Adjust amount in Invoice module
  • Loading branch information
the-prateek-mishra authored Jan 21, 2021
2 parents cbd8dd9 + 26aeb16 commit edb6358
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ <h1>{{baseCurrencySymbol}}{{ totalDue | giddhCurrency }}<span *ngIf="baseCurrenc
<div class="modal-dialog modal-xl">
<div class="modal-content">
<advance-receipt-adjustment-component *ngIf="showAdvanceReceiptAdjust" #advanceReceiptComponent [isUpdateMode]="isUpdateMode" [depositAmount]="depositAmount" [invoiceFormDetails]="invFormData" [advanceReceiptAdjustmentUpdatedData]="advanceReceiptAdjustmentData"
(closeModelEvent)="closeAdvanceReceiptModal()" (submitClicked)="getAdvanceReceiptAdjustData($event)" [isVoucherModule]="true">
(closeModelEvent)="closeAdvanceReceiptModal()" (submitClicked)="getAdvanceReceiptAdjustData($event)" [isVoucherModule]="true" [voucherForAdjustment]="voucherForAdjustment">
</advance-receipt-adjustment-component>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { PurchaseRecordUpdateModel } from '../../purchase/purchase-record/consta
import { InvoiceBulkUpdateService } from '../../services/invoice.bulkupdate.service';
import { PurchaseRecordActions } from '../../actions/purchase-record/purchase-record.action';
import { Location } from '@angular/common';
import { VoucherAdjustments, AdjustAdvancePaymentModal } from '../../models/api-models/AdvanceReceiptsAdjust';
import { VoucherAdjustments, AdjustAdvancePaymentModal, Adjustment } from '../../models/api-models/AdvanceReceiptsAdjust';
import { SalesService } from '../../services/sales.service';
import { GeneralService } from '../../services/general.service';
import { OrganizationType } from '../../models/user-login-state';
Expand Down Expand Up @@ -274,17 +274,19 @@ export class InvoicePreviewComponent implements OnInit, OnChanges, OnDestroy {
public giddhDateFormat: string = GIDDH_DATE_FORMAT;
/** directive to get reference of element */
@ViewChild('datepickerTemplate') public datepickerTemplate: ElementRef;
/* This will store selected date range to show on UI */
/** Stores the voucher eligible for adjustment */
public voucherForAdjustment: Array<Adjustment>;
/** This will store selected date range to show on UI */
public selectedDateRangeUi: any;
/* This will store available date ranges */
/** This will store available date ranges */
public datePickerOption: any = GIDDH_DATE_RANGE_PICKER_RANGES;
/* Selected from date */
/** Selected from date */
public fromDate: string;
/* Selected to date */
/** Selected to date */
public toDate: string;
/* Selected range label */
/** Selected range label */
public selectedRangeLabel: any = "";
/* This will store the x/y position of the field to show datepicker under it */
/** This will store the x/y position of the field to show datepicker under it */
public dateFieldPosition: any = { x: 0, y: 0 };

constructor(
Expand Down Expand Up @@ -1727,6 +1729,7 @@ export class InvoicePreviewComponent implements OnInit, OnChanges, OnDestroy {
this.salesService.getAllAdvanceReceiptVoucher(requestObject).subscribe(res => {
if (res && res.status === 'success') {
if (res.body && res.body.length) {
this.voucherForAdjustment = res.body;
this.isAccountHaveAdvanceReceipts = true;
this.showAdvanceReceiptAdjust = true;
this.adjustPaymentModal.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2890,7 +2890,8 @@
[isUpdateMode]="isUpdateMode" [depositAmount]="depositAmount" [invoiceFormDetails]="invFormData"
[isVoucherModule]="true" [advanceReceiptAdjustmentUpdatedData]="advanceReceiptAdjustmentData"
(closeModelEvent)="closeAdvanceReceiptModal()"
(submitClicked)="getAdvanceReceiptAdjustData($event)">
(submitClicked)="getAdvanceReceiptAdjustData($event)"
[voucherForAdjustment]="voucherForAdjustment">
</advance-receipt-adjustment-component>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ import { PurchaseRecordService } from '../services/purchase-record.service';
import { CommonActions } from '../actions/common.actions';
import { PurchaseRecordActions } from '../actions/purchase-record/purchase-record.action';
import { AdvanceReceiptAdjustmentComponent } from '../shared/advance-receipt-adjustment/advance-receipt-adjustment.component';
import { VoucherAdjustments, AdjustAdvancePaymentModal } from '../models/api-models/AdvanceReceiptsAdjust';
import { VoucherAdjustments, AdjustAdvancePaymentModal, Adjustment } from '../models/api-models/AdvanceReceiptsAdjust';
import { CurrentCompanyState } from '../store/Company/company.reducer';
import { CustomTemplateState } from '../store/Invoice/invoice.template.reducer';
import { PurchaseOrderService } from '../services/purchase-order.service';
Expand Down Expand Up @@ -593,6 +593,8 @@ export class ProformaInvoiceComponent implements OnInit, OnDestroy, AfterViewIni
public accountAddressList: any[] = [];
/** This will hold company addresses */
public companyAddressList: any[] = [];
/** Stores the voucher eligible for adjustment */
public voucherForAdjustment: Array<Adjustment>;

/**
* Returns true, if Purchase Record creation record is broken
Expand Down Expand Up @@ -1148,7 +1150,7 @@ export class ProformaInvoiceComponent implements OnInit, OnDestroy, AfterViewIni
templateUniqueName: null,
number: ''
};

let tempObj;
let voucherDate = this.invFormData.voucherDetails.voucherDate;
let dueDate = this.invFormData.voucherDetails.dueDate;
Expand Down Expand Up @@ -5712,6 +5714,7 @@ export class ProformaInvoiceComponent implements OnInit, OnDestroy, AfterViewIni
};
this.salesService.getAllAdvanceReceiptVoucher(requestObject).subscribe(res => {
if (res && res.status === 'success') {
this.voucherForAdjustment = res.body;
if (res.body && res.body.length) {
this.isAccountHaveAdvanceReceipts = true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ export class AdvanceReceiptAdjustmentComponent implements OnInit {
/** Exceed Amount from invoice amount after adjustment */
public exceedDueAmount: number = 0;




@ViewChild('tdsTypeBox', {static: true}) public tdsTypeBox: ElementRef;
@ViewChild('tdsAmountBox', {static: true}) public tdsAmountBox: ElementRef;

Expand Down Expand Up @@ -81,6 +78,8 @@ export class AdvanceReceiptAdjustmentComponent implements OnInit {
@Input() public adjustedVoucherType: AdjustedVoucherType;
/** True if the current module is voucher module required as all voucher adjustments are not supported from API */
@Input() public isVoucherModule: boolean;
/** Stores the voucher eligible for adjustment */
@Input() public voucherForAdjustment: Array<Adjustment>;

/** Close modal event emitter */
@Output() public closeModelEvent: EventEmitter<{ adjustVoucherData: VoucherAdjustments, adjustPaymentData: AdjustAdvancePaymentModal }> = new EventEmitter();
Expand Down Expand Up @@ -172,7 +171,24 @@ export class AdvanceReceiptAdjustmentComponent implements OnInit {
}
});
} else {
this.getAllAdvanceReceipts();
if (!this.voucherForAdjustment) {
this.getAllAdvanceReceipts();
} else {
if (this.voucherForAdjustment && this.voucherForAdjustment.length) {
this.adjustVoucherOptions = [];
this.voucherForAdjustment.forEach(item => {
if (item) {
item.voucherDate = item.voucherDate.replace(/-/g, '/');
this.adjustVoucherOptions.push({ value: item.uniqueName, label: item.voucherNumber, additional: item });
this.newAdjustVoucherOptions.push({ value: item.uniqueName, label: item.voucherNumber, additional: item });
}
});
} else {
if (this.isVoucherModule) {
this.toaster.warningToast(NO_ADVANCE_RECEIPT_FOUND);
}
}
}
}
if (this.isUpdateMode) {
this.calculateBalanceDue();
Expand Down Expand Up @@ -280,22 +296,21 @@ export class AdvanceReceiptAdjustmentComponent implements OnInit {
* @memberof AdvanceReceiptAdjustmentComponent
*/
public getAllAdvanceReceipts(): void {
this.adjustVoucherOptions = [];
if(this.adjustVoucherForm && this.adjustVoucherForm.adjustments) {
this.adjustVoucherForm.adjustments.forEach(item => {
if (item) {
item.voucherDate = item.voucherDate.replace(/-/g, '/');
this.adjustVoucherOptions.push({ value: item.uniqueName, label: item.voucherNumber, additional: item });
this.newAdjustVoucherOptions.push({ value: item.uniqueName, label: item.voucherNumber, additional: item });
}
});
}

if (this.adjustPayment && this.adjustPayment.customerUniquename && this.adjustPayment.voucherDate) {
this.getAllAdvanceReceiptsRequest.accountUniqueName = this.adjustPayment.customerUniquename;
this.getAllAdvanceReceiptsRequest.invoiceDate = this.adjustPayment.voucherDate;
this.salesService.getAllAdvanceReceiptVoucher(this.getAllAdvanceReceiptsRequest).subscribe(res => {
if (res.status === 'success') {
this.adjustVoucherOptions = [];
if (this.adjustVoucherForm && this.adjustVoucherForm.adjustments) {
this.adjustVoucherForm.adjustments.forEach(item => {
if (item && item.uniqueName) {
item.voucherDate = item.voucherDate.replace(/-/g, '/');
this.adjustVoucherOptions.push({ value: item.uniqueName, label: item.voucherNumber, additional: item });
this.newAdjustVoucherOptions.push({ value: item.uniqueName, label: item.voucherNumber, additional: item });
}
});
}
this.allAdvanceReceiptResponse = res.body
if (res.body && res.body.length) {
if (this.allAdvanceReceiptResponse && this.allAdvanceReceiptResponse.length) {
Expand Down

0 comments on commit edb6358

Please sign in to comment.