Set field "DocumentDate" to PurchFormLetter - x++

I am invoicing a purchase order using the PurchFormLetter:
ttsbegin;
purchTable = PurchTable::find(_deliveryHeader.PurchId, true);
purchFormLetter = PurchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchTable, _deliveryHeader.InvoiceId, today(),PurchUpdate::ReceiveNow);
ttscommit;
the invoice is done perfectly but in VendTrans, the DocumentDate field stays empty.

Related

Using GORM, record is saved into the database, but when i try to retrieve the same entity it gives the saved id+1

def saveTldAndUpdateTimestamp(EntityTld entityTld) {
log.debug("EntityTldService saveTldAndUpdateTimestamp Start")
entityTld.lastUpdated = new Date()
if (!entityTld.dateCreated) {
entityTld.dateCreated = entityTld.lastUpdated
}
EntityTld savedEntityTld = entityTld.save(flush: true, failOnErrors: true)
log.debug("EntityTldService saveTldAndUpdateTimestamp Exit Entity ID:: ${savedEntityTld?.id}")
return savedEntityTld
}
Example : savedEntityTld with id - 200 in the database.
However in the log statement, instead of printing 200, it prints 201 and the rest of the values is similar to the record of id = 200.
FYI, the table corresponding to the domain EntityTld has a GENERATED BY DEFAULT AS IDENTITY column for the id.
The main objective here is, after saving the entitytld record into the database table, i need the saved id and will insert a new record into table2 (this id being one of the columns in table2)

Woocommerce order complete secondary email retrieved from account meta data key value

Scenario: A customer buys any product and upon order completion an additional email gets sent to a stored value in the users meta data.
My meta field is stored in the database as follows:
Table: wp_usermeta
Column: meta_key = iconic-register-email
Column: meta_value = X
I need to retrieve the meta_value based on the meta_key Column iconic-register-email.
My code thus far:
(To be placed in the function.php file of the child theme)
add_filter( 'woocommerce_email_recipient_new_order', 'new_order_conditional_email_recipient', 10, 2 );
function new_order_conditional_email_recipient( $recipient, $order ) {
// Get the order ID (retro compatible)
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
// Get the custom field value (with the right $order_id)
$my_field_name = get_post_meta($order_id, 'my_field_name', true);
if ($my_field_name == "empolyee1#company.com")
$recipient .= ', empolyee1#company.com';
elseif ($my_field_name == "empolyee2#company.com")
$recipient .= ', empolyee2#company.com';
return $recipient;
}
I am not getting any errors but I am also not getting any emails. I tried replacing
$my_field_name = get_post_meta($order_id, 'my_field_name', true);
with
$my_field_name = get_post_meta($order_id, 'iconic-register-email', true);
but that did not work.
In an effort to minimize static coding of each email address to be matched in code below:
if ($my_field_name == "empolyee1#company.com")
is there a way to call the $recipient based off of the meta_value = X

Django Admin shows "(nothing)"

I want to show in the app/model admin the columns of the model but with some customization. These 3 'tar', 'per_hor','per_tar' have choices in their modelfield.
First I wrote this code:
class ValoresAdmin(admin.ModelAdmin):
list_display = ('fecha', 'tar', 'per_hor','per_tar')
list_filter = ('fecha','tar','per_tar','per_hor')
date_hierarchy = 'fecha'
fieldsets = (
(None, {
'fields': ('fecha',('tar', 'per_hor', 'per_tar'))
}),
(None, {
'fields': ('feu', 'coef_perf','sah', 'pmh','carg_cap')
}),
)
I shows the verbose name of the column but the values is always "(nothing)" on the filter page but if I enter the change form they display correctly their value (their choide).
I read some and decided to create methods like these ones and call them in the list_display:
def get_tar(Self):
return self.get_tar_display()
def get_per_hor(Self):
return self.get_per_hor_display()
def get_per_tar(Self):
return self.get_per_tar_display()
get_tar_display.short_description = 'Tarifa'
get_per_hor_display.short_description = 'Periodo horario'
get_per_tar_display.short_description = 'Periodo tarifario'
Now the filter page will display columns named as the short description BUT with the real value of the field instead of theirs "choice value".
Addiotionally if I mark 'per_tar' as non editable it will show also "(nothing)" in the change from instead of it´s stored value.
What am I doing wrong?
Diving in internet I found the answer here:
http://thinkingnectar.com/2009/django-get_foo_display-behaviour-with-characters-and-integer-fields/
The post comment that when the field is char type, the choice key should be a string but when it´s an integer field it should be an interger!
Here was my problem! Changing strings to integer made it work.

