private void addAccountDocItems(ArrayList items) { int ind = 0; MProject firstProj = null; foreach (MAuxilaryDocItem ai in items) { MAccountDocItem di = new MAccountDocItem(new CTable("")); di.ExtFlag = "A"; di.SelectType = ai.SelectType; di.ItemCode = ai.ItemCode; di.ItemNameThai = ai.ItemNameThai; di.ItemId = ai.ItemId; di.FreeText = ai.FreeText; di.ServiceCode = ai.ServiceCode; di.ServiceName = ai.ServiceName; di.ServiceID = ai.ServiceID; di.Quantity = ai.Quantity; di.Discount = ai.Discount; di.UnitPrice = ai.UnitPrice; di.TotalAfterDiscount = ai.TotalAfterDiscount; di.VatTaxFlag = ai.VatTaxFlag; di.WHTaxFlag = ai.WHTaxFlag; di.WHTaxPct = ai.WHTaxPct; di.VatTaxPct = ai.VatTaxPct; di.ItemNote = ai.DocumentNo; di.ProjectID = ai.ProjectID; di.ProjectCode = ai.ProjectCode; di.ProjectName = ai.ProjectName; di.ProjectGroupName = ai.ProjectGroupName; di.RefPoNo = ai.DocumentNo; di.WhGroupCriteria = ai.WhGroup; di.PoItemID = ai.AuxilaryDocItemID; di.PoID = ai.AuxilaryDocID; if (ind == 0) { firstProj = (MProject)di.ProjectObj; } ind++; vw.AddAccountDocItem(di); } if (vw.ProjectID.Equals("") && (firstProj != null)) { //If not yet been set vw.ProjectObj = firstProj; } String poString = vw.GetRefPoString(); vw.RefPoNo = poString; }
private Boolean SaveData() { if (Mode.Equals("A")) { if (SaveToView()) { parentView.AddAccountDocItem(vw); return(true); } return(false); } else if (Mode.Equals("E")) { if (vw.IsModified) { Boolean result = SaveToView(); if (result) { CTable o = actualView.GetDbObject(); o.CopyFrom(vw.GetDbObject()); actualView.NotifyAllPropertiesChanged(); return(true); } return(false); } } return(true); }
private MAccountDoc constructInvoiceFromSaleOrder(MAccountDoc saleOrder) { CTable so = OnixWebServiceAPI.GetAccountDocInfo(saleOrder.GetDbObject()); MAccountDoc sod = new MAccountDoc(so); sod.InitAccountDocItem(); sod.InitEntityAddresses(); MAccountDoc md = new MAccountDoc(new CTable("")); md.DocumentType = ((int)docType).ToString(); md.DocumentDate = sod.DocumentDate; md.DocumentDesc = sod.DocumentDesc; md.DueDate = sod.DocumentDate; md.ProjectID = sod.ProjectID; md.ProjectCode = sod.ProjectCode; md.ProjectName = sod.ProjectName; md.ProjectGroupName = sod.ProjectGroupName; md.EntityId = sod.EntityId; md.EntityCode = sod.EntityCode; md.EntityName = sod.EntityName; md.EntityAddressID = sod.EntityAddressID; md.EmployeeID = sod.EmployeeID; md.EmployeeCode = sod.EmployeeCode; md.EmployeeName = sod.EmployeeName; CTable cust = OnixWebServiceAPI.GetEntityInfo(sod.EntityObj.GetDbObject()); MEntity en = new MEntity(cust); en.InitEntityAddress(); md.ReloadEntityAddresses(en.AddressItems); md.BranchId = sod.BranchId; md.VATType = sod.VATType; md.VAT_PCT = sod.VAT_PCT; md.RefSaleOrderNo = sod.DocumentNo; md.RefSaleOrderID = sod.AccountDocId; md.RefPoNo = sod.RefPoNo; md.RefQuotationNo = sod.RefQuotationNo; foreach (MAccountDocItem ad in sod.AccountItem) { MAccountDocItem adi = new MAccountDocItem(ad.GetDbObject()); adi.ProjectID = sod.ProjectID; adi.ProjectCode = sod.ProjectCode; adi.ProjectName = sod.ProjectName; adi.ExtFlag = "A"; md.AddAccountDocItem(adi); } md.CalculateExtraFields(); md.IsModified = true; return(md); }
private MAccountDoc constructSaleOrderFromQuotation(MAuxilaryDoc quotation) { CTable qt = OnixWebServiceAPI.GetAuxilaryDocInfo(quotation.GetDbObject()); MAuxilaryDoc qd = new MAuxilaryDoc(qt); qd.InitAuxilaryDocItem(); qd.InitEntityAddresses(); MAccountDoc md = new MAccountDoc(new CTable("")); md.DocumentType = ((int)AccountDocumentType.AcctDocSaleOrder).ToString(); md.DocumentDate = qd.DocumentDate; md.DocumentDesc = qd.DocumentDesc; md.DueDate = qd.DocumentDate; md.ProjectID = qd.ProjectID; md.ProjectCode = qd.ProjectCode; md.ProjectName = qd.ProjectName; md.ProjectGroupName = qd.ProjectGroupName; md.EntityId = qd.EntityId; md.EntityCode = qd.EntityCode; md.EntityName = qd.EntityName; md.EntityAddressID = qd.EntityAddressID; md.EmployeeID = qd.EmployeeID; md.EmployeeCode = qd.EmployeeCode; md.EmployeeName = qd.EmployeeName; CTable cust = OnixWebServiceAPI.GetEntityInfo(qd.EntityObj.GetDbObject()); MEntity en = new MEntity(cust); en.InitEntityAddress(); md.ReloadEntityAddresses(en.AddressItems); md.BranchId = qd.BranchId; md.VATType = qd.VatType; md.RefQuotationNo = qd.DocumentNo; md.RefQuotationID = qd.AuxilaryDocID; foreach (MAuxilaryDocItem ad in qd.AuxilaryDocItems) { MAccountDocItem adi = new MAccountDocItem(ad.GetDbObject()); adi.ExtFlag = "A"; md.AddAccountDocItem(adi); } md.CalculateExtraFields(); md.IsModified = true; return(md); }
private void addItemFromPayroll(ArrayList arr, int type) { String projectVariable = "PAYROLL_PROJECT_CODE"; String serviceVariable = "PAYROLL_SERVICE_CODE"; if (type == 2) { serviceVariable = "SOCIAL_SECURITY_SERVICE_CODE"; } String projectCode = CGlobalVariable.GetGlobalVariableValue(projectVariable); CTable p = getObject(projectCode, "PROJECT_CODE", "GetProjectList", "PROJECT_LIST"); MProject pj = new MProject(p); String serviceCode = CGlobalVariable.GetGlobalVariableValue(serviceVariable); CTable s = getObject(serviceCode, "SERVICE_CODE", "GetServiceList", "SERVICE_LIST"); MService sv = new MService(s); foreach (MVPayrollDocument pd in arr) { CTable t = new CTable(""); MAccountDocItem mdi = new MAccountDocItem(t); mdi.CreateDefaultValue(); mdi.SelectType = "1"; mdi.ServiceObj = sv; mdi.ProjectObj = pj; vw.AddAccountDocItem(mdi); MAuxilaryDocSubItem mi = new MAuxilaryDocSubItem(new CTable("")); mi.Description = String.Format("{0}-{1} {2}", pd.FromSalaryDateFmt, pd.ToSalaryDateFmt, pd.EmployeeTypeDesc); mi.SubItemDate = pd.ToSalaryDate; mi.UnitPrice = pd.ReceiveAmount; if (type == 2) { mi.UnitPrice = pd.SocialSecurityCompanyAmount; } mi.Quantity = "1.00"; mdi.AddItemDetail(mi); mdi.CalculateSubItemTotal(); mdi.SerializeItemDetails(); } }