private void UpdateDate(DateTime date, DebtorTransPayment[] payments, bool isInterestnote) { if (payments == null || payments.Length == 0) { return; } var orgList = new DebtorTransPayment[payments.Length]; for (int i = 0; (i < payments.Length); i++) { var debtTrans = payments[i]; var org = new DebtorTransPayment(); StreamingManager.Copy(debtTrans, org); if (isInterestnote) { debtTrans.LastInterest = date; } else { debtTrans.LastCollectionLetter = date; int collectionLetter = debtTrans._CollectionsLetters + 1; debtTrans._CollectionsLetters = (byte)collectionLetter; } orgList[i] = org; } api.UpdateNoResponse(orgList, payments); }
private void localMenu_OnItemClicked(string ActionType) { var selectedItem = dgDebtorTranOpenGrid.SelectedItem as DebtorTransOpenClient; switch (ActionType) { case "DeleteRow": dgDebtorTranOpenGrid.RemoveFocusedRowFromGrid(); break; case "SaveGrid": saveGrid(); break; case "ViewDownloadRow": if (selectedItem != null) { DebtorTransactions.ShowVoucher(dgDebtorTranOpenGrid.syncEntity, api, busyIndicator); } break; case "GenerateJournalLines": if (dgDebtorTranOpenGrid.ItemsSource == null) { return; } CWImportToLine cwLine = new CWImportToLine(api, GetSystemDefaultDate()); #if !SILVERLIGHT cwLine.DialogTableId = 2000000034; #endif cwLine.Closed += async delegate { if (cwLine.DialogResult == true && !string.IsNullOrEmpty(cwLine.Journal)) { busyIndicator.IsBusy = true; Uniconta.API.GeneralLedger.PostingAPI posApi = new Uniconta.API.GeneralLedger.PostingAPI(api); var LineNumber = (int)(await posApi.MaxLineNumber(cwLine.Journal)) + 2; NumberSerieAPI numberserieApi = new NumberSerieAPI(posApi); int nextVoucherNumber = 0; SQLCache payments = api.GetCache(typeof(Uniconta.DataModel.PaymentTerm)); string payment = (from pay in (IEnumerable <Uniconta.DataModel.PaymentTerm>)payments.GetNotNullArray where pay._UseForCollection select pay._Payment).FirstOrDefault(); SQLCache journalCache = api.GetCache(typeof(Uniconta.DataModel.GLDailyJournal)); var DJclient = (Uniconta.DataModel.GLDailyJournal)journalCache.Get(cwLine.Journal); var listLineClient = new List <Uniconta.DataModel.GLDailyJournalLine>(); if (!DJclient._GenerateVoucher && !DJclient._ManualAllocation) { nextVoucherNumber = (int)await numberserieApi.ViewNextNumber(DJclient._NumberSerie); } var visibleRows = dgDebtorTranOpenGrid.GetVisibleRows() as IEnumerable <DebtorTransPayment>; var rows = visibleRows.Where(p => p._FeeAmount > 0.0d && p._OnHold == false); if (cwLine.AggregateAmount) { string lastAcc = null; var rowsGroupBy = rows.GroupBy(a => a.Account); foreach (var group in rowsGroupBy) { string invoice; double FeeAmount, Charge; var rec = group.FirstOrDefault(); if (group.Count() > 1) { FeeAmount = group.Sum(p => p._FeeAmount); Charge = group.Sum(p => p._PaymentCharge); invoice = null; } else { FeeAmount = rec._FeeAmount; Charge = rec._PaymentCharge; invoice = rec.InvoiceAN; } if (group.Key == lastAcc) { continue; } lastAcc = group.Key; CreateGLDailyJournalLine(listLineClient, lastAcc, FeeAmount, Charge, invoice, DJclient, LineNumber, cwLine.Date, cwLine.TransType, cwLine.BankAccount, rec.Currency, nextVoucherNumber, payment); if (nextVoucherNumber != 0) { nextVoucherNumber++; } } } else { DebtorTransPayment lastRec = null; foreach (var row in rows) { if (!object.ReferenceEquals(row, lastRec)) { lastRec = row; CreateGLDailyJournalLine(listLineClient, row.Account, row._FeeAmount, row._PaymentCharge, row.InvoiceAN, DJclient, LineNumber, cwLine.Date, cwLine.TransType, cwLine.BankAccount, row.Currency, nextVoucherNumber, payment); if (nextVoucherNumber != 0) { nextVoucherNumber++; } } } } if (listLineClient.Count > 0) { ErrorCodes errorCode = await api.Insert(listLineClient); busyIndicator.IsBusy = false; if (errorCode != ErrorCodes.Succes) { UtilDisplay.ShowErrorCode(errorCode); } else { if (nextVoucherNumber != 0) { numberserieApi.SetNumber(DJclient._NumberSerie, nextVoucherNumber - 1); } var text = string.Concat(Uniconta.ClientTools.Localization.lookup("GenerateJournalLines"), "; ", Uniconta.ClientTools.Localization.lookup("Completed"), Environment.NewLine, string.Format(Uniconta.ClientTools.Localization.lookup("GoTo"), Uniconta.ClientTools.Localization.lookup("Journallines")), " ?"); var select = UnicontaMessageBox.Show(text, Uniconta.ClientTools.Localization.lookup("Information"), MessageBoxButton.OKCancel); if (select == MessageBoxResult.OK) { AddDockItem(TabControls.GL_DailyJournalLine, DJclient, null, null, true); } } } } busyIndicator.IsBusy = false; }; cwLine.Show(); break; case "AddInterest": if (selectedItem != null) { SetFee(true); } break; case "AddCollection": if (selectedItem != null) { SetFee(false); } break; case "SendAllEmail": SendReport((IEnumerable <DebtorTransPayment>)dgDebtorTranOpenGrid.GetVisibleRows()); break; case "SendMarkedEmail": var markedRows = dgDebtorTranOpenGrid.SelectedItems?.Cast <DebtorTransPayment>(); if (markedRows != null) { SendReport(markedRows); } break; case "SendCurrentEmail": if (dgDebtorTranOpenGrid.SelectedItem != null) { var cwSendInvoice = new CWSendInvoice(); #if !SILVERLIGHT cwSendInvoice.DialogTableId = 2000000031; #endif cwSendInvoice.Closed += delegate { var selectedRow = new DebtorTransPayment[] { (DebtorTransPayment)dgDebtorTranOpenGrid.SelectedItem }; SendReport(selectedRow, cwSendInvoice.Emails, cwSendInvoice.sendOnlyToThisEmail); }; cwSendInvoice.Show(); } break; #if !SILVERLIGHT case "SendAsOutlook": if (dgDebtorTranOpenGrid.SelectedItem != null) { OpenOutlook(); } break; #endif default: gridRibbon_BaseActions(ActionType); break; } }