#nugax_api

1 messages ยท Page 1 of 1 (latest)

limber palmBOT
modest ledgeBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

limber palmBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1235301827592065055

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

plush torrent
#

Hello

quartz crypt
#

Hi!

plush torrent
#

I'm not seeing a tax rate applied to the Invoice Item

quartz crypt
#

Can I show the code that should be applying it?

#

I dont know why its not

plush torrent
#

Sure

quartz crypt
#

ok its php. one moment.

#

oh wiat. one sec

#

that may be wrong code.

#

i apologize.

#

I ma yhave put it in the code that creates the product id.

#
    $product = \Stripe\Product::create([
        'name' => $invoice_item['item_desc'],
        'tax_rates' => [$local_tax_rate],

    ]);```
#

would that be correct, when creating the DRAFT invoice?

#

assuming $local_tax_rate is the id of the tax rate previously created.

#

txr_1PBi1xH0hGHXsp6rjqJ026p1

plush torrent
#

Yeah that looks fine

quartz crypt
#

Warning: Undefined variable $local_tax_rate in /opt/karate-monkey/core/add_invoice_item_engine.php on line 44
Error creating invoice item: Received unknown parameter: tax_rates. Did you mean tax_code?

plush torrent
#

Can you clear your cache and save your code again and then retry?

quartz crypt
#

is it supposed to be tax_rates?

plush torrent
#

But that error indicates an issue with $local_tax_rate

#

So I'd try hardcoding the ID to start

quartz crypt
#

one moment.

#

yes i didnt pull the rate form MySQL.

#

fixing it.

#

oh that was wrong

#

that was on the PRODUCT.

#

it needs to be on the InvoiceItem create.

plush torrent
#

Oh sorry I didn't even look at what method you were calling in your code

quartz crypt
#
    $invoiceItem = \Stripe\InvoiceItem::create([
        'invoice'     => $invoice_item['stripe_invoice_id'],
        'price'       => $price->id,
        'description' => $invoice_item['item_desc'],
        'customer'    => $invoice_item['stripe_customer_id'],
        'quantity'    => $invoice_item['item_qty'],
        'tax_rates' => [$local_tax_rate],
        
    ]); ```
#

like that.

plush torrent
#

Yes correct

quartz crypt
#

one moment

#

hmm

#

close to working!

#

so when you retrieve line item, what is the property for taxes?

plush torrent
#

When you retrieve the Invoice you mean?

#

Oh you specifically said line item

#

Which you can retreive as well

quartz crypt
#

just wanted to show tax collected in a particular line item

#

its not: $lineitem->tax

plush torrent
#

tax_amounts in that case

#

So really $lineitem -> tax_amounts -> amount

quartz crypt
#

$taxes = ConvertCentsToDollars($lineitem->tax_amounts->amount);

#

Like that?

plush torrent
#

Yeah assuming $lineitem is a line item object

quartz crypt
#

its pulling other lineitem data.

#

it gave this error:

#

Warning: Attempt to read property "amount" on array in /opt/karate-monkey/core/edit_invoice.php on line 101

#

which was the above code

#

$taxes = ConvertCentsToDollars($lineitem->tax_amounts->amount);

plush torrent
#

Ah sorry tax_amounts is an array

quartz crypt
#

ooh

#

Warning: Undefined array key "amount" in /opt/karate-monkey/core/edit_invoice.php on line 101

#

is it assoc?

plush torrent
#

What are you doing? It should just be $lineitem->tax_amounts[0]->amount if you only have one tax rate

quartz crypt
#

ah ok

#

your right

#

i didnt realize tax_amounts was an array

#

didnt see that listed, probably overlooked it

#

One more question, is there a fee or charge that can be added to an invoice, not a product.

#

to the total/subtotal (like passing on the stripe processing fee of 3%)

plush torrent
quartz crypt
#

Dang you even have an article for that

plush torrent
#

๐Ÿ˜…

quartz crypt
#

how do you remember where all these articles are...

#

haha

plush torrent
#

That's a pretty common question, thus why we have an article ๐Ÿ™‚

quartz crypt
#

so you add an invoiceitem for this specific charge?

plush torrent
#

Yep

quartz crypt
#

Like "Processing Fee"

plush torrent
#

Yep you can add any description you want

quartz crypt
#

I need a math degree to understand how to calculate it

plush torrent
#

๐Ÿ˜‚

#

My recommendation is don't try to calculate it perfectly

#

Just use an arbitrary amount (like 3%)

quartz crypt
#

why cant it just be total_amount * percent + .35 cents or whatever

#

(100 * .03) + .35

#

would be for 100 dollars

plush torrent
#

Because that is the amount that is then going to be assessed fees

#

So then the fee would be higher than $0.65

#

Because the fee would be calculated based on $100.65

quartz crypt
#

ooooh

#

let me ask chat gpt.

#

he knows

#

lol

plush torrent
#

Good luck

quartz crypt
#

yea he will probably tlel me something wrong.

#

lol

#

thats chatgpt MOP

#

MO

#

thanks for your help bismarck. appreciate it.