Adding multiple Entries under Order Entry Sales Order Transactions - api

I came to a issue where I want to add multiple entries under a sales order transaction using the Sage Intacct developer API. Is it possible to modify your API to insert multiple entries under Sales order transaction on Sage Intacct?

Related

pentaho - sharing out from one transformation to another

I have 2 files. One with stock purchase data and another with stock sales data. purchase file has stockid, count, purchaseamount. Sales data stockid, date, noofstockssold and stocksoldamount. I am able to process the purchase details and found the avg price of stocks purchased. I want to use this avg price with the stocksales data to arrive at profit/loss. I am not able to find a way to pass the avg price. Can someone help ?
You'll need to use a Merge Join step to join the information of both files in one unique stream of data. It seems that the stockid would be the natural column to use to identify how to merge both files.
To use the Merge Join you previously need to sort the stream of data of both files by stockid, so previous to the Merge Join you need two Sort rows steps, one for each file.

Can i Create one table for purchases orders and sales orders?

I'm creating a Motorcycle store system, i wondering if i need to create one table that contains orders, the sales orders and the purchases orders with a column that will be called OrderType that determine if its purchase order or sale order
the same with Payments, money that i pay to supplier and money that customer pay to me, should be in table that called payment and column that determine if its outgoing payment or income
is that ok? or i need to create other tables
I would consider against it... Purchases are from a vendor YOU get the products from to build/fix/manufacture something.
Sales orders would have a customer you are selling to and thus would be foreign keys to different tables... unless your customer table has your vendors too and that has some column to identify difference as Vendor vs Customer.
Additionally, as you expand your design development and queries, purchasing history, etc., it may be more beneficial to have them separate.
You can create a single table. Whether this is good design or unfortunate design depends on how you use the data. How many times do you ever want to query these two datasets as if they were one dataset? How many times to you query them separately?

SQL Server constraints about Relations between tables

I have been working on a SQL Server project that allows the users of a shopping website to insert their reviews for the product they bought.
Basically, I have 4 tables:
Customer: (Customer_ID, Username, Telephone_number, Grade)
Product: (Product_ID, Product_code, Name)
Review: (Review ID, Title, Content, Product_ID, Customer_ID)
Bill: (Bill_ID, Date, Product_ID, Customer_ID)
I've got two problems:
Firstly, I don't know how to force that only people who bought a product can review it.
Secondly, I don't know how to increase the grade in Customer table by a certain number of points (bonus points) after they review of a product.
Can anyone tell me how to solve these problems, especially in SQL Server code?
Several ways that you can do to protect your Review table from inserting such these records and it is best to handle these in your server-side or client-side code but as a design point of your DB, I think the best is to:
Design your Review table like:
(Review_ID, Title, Content, Bill_ID)
and set you Bill_Id column to not allow NULL, so that every review record must relate to a bill (shopping) record then you can handle error in your code which warns the users or...
Also if your grade is only about reviewing, you can set bonus (grade) a ratio of reviews so the grade would be like:
SELECT 5*COUNT(*) -- for example two reviews = 10 bonus
FROM Review
GROUP BY Customer_ID
And one more time I suggest you to handle all these in your code not in your DB.
Another suggestion is (If the logic and business of your application is based on database - which a shopping website is not!!) - is to create a stored procedure for INSERT operation like usp_ReviewInsert and call it in your code as a user wants to post a review, then your stored procedure handles all validating stuff (like relation between Bill and Review) and all updating stuff (like updating grade to a higher) and the insert operation in itself.

Oracle SQL Transaction with INSERT

I am writing a database of warehouse of groceries. I have tables clients, workers, orders, products and some which are not really important in that question.
I want to avoid a problem where client makes a new order for product but there isn't enough amount of this product in our warehouse.
I have to make a transaction which avoid situation when two clients are making a new order at the same time and one of them ordered for example the last item while making order by the second client.
I don't really know how to do it because only workers can decrease amount of every product. So I want so that while deleting a order (which was made by client) by worker the amount of available product was decreased.
I know that I can put it into trigger but the question is:
how to define the transaction of ordering product with checking available amount. Should I count the difference between avalaible
amount in table Products and amount of ordered product by the
time(unrealized orders).
How to do it ?
for orders, you have to manage Stock of that product and every time when someone going to make an order you have to check product availability or not.
One thing you could do is place a trigger on the orders table, that subtracts quantity from the products table and raises an exception if the amount is negative. The trigger would have like:
update products set current_quantity = current_quantity - :new.amount_purchased
where id = :new.product_id
returning current_quantity into l_current_quantity;
if l_current_quantity < 0 then
raise_application_error( -20001, 'Amount ordered larger than remaining quantity.' );
end if;
You'll have to handle the exception in your ordering procedure.

Generating PostgreSQL test data with relationships?

I want to generate 4 tables:
customers
subscriptions (references customersid and plans.id)
plans
invoices (each invoice references a subscription and a customer)
How can I write an INSERT query where I can insert an invoice, and randomly generate the subscription_id by pulling in all id's from subs and selecting one, then pull in the appropriate customer_id of that subscription for that invoice row?
You can search and find Northwind sample data for PostgreSQL on the internet. Northwind model have tables that matches your model. In northwind sample you can rename and use:
Customers,
Employees (Plans),
Orders (Subscriptions),
OrderDetails (Invoices)
Invoices should only reference to Subscriptions (and it already references to Customers).