Exemplo n.º 1
0
        protected async Task OnAccountSelected(ChangeEventArgs args)
        {
            var accountId = Guid.Parse((string)args.Value);

            if (SelectedBooking != null)
            {
                var account = PaymentAccounts.FirstOrDefault(x => x.Id == accountId);
                SelectedBooking.PaymentAccount   = account;
                SelectedBooking.PaymentAccountId = account?.Id;
                await SelectBooking(SelectedBooking);
            }
        }
Exemplo n.º 2
0
        public async Task SelectBooking(Booking booking)
        {
            SelectedBooking = booking;

            if (SelectedBooking.PaymentAccount == null)
            {
                if (booking.AssignedPilot != null)
                {
                    if (booking.PaymentType == PaymentType.Vipps)
                    {
                        booking.PaymentAccountId = booking.AssignedPilot.VippsPaymentAccountId;
                    }
                    else if (booking.PaymentType == PaymentType.IZettle)
                    {
                        booking.PaymentAccountId = booking.AssignedPilot.IZettlePaymentAccountId;
                    }
                    booking.PaymentAccount = PaymentAccounts.FirstOrDefault(a => a.Id == booking.PaymentAccountId);
                }
            }

            using (var scope = ScopeFactory.CreateScope())
            {
                var db = scope.ServiceProvider.GetService <TandemBookingContext>();

                FilteredPaymentAccounts = PaymentAccounts
                                          .Where(p => p.PaymentType == booking.PaymentType)
                                          .ToList();

                FilteredPayments = db.Payments
                                   .Where(p => p.PaymentAccountId == SelectedBooking.PaymentAccountId)
                                   .Where(p => p.UnreconciledAmount > 0)
                                   .AsEnumerable()
                                   .OrderBy(p => Math.Abs((p.PaymentDate - (booking.CompletedDate ?? booking.BookingDate)).TotalSeconds))
                                   .ToList();
            }
        }
Exemplo n.º 3
0
        protected override void BindData()
        {
            base.BindData();
            EntityServerModeSourceTracking.QueryableSource = DataContext.EntitySystemContext.SYS_Tracking.Select(n => new { n.Id, TrackingNumber = n.Id, n.Initiator }).Distinct();


            //List<PaymentAccount> accounts = Essential.SystemSettingForm.DeSerializePaymentAccounts(DataAccessLayer.ApplicationContext.Instance.CompanySite.PaymentAccounts, typeof(List<GLX.PaymentAccount>));
            if (this.Tag is Accounting.Payment.MakePaymentsForm)
            {
                DB.SYS_Entity  entityAccount   = BL.SYS.SYS_Entity.Load(BL.ApplicationDataContext.Instance.SiteAccounts.Creditors.EntityId, DataContext);
                DB.GLX_Account creditorAccount = BL.GLX.GLX_Account.Load(entityAccount.Id, DataContext);

                ServerModeSourceCompanyAccount.QueryableSource = DataContext.ReadonlyContext.VW_Account.Where(n => n.Archived == false && n.ControlId == creditorAccount.Id);
                TabIcon = global::CDS.Shared.Resources.Properties.Resources.money_minus_32;
            }
            else if (this.Tag is Accounting.Payment.ReceivePaymentsForm)
            {
                DB.SYS_Entity  entityAccount  = BL.SYS.SYS_Entity.Load(BL.ApplicationDataContext.Instance.SiteAccounts.Debtors.EntityId, DataContext);
                DB.GLX_Account debtorsAccount = BL.GLX.GLX_Account.Load(entityAccount.Id, DataContext);
                ServerModeSourceCompanyAccount.QueryableSource = DataContext.ReadonlyContext.VW_Account.Where(n => n.Archived == false && n.ControlId == debtorsAccount.Id);
                TabIcon = global::CDS.Shared.Resources.Properties.Resources.money2_add_32;
            }
            else
            {
                ServerModeSourceCompanyAccount.QueryableSource = DataContext.ReadonlyContext.VW_Account.Where(n => n.Archived == false);
            }

            // ServerModeSourcePaymentAccount.QueryableSource = CDS.Client.DataAccessLayer.ApplicationContext.Instance.Context.GLX_Account.Where(n=> accounts.Select(l=>l.AccountId).Contains(n.Id));
            //Filter for master Accountants
            if (BL.ApplicationDataContext.Instance.AccessGranted(BL.SEC.AccessCodes.FIAARE))
            {
                ServerModeSourcePaymentAccount.QueryableSource = DataContext.ReadonlyContext.VW_Account.Where(n => PaymentAccounts.Contains(n.Id));
            }
            else
            {
                long?defaultSiteId = BL.ApplicationDataContext.Instance.LoggedInUser.DefaultSiteId;
                ServerModeSourcePaymentAccount.QueryableSource = DataContext.ReadonlyContext.VW_Account.Where(n => PaymentAccounts.Contains(n.Id) && n.SiteId == defaultSiteId);
            }
            ServerModeSourceAging.QueryableSource = DataContext.EntityAccountingContext.GLX_Aging;
        }
