Я хочу получить любое значение даты передачи из ввода Datepicker веб-компонента Lightning в переменную PostingDate в LWCcontroller.cls
import { LightningElement,api ,track} from 'lwc';
import getInvoiceData from '@salesforce/apex/CustomerRefundLwcController.getInvoiceData';
import getBankAccounts from '@salesforce/apex/CustomerRefundLwcController.getBankAccounts';
import processCustomerRefund from '@salesforce/apex/CustomerRefundLwcController.processCustomerRefund';
export default class CustomerRefund extends LightningElement {
@api recordId; /*Sales Credit Id*/
@track invoiceData;
@track invoiceLinesData;
@api headerText;
@api recordProcessing;
@api bankAccounts = new Array();
@track selectedBankId;
@track allocateToSalesCredit;
@track referenceDetail;
@track bShowModal = false;
@track PostingDate;
/*Toast Event Variables*/
@api isError = false;
@api iswarning = false;
@api issuccess = false;
@api ToastMessage;
PostingDateChange(event)
{
this.PostingDate = event.target.value;
this.invoiceData.PostingDate = this.PostingDate;
}
processRefundHandler() {
this.recordProcessing = true;
//console.log('this.formData----'+JSON.stringify(this.invoiceLinesData));
console.log('this.formData----'+JSON.stringify(this.invoiceData));
processCustomerRefund({ lstInvoiceLines : this.invoiceLinesData, bankId : this.selectedBankId, allocateToSalesCredit : this.allocateToSalesCredit, reference : this.referenceDetail, postingdate : this.PostingDate })
.then(result => {
var responseMessage = result;
this.recordProcessing = false;
this.ToastMessage = responseMessage;
if(responseMessage == "Success"){
//this.issuccess = true;
this.isError = false;
this.ToastMessage = "Your Bank Customer Refund has been created";
this.bShowModal = true;
}else{
this.isError = true;
}
})
.catch(error => {
this.isError = true;
this.ToastMessage = error ;
console.log(error);
});
}
<div class="slds-col">
<label class="slds-form-element__label slds-no-flex">Posting Date</label>
<lightning-input type="date"
name="Postingdate"
value={PostingDate}
onchange={PostingDateChange}
>
</lightning-input>
</div>
CRLW C .cls @AuraEnabled publi c stati c string processCustomerRefund (List lstInvoiceLines, string bankId, boolean allocateToSalesCredit, string reference) { system.debug ('начать обновление'); строка successMessage = 'Успех'; строка responseMessage = 'Успех'; Точка сохранения spTran = database.setSavePoint (); попробуйте {List lstLinesToUpdate = новый список (); десятичная сумма = 0; Id taxRate; Id salesinvoiceid;
boolean isValid = true;
boolean allocateToInvoice = allocateToSalesCredit;
map<id,Sales_Invoice_Line_Item__c> mapOfSelectedLines = new map<id,Sales_Invoice_Line_Item__c>();
for(ScLineWrapper lineWrapper : lstInvoiceLines){
system.debug('isselect>> ' + lineWrapper.isSelected);
if(lineWrapper.isSelected){
salesinvoiceid = lineWrapper.InvoiceLine.Sales_Invoice__c;
decimal lineAmount = lineWrapper.InvoiceLine.Foreign_Gross__c;
if(lineAmount != null && lineAmount > 0){
amount += lineAmount;
mapOfSelectedLines.put(lineWrapper.InvoiceLine.id,lineWrapper.InvoiceLine);
}
if(lineWrapper.InvoiceLine.Tax_Rate__c != null){
taxRate = lineWrapper.InvoiceLine.Tax_Rate__c;
}
}
}
if(salesinvoiceid == null){
isValid = false;
responseMessage = 'Please select at least one sales invoice line';
}else if(bankId == null){
isValid = false;
responseMessage = 'Please select bank account';
}else if(amount <= 0){
isValid = false;
responseMessage = 'Refund amount should be greater than zero';
}
system.debug('updatelst>> ' + lstLinesToUpdate);
//update lstLinesToUpdate;
if(isValid){
Sales_Invoice__c siInfo = [select id,Status__c,Account__c,Name from Sales_Invoice__c where id=: salesinvoiceid];
BankCustomerRefundService objCustomerRefundService = new BankCustomerRefundService();
BankCustomerRefundService.BankCustomerRefundWrapper objRefundWrapper = new BankCustomerRefundService.BankCustomerRefundWrapper();
Id accountId = siInfo.Account__c;
objRefundWrapper.AccountId = accountId;
objRefundWrapper.PostingDate = Date.Today()+(-216);
objRefundWrapper.BankAccountId = bankId;
objRefundWrapper.TaxRate = taxRate;
objRefundWrapper.Amount = amount;
objRefundWrapper.Reference = reference;
BankCustomerRefundService.Response objResponse = objCustomerRefundService.CreateBankCustomerRefund(objRefundWrapper);
responseMessage = objResponse.ResponseMessage;
if(allocateToInvoice && responseMessage == successMessage){
Bank_Payment__c objBankPayment = objResponse.BankPayments.get(accountId);
List<Ledger__c> listofLedgers = [Select id,name,Foreign_Gross_Total__c,Type__c
FROM Ledger__c
Where Customer_Supplier_Account_Name__c =: accountId AND Show_On_Transaction__c=1
AND Paid__c = 'N' AND Is_Deleted__c = false
AND (Sales_Invoice_Line_Item__c IN: mapOfSelectedLines.keyset() OR Bank_Payment__c =: objBankPayment.id) ];
if(!listofLedgers.isEmpty()){
BankAllocateCreditsAndPaymentsService objAllocateCreditsAndPaymentService = new BankAllocateCreditsAndPaymentsService();
BankAllocateCreditsAndPaymentsService.BankAllocateCreditsAndPaymentsWrapper objAllocateCreditWrapper = new BankAllocateCreditsAndPaymentsService.BankAllocateCreditsAndPaymentsWrapper();
objAllocateCreditWrapper.AccountId = accountId;
objAllocateCreditWrapper.PostingDate = Date.Today()+(-216);
List<BankAllocateCreditsAndPaymentsService.BankAllocateCreditsAndPaymentsLineWrapper> BankAllocateCreditsAndPaymentsLines = new List<BankAllocateCreditsAndPaymentsService.BankAllocateCreditsAndPaymentsLineWrapper>();
for(Ledger__c ledger : listofLedgers){
BankAllocateCreditsAndPaymentsService.BankAllocateCreditsAndPaymentsLineWrapper objPaymentLine = new BankAllocateCreditsAndPaymentsService.BankAllocateCreditsAndPaymentsLineWrapper();
objPaymentLine.LedgerName = ledger.Name;
objPaymentLine.Amount = ledger.Foreign_Gross_Total__c;
BankAllocateCreditsAndPaymentsLines.add(objPaymentLine);
}
objAllocateCreditWrapper.BankAllocateLines = BankAllocateCreditsAndPaymentsLines;
BankAllocateCreditsAndPaymentsService.Response objAllocateResponse = objAllocateCreditsAndPaymentService.BankAllocateCustomerBalance(objAllocateCreditWrapper);
responseMessage = objAllocateResponse.ResponseMessage;
system.debug('Response>>' + objAllocateResponse.ResponseMessage);
}
}
}
}catch(Exception ex){
responseMessage = ex.getStackTraceString();
}
if(responseMessage != successMessage){
Database.rollback(spTran);
}
system.debug('Response>>' + responseMessage);
return responseMessage;
}