SmartGwt: how to fetch the data in my listgrid

i have a list grid ,i am assiging the values to listGrid by some method in my app
like this
private ListGridRecord[] getData(UserRecord selectedClient) {
return new ListGridRecord[]{
new NameValueRecord(1, "US Siren", selectedClient.getClientsId()),
new NameValueRecord(2, "EN: Liste des identifiants", selectedClient.getClientId2()),
new NameValueRecord(3, "Account number", selectedClient.getClientId3()),
new NameValueRecord(4, "Partner number", selectedClient.getClientId4()),
new NameValueRecord(5, "REGON", selectedClient.getClientId5()),
new NameValueRecord(6, "US Siren*", selectedClient.getClientId6()) ,
new NameValueRecord(7, "TEST", selectedClient.getClientId7())
};
}
It works fine for me and shows the given values in the grid when the app runs .
Now i want to get these values which are displaying in the grid (Which user can also edit from the grid)
I can get the edited values like this
clientIdsGrid.setEditorCustomizer(new ListGridEditorCustomizer() {
public FormItem getEditor(ListGridEditorContext context) {
ListGridField field = context.getEditField();
if (field.getName().equals("value")) {
NameValueRecord record = (NameValueRecord) context.getEditedRecord();
But if a user dont even click on any record and just click save to save the values as it is.
How can i then get the data which is in my grid .
I am trying these
clientIdsGrid.getRecord(1);
clientIdsGrid.getRecords();
but this gives me a listGrid/listGridRecord , how can i then fetch the individual data on each row from them .
grid.addEditorExitHandler may help. Within it u can use:
grid.getEditValueAsString(row num, Column name) for getting new edited value.
If no new it will return null.

Asp.Net MVC 2 Dropdown Displaying System.Web.MVC.SelectListItem

I have a table that contains a list of EquipmentIDs and another table that has maintenance records.
When the user edits a maintenance record I want there to be a drop down list of all of the equipment IDs from the table.
The dropdown list populates, and it populates with the correct amount of entries, however they all say System.Web.MVC.SelectListItem instead of the value of the ID.
Here is the code that generates the list:
public ActionResult Edit(int id)
{
MaintPerformed maintPerformed = maintPerformedRepository.GetMaintPerformed(id);
IList<EquipmentID> IDs = equipmentIDRepository.GetEquipmentIDAsList();
IEnumerable<SelectListItem> selectEquipList =
from c in IDs
select new SelectListItem
{
//Selected = (c.EquipID == maintPerformed.EquipID),
Text = c.EquipID,
Value = c.Sort.ToString()
};
ViewData["EquipIDs"] = new SelectList(selectEquipList, maintPerformed.ID);
return View(maintPerformed);
}
Here is the entry in the .aspx page for the Dropdown list:
%: Html.DropDownList("EquipIDs") %>
Here is how I am generating the list from the table:
public List<EquipmentID> GetEquipmentIDAsList()
{
return db.EquipmentIDs.ToList();
}
It appears that everything is working correctly with the exception of assigning the text to be displayed in the drop down box.
What am I missing or not thinking correctly about?
SelectList and SelectListItem are actually mutually exclusive. You should be using one or the other. Etiher pass the constructor of SelectList your raw data (IDs) or don't use SelectList at all and just make ViewData["EquipIDs"] your enumerable of SelectListItem. If you go with the latter approach, you will have to tweak your code so that you are setting the selected item in the constructor of SelectListItem (as you had done, but commented out).
Either:
ViewData["EquipIDs"] = new SelectList(IDs, maintPerformed.ID, "EquipID", "Sort");
Or:
IEnumerable<SelectListItem> selectEquipList =
from c in IDs
select new SelectListItem
{
Selected = c.EquipID == maintPerformed.EquipID,
Text = c.EquipID,
Value = c.Sort.ToString()
};
ViewData["EquipIDs"] = selectEquipList;

Resources