Beispiel #1
0
        protected override void doUpdate(EventJournal en)
        {
            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            m_command.Transaction = trc;
            try
            {
                Payment e = (Payment)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (PaymentItem sti in e.EVENT_JOURNAL_ITEMS)
                {
                    sti.VENDOR_BALANCE_SUPPLIER_INVOICE_TYPE = sti.SUPPLIER_INVOICE_JOURNAL_ITEM.GET_EVENT_JOURNAL.VENDOR_BALANCE_ENTRY_TYPE;
                    if (sti.ID > 0)
                    {
                        m_command.CommandText = sti.GetUpdateSQL();
                        m_command.ExecuteNonQuery();
                    }
                    else
                    {
                        m_command.CommandText = sti.GetInsertSQL();
                        m_command.ExecuteNonQuery();
                        m_command.CommandText = PaymentItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                    if (sti.PAYMENT_TYPE == PaymentType.APDebitNote)
                    {
                        m_command.CommandText = APDebitNote.UpdateUsedForPayment(sti.AP_DEBIT_NOTE.ID, true);
                        m_command.ExecuteNonQuery();
                    }
                }
                m_command.CommandText = PaymentItem.GetNotInTypeAPDN(e.ID, e.EVENT_JOURNAL_ITEMS);
                MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
                IList pymnts = PaymentItem.TransformReaderList(r);
                r.Close();
                foreach (PaymentItem itm in pymnts)
                {
                    m_command.CommandText = APDebitNote.UpdateUsedForPayment(itm.AP_DEBIT_NOTE.ID, false);
                    m_command.ExecuteNonQuery();
                }


                m_command.CommandText = PaymentItem.DeleteUpdate(e.ID, e.EVENT_JOURNAL_ITEMS);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
Beispiel #2
0
        internal static IList FindPaymentUsingAPDN(MySql.Data.MySqlClient.MySqlCommand cmd, int apDNID)
        {
            cmd.CommandText = PaymentItem.GetPaymentItemByAPDN(apDNID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            IList result = PaymentItem.TransformReaderList(r);

            r.Close();
            foreach (PaymentItem i in result)
            {
                cmd.CommandText = Payment.GetByIDSQL(i.EVENT_JOURNAL.ID);
                r = cmd.ExecuteReader();
                i.EVENT_JOURNAL = Payment.TransformReader(r);
                r.Close();
            }
            return(result);
        }
Beispiel #3
0
        internal static IList FindPaidCustomerInvoice(MySql.Data.MySqlClient.MySqlCommand cmd, int siID)
        {
            cmd.CommandText = PaymentItem.GetSupplierInvoiceBySOIID(siID, VendorBalanceEntryType.CustomerInvoice);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            IList result = PaymentItem.TransformReaderList(r);

            r.Close();
            foreach (PaymentItem i in result)
            {
                cmd.CommandText = Payment.GetByIDSQL(i.EVENT_JOURNAL.ID);
                r = cmd.ExecuteReader();
                i.EVENT_JOURNAL = Payment.TransformReader(r);
                r.Close();
            }
            return(result);
        }
Beispiel #4
0
        protected override void doSave(EventJournal e)
        {
            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            try
            {
                m_command.Transaction = trc;

                DateTime     trDate     = DateTime.Today;
                string       codesample = AutoNumberSetupRepository.GetCodeSampleByDomainName(m_command, "Payment");
                EventJournal codeDate   = FindLastCodeAndTransactionDate(codesample);
                string       lastCode   = codeDate == null ? string.Empty : codeDate.CODE;
                DateTime     lastDate   = codeDate == null ? trDate : codeDate.TRANSACTION_DATE;
                int          trCount    = RecordCount();
                e.CODE = AutoNumberSetupRepository.GetAutoNumberByDomainName(m_command, "Payment", e.CODE, lastCode, lastDate, trDate, trCount == 0);

                Payment stk = (Payment)e;
                m_command.CommandText = stk.GetInsertSQL();
                m_command.ExecuteNonQuery();
                m_command.CommandText = Payment.SelectMaxIDSQL();
                stk.ID = Convert.ToInt32(m_command.ExecuteScalar());
                foreach (PaymentItem item in stk.EVENT_JOURNAL_ITEMS)
                {
                    item.VENDOR_BALANCE_SUPPLIER_INVOICE_TYPE = item.SUPPLIER_INVOICE_JOURNAL_ITEM.GET_EVENT_JOURNAL.VENDOR_BALANCE_ENTRY_TYPE;
                    m_command.CommandText = item.GetInsertSQL();
                    m_command.ExecuteNonQuery();
                    m_command.CommandText = PaymentItem.SelectMaxIDSQL();
                    item.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    if (item.PAYMENT_TYPE == PaymentType.APDebitNote)
                    {
                        m_command.CommandText = APDebitNote.UpdateUsedForPayment(item.AP_DEBIT_NOTE.ID, true);
                        m_command.ExecuteNonQuery();
                    }
                }
                trc.Commit();
            }
            catch (Exception x)
            {
                e.ID = 0;
                foreach (EventJournalItem item in e.EVENT_JOURNAL_ITEMS)
                {
                    item.ID = 0;
                }
                trc.Rollback();
                throw x;
            }
        }
Beispiel #5
0
        protected override EventJournal doGet(int ID)
        {
            m_command.CommandText = Payment.GetByIDSQL(ID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            Payment st = Payment.TransformReader(r);

            r.Close();
            m_command.CommandText = PaymentItem.GetByEventIDSQL(ID);
            r = m_command.ExecuteReader();
            IList stis = PaymentItem.TransformReaderList(r);

            r.Close();
            foreach (PaymentItem sti in stis)
            {
                sti.EVENT_JOURNAL = st;
                //sti.VENDOR = PartRepository.GetByID(m_command, sti.PART.ID);
                sti.VENDOR_BALANCE_ENTRY = VendorBalanceEntryRepository.FindVendorBalanceEntryByEventItem(m_command, sti.ID, sti.VENDOR_BALANCE_ENTRY_TYPE);
                //sti.GRN_ITEM = GoodReceiveNoteRepository.FindGoodReceiveNoteItem(m_command, sti.GRN_ITEM.ID);
                //sti.GRN_ITEM.PART = PartRepository.GetByID(m_command, sti.GRN_ITEM.PART.ID);
                if (sti.VENDOR_BALANCE_SUPPLIER_INVOICE_TYPE == VendorBalanceEntryType.SupplierInvoice)
                {
                    if (sti.SUPPLIER_INVOICE_JOURNAL_ITEM != null)
                    {
                        sti.SUPPLIER_INVOICE_JOURNAL_ITEM = SupplierInvoiceJournalRepository.FindSIJournalItemlistForPayment(m_command, sti.SUPPLIER_INVOICE_JOURNAL_ITEM.GetID());
                    }
                }
                if (sti.VENDOR_BALANCE_SUPPLIER_INVOICE_TYPE == VendorBalanceEntryType.SupplierOutStandingInvoice)
                {
                    if (sti.SUPPLIER_INVOICE_JOURNAL_ITEM != null)
                    {
                        sti.SUPPLIER_INVOICE_JOURNAL_ITEM = SupplierOutStandingInvoiceRepository.FindSOIItemlistForPayment(m_command, sti.SUPPLIER_INVOICE_JOURNAL_ITEM.GetID());
                    }
                }
                if (sti.PAYMENT_TYPE == PaymentType.Bank)
                {
                    sti.BANK = getBank(sti.BANK.ID);
                }
                if (sti.PAYMENT_TYPE == PaymentType.APDebitNote)
                {
                    sti.AP_DEBIT_NOTE = APDebitNoteRepository.FindAPDNForPayment(m_command, sti.AP_DEBIT_NOTE.ID);
                }
                st.EVENT_JOURNAL_ITEMS.Add(sti);
            }
            return(st);
        }
Beispiel #6
0
        protected override void doDeleteNoTransaction(EventJournal e)
        {
            Payment st = (Payment)e;

            try
            {
                if (getEventStatus(st.ID) == EventStatus.Confirm)
                {
                    throw new Exception("Revise before delete");
                }
                m_command.CommandText = PaymentItem.DeleteAllByEventSQL(st.ID);
                m_command.ExecuteNonQuery();
                m_command.CommandText = Payment.DeleteSQL(st.ID);
                m_command.ExecuteNonQuery();
            }
            catch (Exception x)
            {
                throw x;
            }
        }
Beispiel #7
0
        public static IList TransformReaderList(MySql.Data.MySqlClient.MySqlDataReader aReader)
        {
            IList result = new ArrayList();

            while (aReader.Read())
            {
                PaymentItem transaction = new PaymentItem();
                transaction.ID            = Convert.ToInt32(aReader["payi_id"]);
                transaction.EVENT_JOURNAL = new Payment(Convert.ToInt32(aReader["pay_id"]));
                transaction.VENDOR        = new Supplier(Convert.ToInt32(aReader["sup_id"]));
                transaction.CURRENCY      = new Currency(Convert.ToInt32(aReader["ccy_id"]));
                transaction.AMOUNT        = Convert.ToDouble(aReader["payi_amount"]);
                //transaction.VENDOR_BALANCE_ENTRY = new VendorBalanceEntry(
                //VENDOR_BALANCE == null ? 0 : VENDOR_BALANCE.ID,
                transaction.VENDOR_BALANCE_ENTRY_TYPE = VendorBalanceEntryType.Payment;
                transaction.INVOICE_DATE           = Convert.ToDateTime(aReader["payi_invoicedate"]);
                transaction.INVOICE_NO             = aReader["payi_invoiceno"].ToString();
                transaction.DUE_DATE               = Convert.ToDateTime(aReader["payi_duedate"]);
                transaction.EMPLOYEE               = new Employee(Convert.ToInt32(aReader["emp_id"]));
                transaction.DISCOUNT               = Convert.ToDouble(aReader["payi_discount"]);
                transaction.AMOUNT_BEFORE_DISCOUNT = Convert.ToDouble(aReader["payi_amountbeforediscount"]);
                transaction.TOP         = new TermOfPayment(Convert.ToInt32(aReader["top_id"]));
                transaction.DESCRIPTION = aReader["payi_description"].ToString();
                transaction.NOTES       = aReader["payi_notes"].ToString();
                transaction.VENDOR_BALANCE_SUPPLIER_INVOICE_TYPE = (VendorBalanceEntryType)Enum.Parse(typeof(VendorBalanceEntryType), aReader["inv_type"].ToString());
                if (transaction.VENDOR_BALANCE_SUPPLIER_INVOICE_TYPE == VendorBalanceEntryType.SupplierInvoice)
                {
                    transaction.SUPPLIER_INVOICE_JOURNAL_ITEM = new SupplierInvoiceJournalItem(Convert.ToInt32(aReader["inv_id"]));
                }
                else
                {
                    transaction.SUPPLIER_INVOICE_JOURNAL_ITEM = new SupplierOutStandingInvoiceItem(Convert.ToInt32(aReader["inv_id"]));
                }
                transaction.BANK          = new Bank(Convert.ToInt32(aReader["bank_id"]));
                transaction.PAYMENT_TYPE  = (PaymentType)Enum.Parse(typeof(PaymentType), aReader["payi_paymenttype"].ToString());
                transaction.AP_DEBIT_NOTE = new APDebitNote(Convert.ToInt32(aReader["apdn_id"]));
                result.Add(transaction);
            }
            return(result);
        }