Example #1
0
        protected override void doDeleteNoTransaction(EventJournal e)
        {
            Receipt st = (Receipt)this.Get(e.ID);

            try
            {
                if (getEventStatus(st.ID) == EventStatus.Confirm)
                {
                    throw new Exception("Revise before delete");
                }
                foreach (ReceiptItem sti in e.EVENT_JOURNAL_ITEMS)
                {
                    if (sti.PAYMENT_TYPE == ReceiptType.ARCreditNote)
                    {
                        m_command.CommandText = ARCreditNote.UpdateUsedForReceipt(sti.AR_CREDIT_NOTE.ID, false);
                        m_command.ExecuteNonQuery();
                    }
                }
                m_command.CommandText = ReceiptItem.DeleteAllByEventSQL(st.ID);
                m_command.ExecuteNonQuery();
                m_command.CommandText = Receipt.DeleteSQL(st.ID);
                m_command.ExecuteNonQuery();
            }
            catch (Exception x)
            {
                throw x;
            }
        }
Example #2
0
        protected override void doDelete(EventJournal e)
        {
            Receipt st = (Receipt)e;

            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            m_command.Transaction = trc;
            try
            {
                if (getEventStatus(st.ID) == EventStatus.Confirm)
                {
                    throw new Exception("Revise before delete");
                }
                foreach (ReceiptItem sti in e.EVENT_JOURNAL_ITEMS)
                {
                    if (sti.PAYMENT_TYPE == ReceiptType.ARCreditNote)
                    {
                        m_command.CommandText = ARCreditNote.UpdateUsedForReceipt(sti.AR_CREDIT_NOTE.ID, false);
                        m_command.ExecuteNonQuery();
                    }
                }
                m_command.CommandText = ReceiptItem.DeleteAllByEventSQL(st.ID);
                m_command.ExecuteNonQuery();
                m_command.CommandText = Receipt.DeleteSQL(st.ID);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
Example #3
0
        protected override void doUpdateNoTransaction(EventJournal en)
        {
            try
            {
                Receipt e = (Receipt)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (ReceiptItem sti in e.EVENT_JOURNAL_ITEMS)
                {
                    if (sti.ID > 0)
                    {
                        m_command.CommandText = sti.GetUpdateSQL();
                        m_command.ExecuteNonQuery();
                    }
                    else
                    {
                        m_command.CommandText = sti.GetInsertSQL();
                        m_command.ExecuteNonQuery();
                        m_command.CommandText = ReceiptItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                }
                m_command.CommandText = ReceiptItem.DeleteUpdate(e.ID, e.EVENT_JOURNAL_ITEMS);
                m_command.ExecuteNonQuery();
            }
            catch (Exception x)
            {
                throw x;
            }
        }
Example #4
0
        protected override void doRevise(Event events, Period p)
        {
            foreach (EventItem item in events.EVENT_ITEMS)
            {
                SetStockCard(item, p);
            }

            CustomerInvoiceJournal sij = (CustomerInvoiceJournal)r_cij.FindCIJbyPOSId(events.ID);

            if (sij == null)
            {
                throw new Exception("Customer Invoice Journal is missing");
            }

            ReceiptItem rec = r_receipt.FindReceiptItemByCIJ(((CustomerInvoiceJournalItem)sij.EVENT_JOURNAL_ITEMS[0]).ID);

            if (rec == null)
            {
                throw new Exception("Receipt is missing");
            }

            r_receipt.ReviseForPOSNoTransaction(rec.EVENT_JOURNAL.ID);
            r_receipt.DeleteNoTransaction(rec.EVENT_JOURNAL);

            r_cij.ReviseNoTransaction(sij.ID);
            r_cij.DeleteNoTransaction(sij);
        }
Example #5
0
        public ReceiptItem FindReceiptItemByCIJ(int CIId)
        {
            string sql = ReceiptItem.GetCustomerInvoiceBySOIID(CIId, VendorBalanceEntryType.CustomerInvoice);

            m_command.CommandText = sql;
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            ReceiptItem rest = ReceiptItem.TransformReader(r);

            r.Close();
            return(rest);
        }
Example #6
0
        protected override void doUpdate(EventJournal en)
        {
            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            m_command.Transaction = trc;
            try
            {
                Receipt e = (Receipt)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (ReceiptItem sti in e.EVENT_JOURNAL_ITEMS)
                {
                    sti.VENDOR_BALANCE_CUSTOMER_INVOICE_TYPE = sti.CUSTOMER_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 = ReceiptItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                    if (sti.PAYMENT_TYPE == ReceiptType.ARCreditNote)
                    {
                        m_command.CommandText = ARCreditNote.UpdateUsedForReceipt(sti.AR_CREDIT_NOTE.ID, true);
                        m_command.ExecuteNonQuery();
                    }
                }
                m_command.CommandText = ReceiptItem.GetNotInTypeARCR(e.ID, e.EVENT_JOURNAL_ITEMS);
                MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
                IList pymnts = ReceiptItem.TransformReaderList(r);
                r.Close();
                foreach (ReceiptItem itm in pymnts)
                {
                    m_command.CommandText = ARCreditNote.UpdateUsedForReceipt(itm.AR_CREDIT_NOTE.ID, false);
                    m_command.ExecuteNonQuery();
                }


                m_command.CommandText = ReceiptItem.DeleteUpdate(e.ID, e.EVENT_JOURNAL_ITEMS);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
Example #7
0
        protected override EventJournal doGet(int ID)
        {
            m_command.CommandText = Receipt.GetByIDSQL(ID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            Receipt st = Receipt.TransformReader(r);

            r.Close();
            if (st == null)
            {
                return(null);
            }
            m_command.CommandText = ReceiptItem.GetByEventIDSQL(ID);
            r = m_command.ExecuteReader();
            IList stis = ReceiptItem.TransformReaderList(r);

            r.Close();
            foreach (ReceiptItem 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_CUSTOMER_INVOICE_TYPE == VendorBalanceEntryType.CustomerInvoice)
                {
                    if (sti.CUSTOMER_INVOICE_JOURNAL_ITEM != null)
                    {
                        sti.CUSTOMER_INVOICE_JOURNAL_ITEM = CustomerInvoiceJournalRepository.FindCIJournalItemlistForReceipt(m_command, sti.CUSTOMER_INVOICE_JOURNAL_ITEM.GetID());
                    }
                }
                if (sti.VENDOR_BALANCE_CUSTOMER_INVOICE_TYPE == VendorBalanceEntryType.CustomerOutStandingInvoice)
                {
                    if (sti.CUSTOMER_INVOICE_JOURNAL_ITEM != null)
                    {
                        sti.CUSTOMER_INVOICE_JOURNAL_ITEM = CustomerOutStandingInvoiceRepository.FindCOIItemlistForReceipt(m_command, sti.CUSTOMER_INVOICE_JOURNAL_ITEM.GetID());
                    }
                }
                if (sti.PAYMENT_TYPE == ReceiptType.Bank)
                {
                    sti.BANK = getBank(sti.BANK.ID);
                }
                if (sti.PAYMENT_TYPE == ReceiptType.ARCreditNote)
                {
                    sti.AR_CREDIT_NOTE = ARCreditNoteRepository.FindARCRForReceipt(m_command, sti.AR_CREDIT_NOTE.ID);
                }
                st.EVENT_JOURNAL_ITEMS.Add(sti);
            }
            return(st);
        }
Example #8
0
        internal static IList FindReceiptUsingARCR(MySql.Data.MySqlClient.MySqlCommand cmd, int apDNID)
        {
            cmd.CommandText = ReceiptItem.GetReceiptItemByARCR(apDNID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            IList result = ReceiptItem.TransformReaderList(r);

            r.Close();
            foreach (ReceiptItem i in result)
            {
                cmd.CommandText = Receipt.GetByIDSQL(i.EVENT_JOURNAL.ID);
                r = cmd.ExecuteReader();
                i.EVENT_JOURNAL = Receipt.TransformReader(r);
                r.Close();
            }
            return(result);
        }
Example #9
0
        internal static IList FindPaidCustomerInvoice(MySql.Data.MySqlClient.MySqlCommand cmd, int siID)
        {
            cmd.CommandText = ReceiptItem.GetCustomerInvoiceBySOIID(siID, VendorBalanceEntryType.CustomerInvoice);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            IList result = ReceiptItem.TransformReaderList(r);

            r.Close();
            foreach (ReceiptItem i in result)
            {
                cmd.CommandText = Receipt.GetByIDSQL(i.EVENT_JOURNAL.ID);
                r = cmd.ExecuteReader();
                i.EVENT_JOURNAL = Receipt.TransformReader(r);
                r.Close();
            }
            return(result);
        }
Example #10
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, "Receipt");
                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, "Receipt", e.CODE, lastCode, lastDate, trDate, trCount == 0);

                Receipt stk = (Receipt)e;
                m_command.CommandText = stk.GetInsertSQL();
                m_command.ExecuteNonQuery();
                m_command.CommandText = Receipt.SelectMaxIDSQL();
                stk.ID = Convert.ToInt32(m_command.ExecuteScalar());
                foreach (ReceiptItem item in stk.EVENT_JOURNAL_ITEMS)
                {
                    item.VENDOR_BALANCE_CUSTOMER_INVOICE_TYPE = item.CUSTOMER_INVOICE_JOURNAL_ITEM.GET_EVENT_JOURNAL.VENDOR_BALANCE_ENTRY_TYPE;
                    m_command.CommandText = item.GetInsertSQL();
                    m_command.ExecuteNonQuery();
                    m_command.CommandText = ReceiptItem.SelectMaxIDSQL();
                    item.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    if (item.PAYMENT_TYPE == ReceiptType.ARCreditNote)
                    {
                        m_command.CommandText = ARCreditNote.UpdateUsedForReceipt(item.AR_CREDIT_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;
            }
        }
Example #11
0
        public static IList TransformReaderList(MySql.Data.MySqlClient.MySqlDataReader aReader)
        {
            IList result = new ArrayList();

            while (aReader.Read())
            {
                ReceiptItem transaction = new ReceiptItem();
                transaction.ID            = Convert.ToInt32(aReader["reci_id"]);
                transaction.EVENT_JOURNAL = new Receipt(Convert.ToInt32(aReader["rec_id"]));
                transaction.VENDOR        = new Customer(Convert.ToInt32(aReader["cus_id"]));
                transaction.CURRENCY      = new Currency(Convert.ToInt32(aReader["ccy_id"]));
                transaction.AMOUNT        = Convert.ToDouble(aReader["reci_amount"]);
                //transaction.VENDOR_BALANCE_ENTRY = new VendorBalanceEntry(
                //VENDOR_BALANCE == null ? 0 : VENDOR_BALANCE.ID,
                transaction.VENDOR_BALANCE_ENTRY_TYPE = VendorBalanceEntryType.Receipt;
                transaction.INVOICE_DATE           = Convert.ToDateTime(aReader["reci_invoicedate"]);
                transaction.INVOICE_NO             = aReader["reci_invoiceno"].ToString();
                transaction.DUE_DATE               = Convert.ToDateTime(aReader["reci_duedate"]);
                transaction.EMPLOYEE               = new Employee(Convert.ToInt32(aReader["emp_id"]));
                transaction.DISCOUNT               = Convert.ToDouble(aReader["reci_discount"]);
                transaction.AMOUNT_BEFORE_DISCOUNT = Convert.ToDouble(aReader["reci_amountbeforediscount"]);
                transaction.TOP         = new TermOfPayment(Convert.ToInt32(aReader["top_id"]));
                transaction.DESCRIPTION = aReader["reci_description"].ToString();
                transaction.NOTES       = aReader["reci_notes"].ToString();
                transaction.VENDOR_BALANCE_CUSTOMER_INVOICE_TYPE = (VendorBalanceEntryType)Enum.Parse(typeof(VendorBalanceEntryType), aReader["inv_type"].ToString());
                if (transaction.VENDOR_BALANCE_CUSTOMER_INVOICE_TYPE == VendorBalanceEntryType.CustomerInvoice)
                {
                    transaction.CUSTOMER_INVOICE_JOURNAL_ITEM = new CustomerInvoiceJournalItem(Convert.ToInt32(aReader["inv_id"]));
                }
                else
                {
                    transaction.CUSTOMER_INVOICE_JOURNAL_ITEM = new CustomerOutStandingInvoiceItem(Convert.ToInt32(aReader["inv_id"]));
                }
                transaction.BANK           = new Bank(Convert.ToInt32(aReader["bank_id"]));
                transaction.PAYMENT_TYPE   = (ReceiptType)Enum.Parse(typeof(ReceiptType), aReader["reci_receipttype"].ToString());
                transaction.AR_CREDIT_NOTE = new ARCreditNote(Convert.ToInt32(aReader["arcr_id"]));
                result.Add(transaction);
            }
            return(result);
        }
Example #12
0
        protected override void doConfirm(Event events, Period p)
        {
            foreach (EventItem item in events.EVENT_ITEMS)
            {
                SetStockCard(item, p);
            }
            POS pos = (POS)events;

            CustomerInvoiceJournal cij = new CustomerInvoiceJournal();

            // sij.LastUpdate = DateTime.Now;
            // sij.ByTransaction = true;
            cij.CODE = pos.CODE;
            //sij.ComputerName = si.ComputerName;
            cij.CURRENCY         = pos.CURRENCY;
            cij.EVENT_STATUS     = EventStatus.Entry;
            cij.NOTES            = pos.NOTES;
            cij.NOTICE_DATE      = pos.NOTICE_DATE;
            cij.TRANSACTION_DATE = pos.TRANSACTION_DATE;
            // sij.UserName = si.UserName;
            cij.VENDOR      = pos.CUSTOMER;
            cij.POS_INVOICE = pos;
            cij.NET_AMOUNT  = pos.NET_TOTAL;
            cij.EMPLOYEE    = pos.EMPLOYEE;
            cij.VENDOR_BALANCE_ENTRY_TYPE = VendorBalanceEntryType.CustomerInvoice;


            CustomerInvoiceJournalItem ciji = new CustomerInvoiceJournalItem();

            ciji.AMOUNT                    = pos.NET_TOTAL;
            ciji.CURRENCY                  = pos.CURRENCY;
            ciji.EVENT_JOURNAL             = cij;
            ciji.VENDOR                    = pos.CUSTOMER;
            ciji.INVOICE_NO                = pos.CODE;
            ciji.INVOICE_DATE              = pos.TRANSACTION_DATE;
            ciji.TOP                       = pos.TOP;
            ciji.EMPLOYEE                  = pos.EMPLOYEE;
            ciji.DUE_DATE                  = pos.DUE_DATE;
            ciji.OUTSTANDING_AMOUNT        = pos.NET_TOTAL;
            ciji.VENDOR_BALANCE_ENTRY_TYPE = VendorBalanceEntryType.CustomerInvoice;

            cij.EVENT_JOURNAL_ITEMS.Add(ciji);
            r_cij.SaveNoTransaction(cij);
            r_cij.ConfirmNoTransaction(cij.ID);

            Receipt rc = new Receipt();

            rc.CURRENCY                  = cij.CURRENCY;
            rc.NET_AMOUNT                = cij.NET_AMOUNT;
            rc.NOTES                     = "Auto generate from POS Transaction";
            rc.NOTICE_DATE               = cij.NOTICE_DATE;
            rc.OTHER_EXPENSE             = cij.OTHER_EXPENSE;
            rc.SUBTOTAL_AMOUNT           = cij.SUBTOTAL_AMOUNT;
            rc.TRANSACTION_DATE          = cij.TRANSACTION_DATE;
            rc.VENDOR                    = cij.VENDOR;
            rc.VENDOR_BALANCE_ENTRY_TYPE = VendorBalanceEntryType.Receipt;
            rc.EMPLOYEE                  = cij.EMPLOYEE;

            ReceiptItem rci = new ReceiptItem();

            rci.EVENT_JOURNAL = rc;
            rci.AMOUNT        = ciji.AMOUNT;
            rci.CURRENCY      = rc.CURRENCY;
            rci.DUE_DATE      = rc.TRANSACTION_DATE;
            rci.EMPLOYEE      = rc.EMPLOYEE;
            rci.EVENT_JOURNAL = cij;
            rci.INVOICE_DATE  = cij.TRANSACTION_DATE;
            rci.INVOICE_NO    = cij.CODE;
            rci.NOTES         = "Autogenerate Payment from POS transaction";
            rci.PAYMENT_TYPE  = ReceiptType.Cash;
            rci.VENDOR_BALANCE_CUSTOMER_INVOICE_TYPE = VendorBalanceEntryType.Receipt;
            rci.VENDOR_BALANCE_ENTRY_TYPE            = VendorBalanceEntryType.Receipt;
            rci.VENDOR_BALANCE_TYPE           = VendorBalanceType.Customer;
            rci.CUSTOMER_INVOICE_JOURNAL_ITEM = ciji;
            rci.VENDOR = cij.VENDOR;
            rc.EVENT_JOURNAL_ITEMS.Add(rci);

            r_receipt.SaveNoTransaction(rc);
            r_receipt.ConfirmNoTransaction(rc.ID);
        }