} // setAccount /// <summary> /// Get Account Combination based on Account and Overwrite /// </summary> /// <returns>account</returns> public MAccount GetAccount() { MAccount acct = MAccount.Get(GetCtx(), _account.GetAD_Client_ID(), IsOverwriteOrg() && GetOrg_ID() != 0 ? GetOrg_ID() : _account.GetAD_Org_ID(), _account.GetC_AcctSchema_ID(), IsOverwriteAcct() && GetAccount_ID() != 0 ? GetAccount_ID() : _account.GetAccount_ID(), _account.GetC_SubAcct_ID(), // IsOverwriteProduct() ? GetM_Product_ID() : _account.GetM_Product_ID(), IsOverwriteBPartner() ? GetC_BPartner_ID() : _account.GetC_BPartner_ID(), IsOverwriteOrgTrx() ? GetAD_OrgTrx_ID() : _account.GetAD_OrgTrx_ID(), IsOverwriteLocFrom() ? GetC_LocFrom_ID() : _account.GetC_LocFrom_ID(), IsOverwriteLocTo() ? GetC_LocTo_ID() : _account.GetC_LocTo_ID(), IsOverwriteSalesRegion() ? GetC_SalesRegion_ID() : _account.GetC_SalesRegion_ID(), IsOverwriteProject() ? GetC_Project_ID() : _account.GetC_Project_ID(), IsOverwriteCampaign() ? GetC_Campaign_ID() : _account.GetC_Campaign_ID(), IsOverwriteActivity() ? GetC_Activity_ID() : _account.GetC_Activity_ID(), IsOverwriteUser1() ? GetUser1_ID() : _account.GetUser1_ID(), IsOverwriteUser2() ? GetUser2_ID() : _account.GetUser2_ID(), _account.GetUserElement1_ID(), _account.GetUserElement2_ID()); return(acct); } // setAccount
/// <summary> /// Get Distribution for combination /// </summary> /// <param name="acct">account (ValidCombination)</param> /// <param name="PostingType">only posting type</param> /// <param name="C_DocType_ID">only document type</param> /// <returns>array of distributions</returns> public static MDistribution[] Get(MAccount acct, String PostingType, int C_DocType_ID) { return(Get(acct.GetCtx(), acct.GetC_AcctSchema_ID(), PostingType, C_DocType_ID, acct.GetAD_Org_ID(), acct.GetAccount_ID(), acct.GetM_Product_ID(), acct.GetC_BPartner_ID(), acct.GetC_Project_ID(), acct.GetC_Campaign_ID(), acct.GetC_Activity_ID(), acct.GetAD_OrgTrx_ID(), acct.GetC_SalesRegion_ID(), acct.GetC_LocTo_ID(), acct.GetC_LocFrom_ID(), acct.GetUser1_ID(), acct.GetUser2_ID())); } // get
/// <summary> /// Factory: default combination /// </summary> /// <param name="acctSchema">accounting schema</param> /// <param name="optionalNull">if true, the optional values are null</param> /// <returns>Account</returns> public static MAccount GetDefault(MAcctSchema acctSchema, bool optionalNull) { MAccount vc = new MAccount(acctSchema); // Active Elements MAcctSchemaElement[] elements = acctSchema.GetAcctSchemaElements(); for (int i = 0; i < elements.Length; i++) { MAcctSchemaElement ase = elements[i]; String elementType = ase.GetElementType(); int defaultValue = ase.GetDefaultValue(); bool setValue = ase.IsMandatory() || (!ase.IsMandatory() && !optionalNull); // if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) { vc.SetAD_Org_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Account)) { vc.SetAccount_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount) && setValue) { vc.SetC_SubAcct_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_BPartner) && setValue) { vc.SetC_BPartner_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Product) && setValue) { vc.SetM_Product_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Activity) && setValue) { vc.SetC_Activity_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom) && setValue) { vc.SetC_LocFrom_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo) && setValue) { vc.SetC_LocTo_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Campaign) && setValue) { vc.SetC_Campaign_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx) && setValue) { vc.SetAD_OrgTrx_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Project) && setValue) { vc.SetC_Project_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion) && setValue) { vc.SetC_SalesRegion_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserList1) && setValue) { vc.SetUser1_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserList2) && setValue) { vc.SetUser2_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserElement1) && setValue) { vc.SetUserElement1_ID(defaultValue); } else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserElement2) && setValue) { vc.SetUserElement2_ID(defaultValue); } } _log.Fine("Client_ID=" + vc.GetAD_Client_ID() + ", Org_ID=" + vc.GetAD_Org_ID() + " - AcctSchema_ID=" + vc.GetC_AcctSchema_ID() + ", Account_ID=" + vc.GetAccount_ID()); return(vc); }