grabbing parent records in sugarcrm - sugarcrm

what I have done? and what I need?
I have created two module 1.invoice 2. payment there is one to many relationship between invoice and payment
it means one invoice have many payment.
for calculating payment I have used a logic hook in payment module.
now I want invoice_id in payment module to retrive data.
for that I use
$invoice = new invoi_invoice();
$invi = $invoice->get_linked_beans('invoi_invoice_t_hotel_payment_1','invoi_invoice');
var_dump($invi);
it return
array(0){
}
and also I used
$invoice = new invoi_invoice();
$id=$invoice->retrieve($bean->invoi_invoice_t_hotel_payment_1invoi_invoice_ida);
but this also does not give me id of invoice.
i have read lots of blog and tutorial all are grabing parent record same like me.
but I don1t get id till now.
any help please..

I got the solution
for simply getting the parent id use
var_dump($_REQUEST);
then you got parent id like this:-
$parent_id=$_REQUEST["return_id"];

Related

REST: If the procedure is a DB UPDATE command, should your API call strictly be PUT?

Consider the following invoice table with two entries, id 1 and 2:
id, item, date_paid
1, 'apple', ''
2, 'banana', ''
When a payment is made date_paid column needs to be updated.
What is a proper REST verb for this?
POST invoices/1/payments
or
PUT invoices/1/payments
I feel like POST is proper since I am "adding" a payment detail but then again internally I'm actually "updating" a DB row so PUT seems applicable also.
If I understand your example, you have an invoice that was created in your Invoice table at some point in the past. You're now updating said invoice to reflect that a payment was made. That's definitely an update and PUT is the correct verb. Presumably you might also have a Payment table with the actual payment details (amount, payer, etc.). If so, then that's where you would be adding a new payment record. That call would be a POST.

API V3 CustomSalesTax

I am currently testing V3 of the API with QBO.
Creating an invoice that includes tax is fine if the TxnTaxDetail includes a TxnTaxCodeRef that exists in QBO.
However I noticed when pulling the list of tax codes from QBO that there is a special one called CustomSalesTax.
Can this CustomSalesTax be used to add a custom sales tax to an invoice ?. For instance, I'd supply the TotalTax = 1000, TaxLine.Amount=1000, TaxLine.TaxLineDetail.PercentBased=false in order to add 1000 of tax to the invoice.
Thanks
Fernando
CustomSalesTax is a special id that represents the old US tax model. So this can be used to update any old transactions that are tied to old US tax model. Cannot create new transactions using this CustomSalesTax.
Thanks

Getting multiple invoices from intuit anywhere api at once

When I update an invoice in QB (after its been changed in my system), I want to avoid updating anything that the user has modified in QB. My plan was to use the filter API method and filter by Ids to get the list of invoices from QB that my app created. However, it doesn't look like InvoiceFilter accepts ListIdSet. It does have a TransactionIdSet, but I can't find a way to get ahold of that number (i.e., the TransactionId) via Data Services. It's certainly not in the response when invoices are read. So, how do I query for a specific set of invoices via the API?
The transaction id refers to the id of the invoice here.
For eg, the following invoice query will retrieve the invoice with Id 4 -
<InvoiceQuery xmlns="http://www.intuit.com/sb/cdm/v2">
<TransactionIdSet>
<Id idDomain="QB">4</Id>
</TransactionIdSet>
</InvoiceQuery>

Symfony2: How to create entity form with creation of multiple subentities?

This is propably a simple task to solve in Symfony2 but I am really stuck here:
I am building a very simple shop. There are three entities: Products, Customers, and Orders. The last one contains three columns: customer_id, product_id, and quantity. The shop simply consists of a page listing all the products with a select field for each to chose the quantity, followed by a form to enter your customer data.
I have no problem creating the form for the customer data nor listing the products itself (without the select fields).
But how do I create a form including the select fields of the products, which then should become order entities?
I played around with form collections and I do understand all the given examples with adding tags to an entity etc. But I can't get the hang of how to adjust it to my situation.
What I have in mind goes something like this:
// Create new customer
$customer = new Customer();
// At this point, create form and validate it.
// Having trouble here, need a hint to get it right.
...
// If form is ok, loop thru all the products.
// Since I do not know yet how to define the form,
// I don't know yet what to loop over, too.
foreach( ..... ){
if($quantity > 0){
$order = new Order();
$order->setQuantity($quantity);
$order->setProduct($product);
$customer->addOrder($order);
}
}
// then persist $customer, cascading its orders.
...
I have been spending hours on this. Any help is greatly appreciated. Thanks!
Update:
Eventually I got it working. I created an OrderFactory and a OrderFormType and had to change around the whole setting a bit. The AcmePizzaBundle which is mentioned in the responses below was actually a great help to get the missing parts right.
Take a look at an example: AcmePizzaBundle.
It has 4 entities you need: Pizza, Order, OrderItem, Customer.

Satchmo: Specify delivery date/shipping date for an order

I working on e-commerce website using Satchmo. However, there are few customization required for my store.
While ordering a product I should be able to specify a delivery date (shipping date).
There can be only 20 (max_num_delievries) deliveries possible per day for a product. If number of deliveries for a particular date for a particular product exceeds 'max_num_delievries', user should not be able to select that date while ordering the product.
Can someone please help in this and guide me how to achieve this using Satchmo?
Thanks in advance..
I would try something like this:
1) create a local app (eg. delivery_date) with a model like "DeliveryDate" or so. For example localsite/delivery_date/models.py:
class DeliveryDate(models.Model):
product = models.ForeignKey(Product)
date = models.DateField()
order = models.ManyToManyField(Order)
class Meta:
unique_together = ("product", "date")
2) the validation of the max 20 existing orders... mhh, good question, maybe the best would be, to do it on the form? Override the clean method and check if this delivery date is associated with 20 orders already... maybe something like localsite/delivery_date/forms.py
class DeliveryDateForm(forms.ModelForm):
class Meta:
model = DeliveryDate
def clean(self):
super(DeliveryDateForm, self).clean()
... check here the order_set count
... but maybe the form isn't the best place to do this.
You also probably want to hide and auto-set the initial values for product and order yourself, and the user only being supposed to select a date.
3) Regarding satchmo... I would use signals to react after a product has been added to the cart (there is a signal just for this case), and add a listener which redirects the user to a view where he can select the date for this product. Look at the example here with the signal "cart_add_view": http://www.facebook.com/note.php?note_id=101466134049
Maybe ajax would be a good option here. With a hidden container in your page... which shows up after adding a product to the cart (only if the product hasn't already a DeliveryDate associated to this order/product), and asking the user to select a date.
This whole stuff would be on the listener: check if the product needs a delivery date, and if yes, send an ajax response to pop-up the window, and put in the repsonse-context the form, with the initial product and order hidden fields.
And to save the delivery-date you will need another ajax-view.
Well it's merely an idea how I would try to do it ;-) It will probably need adjustments here and there, of course. But hopefully it helps you further.
Regards,
Andrea