public CashReceiptVoucherUI(string pJournalEntryId) { InitializeComponent(); loCustomer = new Customer(); lOperation = GlobalVariables.Operation.Edit; loJournalEntry = new JournalEntry(); loJournalEntryDetail = new JournalEntryDetail(); loCashReceiptDetail = new CashReceiptDetail(); loChartOfAccount = new ChartOfAccount(); loSalesOrder = new SalesOrder(); lJournalEntryId = pJournalEntryId; }
public CashReceiptJournalUI() { InitializeComponent(); loJournalEntry = new JournalEntry(); loJournalEntryDetail = new JournalEntryDetail(); loCashReceiptDetail = new CashReceiptDetail(); loSalesOrder = new SalesOrder(); loCommon = new Common(); ldtJournalEntry = new System.Data.DataTable(); loCashReceiptJournalRpt = new CashReceiptJournalRpt(); loCashReceiptVoucherRpt = new CashReceiptVoucherRpt(); loReportViewer = new ReportViewerUI(); }
private void SaveReceipt(string isNext, bool isChequePayment) { List<Receipt> receipts; Receipt receipt = null; OpenItemReceiptAllocation openItemReceiptAllocation; CashReceiptDetail cashReceiptDetail; int refNo = 0; isChanged = true; try { receipts = new List<Receipt>(); if (IsApplyPaymentsApplicable) { foreach (OpenItemSearch openItem in openItems.Where(item => item.AmountDue > 0).OrderBy(item => item.OpenItemID)) { if (refNo != openItem.ContractNo || IsApplyPaymentsApplicable == false) { receipt = new Receipt(); if (receipts.Count == 0 && receiptID != 0) { receipt.ID = Receipt.ID; } receipt.ReceiptBatchID = Receipt.ReceiptBatchID; receipt.ReceiptDate = Receipt.ReceiptDate; receipt.ApplyToTypeID = Receipt.ApplyToTypeID; receipt.Reference = Receipt.Reference; receipt.LastUserID = ((OperationsPrincipal)Thread.CurrentPrincipal).Identity.User.UserEntityId; receipt.ContractID = openItem.ContractNo; receipt.InternalReference = receipt.ContractID.ToString(); if (receiptApplyTo == ReceiptApplyTo.Invoice) { receipt.InvoiceAssetId = business.InvoiceFunctions.GetInvoiceAssetID(openItem.ContractNo, applyToObjectID.GetValueOrDefault()); receipt.InternalReference = receipt.InvoiceAssetId.GetValueOrDefault().ToString(); } if (batchType == ReceiptBatchType.CashCheque) { if (isChequePayment) { receipt.ChequeReceiptDetail = new ChequeReceiptDetail(); receipt.ChequeReceiptDetail.AccountName = Receipt.ChequeReceiptDetail.AccountName; receipt.ChequeReceiptDetail.BankName = Receipt.ChequeReceiptDetail.BankName; receipt.ChequeReceiptDetail.BSBNumber = Receipt.ChequeReceiptDetail.BSBNumber; receipt.ChequeReceiptDetail.ChequeNumber = Receipt.ChequeReceiptDetail.ChequeNumber; receipt.ChequeReceiptDetail.PaymentTypeID = (int)paymentType; receipt.ChequeReceiptDetail.ReceiptID = receipt.ID; receipt.ChequeReceiptDetail.Receipt = receipt; } else { receipt.ChequeReceiptDetail = null; cashReceiptDetail = new CashReceiptDetail(); cashReceiptDetail.ReceiptID = receipt.ID; if (receipts.Count == 0 && Receipt.CashReceiptDetails != null && Receipt.CashReceiptDetails.Count > 0) { cashReceiptDetail.ID = Receipt.CashReceiptDetails.FirstOrDefault().ID; } cashReceiptDetail.PaymentTypeID = (int)paymentType; receipt.CashReceiptDetails = new List<CashReceiptDetail>(); receipt.CashReceiptDetails.Add(cashReceiptDetail); } } else if (batchType == ReceiptBatchType.DirectDebit) { receipt.DirectDebitReceiptDetails = new List<DirectDebitReceiptDetail>(); if (receipts.Count == 0) { receipt.DirectDebitReceiptDetails.Add(new DirectDebitReceiptDetail { LesseeBankAccountID = DDCCAccountID, ID = Receipt.DirectDebitReceiptDetails.FirstOrDefault().ID, ReceiptID = Receipt.ID }); } else { receipt.DirectDebitReceiptDetails.Add(new DirectDebitReceiptDetail { LesseeBankAccountID = DDCCAccountID }); } } else if (batchType == ReceiptBatchType.CreditCard) { receipt.CreditCardReceiptDetails = new List<CreditCardReceiptDetail>(); if (receipts.Count == 0) { receipt.CreditCardReceiptDetails.Add(new CreditCardReceiptDetail { LesseeBankAccountID = DDCCAccountID, ID = Receipt.CreditCardReceiptDetails.FirstOrDefault().ID, ReceiptID = Receipt.ID }); } else { receipt.CreditCardReceiptDetails.Add(new CreditCardReceiptDetail { LesseeBankAccountID = DDCCAccountID }); } } receipt.OpenItemReceiptAllocations = new List<OpenItemReceiptAllocation>(); receipts.Add(receipt); refNo = openItem.ContractNo; } openItemReceiptAllocation = new OpenItemReceiptAllocation(); openItemReceiptAllocation.OpenItemID = openItem.OpenItemID; openItemReceiptAllocation.ReceiptID = receiptID; openItemReceiptAllocation.GrossAmountDue = openItem.AmountDue; openItemReceiptAllocation.GrossAmountApplied = Convert.ToDecimal(openItem.AmountApplied); receipt.OpenItemReceiptAllocations.Add(openItemReceiptAllocation); } } else { receipt = new Receipt(); receipt.ID = Receipt.ID; receipt.ReceiptBatchID = Receipt.ReceiptBatchID; receipt.ReceiptDate = Receipt.ReceiptDate; receipt.ApplyToTypeID = Receipt.ApplyToTypeID; receipt.Reference = Receipt.Reference; receipt.LastUserID = ((OperationsPrincipal)Thread.CurrentPrincipal).Identity.User.UserEntityId; receipt.GrossAmountReceived = amountReceived; receipt.NetAmountReceived = amountReceived; if (receiptApplyTo == ReceiptApplyTo.Quote) { receipt.QuoteID = applyToObjectID.GetValueOrDefault(); receipt.InternalReference = receipt.QuoteID.ToString(); } if (batchType == ReceiptBatchType.CashCheque) { if (isChequePayment) { receipt.ChequeReceiptDetail = new ChequeReceiptDetail(); receipt.ChequeReceiptDetail.AccountName = Receipt.ChequeReceiptDetail.AccountName; receipt.ChequeReceiptDetail.BankName = Receipt.ChequeReceiptDetail.BankName; receipt.ChequeReceiptDetail.BSBNumber = Receipt.ChequeReceiptDetail.BSBNumber; receipt.ChequeReceiptDetail.ChequeNumber = Receipt.ChequeReceiptDetail.ChequeNumber; receipt.ChequeReceiptDetail.PaymentTypeID = (int)paymentType; receipt.ChequeReceiptDetail.ReceiptID = receipt.ID; receipt.ChequeReceiptDetail.Receipt = receipt; } else { receipt.ChequeReceiptDetail = null; receipt.CashReceiptDetails = new List<CashReceiptDetail>(); receipt.CashReceiptDetails.Add(new CashReceiptDetail() { ReceiptID = receipt.ID, PaymentTypeID = (int)paymentType }); if (receipts.Count == 0 && Receipt.CashReceiptDetails != null && Receipt.CashReceiptDetails.Count > 0) { receipt.CashReceiptDetails.FirstOrDefault().ID = Receipt.CashReceiptDetails.FirstOrDefault().ID; } } } else if (batchType == ReceiptBatchType.DirectDebit) { receipt.DirectDebitReceiptDetails = new List<DirectDebitReceiptDetail>(); if (receipts.Count == 0) { receipt.DirectDebitReceiptDetails.Add(new DirectDebitReceiptDetail { LesseeBankAccountID = DDCCAccountID, ID = Receipt.DirectDebitReceiptDetails.FirstOrDefault().ID, ReceiptID = Receipt.ID }); } else { receipt.DirectDebitReceiptDetails.Add(new DirectDebitReceiptDetail { LesseeBankAccountID = DDCCAccountID }); } } else if (batchType == ReceiptBatchType.CreditCard) { receipt.CreditCardReceiptDetails = new List<CreditCardReceiptDetail>(); if (receipts.Count == 0) { receipt.CreditCardReceiptDetails.Add(new CreditCardReceiptDetail { LesseeBankAccountID = DDCCAccountID, ID = Receipt.CreditCardReceiptDetails.FirstOrDefault().ID, ReceiptID = Receipt.ID }); } else { receipt.CreditCardReceiptDetails.Add(new CreditCardReceiptDetail { LesseeBankAccountID = DDCCAccountID }); } } receipts.Add(receipt); } ReceiptFunctions.Save(receipts); isChanged = false; if (Convert.ToBoolean(isNext)) { receiptID = 0; SetReceiptDefaults(Receipt.ReceiptBatchID); SetIcon(); RaisePropertyChanged("IsReceiptinEditMode"); } else { Close(); } } catch (Exception ex) { ExceptionLogger.WriteLog(ex); ShowErrorMessage("Error occurred while Saving Receipt", "Add Receipt - Error"); IsBusy = false; } }
private void OnSave() { List<Receipt> receipts; ReceiptBatch receiptBatch; Receipt receipt; CashReceiptDetail cashReceiptDetail; PaymentType paymentType; OpenItemReceiptAllocation openItemReceiptAllocation; bool confirmResult = true; try { IsBusy = true; receipts = new List<Receipt>(); foreach (CashReceiptExcel excelItem in Receipts) { receipt = new Receipt(); paymentType = CashReceiptExcelImportViewModel.CashChequePaymentTypes.Where(payType => payType.PaymentTypeDesc.ToLower() == excelItem.PaymentMethod.ToLower()).FirstOrDefault(); receipt.ReceiptBatchID = receiptBatchID; receipt.ReceiptDate = Convert.ToDateTime(excelItem.ReceiptDate); receipt.ApplyToTypeID = (int)ReceiptApplyTo.Contract; receipt.ContractID = Convert.ToInt32(excelItem.ContractID); receipt.Reference = excelItem.ReferenceNo; receipt.GrossAmountReceived = Math.Round(Convert.ToDecimal(excelItem.AmountReceived), 2); receipt.LastUserID = ((OperationsPrincipal)Thread.CurrentPrincipal).Identity.User.UserEntityId; receipt.InternalReference = receipt.ContractID.ToString(); if (paymentType.SCPaymentTypeId == (int)SCPaymentTypes.Cheque) { receipt.ChequeReceiptDetail = new ChequeReceiptDetail(); receipt.ChequeReceiptDetail.PaymentTypeID = paymentType.PaymentTypeId; receipt.ChequeReceiptDetail.ChequeNumber = excelItem.ChequeNumber; receipt.ChequeReceiptDetail.AccountName = excelItem.AccountName; receipt.ChequeReceiptDetail.BankName = excelItem.BankName; receipt.ChequeReceiptDetail.BSBNumber = excelItem.BSBNumber; } else { cashReceiptDetail = new CashReceiptDetail(); cashReceiptDetail.PaymentTypeID = paymentType.PaymentTypeId; receipt.CashReceiptDetails.Add(cashReceiptDetail); } receipt.OpenItemReceiptAllocations = new List<OpenItemReceiptAllocation>(); foreach (OpenItemSearch openItem in excelItem.OpenItems) { openItemReceiptAllocation = new OpenItemReceiptAllocation(); openItemReceiptAllocation.OpenItemID = openItem.OpenItemID; openItemReceiptAllocation.GrossAmountDue = openItem.AmountDue; openItemReceiptAllocation.GrossAmountApplied = Convert.ToDecimal(openItem.AmountApplied); receipt.OpenItemReceiptAllocations.Add(openItemReceiptAllocation); } receipts.Add(receipt); } if (receipts.Where(item => item.ReceiptDate > DateTime.Today).Count() > 0) { UIConfirmation.Raise( new ConfirmationWindowViewModel(this) { Content = "One or more Receipt Date(s) are in the future. Select OK to continue or Cancel to modify", Icon = "Question.ico", Title = "Receipt Date Confirmation" }, (popupCallBack) => { if (popupCallBack.Confirmed) { ReceiptFunctions.Save(receipts); Close(); } }); } else { ReceiptFunctions.Save(receipts); Close(); } IsBusy = false; } catch (Exception ex) { ExceptionLogger.WriteLog(ex); ShowErrorMessage("Error encountered while saving Excel entries.", "Excel Import - Error"); } finally { IsBusy = false; } }