Drupal 7 Create a new account for an anonymous order only for commerce license orders - entity-framework

With Drupal 7 using Rules 7.27, I've installed and set up Drupal Commerce with no real problems.
The rule ‘Create a new account for an anonymous order’ works well but I need to add a condition that only executes the action of creating a new account only if the product being ordered is a Commerce License. Commerce License is an entity so I tried both of the following conditions, but they prevent the Rules actions from triggering:
Entity is of type: Parameter: Entity: [site:current-cart-order], Entity type: Commerce License
Entity is of type: Parameter: Entity: [commerce-order], Entity type: Commerce License
It's apparent I don't have a full grasp of how to tell the Rule that the order processed is not just any old order but a specific order type. I would be fine with identifying it with any criteria possible, like product/order name, but it seems that I've hit a blockage in understanding the whole Commerce universe in relation to Rules.
Does anyone have any idea what conditions to specify to tell the actions only to fire if the order is for a commerce license?

Use the condition Commerce Order: Order contains products of particular product types.

Related

How should I design DDD aggregate with an invariant based on information from multiple aggregates?

I'm new to Domain Driven Desing and completely stucked with modelling problem. Here is a screenshot of design level event storming of simple feature with only one invariant:
Let's assume that eventual consistency is not allowed for certificate's condition and it is absolutely crucial to fulfill this condition immediately to process an order. In this case to check my certificate invariant I need an access to:
season of the order
supplier's country
season from which certificates are checked for specific country
supplier's certificates and if they are accepted and up to date
Initially I tried to split my application into multiple bounded contexts and for me those informations belong to different bounded contexts. Should I then have all these necassary data (list above) in one aggregate in order to ensure consistency and have its quite large or maybe there is any other solution? Maybe my whole reasoning is wrong and it doesn't make much sense? Maybe the bounded contexts boundaries are wrong due to necesity to reach for data to other contexts (not being autonomous)? Maybe domain service could be a solution? I would be really grateful for any help because I'm quite confused with those ddd topics :/
before answering your question I suggest you keep in mind the next statements:
Consolidate your business invariants(rules) inside Aggregate.
Design small and autonomous aggregates, if it is possible.
Reference other Aggregates by using their id.
Update other Aggregates using eventual consistency.
now let me share my opinion and give you advice (I've used C# syntax in below code snippets)
I recommend to you use 2 BC - Order and Supplier, and each of those is a good candidate for the individual aggregate. Certificate is not an aggregate and we have access to it via Supplier aggregate.
Preface: We have 2 services, - Order application service which injects repository interfaces to retrieve specific data. Also, we have an Order domain service where we're working with our aggregates.
Now if you want to check the certificate invariant, to do the next steps -
We should arrange all required data in the order application service by pulling data from repositories
Now it's time to validate
(supplier's certificates and if they are accepted and up to date) certificate invariant.
Let's switch to the Order domain service to decide about order processing where we have the next method public void AddOrder(Order newOrder, Supplier supplier).
But let's start with adding the concrete business rule class like that
public class SupplierCertificatesAreValidRule{
public SupplierCertificatesAreValidRule(IList<Certificate> supplierCertificates){
...
}
public bool IsValid() {...}
}
Get from the Supplier entity collection of its certificates.
Let's define the season of the order
Then get the supplier's country
Fetch the season from which certificates are checked for specific country
Add the Add method in the Order entity itself, where at beginning of this method we should call our business rule like that :
public static Order Add(Order newOrder, Supplier supplier){
CheckRule(new SupplierCertificatesAreValidRule(supplier.Certificates));
return new Order();
}
If the rule does not meet, then we should throw some business rule validation exception and explain the reason there.
If our rule is met, then it means that we can process our order

Skip field validation when creating a record using Dynamics 365 web api

I am integrating Dynamics 365 with our product, and I am running into an issue when creating fields on dynamics 365 using web api.
I am creating a contact or lead using a set of fields such as email, name etc. Some fields seem to have validation, such as number only field, or picklist. In these cases I am getting an error with 400 status and the record is not created. Is there a way to just create the record using the valid fields and just skip updating the fields that failed validation.
This is the end point I am using for creating a contact:
/api/data/v9.1/contacts
Headers used:
Prefer:return=representation
Content-Type:application/json
OData-MaxVersion:4.0
OData-Version:4.0
If-None-Match:null
You have two options:
Either do the proper validation when user entering values for those fields from outside Dynamics.
Or create custom fields in Dynamics contact entity to store the string type values
Web api payload has to be whole and cannot be truncated/set for adhoc scenarios like skip failing datatypes (your requirement).
Hope this helps. No matter what software or environment you are integrating with, it is important to know your data structure including data types, data validations (including required yes/no) and data constraints (length, decimal places, etc.).
There are three ways you can integrate with Dynamics 365 factoring in the above.
1. Static code based on the Dynamics 365 configuration
If you can login to Dynamics 365, you can view the environment definition by going to Settings > Customizations > Customize the System.
From here you can view all Entity and Attribute definitions and and write your code accordingly. You can also "require" installation of your own solution with Entities and Attributes, giving you control over what your integrating with.
2. Creating Early-Bound classes
You can generate Early Bound classes with the Entity and Attribute definition from Dynamics 365 with the CrmSvcUtil tool. For more information.
For more information:
https://learn.microsoft.com/en-us/dynamics365/customer-engagement/developer/org-service/create-early-bound-entity-classes-code-generation-tool
3. Dynamics 365 Metadata service
Dynamics 365 provides a Metadata service, enabling you to retrieve the exact definition of alle Entities and Attributes directly from the given Dynamics 365 environment. As such you can retrieve the definition prior to integrating.
I think considering the performance, this is definitly not something you would like to do every single message. To resolve this you could retrieve the definition on request (manual trigger) or daily.
For more information: https://learn.microsoft.com/en-us/dynamics365/customer-engagement/customize/create-edit-metadata
When working with Dynamics 365, the XRMToolBox is a must have tool for any developer or consultant. With the tools Metadata Browser plugin you can view the data that you can retrieve by the Metadata service.

Dynamic Rules creation with any java rule engine

I have this question and trying to get suggestions ,i am working on a a project where the business admins go to UI and sets some rules ..For example lets say JIRA has a feature like if this jiraticket belongs to (Some arbitrary board "XYZ" ) board and type of the jira is "Task" then Label should be added ..
This kind of rules the admin of JIRA through the admin screens sets this rules(How he sets it keep it a side for now )...Now when the user creates a JIRA under the board and sets type with our Lable then based on the rule it should throw an error saying the label should be set ..
There are two parts to implement this feature
1)While admin sets this through the screen we need to create the rule and store it some where..
2)While user creates the jira run the rules which has been stored and say it is valid or not
I am looking for any framework in java it can be done easily for 1) which creates the rule where some framework can understans it and can run the riles with 2) point.
Does some one has any suggestions on this ..?
Thanks,
Swati

