Could anyone help in writing trigger for this scenario in salesforce - triggers

My customer purchased some drugs from my company then if the customer raises a case from email (inside email drug name and quantity will come from the customer ) then automatically the Total price of the drug with quantity should be sent automatically from salesforce org. I need the code using triggers. And in the Automatic Response email, the customer name should be merged saying Dear
drug name: paracetamol
quantity: 10
Price of Each: 5 Rs
total Price: 50 Rs
If the customer is Indian then it should send the price in Indian rupeesĀ 
If the customer is from the USA then it should send the price in US dollarsĀ 
And the customer should have a profile in salesforce org...

Related

Is there a better way to design an E-commerce products database when the products can have multiple price lines?

I'm trying to develop a new products database for a client and I am having a hard time finding a solution to handle the many different prices a product can have.
Variables that can affect the price of a product:
region (where the customer lives).
customer type (whether they're a new customer or a registered customer).
order type (whether you want to purchase the item once or subscribe monthly).
store type (there were many store types, but now they're transitioning to one, but I don't know if they will add more in the future again so I want this to be flexible
Product Table
id
product_name
sku
description
1
Vanilla Protein Powder
1111
This is a description...
Attributes Table
id
associate_type
region
store
currency_code
order_type
1
2
1
11
usd
1
2
2
1
11
usd
2
Product Attributes Table
id
price
product_id
attribute_id
1
49.95
1
1
2
29.95
1
2
I was initially thinking this would be a good route to go, but the issue that arises is on the product page I want to display the price of the product if you want to purchase it once and the price if you wanted to subscribe. The same issue would happen if I also wanted to show a list of product cards on a product category page displaying both prices.
The issue I run into
When I write a query to get the correct products with the correct price lines, I would filter all the products by the variables mentioned above, but I will always want the subscription price and the one-time price, so in the query, I would have to include WHERE order_type = 1 AND order_type = 2 but doing this would return duplicate records of the product/ products because of the different prices for a one-time purchase and a subscription purchase.
Is there a better way to set up the tables I have so that the query would not return duplicate records of the product/ products? Or is there a way to write the query to handle this for me? Or do I even need to switch up my database design altogether?

I already SMS module create in Tally Developer 9.Working Properly but my requirement is multiple item select than message not proper way

single item select:-
Example: "Dear Sir, your sales item name is mobile and price 100 Rs."
Multiple items select:- "Dear Sir, your sales item name is mobile, price 100 Rs 1 qty and laptop price 10000 Rs 1 qty"

Passing the Billing Address to Paypal Express API

I am working on a small membership site in WordPress. We already have the users Name and Address and wish to pass that information to PayPal Express to prepopulate the Billing Information if the user chooses to pay by Debit or Credit Card. The site only sells to 5 countries at present (UK, US, AU, CA, NZ).
Using the Paypal Sandbox I can get the Billing information across to CA, AU and NZ but using the same nvp string (with variations for currency / country code) I can't pass it to the UK or US.
Here's my Working CA String:
&PAYMENTREQUEST_0_ITEMAMT=250.00
&PAYMENTREQUEST_0_CURRENCYCODE=CAD
&PAYMENTREQUEST_0_SHIPTONAME=Test User
&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=CA
&PAYMENTREQUEST_0_SHIPTOPHONENUM=01234567890
&PAYMENTREQUEST_0_SHIPTOSTREET=Test Address 1
&PAYMENTREQUEST_0_SHIPTOSTREET2=Test Address 2
&PAYMENTREQUEST_0_SHIPTOCITY=Test City
&PAYMENTREQUEST_0_SHIPTOSTATE=Test State
&PAYMENTREQUEST_0_SHIPTOZIP=123456
&DESC=Example+Description
&NOTIFYURL=http%3A%2F%2Fwww.example.com%2Fwp-admin%2Fadmin-ajax.php%3Faction%3Dipnhandler
&PAYMENTREQUEST_0_SHIPPINGAMT=30.00
&NOSHIPPING=0
&PAYMENTREQUEST_0_AMT=280
&L_BILLINGAGREEMENTDESCRIPTION0=Billing+Description
&L_PAYMENTTYPE0=Any
&ReturnUrl=http%3A%2F%2Fwww.example.com%2Freturnurl
&CANCELURL=http%3A%2F%2Fwww.example.com%2Fcancelurl
&SOLUTIONTYPE=Sole
&LANDINGPAGE=Billing
And here's my non-working UK string:
&PAYMENTREQUEST_0_ITEMAMT=135.00
&PAYMENTREQUEST_0_CURRENCYCODE=GBP
&PAYMENTREQUEST_0_SHIPTONAME=User Name
&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=UK
&PAYMENTREQUEST_0_SHIPTOPHONENUM=01234567890
&PAYMENTREQUEST_0_SHIPTOSTREET=Test Address 1
&PAYMENTREQUEST_0_SHIPTOSTREET2=Test Address 2
&PAYMENTREQUEST_0_SHIPTOCITY=Test City
&PAYMENTREQUEST_0_SHIPTOSTATE=Test State
&PAYMENTREQUEST_0_SHIPTOZIP=123456
&DESC=Example+Description
&NOTIFYURL=http%3A%2F%2Fwww.example.com%2Fwp-admin%2Fadmin-ajax.php%3Faction%3Dipnhandler
&PAYMENTREQUEST_0_SHIPPINGAMT=20.00
&NOSHIPPING=0
&PAYMENTREQUEST_0_AMT=155
&L_BILLINGAGREEMENTDESCRIPTION0=Billing+Description
&L_PAYMENTTYPE0=Any
&ReturnUrl=http%3A%2F%2Fwww.example.com%2Freturnurl
&CANCELURL=http%3A%2F%2Fwww.example.com%2Fcancelurl
&SOLUTIONTYPE=Sole
&LANDINGPAGE=Billing
As you can see virtually identical. The country does get populated correctly in all cases, just not the actual address info. What fundamental thing am I missing??
UK country code is not UK it is GB

Mapping payments in IIF to QBXML

For having deprecated IIF, you'd think Intuit would make it easier to map the calls but I've found myself in something of a corner.
I have a fairly old script mapping our stuff to IIF.
!TRNS TRNSTYPE DATE ACCNT NAME AMOUNT DOCNUM MEMO CLEAR REP PAYMETH ADDR1 ADDR2 ADDR3 ADDR4
!SPL TRNSTYPE DATE ACCNT NAME AMOUNT DOCNUM MEMO CLEAR QNTY PRICE INVITEM PAYMETH EXTRA
!ENDTRNS
TRNS PAYMENT 1/21/2010 Paypal Account Dear Customer 1230.9 PAYPAL - Invoice123 N PAYPAL Dear Customer 123 Dear Dr
SPL PAYMENT 1/21/2010 Accounts Receivable Dear Customer -1230.9 Invoice123 PAYPAL - Invoice123 N PAYPAL
ENDTRNS
TRNS CHECK 1/21/2010 Paypal Account Paypal Account -29.84 Transaction Fees - Invoice123 N
SPL CHECK 1/21/2010 Fees:Paypal Fees Dear Customer 29.84 Transaction Fees - Invoice123 N
ENDTRNS
Now, I have a script that handles the customer and finding the right record in QB but I'm trying to find the right call to put all these records in. It looks like the first two can fit into ReceivePaymentAddRq but it's less clear on the second set.
Then I have another set that starts with BILL
TRNS BILL 5/15/2014 Accounts Payable Our Vendor -344.81 450608 N 6/14/2014 Net 30
SPL BILL 5/15/2014 Cost of Goods Sold:Purchases Dear Customer 344.81 450608 Invoice123 N
ENDTRNS
I think both fall under BillAdd but that COGS line could also fall under ChargeAdd
The transaction type PAYMENT would indeed be a ReceivePaymentAddRq. The CHECK type would be a CheckAddRq as you are not effecting an Accounts Receivable account. The transaction type of BILL would be a BillAddRq, as you are wanting to effect Accounts Payable. The ChargeAddRq is used for a customer charge, which is not the same as a CreditCardChargeAddRq.
It helps to have used QuickBooks manually a bit to understand the types of transactions that are used, but here's a quick little reference (these include the AddRq, QueryRq and ModRq where applicable). Note that this is not 100% as there are situations where you might use a different transaction type, but it's a good starting point:
Effect Accounts Receivable:
Invoice
ReceivePayment
Charge
CreditMemo
Effect Accounts Payable:
Bill
ItemReceipt
VendorCredit
BillPaymentCheck
BillPaymentCreditCard
Effect Bank Account:
Check
Deposit
Effect Credit Card Account:
CreditCardCharge
CreditCardCredit

PayPal Charge Tax on shipping (not just items)

I am using the PayPal url approach which works well but when I try charge tax it only seems to apply the tax to the total value of all of the goods, whereas I would like to charge Tax on the Total goods + Shipping, ie
Goods $100.00,
Shipping $20.00,
SubTotal $120.00,
Tax (10%) $12.00,
Grand Total $132.00
This is what I have
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_cart&business=xxxxxxxxxxxxxx_biz#gmail.com&button_subtype=services&upload=1&no_note=1&currency_code=USD&rm=1&item_name_1=Product1&amount_1=200.00&quantity_1=2&item_name_2=Product2&amount_2=200.00&quantity_2=22&shipping_2=6&tax_1=10&tax_2=10&return=http://staging.xxxx.com/store/success.aspx&cancel_return=http://staging.xxxx.com/store/failed.aspx
I made a change to the tax variable to apply a rate rather than an amount. At this time PayPal doesn't charge tax including shipping as services are typically not taxable.
If this is a requirement I'd recommend calculating the total tax amount on your site before sending the Post to PayPal. The value can be entered in the tax_1 field. I've shown an example of this in the second post.
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_cart
&business=xxxxxxxxxxxxxx_biz#gmail.com
&button_subtype=services
&upload=1
&no_note=1
&currency_code=USD
&rm=1
&item_name_1=Product1
&amount_1=200.00
&quantity_1=2
&item_name_2=Product2
&amount_2=200.00
&quantity_2=2
&shipping_2=6
&tax_rate_1=10
&tax_rate_2=10
&return=http://staging.xxxx.com/store/success.aspx
&cancel_return=http://staging.xxxx.com/store/failed.aspx
Here's an example with you calculating the amount. Notice you're only sending one tax amount rather than a tax amount for each item. PayPal doesn't show itemized tax amounts to the customer so there is no impact on the customer's end.
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_cart
&business=xxxxxxxxxxxxxx_biz#gmail.com
&button_subtype=services
&upload=1
&no_note=1
&currency_code=USD
&rm=1
&item_name_1=Product1
&amount_1=200.00
&quantity_1=2
&item_name_2=Product2
&amount_2=200.00
&quantity_2=2
&shipping_2=6
&tax_1=10
&return=http://staging.xxxx.com/store/success.aspx
&cancel_return=http://staging.xxxx.com/store/failed.aspx