Exemplo n.º 4
0
 public PaymentProcessing(PaymentAccounts account, PaymentMethods method)
 {
     _account = account;
     _method  = method;
 }
Exemplo n.º 5
0
        protected override bool SaveSuccessful()
        {
            try
            {
                using (new CDS.Client.Desktop.Essential.UTL.WaitCursor())
                {
                    this.OnSaveRecord();
                    if (!IsValid)
                    {
                        return(false);
                    }

                    foreach (BulkPaymentEntry mainLine in BulkPaymentEntries)
                    {
                        Int64 trackingNumber = -1;
                        // Make a new header entry
                        DB.GLX_Header header = BL.GLX.GLX_Header.New;
                        header.TrackId           = -1;
                        header.PeriodId          = mainLine.PeriodId.Value;
                        header.ReferencePeriodId = mainLine.PeriodId.Value;
                        header.Date        = mainLine.Date.Value;
                        header.PostedDate  = BL.ApplicationDataContext.Instance.ServerDateTime.Date;
                        header.Reference   = mainLine.Reference;
                        header.Description = mainLine.Description;
                        header.StatusId    = 52;

                        if (mainLine.Amount >= 0)
                        {
                            // header.Description = "CREDITOR PAYMENT RECEIVED";
                            header.JournalTypeId = (byte)BL.GLX.GLX_JournalType.Payment;
                        }
                        else
                        {
                            //  header.Description = "CREDITOR PAYMENT REVERSAL";
                            header.JournalTypeId = (byte)BL.GLX.GLX_JournalType.Reversal;
                        }

                        //Double check if this has a use
                        if (!trackingNumber.Equals(-1))
                        {
                            header.TrackId = trackingNumber;
                        }

                        //Loop through INV or C/N or BBF (Agings)
                        foreach (var agingAmount in mainLine.BulkPaymentItems.Where(n => n.Checked.Equals(true)).GroupBy(g => g.AgingId).Select(l => new { AgingId = l.Key, Balance = l.Sum(i => i.Balance) }))
                        {
                            //DEBTOR LINE
                            DB.GLX_Line linecreditor = BL.GLX.GLX_Line.New;
                            //TODO: ACCOUNT NOT LOADING ON subLine
                            linecreditor.EntityId = mainLine.AccountId.Value;
                            linecreditor.AgingId  = agingAmount.AgingId;
                            linecreditor.Amount   = -agingAmount.Balance;
                            header.GLX_Line.Add(linecreditor);
                        }
                        //BANK LINE
                        DB.GLX_Line linebank = BL.GLX.GLX_Line.New;
                        linebank.EntityId = Convert.ToInt64(ddlAccount.EditValue);
                        linebank.AgingId  = 1;
                        linebank.Amount   = mainLine.Amount;
                        header.GLX_Line.Add(linebank);
                        //SETTLEMENT DISCOUNT TAX LINE
                        DB.GLX_Line linesettlementtax = BL.GLX.GLX_Line.New;
                        DB.GLX_Tax  taxType           = DataContext.EntityAccountingContext
                                                        .GLX_Tax.FirstOrDefault(n => n.Id == PaymentAccounts
                                                                                .Where(nn => nn.AccountId.Equals(((DB.GLX_Account)ddlSettlementAccount.GetSelectedDataRow()).Id))
                                                                                .Select(nn => nn.TaxId).FirstOrDefault());
                        if (taxType != null && taxType.Percentage != 0)
                        {
                            linesettlementtax.Amount = mainLine.Settlement * (1 - taxType.Percentage);
                        }
                        else
                        {
                            linesettlementtax.Amount = mainLine.Settlement;
                        }

                        header.GLX_Line.Add(linesettlementtax);
                        //SETTLEMENT DISCOUNT LINE
                        DB.GLX_Line linesettlement = BL.GLX.GLX_Line.New;
                        linesettlement.EntityId = Convert.ToInt64(ddlSettlementAccount.EditValue);
                        linesettlement.AgingId  = 1;
                        linesettlement.Amount   = mainLine.Settlement - linesettlementtax.Amount;
                        header.GLX_Line.Add(linesettlement);

                        //Change the subLines's tracking number to the new tracking number
                        foreach (var subLine in mainLine.BulkPaymentItems.Where(n => n.Checked.Equals(true)))
                        {
                            BL.GLX.GLX_Header.UpdateTrackNumber(subLine.HeaderId, trackingNumber, DataContext);
                        }
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                HasErrors = true;
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
                return(false);
            }
        }