public double GetPaid(int sijiID) { m_command.CommandText = SupplierInvoiceJournalItem.GetByPaidSQL(sijiID); double d = Convert.ToDouble(m_command.ExecuteScalar()); return(d); }
public static IList TransformReaderList(MySql.Data.MySqlClient.MySqlDataReader aReader) { IList result = new ArrayList(); while (aReader.Read()) { SupplierInvoiceJournalItem transaction = new SupplierInvoiceJournalItem(); transaction.ID = Convert.ToInt32(aReader["siji_id"]); transaction.EVENT_JOURNAL = new SupplierInvoiceJournal(Convert.ToInt32(aReader["sij_id"])); transaction.VENDOR = new Supplier(Convert.ToInt32(aReader["sup_id"])); transaction.CURRENCY = new Currency(Convert.ToInt32(aReader["ccy_id"])); transaction.AMOUNT = Convert.ToDouble(aReader["siji_amount"]); //transaction.VENDOR_BALANCE_ENTRY = new VendorBalanceEntry( //VENDOR_BALANCE == null ? 0 : VENDOR_BALANCE.ID, transaction.VENDOR_BALANCE_ENTRY_TYPE = VendorBalanceEntryType.SupplierInvoice; transaction.INVOICE_DATE = Convert.ToDateTime(aReader["siji_invoicedate"]); transaction.INVOICE_NO = aReader["siji_invoiceno"].ToString(); transaction.DUE_DATE = Convert.ToDateTime(aReader["siji_duedate"]); transaction.EMPLOYEE = new Employee(Convert.ToInt32(aReader["emp_id"])); transaction.DISCOUNT = Convert.ToDouble(aReader["siji_discount"]); transaction.AMOUNT_BEFORE_DISCOUNT = Convert.ToDouble(aReader["siji_amountbeforediscount"]); transaction.TOP = new TermOfPayment(Convert.ToInt32(aReader["top_id"])); transaction.DESCRIPTION = aReader["siji_description"].ToString(); transaction.NOTES = aReader["siji_notes"].ToString(); transaction.AGAINST_PAYMENT_STATUS = (AgainstStatus)Enum.Parse(typeof(AgainstStatus), aReader["siji_againstpaymentstatus"].ToString()); transaction.OUTSTANDING_AMOUNT = Convert.ToDouble(aReader["siji_outstandingamount"]); transaction.PAID_AMOUNT = Convert.ToDouble(aReader["siji_paidamount"]); result.Add(transaction); } return(result); }
protected override void doUpdateNoTransaction(EventJournal en) { try { SupplierInvoiceJournal e = (SupplierInvoiceJournal)en; m_command.CommandText = e.GetUpdateSQL(); m_command.ExecuteNonQuery(); foreach (SupplierInvoiceJournalItem 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 = SupplierInvoiceJournalItem.SelectMaxIDSQL(); sti.ID = Convert.ToInt32(m_command.ExecuteScalar()); } } m_command.CommandText = SupplierInvoiceJournalItem.DeleteUpdate(e.ID, e.EVENT_JOURNAL_ITEMS); m_command.ExecuteNonQuery(); } catch (Exception x) { throw x; } }
internal static SupplierInvoiceJournalItem FindSIJournalItemlistForPayment(MySql.Data.MySqlClient.MySqlCommand cmd, int supinvItemID) { cmd.CommandText = SupplierInvoiceJournalItem.GetByIDSQL(supinvItemID); MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader(); SupplierInvoiceJournalItem result = SupplierInvoiceJournalItem.TransformReader(r); r.Close(); cmd.CommandText = SupplierInvoiceJournal.GetByIDSQL(result.EVENT_JOURNAL.ID); r = cmd.ExecuteReader(); result.EVENT_JOURNAL = SupplierInvoiceJournal.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 doSaveNoTransaction(EventJournal e) { try { DateTime trDate = DateTime.Today; string codesample = AutoNumberSetupRepository.GetCodeSampleByDomainName(m_command, "SupplierInvoiceJournal"); 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, "SupplierInvoiceJournal", e.CODE, lastCode, lastDate, trDate, trCount == 0); SupplierInvoiceJournal stk = (SupplierInvoiceJournal)e; m_command.CommandText = stk.GetInsertSQL(); m_command.ExecuteNonQuery(); m_command.CommandText = SupplierInvoiceJournal.SelectMaxIDSQL(); stk.ID = Convert.ToInt32(m_command.ExecuteScalar()); foreach (SupplierInvoiceJournalItem item in stk.EVENT_JOURNAL_ITEMS) { m_command.CommandText = item.GetInsertSQL(); m_command.ExecuteNonQuery(); m_command.CommandText = SupplierInvoiceJournalItem.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; } }
private void AssertPaidInvoice(SupplierInvoiceJournalItem item) { IList used = PaymentRepository.FindPaidSupplierInvoice(m_command, item.ID); if (used.Count > 0) { throw new Exception("This Invoice [" + item.INVOICE_NO + "] is paid [" + ((PaymentItem)used[0]).EVENT_JOURNAL.CODE + "], please delete payment first."); } }
public static void UpdateAgainstStatus(MySql.Data.MySqlClient.MySqlCommand cmd, EventJournal e, ISupplierInvoiceJournalItem ei) { SupplierInvoiceJournal po = (SupplierInvoiceJournal)e; SupplierInvoiceJournalItem poi = (SupplierInvoiceJournalItem)ei; cmd.CommandText = poi.UpdateAgainstStatus(); cmd.ExecuteNonQuery(); cmd.CommandText = po.UpdateAgainstStatus(); cmd.ExecuteNonQuery(); }
public void UpdateAgainstPaymentStatusSIJ() { bool allClosed = true; for (int i = 0; i < EVENT_JOURNAL_ITEMS.Count; i++) { SupplierInvoiceJournalItem poi = EVENT_JOURNAL_ITEMS[i] as SupplierInvoiceJournalItem; if (poi.AGAINST_PAYMENT_STATUS == AgainstStatus.Close) { continue; } allClosed = false; break; } AGAINST_PAYMENT_STATUS = allClosed ? AgainstStatus.Close : AgainstStatus.Outstanding; }
protected override void doConfirm(Event events, Period p) { foreach (EventItem item in events.EVENT_ITEMS) { SetStockCard(item, p); } SupplierInvoice si = (SupplierInvoice)events; SupplierInvoiceJournal sij = new SupplierInvoiceJournal(); // 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.SUPPLIER; sij.SUPPLIER_INVOICE = si; sij.NET_AMOUNT = si.NET_TOTAL; sij.EMPLOYEE = si.EMPLOYEE; sij.VENDOR_BALANCE_ENTRY_TYPE = VendorBalanceEntryType.SupplierInvoice; SupplierInvoiceJournalItem siji = new SupplierInvoiceJournalItem(); siji.AMOUNT = si.NET_TOTAL; siji.CURRENCY = si.CURRENCY; siji.EVENT_JOURNAL = sij; siji.VENDOR = si.SUPPLIER; 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.SupplierInvoice; sij.EVENT_JOURNAL_ITEMS.Add(siji); r_sij.SaveNoTransaction(sij); r_sij.ConfirmNoTransaction(sij.ID); }
protected override void doDeleteNoTransaction(EventJournal e) { SupplierInvoiceJournal st = (SupplierInvoiceJournal)e; try { if (getEventStatus(st.ID) == EventStatus.Confirm) { throw new Exception("Revise before delete"); } m_command.CommandText = SupplierInvoiceJournalItem.DeleteAllByEventSQL(st.ID); m_command.ExecuteNonQuery(); m_command.CommandText = SupplierInvoiceJournal.DeleteSQL(st.ID); m_command.ExecuteNonQuery(); } catch (Exception x) { throw x; } }
public IList FindSIJournalItemlistForPayment(string find, int ccyID, int supplier, 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 = SupplierInvoiceJournalItem.GetSearchForPayment(find, ccyID, supplier, pois, trdate); MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader(); IList result = SupplierInvoiceJournalItem.TransformReaderList(r); r.Close(); foreach (SupplierInvoiceJournalItem t in result) { m_command.CommandText = SupplierInvoiceJournal.GetByIDSQL(t.EVENT_JOURNAL.ID); r = m_command.ExecuteReader(); t.EVENT_JOURNAL = SupplierInvoiceJournal.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 = SupplierInvoiceJournal.GetByIDSQL(ID); MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader(); SupplierInvoiceJournal st = SupplierInvoiceJournal.TransformReader(r); r.Close(); m_command.CommandText = SupplierInvoiceJournalItem.GetByEventIDSQL(ID); r = m_command.ExecuteReader(); IList stis = SupplierInvoiceJournalItem.TransformReaderList(r); r.Close(); foreach (SupplierInvoiceJournalItem 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) { SupplierInvoiceJournal st = (SupplierInvoiceJournal)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 = SupplierInvoiceJournalItem.DeleteAllByEventSQL(st.ID); m_command.ExecuteNonQuery(); m_command.CommandText = SupplierInvoiceJournal.DeleteSQL(st.ID); m_command.ExecuteNonQuery(); trc.Commit(); } catch (Exception x) { trc.Rollback(); throw x; } }