DMF and Advanced accounting structure - dynamics-ax-2012-r3

I have 10 dimensions in standard accounting structure and 7 dimensions defined in advanced rule.
Importing journals through DMF in excel throws error for 17 dimensions but works with 10 dimensions.
What's the right way to resolve this?

I got the solution. The issue was in generateDynamicDimension() method in DmfDimensionHelper Class.
Although It was bringing in all the dimensions values from the Segmented Entry Dimension column from Excel Sheet, it was picking only those Dimension names from the table where DimensionHierarchyType is AccountStructure and not from the Advanced Rule. I included DimensionHierarchyType of AccountRuleStructure as well. Now it's working.
while select Level from dimHierarchyLevel
order by dimHierarchyLevel.DimensionHierarchy, dimHierarchyLevel.Level
where (dimHierarchyLevel.DimensionHierarchy == dimHierarchyId
&& dimHierarchy.IsDraft == false
&& dimHierarchy.IsSystemGenerated == false
&& (dimHierarchy.StructureType == DimensionHierarchyType::AccountStructure || dimHierarchy.StructureType == DimensionHierarchyType::AccountRuleStructure)
join * from dimAttribute where
dimAttribute.RecId == dimHierarchyLevel.DimensionAttribute
exists join ledgerStructure
where ledgerStructure.DimensionHierarchy == dimHierarchy.RecId
&& ledgerStructure.Ledger == Ledger::current()
This is the additional Condtition I entered:
dimHierarchy.StructureType == DimensionHierarchyType::AccountRuleStructure

Related

If AND with 3 conditions apps script

Im trying to make somthing like this:
IF( A>B && A>C && A >= D){
than do this;
}
¿Can an IF have 3 conditions?
There can be any number of conditions in an if() statement.
Apps Script is JavaScript and therefore case-sensitive, and keywords such as if are spelled in lower case. It is a good practice to use lower case with variable names as well, like this:
if (a > b && a > c && a >= d) {
// ...do something
}
See if...else.

Having trouble with Create-Only rules in Firebase Realtime Database

I'm trying to create a card deck database.
I have a node, "decks". Inside it are more nodes, numbered from '00001'. Inside '00001' is a node for each card, numbered appropriately, and inside each card node is the card data.
deck
00001
card001
SetCode:Alpha
SetID:001
card002
etc.
My problem is when it comes to the security rules. I don't want anyone to be able to update or delete any decks.
"decks":{
"$deckId":{
".validate": "$deckId.matches(/^[0-9]{5,5}$/) && $deckId.length == 5 && data.val() == null && newData.val() != null",
"$cardNumber":{
".validate": "$cardNumber.matches(/^[C][a][r][d][0](30|2[0-9]|1[0-9]|[0][1-9])$/) && $cardNumber.length == 7",
"SetCode":{".validate": "newData.isString()&& newData.val().matches(/^[A-Z][a-z]{4}$/)"},
"SetID":{".validate": "newData.isString()&& newData.val().matches(/^[0-9]{3}$/)"},
}}}
and I can't seem to find a set of rules that lets me make a new deck while also preventing anyone from deleting it or updating an existing deck.
Some rules I've tried are:
".write": "auth != null",
".write": "data.val() == null && newData.hasChildren() != null",
".write": "!data.exists()"
".write": "data.val() == null && newData.val() != null"
in various 'depths' of the rules, but I've been hitting my head against this for hours now. If someone could point me to the correct rule in the correct 'depth', I would be very grateful.
Edit: The main instance that I thought would work - and that I had found on multiple resources for Creation-Only rules, was:
'decks':{
".write": "data.val() == null && newData.val() != null",
}
It could be that I'm putting it in the wrong depth or if there's some other factor I haven't taken into account, but I don't understand why this doesn't work. I don't have any other read/write rules on higher levels.
The problem is where you defined the rule, not their contents.
You need to define the rule on the exact path where the write operation occurs. Since you want to allow creating a new deck, you need the rule to be on the individual deck, which you can do by using a wildcard variable:
'decks':{
"$deckid": {
".write": "!data.exist" // allows creation, but not updating or deletion
}
}

how can i use both ternary operator and isnull function in SSIS?

For this table, I have two null value in suburb and postcode.
I want to change 'IsValid' column into "N" if the suburb, and postcode is "Null". otherwise the 'IsValid' is "Y"
Here's my expression:
LEN(LTRIM(RTRIM(School_Suburb))) == 0 ||
LEN(LTRIM(RTRIM(School_Postcode))) == 0 ||
ISNULL(School_Suburb) ||
ISNULL(School_Postcode) ? "N" : "Y"
and this is the error message.
So just wondering if anyone know which part I wrote it wrong? How can I change it?
this is the screenshot of derived column edit page
If you remove IsValid from the Expression and put it in the first column, currently "Derived Column 1".
The other change is that you will need to wrap the entirety of your logical ORs together with parentheses for
(LEN(LTRIM(RTRIM(School_Suburb))) == 0 || LEN(LTRIM(RTRIM(School_Postcode))) == 0 || ISNULL(School_Suburb) || ISNULL(School_Postcode)) ? "N" : "Y"
A good rule of thumb on expressions is that if it doesn't fit in the visible box, it's probably too long. Here, I'd break it out into three new columns split across two Derived Column Components.
Here I create two new columns IsSuburbInvalid and IsSchoolInvalid (although mislabled in the screenshot as Valid, not Invalid)
LEN(LTRIM(RTRIM(School_Suburb))) == 0 || ISNULL(School_Suburb)
LEN(LTRIM(RTRIM(School_Postcode))) == 0 || ISNULL(School_Postcode)
In the next Derived Column (has to be a separate component since it will use the new columns we just created), I create IsValid with a much easier to debug logic of
IsSchoolInvalid || IsSuburbInvalid ? "N" : "Y"

Entity framework updates several records when FirstOrDefault() is used

I have a rather strange problem which is scratching my head at the moment. I am using EF together with MySQL for a project and when I want to update a record on the database like this
using (var context = new MyDbContext())
{
var record = (from d in context.Dictionary where d.CompanyName == companyName && d.Name == "Logo" select d).FirstOrDefault();
record.Value = _path;
context.SaveChanges();
}
Then every record that has d.Name == "Logo" gets updated for some reason, which means that it ignores the d.CompanyName == companyName part. Anyone who has experienced the same problem or know how to solve it?
Thanks in advance.
Actually I don't use EF Provider for MySQL often but I suppose it works.
The problem can be splitted in 2 parts, a select and an update. The select is fine, if you need to see what is the query you can split the select statement like this
var query = (from d in context.Dictionary where d.CompanyName == companyName && d.Name == "Logo" select d);
var record = query.FirstOrDefault();
and have a look to query variable (just point it in debug mode).
About your issue the only reason that I can immagine is that you did not configure the Dictionary class in the right way.
I mean, when you run context.SaveChanges an Update query is generated using the Key definition of Dictionary (the Where part of the query). If the key definition is wrong, the where clause will be wrong.
Use this I hope this will help you.
using (var context = new MyDbContext())
{
var record = context.Dictionary.Where(x=> x.CompanyName == companyName && x.Name == "Logo").FirstOrDefault();
record.Value = _path;
context.SaveChanges();
}

Using a variable in a SQLAlchemy filter

I want to use a variable like this :
myVariable = 0.5
myQuery.filter(myTable.column1 == myVariable*myTable.column2)
I have then no results when I apply all() to myQuery.
If I replace the variable with its value, it is OK.
queryBidOffer = session.query(BidOffer.id, BidOffer.price, BidOffer.qmin, BidOffer.qmax)
queryBidOffer = queryBidOffer.join(Equipment).filter(BidOffer.equipment==Equipment.id, Equipment.equipment_type.in_(['L','P','W','M']))
queryBidOffer_day = queryBidOffer.filter(BidOffer.day == day)
queryBidOffer_hour = queryBidOffer_day.filter(BidOffer.start_hour == timeSlice)
queryBidOffer_hour = queryBidOffer_hour.join(EquipmentDayHour, BidOffer.equipment == EquipmentDayHour.equipment)
queryBidOffer_hour = queryBidOffer_hour.filter(EquipmentDayHour.day == day)
queryBidOffer_hour = queryBidOffer_hour.filter(EquipmentDayHour.hour == timeSlice)
factor1 = 1.00 - 0.07
queryBidOffer_hour = queryBidOffer_hour.filter(BidOffer.equipment == EquipmentDayHour.equipment, factor1*func.abs(EquipmentDayHour.ref_prog) == 930)
The problem is with the two last lines (factor1).
In the last line, if I replace factor1 by its value, it is OK.
IEEE floating point numbers as used by Python, and many databases do not always work as your school math. The reason why 0.93 worked was that that was the bitwisely exact value that you had originally stored in database. But slight error appears in the subtraction.
See this for example:
>>> print "%0.64f" % (1.0 - 0.07)
0.9299999999999999378275106209912337362766265869140625000000000000
>>> print "%0.64f" % (0.93)
0.9300000000000000488498130835068877786397933959960937500000000000
Read more here How should I do floating point comparison and then for very in depth essay you could read What Every Computer Scientist Should Know About Floating-Point Arithmetic...
One solution could be to use decimal.Decimal in Python and Numeric in SQL.
I've just tested out something similar to the code you are describing, but get results whether I use a variable or a literal:
myVariable = 0.5
myQuery.filter(myTable.column1 == myVariable*myTable.column2).all()
vs.
myQuery.filter(myTable.column1 == 0.5*myTable.column2).all()
Can you post up the literal SQL that is being genarated? i.e. the results of
print myQuery
for both of those?