internal static CustomerInvoiceJournalItem FindCIJournalItemlistForReceipt(MySql.Data.MySqlClient.MySqlCommand cmd, int cusinvItemID)
        {
            cmd.CommandText = CustomerInvoiceJournalItem.GetByIDSQL(cusinvItemID);
            MySql.Data.MySqlClient.MySqlDataReader r      = cmd.ExecuteReader();
            CustomerInvoiceJournalItem             result = CustomerInvoiceJournalItem.TransformReader(r);

            r.Close();
            cmd.CommandText = CustomerInvoiceJournal.GetByIDSQL(result.EVENT_JOURNAL.ID);
            r = cmd.ExecuteReader();
            result.EVENT_JOURNAL = CustomerInvoiceJournal.TransformReader(r);
            r.Close();

            cmd.CommandText = Currency.GetByIDSQLStatic(result.CURRENCY.ID);
            r = cmd.ExecuteReader();
            result.CURRENCY = Currency.GetCurrency(r);
            r.Close();

            cmd.CommandText = TermOfPayment.GetByIDSQLStatic(result.TOP.ID);
            r          = cmd.ExecuteReader();
            result.TOP = TermOfPayment.GetTOP(r);
            r.Close();

            cmd.CommandText = Employee.GetByIDSQLStatic(result.EMPLOYEE.ID);
            r = cmd.ExecuteReader();
            result.EMPLOYEE = Employee.GetEmployee(r);
            r.Close();


            return(result);
        }
        protected override void doUpdateNoTransaction(EventJournal en)
        {
            try
            {
                CustomerInvoiceJournal e = (CustomerInvoiceJournal)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (CustomerInvoiceJournalItem 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 = CustomerInvoiceJournalItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                }
                m_command.CommandText = CustomerInvoiceJournalItem.DeleteUpdate(e.ID, e.EVENT_JOURNAL_ITEMS);
                m_command.ExecuteNonQuery();
            }
            catch (Exception x)
            {
                throw x;
            }
        }
        public double GetOutstanding(int sijiID)
        {
            m_command.CommandText = CustomerInvoiceJournalItem.GetByOutstandingSQL(sijiID);
            double d = Convert.ToDouble(m_command.ExecuteScalar());

            return(d);
        }
        protected override void doUpdate(EventJournal en)
        {
            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            m_command.Transaction = trc;
            try
            {
                CustomerInvoiceJournal e = (CustomerInvoiceJournal)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (CustomerInvoiceJournalItem 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 = CustomerInvoiceJournalItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                }
                m_command.CommandText = CustomerInvoiceJournalItem.DeleteUpdate(e.ID, e.EVENT_JOURNAL_ITEMS);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
        protected override void doSaveNoTransaction(EventJournal e)
        {
            try
            {
                DateTime     trDate     = DateTime.Today;
                string       codesample = AutoNumberSetupRepository.GetCodeSampleByDomainName(m_command, "CustomerInvoiceJournal");
                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, "CustomerInvoiceJournal", e.CODE, lastCode, lastDate, trDate, trCount == 0);

                CustomerInvoiceJournal stk = (CustomerInvoiceJournal)e;
                m_command.CommandText = stk.GetInsertSQL();
                m_command.ExecuteNonQuery();
                m_command.CommandText = CustomerInvoiceJournal.SelectMaxIDSQL();
                stk.ID = Convert.ToInt32(m_command.ExecuteScalar());
                foreach (CustomerInvoiceJournalItem item in stk.EVENT_JOURNAL_ITEMS)
                {
                    m_command.CommandText = item.GetInsertSQL();
                    m_command.ExecuteNonQuery();
                    m_command.CommandText = CustomerInvoiceJournalItem.SelectMaxIDSQL();
                    item.ID = Convert.ToInt32(m_command.ExecuteScalar());
                }
            }
            catch (Exception x)
            {
                e.ID = 0;
                foreach (EventJournalItem item in e.EVENT_JOURNAL_ITEMS)
                {
                    item.ID = 0;
                }
                throw x;
            }
        }
        public double GetPaid(int sijiID)
        {
            m_command.CommandText = CustomerInvoiceJournalItem.GetByReceiptSQL(sijiID);
            double d = Convert.ToDouble(m_command.ExecuteScalar());

            return(d);
        }
Пример #7
0
        public static IList TransformReaderList(MySql.Data.MySqlClient.MySqlDataReader aReader)
        {
            IList result = new ArrayList();

            while (aReader.Read())
            {
                CustomerInvoiceJournalItem transaction = new CustomerInvoiceJournalItem();
                transaction.ID            = Convert.ToInt32(aReader["ciji_id"]);
                transaction.EVENT_JOURNAL = new CustomerInvoiceJournal(Convert.ToInt32(aReader["cij_id"]));
                transaction.VENDOR        = new Customer(Convert.ToInt32(aReader["cus_id"]));
                transaction.CURRENCY      = new Currency(Convert.ToInt32(aReader["ccy_id"]));
                transaction.AMOUNT        = Convert.ToDouble(aReader["ciji_amount"]);
                //transaction.VENDOR_BALANCE_ENTRY = new VendorBalanceEntry(
                //VENDOR_BALANCE == null ? 0 : VENDOR_BALANCE.ID,
                transaction.VENDOR_BALANCE_ENTRY_TYPE = VendorBalanceEntryType.CustomerInvoice;
                transaction.INVOICE_DATE           = Convert.ToDateTime(aReader["ciji_invoicedate"]);
                transaction.INVOICE_NO             = aReader["ciji_invoiceno"].ToString();
                transaction.DUE_DATE               = Convert.ToDateTime(aReader["ciji_duedate"]);
                transaction.EMPLOYEE               = new Employee(Convert.ToInt32(aReader["emp_id"]));
                transaction.DISCOUNT               = Convert.ToDouble(aReader["ciji_discount"]);
                transaction.AMOUNT_BEFORE_DISCOUNT = Convert.ToDouble(aReader["ciji_amountbeforediscount"]);
                transaction.TOP                    = new TermOfPayment(Convert.ToInt32(aReader["top_id"]));
                transaction.DESCRIPTION            = aReader["ciji_description"].ToString();
                transaction.NOTES                  = aReader["ciji_notes"].ToString();
                transaction.AGAINST_RECEIPT_STATUS = (AgainstStatus)Enum.Parse(typeof(AgainstStatus), aReader["ciji_againstpaymentstatus"].ToString());
                transaction.OUTSTANDING_AMOUNT     = Convert.ToDouble(aReader["ciji_outstandingamount"]);
                transaction.RECEIPT_AMOUNT         = Convert.ToDouble(aReader["ciji_receiptamount"]);
                result.Add(transaction);
            }
            return(result);
        }
        private void AssertPaidInvoice(CustomerInvoiceJournalItem item)
        {
            IList used = ReceiptRepository.FindPaidCustomerInvoice(m_command, item.ID);

            if (used.Count > 0)
            {
                throw new Exception("This Invoice [" + item.INVOICE_NO + "] is paid [" + ((ReceiptItem)used[0]).EVENT_JOURNAL.CODE + "], please delete receipt first.");
            }
        }
        public static void UpdateAgainstStatus(MySql.Data.MySqlClient.MySqlCommand cmd, EventJournal e, ICustomerInvoiceJournalItem ei)
        {
            CustomerInvoiceJournal     po  = (CustomerInvoiceJournal)e;
            CustomerInvoiceJournalItem poi = (CustomerInvoiceJournalItem)ei;

            cmd.CommandText = poi.UpdateAgainstStatus();
            cmd.ExecuteNonQuery();
            cmd.CommandText = po.UpdateAgainstStatus();
            cmd.ExecuteNonQuery();
        }
Пример #10
0
        public void UpdateAgainstReceiptStatusSIJ()
        {
            bool allClosed = true;

            for (int i = 0; i < EVENT_JOURNAL_ITEMS.Count; i++)
            {
                CustomerInvoiceJournalItem poi = EVENT_JOURNAL_ITEMS[i] as CustomerInvoiceJournalItem;
                if (poi.AGAINST_RECEIPT_STATUS == AgainstStatus.Close)
                {
                    continue;
                }
                allClosed = false;
                break;
            }
            AGAINST_RECEIPT_STATUS = allClosed ? AgainstStatus.Close : AgainstStatus.Outstanding;
        }
Пример #11
0
        protected override void doConfirm(Event events, Period p)
        {
            foreach (EventItem item in events.EVENT_ITEMS)
            {
                SetStockCard(item, p);
            }
            CustomerInvoice si = (CustomerInvoice)events;

            CustomerInvoiceJournal sij = new CustomerInvoiceJournal();

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

            CustomerInvoiceJournalItem siji = new CustomerInvoiceJournalItem();

            siji.AMOUNT                    = si.NET_TOTAL;
            siji.CURRENCY                  = si.CURRENCY;
            siji.EVENT_JOURNAL             = sij;
            siji.VENDOR                    = si.CUSTOMER;
            siji.INVOICE_NO                = si.CODE;
            siji.INVOICE_DATE              = si.TRANSACTION_DATE;
            siji.TOP                       = si.TOP;
            siji.EMPLOYEE                  = si.EMPLOYEE;
            siji.DUE_DATE                  = si.DUE_DATE;
            siji.OUTSTANDING_AMOUNT        = si.NET_TOTAL;
            siji.VENDOR_BALANCE_ENTRY_TYPE = VendorBalanceEntryType.CustomerInvoice;

            sij.EVENT_JOURNAL_ITEMS.Add(siji);
            r_sij.SaveNoTransaction(sij);
            r_sij.ConfirmNoTransaction(sij.ID);
        }
        public CustomerInvoiceJournal FindCIJbyPOSId(int POSId)
        {
            string sql = CustomerInvoiceJournal.FindCustomerInvoiceJournalItembyPOSId(POSId);

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

            r.Close();
            if (rest == null)
            {
                return(null);
            }
            m_command.CommandText = CustomerInvoiceJournalItem.GetByEventIDSQL(rest.ID);
            r = m_command.ExecuteReader();
            rest.EVENT_JOURNAL_ITEMS = CustomerInvoiceJournalItem.TransformReaderList(r);
            r.Close();
            return(rest);
        }
        protected override void doDeleteNoTransaction(EventJournal e)
        {
            CustomerInvoiceJournal st = (CustomerInvoiceJournal)e;

            try
            {
                if (getEventStatus(st.ID) == EventStatus.Confirm)
                {
                    throw new Exception("Revise before delete");
                }
                m_command.CommandText = CustomerInvoiceJournalItem.DeleteAllByEventSQL(st.ID);
                m_command.ExecuteNonQuery();
                m_command.CommandText = CustomerInvoiceJournal.DeleteSQL(st.ID);
                m_command.ExecuteNonQuery();
            }
            catch (Exception x)
            {
                throw x;
            }
        }
        public IList FindCIJournalItemlistForReceipt(string find, int ccyID, int customer, DateTime trdate, IList notIn)
        {
            StringBuilder poisSB = new StringBuilder();

            foreach (int i in notIn)
            {
                poisSB.Append(i.ToString());
                poisSB.Append(',');
            }
            string pois = poisSB.ToString();

            pois = notIn.Count > 0 ? pois.Substring(0, pois.Length - 1) : "";
            m_command.CommandText = CustomerInvoiceJournalItem.GetSearchForReceipt(find, ccyID, customer, pois, trdate);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            IList result = CustomerInvoiceJournalItem.TransformReaderList(r);

            r.Close();
            foreach (CustomerInvoiceJournalItem t in result)
            {
                m_command.CommandText = CustomerInvoiceJournal.GetByIDSQL(t.EVENT_JOURNAL.ID);
                r = m_command.ExecuteReader();
                t.EVENT_JOURNAL = CustomerInvoiceJournal.TransformReader(r);
                r.Close();

                m_command.CommandText = Currency.GetByIDSQLStatic(t.CURRENCY.ID);
                r          = m_command.ExecuteReader();
                t.CURRENCY = Currency.GetCurrency(r);
                r.Close();

                m_command.CommandText = TermOfPayment.GetByIDSQLStatic(t.TOP.ID);
                r     = m_command.ExecuteReader();
                t.TOP = TermOfPayment.GetTOP(r);
                r.Close();

                m_command.CommandText = Employee.GetByIDSQLStatic(t.EMPLOYEE.ID);
                r          = m_command.ExecuteReader();
                t.EMPLOYEE = Employee.GetEmployee(r);
                r.Close();
            }
            return(result);
        }
        protected override EventJournal doGet(int ID)
        {
            m_command.CommandText = CustomerInvoiceJournal.GetByIDSQL(ID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            CustomerInvoiceJournal st = CustomerInvoiceJournal.TransformReader(r);

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

            r.Close();
            foreach (CustomerInvoiceJournalItem 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);
                st.EVENT_JOURNAL_ITEMS.Add(sti);
            }
            return(st);
        }
        protected override void doDelete(EventJournal e)
        {
            CustomerInvoiceJournal st = (CustomerInvoiceJournal)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");
                }
                m_command.CommandText = CustomerInvoiceJournalItem.DeleteAllByEventSQL(st.ID);
                m_command.ExecuteNonQuery();
                m_command.CommandText = CustomerInvoiceJournal.DeleteSQL(st.ID);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
Пример #17
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);
        }