REST API Design for systems with multiple companies or organizations

Most of the examples I see implement REST URL patterns like http://www.app.com/books/1 to access a book with ID 1 or http://www.app.com/books to access all the books.
That's great, but commonly I work on applications that support multiple companies. For example, Company ABC has 2 users and Company DEF has 2 users. A user from company ABC creates a book with id 100. Now when a RESTful call comes in from a user at company DEF:
http://www.app.com/books/100
there would need to be an Access exception, or
http://www.app.com/books
would only list all books belonging to DEF (not the new book with id 100). For many entities, like Book, the company ID is part of the table, but for other entities that may not be the case. For example, if there was a REST operation for one chapter in a book, http://www.app.com/chapter/333 the chapter table would have a foreign key reference to the book but not the company.
What would best practices be for managing access to this resource? If somebody from DEF tried to access a chapter from ABC I would have to construct a query to join the chapter to the book to verify the company id was valid.
I'm using Grails 3.x where most of this logic is abstracted and thinks happen "automagically". So a URL that comes in for a specific book ID is returned automatically and the request to list all returns every book in the database. It seems that to proceed I would have to override most of this automatic functionality and implement my own security, perhaps in the service layer where the company id would be a required parameter for every operation. Does that sound reasonable?
Is there an established best practice for this sort of thing?
Don't know if it fits your needs but it's interesting to know there is an ACL plugin written by Burt Beckwith :
Spring Security ACL Plugin

Is it possible to create Schema.org offers for lease items?

I am trying to create markup for vehicles that are available for lease.
These vehicles have three offers attached to them:
Buy now
Zero down lease
Lease with down payment
I have looked through the Schema.org properties and can't seem to find any property that lets me define the payment schedule (monthly, weekly etc.) or define a down payment and then incremental payments after.
You can try the https://schema.org/BusinessFunction for the Offer
The business function specifies the type of activity or access (i.e., the bundle of rights) offered by the organization or business person through the offer. Typical are sell, rental or lease, maintenance or repair, manufacture / produce, recycle / dispose, engineering / construction, or installation. Proprietary specifications of access rights are also instances of this class.
Commonly used values:
...
http://purl.org/goodrelations/v1#LeaseOut
...
Maybe you can combine them with the https://schema.org/PayAction or https://schema.org/RentAction as a https://schema.org/potentialAction on your Offer