I have used switch statement to separate payment on basis of their method , code is given below:
str cust = custInvoiceJour.paymMode(); switch(cust) { case "CASH": salesOrderInvoiceTmp.PaymModeCash = custInvoiceJour.paymMode(); salesOrderInvoiceTmp.CashAmount = custInvoiceJour.InvoiceAmount; break; case "CHECK": salesOrderInvoiceTmp.PaymModeCheck = custInvoiceJour.paymMode(); salesOrderInvoiceTmp.CheckAmount = custInvoiceJour.InvoiceAmount; break; case "ELECTRONIC": salesOrderInvoiceTmp.PaymModeElectronic = custInvoiceJour.paymMode(); salesOrderInvoiceTmp.ElectronicAmount = custInvoiceJour.InvoiceAmount; break; case "PDC": salesOrderInvoiceTmp.PaymModePdc = custInvoiceJour.paymMode(); salesOrderInvoiceTmp.PDCAmount = custInvoiceJour.InvoiceAmount; break; case "REFUND": salesOrderInvoiceTmp.PaymModeRefund = custInvoiceJour.paymMode(); salesOrderInvoiceTmp.RefundAmount = custInvoiceJour.InvoiceAmount; break; }
Now I have a scenario if I have 5 methods of payment and system has updated 6th method ,then I have to update it manually through code in report . Is there any other way through which i can perform this validation in code whenever system updates a method it should automatically separate payment on basis of payment method.
any suggestions?