Example #1
0
        private void New_Sale_Payment()
        {
            ///Creating new SALES INVOICE for upcomming sale.
            ///TransDate = 0 because in Point of Sale we are assuming sale will always be done today.
            sales_invoice sales_invoice = SalesInvoiceDB.New(0, false);

            SalesInvoiceDB.sales_invoice.Add(sales_invoice);

            Dispatcher.BeginInvoke((Action)(() => {
                sales_invoiceViewSource = ((CollectionViewSource)(FindResource("sales_invoiceViewSource")));
                sales_invoiceViewSource.Source = SalesInvoiceDB.sales_invoice.Local;
                sales_invoiceViewSource.View.MoveCurrentTo(sales_invoice);
            }));

            PaymentDB = new PaymentDB();
            ///Creating new PAYMENT for upcomming sale.
            payment payment = PaymentDB.New(true);

            payment.id_currencyfx = sales_invoice.id_currencyfx;
            PaymentDB.payments.Add(payment);

            Dispatcher.BeginInvoke((Action)(() =>
            {
                paymentViewSource = ((CollectionViewSource)(FindResource("paymentViewSource")));
                paymentViewSource.Source = PaymentDB.payments.Local;
                paymentViewSource.View.MoveCurrentTo(payment);

                tabContact.Focus();
                sbxContact.Text = "";
            }));
        }
Example #2
0
        public Payment(Modes App_Mode, List <payment_schedual> _payment_schedualList)
        {
            InitializeComponent();

            //Setting the Mode for this Window. Result of this variable will determine logic of the certain Behaviours.
            Mode = App_Mode;

            paymentViewSource = (CollectionViewSource)this.FindResource("paymentViewSource");
            paymentpayment_detailViewSource = (CollectionViewSource)this.FindResource("paymentpayment_detailViewSource");
            payment_schedualList            = _payment_schedualList;

            payment payment = new payment();

            if (Mode == Modes.Recievable)
            {
                payment            = PaymentDB.New(true);
                payment.GrandTotal = payment_schedualList.Sum(x => x.AccountReceivableBalance);
            }
            else
            {
                payment            = PaymentDB.New(false);
                payment.GrandTotal = payment_schedualList.Sum(x => x.AccountPayableBalance);
            }

            PaymentDB.payments.Add(payment);
            paymentViewSource.Source = PaymentDB.payments.Local;

            int id_contact = payment_schedualList.FirstOrDefault().id_contact;

            if (PaymentDB.contacts.Where(x => x.id_contact == id_contact).FirstOrDefault() != null)
            {
                payment.id_contact = id_contact;
                payment.contact    = PaymentDB.contacts.Where(x => x.id_contact == id_contact).FirstOrDefault();
            }

            foreach (payment_schedual payment_schedual in payment_schedualList)
            {
                if (payment_schedual.payment_detail != null)
                {
                    payment_detail payment_detail = PaymentDB.payment_detail.Where(x => x.id_payment_detail == payment_schedual.id_payment_detail).FirstOrDefault();
                    payment_detail.IsSelected          = true;
                    payment_detail.id_payment_schedual = payment_schedual.id_payment_schedual;
                    payment.payment_detail.Add(payment_detail);
                }
                else
                {
                    payment_detail payment_detail = new payment_detail();
                    payment_detail.IsSelected = true;
                    payment_detail.payment    = payment;

                    int id_currencyfx = payment_schedual.id_currencyfx;

                    if (PaymentDB.app_currencyfx.Where(x => x.id_currencyfx == id_currencyfx).FirstOrDefault() != null)
                    {
                        payment_detail.id_currencyfx         = id_currencyfx;
                        payment_detail.payment.id_currencyfx = id_currencyfx;
                        payment_detail.app_currencyfx        = PaymentDB.app_currencyfx.Where(x => x.id_currencyfx == id_currencyfx).FirstOrDefault();
                    }
                    if (Mode == Modes.Recievable)
                    {
                        payment_detail.value = payment_schedual.AccountReceivableBalance;
                    }
                    else
                    {
                        payment_detail.value = payment_schedual.AccountPayableBalance;
                    }

                    payment_detail.id_payment_schedual = payment_schedual.id_payment_schedual;
                    payment.payment_detail.Add(payment_detail);
                }
            }

            paymentViewSource.View.MoveCurrentTo(payment);
            paymentpayment_detailViewSource.View.MoveCurrentToFirst();
        }