// Local storage for the batch entry header private Sage.Accounting.SalesLedger.PendingSalesUnspecifiedBatchEntry batchEntry = null; // Local storage for the sales invoice instrument private Sage.Accounting.SalesLedger.SalesBankReceiptInstrument receiptInvoiceInstrument = null; // Local storage for the customer private Sage.Accounting.SalesLedger.Customer customersale = null; private void Create_Batch(string accref, string reference, string transdate, string cash, string card,string cheque,string deposit) { try { //card = Convert.ToString(Convert.ToDecimal(card) - Convert.ToDecimal(deposit)); Create_Batch_Header(accref, transdate, cash, card, cheque); // Update the batch header this.batchEntry.Update(); // Now the header has been updated we can get the specified entry Sage.Accounting.SalesLedger.PendingSalesReceiptBatchEntry specifiedEntry = (Sage.Accounting.SalesLedger.PendingSalesReceiptBatchEntry) this.batchEntry.SpecifiedEntry; // From the specified entry we can create a new sales invoice batch item Sage.Accounting.SalesLedger.PendingSalesReceiptBatchItem invoiceBatchItem = (Sage.Accounting.SalesLedger.PendingSalesReceiptBatchItem) specifiedEntry.CreateBatchItem(); // We can get the sales invoice instrument from the invoice batch item this.receiptInvoiceInstrument = invoiceBatchItem.Instrument; // Suppress warnings that we do not wish to show Suppress_Warnings(); // Set the first invoice details Set_Invoice_Details(accref, reference, transdate, card, deposit); // Update the invoice item and specified entry Update_InvoiceItem_and_SpecifiedEntry(invoiceBatchItem, specifiedEntry); // From the specified entry we can create a second sales invoice batch item invoiceBatchItem = (Sage.Accounting.SalesLedger.PendingSalesReceiptBatchItem) specifiedEntry.CreateBatchItem(); // We can get the sales invoice instrument from the invoice batch item this.receiptInvoiceInstrument = invoiceBatchItem.Instrument; // Suppress warnings that we do not wish to show Suppress_Warnings(); // Set the second invoice details Set_Invoice2_Details(accref, reference, transdate, cash); // Update the invoice item and specified entry Update_InvoiceItem_and_SpecifiedEntry(invoiceBatchItem, specifiedEntry); //For cheque if (Convert.ToDecimal(cheque) > 0) { // From the specified entry we can create a third sales invoice batch item //invoiceBatchItem = // (Sage.Accounting.SalesLedger.PendingSalesReceiptBatchItem) // specifiedEntry.CreateBatchItem(); //// We can get the sales invoice instrument from the invoice batch item //this.receiptInvoiceInstrument = invoiceBatchItem.Instrument; //// Suppress warnings that we do not wish to show //Suppress_Warnings(); //// Set the third invoice details //Set_Invoice3_Details(accref, reference, transdate, cheque); //// Update the invoice item and specified entry //Update_InvoiceItem_and_SpecifiedEntry(invoiceBatchItem, specifiedEntry); } //End of cheque // Since the actual batch count and value have changed on the header we need // to commit these changes to the database this.batchEntry.Update(); // Optional: At this point we can commit the batch which will update // the entries to the database. //this.batchEntry.Commit(); } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } } private void Create_Batch_Header(string accref, string transdate, string cash, string card, string cheque) { // Create a new batch entry Sage.Accounting.SalesLedger.PendingSalesUnspecifiedBatchEntries batchEntries = Sage.Accounting.SalesLedger.PendingSalesUnspecifiedBatchEntriesFactory.Factory.FetchAllBatches(); this.batchEntry = (Sage.Accounting.SalesLedger.PendingSalesUnspecifiedBatchEntry) batchEntries.AddNew(); // Set the batch title this.batchEntry.BatchTitle = accref + " - " + transdate; // Set the batch type this.batchEntry.BatchType = Sage.Accounting.TradingAccountEntryTypeEnum.TradingAccountEntryTypePurchasePaymentSalesReceipt;//.TradingAccountEntryTypePurchaseReceiptSalesPayment; //.TradingAccountEntryTypeInvoice; // Set the total number of items we are expecting in the batch. if (Convert.ToDecimal(cheque) > 0) this.batchEntry.ExpectedBatchItemCount = 3; // maximum 999 else this.batchEntry.ExpectedBatchItemCount = 2; // Set the expected batch total value. this.batchEntry.ExpectedBatchTotal = Math.Round(Convert.ToDecimal(card) + Convert.ToDecimal(cash) + Convert.ToDecimal(cheque), 2); //234.91M; // Set additional information this.batchEntry.CreationDate = System.DateTime.Today; this.batchEntry.BatchUserName = Sage.Accounting.Application.ActiveUserName; this.batchEntry.UserNumber = Sage.Accounting.Application.ActiveUserNumber; } private void Suppress_Warnings() { // Suppress the warnings that we do not want to show // allow customer to be over their credit limit this.receiptInvoiceInstrument.SuppressExceedsCreditLimitException = true; // allow the batch to be posted with zero net and tax values this.receiptInvoiceInstrument.SuppressZeroGoodsTaxException = true; }
Sales Invoice Card Posting private void Set_Invoice_Details(string accref, string reference, string transdate, string card, string deposit) { // Get the customer we wish to create an invoice for customersale = Sage.Accounting.SalesLedger.CustomerFactory.Factory.Fetch(accref); // Set the customer on the invoice instrument this.receiptInvoiceInstrument.Customer = customersale; // Set the transaction references this.receiptInvoiceInstrument.InstrumentNo = "cards"; this.receiptInvoiceInstrument.SecondReferenceNo = "inc Deposit " + deposit; // Set the transaction date this.receiptInvoiceInstrument.InstrumentDate = Convert.ToDateTime(transdate); // Set the net value on the invoice instrument this.receiptInvoiceInstrument.NetValue = Convert.ToDecimal(card); //getlasttwocharter //mystring.Substring(Math.Max(0, mystring.Length - 2)); Sage.Accounting.CashBook.Banks banks = Sage.Accounting.CashBook.BanksFactory.Factory.CreateNew(); banks.Query.Filters.Add(new Sage.ObjectStore.Filter(Sage.Accounting.CashBook.Bank.FIELD_REFERENCE, Sage.Common.Data.FilterOperator.Equal, accref.Substring(Math.Max(0, accref.Length - 2)))); banks.Find(); Sage.Accounting.CashBook.Bank bank = banks.First; this.receiptInvoiceInstrument.Bank = bank; }
Sales Invoice Cash Posting
private void Set_Invoice2_Details(string accref, string reference, string transdate, string cash) { // Get the customer we wish to create an invoice for this.customersale = Sage.Accounting.SalesLedger.CustomerFactory.Factory.Fetch(accref); // Set the customer on the invoice instrument this.receiptInvoiceInstrument.Customer = customersale; // Set the transaction references this.receiptInvoiceInstrument.InstrumentNo = "cash"; // Set the transaction date this.receiptInvoiceInstrument.InstrumentDate = Convert.ToDateTime(transdate); // Set the net value on the invoice instrument this.receiptInvoiceInstrument.NetValue = Convert.ToDecimal(cash); Sage.Accounting.CashBook.Banks banks = Sage.Accounting.CashBook.BanksFactory.Factory.CreateNew(); banks.Query.Filters.Add(new Sage.ObjectStore.Filter(Sage.Accounting.CashBook.Bank.FIELD_REFERENCE, Sage.Common.Data.FilterOperator.Equal, accref)); banks.Find(); Sage.Accounting.CashBook.Bank bank = banks.First; this.receiptInvoiceInstrument.Bank = bank; }
Sales Invoice Cheque Posting
private void Set_Invoice3_Details(string accref, string reference, string transdate, string cheque) { // Get the customer we wish to create an invoice for this.customersale = Sage.Accounting.SalesLedger.CustomerFactory.Factory.Fetch(accref); // Set the customer on the invoice instrument this.receiptInvoiceInstrument.Customer = customersale; // Set the transaction references this.receiptInvoiceInstrument.InstrumentNo = "cheque"; // Set the transaction date this.receiptInvoiceInstrument.InstrumentDate = Convert.ToDateTime(transdate); // Set the net value on the invoice instrument this.receiptInvoiceInstrument.NetValue = Convert.ToDecimal(cheque); Sage.Accounting.CashBook.Banks banks = Sage.Accounting.CashBook.BanksFactory.Factory.CreateNew(); banks.Query.Filters.Add(new Sage.ObjectStore.Filter(Sage.Accounting.CashBook.Bank.FIELD_REFERENCE, Sage.Common.Data.FilterOperator.Equal, "09")); banks.Find(); Sage.Accounting.CashBook.Bank bank = banks.First; this.receiptInvoiceInstrument.Bank = bank; } private void Update_InvoiceItem_and_SpecifiedEntry(Sage.Accounting.SalesLedger.PendingSalesReceiptBatchItem invoiceBatchItem, Sage.Accounting.SalesLedger.PendingSalesReceiptBatchEntry specifiedEntry) { // Save the item, this copies the data from the instrument into the // items dataobject. // This method also updates the actual batch count and value for the batch entry invoiceBatchItem.SaveItem(); // Add the invoice batch item to the entry specifiedEntry.SalesBatchItems.Add(invoiceBatchItem); // Update the invoice batch item invoiceBatchItem.Update(); // Update the specified entry specifiedEntry.Update(); }
For further help please drop an email:- [email protected]
Cell:- +447429143498