I am new to Visual Fox Pro so if anybody could help me I would really appreciate it.
How do the formulas below can be written in fox pro,
Prev_Pay=-pmt(rate%/12,30*12,Loan)
New_Mod=Sum(Loan*90%)
New_Pay=-pmt(2%/12,30*12,New_Mod)
I need to find the value of Prev_Pay, New_Mod and New_Pay fields based on the Loan and Rate.
Check out VFP's Payment() function.
Loan = 20000
rate = .075
Prev_Pay = -PAYMENT(Loan, rate/12, 30*12)
New_mod = (Loan * .90)
New_Pay = -PAYMENT(New_mod, .02/12, 30*12)
? Prev_Pay
? New_mod
? New_Pay
Please see my question regarding the calc of New_mod
Related
https://www.moneysmart.gov.au/tools-and-resources/calculators-and-apps/savings-goals-calculator
I want to get result like above calculator when I select:
I want to save: 6000
I want to spend it: As soon as possible
Starting balance: 0
Interest rate : 10%
Regular savings: 1000 Monthly
But I am getting not correct result using this code:
loan = 6000.0
interest = 10.0
monthly_payment = 1000.0
i =0.0
record = []
count = 1
add_interst = 0.0
while( loan>=0)
i = interest/(100*12)*loan
loan=i+(loan)-(monthly_payment);
add_interst = add_interst + i
end
puts add_interst
I am getting 181.42163384701658 which should be 168. I don't know where I am wrong.
The code doesn't work because you are doing the opposite of what the link you reference is doing. What they are calculating is saving interest, what you are calculating is loan interest.
Basically, this is how you should define the variables.Also, as others have pointed out, it is good to use BigDecimal to calculate money:
require 'bigdecimal'
balance = 0.to_d
interest = 10.to_d/1200.to_d
regular_saving = 1000;
goal =6000;
i = 0;
added_interest = 0
So, to correct things, you have to start from the starting balance (i.e 0) and start incrementing. Something like this:
while balance < goal
balance += regular_saving;
i = balance * (interest);
balance +=i;
added_interest+=i;
end
Note also, that in the last year you don't need to pay the full saving amount. You only need to pay to reach the goal. For that, you need to add a conditional statement to check goal - balance < regular_saving. If this was the case, the interest should be calculated in terms of the balance that should be paid (slightly less than the goal).
This post should be a little more complex than usual.
We have created a new field for an account.invoice.line : pack_operation. With this field, we can print serial/lot number for each line on the PDF invoice (this part works well).
Many hours passed trying to write the domain to select the EXACT and ONLY stock pack operation for each invoice line.
In the code below, we used the domain [('id','=', 31)] to make our tests printing the PDF.
Ho to write this domain to be sure at 100 % that we will get the right stock pack operation for each invoice line?
I really need your help here... Too complex for my brain.
Our code :
class AccountInvoiceLine(models.Model):
_inherit = "account.invoice.line"
pack_operation = fields.Many2one(comodel_name='stock.pack.operation', compute='compute_stock_pack_operation_id')
def compute_stock_pack_operation_id(self):
stock_operation_obj = self.env['stock.pack.operation']
stock_operation = stock_operation_obj.search( [('id','=', 31)] )
self.pack_operation = stock_operation[0]
EDIT#1
I know that you won't like my code. But, this one seems to work. I take any comments and improvements with pleasure.
class AccountInvoiceLine(models.Model):
_inherit = "account.invoice.line"
pack_operation = fields.Many2one(comodel_name='stock.pack.operation', compute='compute_stock_pack_operation_id')#api.one
def compute_stock_pack_operation_id(self):
procurement_order_obj = self.env['procurement.order']
stock_operation_obj = self.env['stock.pack.operation']
all_picking_ids_for_this_invoice_line = []
for saleorderline in self.sale_line_ids:
for procurement in saleorderline.procurement_ids:
for stockmove in procurement.move_ids:
if stockmove.picking_id.id not in all_picking_ids_for_this_invoice_line
all_picking_ids_for_this_invoice_line.append(stockmove.picking_id.id)
all_picking_ids_for_this_invoice_line))
stock_operation = stock_operation_obj.search(
[ '&',
('picking_id','in',all_picking_ids_for_this_invoice_line),
('product_id','=',self.product_id.id)
]
)
self.pack_operation = stock_operation[0]
The pack_operation field is a computed field, that be default means that the field will not be saved on the database unless you set store=True when you define your field.
So, what you can do here is change:
pack_operation = fields.Many2one(comodel_name='stock.pack.operation', compute='compute_stock_pack_operation_id')
to:
pack_operation = fields.Many2one(comodel_name='stock.pack.operation', compute='compute_stock_pack_operation_id', store=True)
And try running your query again.
Is it possible to get a EUR/USD currency pair from the YQL yahoo.finance.historicaldata? I managed to get the "EUR=x" (results in USD/EUR) but how can i get a EUR/USD price to avoid calculating every price/inverting it?
This works fine: select * from yahoo.finance.historicaldata where symbol = "EUR=x" and startDate = "2016-08-01" and endDate = "2016-08-04"
But not: select * from yahoo.finance.historicaldata where symbol = "EURUSD=x" and startDate = "2016-08-01" and endDate = "2016-08-04"
I found these two great list with all yahoo stock tickers:
http://investexcel.net/all-yahoo-finance-stock-tickers/
But it looks like the webservices do not offer the inverted price (EUR/USD) only the EUR=X (USD/EUR) ? Is this the case?
http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote
Many Thanks
Micke
hasAccount(Person,Bank,Amount) – the Person has an account at the Bank with the balance Amount,
lives(Person,City) – the Person lives in the City,
created(Person,Bank,Month,Year) – the Person opened an account at the Bank in Month of the Year.
With the predicates above, I want to try few things, say printing a list of names with accounts they have, I tried the following query.
?- hasAccount(Someone, Bank1, Balance1), hasAccount(Someone, Bank2, Balance2), not Bank1 = Bank2.
Someone = ann
Bank1 = metro_credit_union
Balance1 = 1000
Bank2 = toronto_dominion
Balance2 = 12000
Yes (0.00s cpu, solution 1, maybe more)
Someone = ann
Bank1 = toronto_dominion
Balance1 = 12000
Bank2 = metro_credit_union
Balance2 = 1000
Can you please explain why do I have reversed list again and what I can do to prevent this happening? Thank you!
why I have reversed list again
it happens since you're not stating in your query enough info to break symmetry.
You can use instead
?- hasAccount(Someone, Bank1, Balance1), hasAccount(Someone, Bank2, Balance2), Bank1 #< Bank2.
or some builtin, like findall/3 (or bagof/3)
Based on this url i found Bayesian Rating, which explains the rating model very well, i wanted to summarize the formula to make it much easier for anyone implementing an SQL statement. Would this be correct if i summarized the formula like this?
avg_num_votes = Sum(votes)/Count(votes) * Count(votes)
avg_rating = sum(votes)/count(votes)
this_num_votes = count(votes)
this_rating = Positive_votes - Negative_votes
Gath
It would look more like this:
avg_num_votes = Count(votes)/Count(items with at least 1 vote)
avg_rating = Sum(votes)/Count(items with at least 1 vote)
this_num_votes = Count(votes for this item)
this_rating = Sum(votes for this item)/Count(votes for this item)
If you are using a simple +/- system, Sum(votes) = Count(positive votes) (ie. treat + as 1, - as 0)
See also: Bayesian average.
Should the avg_rating not be:
Sum(votes)/Count(votes)
Yves