public List <MergeSalesOrder> PackingSalesOrder(List <SalesOrder> salesOrderList) { List <MergeSalesOrder> mergeSalesOrderList = new List <MergeSalesOrder>(); foreach (var item in salesOrderList) { MergeSalesOrder mergeSalesOrder = new MergeSalesOrder(); mergeSalesOrder.DocEntry = item.DocEntry; mergeSalesOrder.BusinessType = item.BusinessType; mergeSalesOrder.CardCode = item.CardCode; mergeSalesOrder.DocType = item.DocType; mergeSalesOrder.Freight = item.Freight; mergeSalesOrder.OMSDocDate = item.OMSDocDate; mergeSalesOrder.PlatformCode = item.PlatformCode; mergeSalesOrder.PayMethod = item.PayMethod; mergeSalesOrder.OrderPaied = item.OrderPaied; mergeSalesOrder.SalesOrders.Add(new OriginSalesOrder() { DocEntry = item.DocEntry }); foreach (var line in item.SalesOrderItems) { MergeSalesOrderItem mergeSalesOrderItem = new MergeSalesOrderItem(); mergeSalesOrderItem.ItemCode = line.ItemCode; mergeSalesOrderItem.Quantity = line.Quantity; mergeSalesOrderItem.Price = line.Price; mergeSalesOrderItem.ItemPaied = line.ItemPaied; mergeSalesOrder.MergeSalesOrderItems.Add(mergeSalesOrderItem); } mergeSalesOrderList.Add(mergeSalesOrder); } return(mergeSalesOrderList); }
public static Result CreateJournalEntry(MergeSalesOrder salesOrder) { Result result = new Result(); SAPbobsCOM.JournalEntries myJE = SAP.SAPCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries); myJE.ReferenceDate = salesOrder.OMSDocDate; myJE.UserFields.Fields.Item("U_DocType").Value = salesOrder.DocType; myJE.UserFields.Fields.Item("U_BusinessType").Value = salesOrder.BusinessType; myJE.UserFields.Fields.Item("U_PlatformCode").Value = salesOrder.PlatformCode; myJE.UserFields.Fields.Item("U_CardCode").Value = salesOrder.CardCode; foreach (var item in salesOrder.MergeSalesOrderItems) { Tuple <string, string> Accout = BOneCommon.GetAccountByPayMethod(salesOrder.PayMethod); myJE.Lines.AccountCode = Accout.Item1; myJE.Lines.ShortName = Accout.Item2; myJE.Lines.Debit = Convert.ToDouble(salesOrder.OrderPaied); myJE.Lines.UserFields.Fields.Item("U_PayMethod").Value = salesOrder.PayMethod; myJE.Lines.Add(); if (salesOrder.Freight != 0) { myJE.Lines.AccountCode = Accout.Item1; myJE.Lines.ShortName = Accout.Item2; myJE.Lines.Debit = Convert.ToDouble(salesOrder.Freight); myJE.Lines.UserFields.Fields.Item("U_PayMethod").Value = salesOrder.PayMethod; myJE.Lines.Add(); myJE.Lines.AccountCode = "224101"; myJE.Lines.ShortName = "224101"; myJE.Lines.Credit = Convert.ToDouble(salesOrder.Freight); myJE.Lines.Add(); } myJE.Lines.AccountCode = GetAccountCode(salesOrder.BusinessType, item.ItemCode); myJE.Lines.ShortName = GetShortName(salesOrder.BusinessType, item.ItemCode, salesOrder.CardCode); myJE.Lines.Credit = Convert.ToDouble(salesOrder.OrderPaied); myJE.Lines.UserFields.Fields.Item("U_ItemCode").Value = item.ItemCode; myJE.Lines.UserFields.Fields.Item("U_Quantity").Value = Convert.ToDouble(item.Quantity); myJE.Lines.UserFields.Fields.Item("U_RefDate").Value = salesOrder.OMSDocDate; myJE.Lines.Add(); } int rtCode = myJE.Add(); if (rtCode != 0) { result.ResultCode = SAP.SAPCompany.GetLastErrorCode(); result.Message = SAP.SAPCompany.GetLastErrorDescription(); } else { result.ResultCode = 0; result.ObjCode = SAP.SAPCompany.GetNewObjectKey(); result.Message = "Create JournalEntry Successfully."; } return(result); }
public static Result CreateInvoice(MergeSalesOrder salesOrder) { Result result = new Result(); SAPbobsCOM.Documents myDocuments = SAP.SAPCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices); myDocuments.DocDate = salesOrder.OMSDocDate; myDocuments.DocDueDate = salesOrder.OMSDocDate; myDocuments.TaxDate = salesOrder.OMSDocDate; myDocuments.UserFields.Fields.Item("U_DocType").Value = salesOrder.DocType; myDocuments.UserFields.Fields.Item("U_BusinessType").Value = salesOrder.BusinessType; myDocuments.UserFields.Fields.Item("U_PlatformCode").Value = salesOrder.PlatformCode; myDocuments.CardCode = salesOrder.CardCode; foreach (var item in salesOrder.MergeSalesOrderItems) { myDocuments.Lines.ItemCode = item.ItemCode; if (salesOrder.DocType == "S01") { myDocuments.Lines.Quantity = Convert.ToDouble(item.Quantity); } else { myDocuments.Lines.Quantity = -Convert.ToDouble(item.Quantity); } myDocuments.Lines.VatGroup = BOneCommon.GetVatGroupbyItemCode(item.ItemCode).Item2; myDocuments.Lines.PriceAfterVAT = Convert.ToDouble(item.ItemPaied) / myDocuments.Lines.Quantity; myDocuments.Lines.Add(); } int rtCode = myDocuments.Add(); if (rtCode != 0) { result.ResultCode = -1; result.Message = SAP.SAPCompany.GetLastErrorDescription(); } else { result.ResultCode = 0; result.ObjCode = SAP.SAPCompany.GetNewObjectKey(); result.Message = "Create Invoice Successfully."; } return(result); }