Let's say I manage a Domain name site where I sell domain names and their hosting.
Each of my clients will have a cost:
Domain name: example.com
Cost: 100.00 dollars
Duration: 1 year
What I want to do in my program, is to auto generate an invoice when their domain name is about to expire.
I already have the following approach:
Recurring invoice table:
Recurring_Invoices
InvoiceID[ID]
domain_name[VARCHAR]
Price[Double]
Last_Invoice_Date[DATETIME]
Is_Recurring[BYTE]
Next_Invoice_Date[DATETIME]
My approach on my code level is the following:
Every time my program gets launched, I will check if there are invoices to be generated for that month. In pseudo code I will do:
void getRecurringInvoices()
{
//Select the invoices WHERE Is_Recurring = 1
}
foreach (Invoice i in RecurringInvoices)
{
// Get the month of Next_Invoice_Date
if(Month of Next_Invoice_Date == DateTime.Now.Month)
{
//this is an invoice that needs to be generated + Next Invoice Date needs
to be prolonged with 1 year
}
I wanted to ask if this is approach is OK. My only concern with this one is that if my program doesn't get run for 1 month, recurring invoices of that month won't be generated.
That's why I'm still having my doubts off this approach.
What could I do to optimize this process?
Related
in Acumatica, the out of the box GL report" lists gl beginning balance, debits, credit and ending balance by Account / Sub-Account. MY client is requesting that a new sub-total be added at the end of each account that totals for the account, i.e. if there are 3 sub-accounts on a single account, they are requesting the beginning balance, total debits, total credits and ending balance for the ACCOUNT.
I added a new Account group above the account/sub-account group and added variables for the beginning balance, debits and credits and ending balance.
the debit, credit and ending balance variables work perfectly, and SOMETIMES the beginning balance at the Account level is correct, but often the beginning balance variable is multiplied by the number of transactions at the account/sub-account level.
for instance, the beginning balance of account 10000-00-00 for 12-2021 is 9133.07, there are 3 pages of transactions and the beginning balance, debits, credits and ending balance in the Account group footer are correct, BUT for account 12080-00-00 the beginning balance is 1,063,150.46 and what is printing in the group footer for this account is 4,263,486.84 which is the actual beginning balance * 4 and there are 4 transactions in this account.
in the asset and liability section there are about 150 accounts, and this incorrect beginning balance shows up on only 4 accounts for period 11 and 12 of 2021. it does happen a LOT more on income statement accounts, and in other periods.
Because the variable DOES work sometimes but not others I THINK I have created the variable correctly, but I am not finding much support for variables.
Acumatica support was unable to help with this issue and suggested I post on Stack Overflow.
I have attached the logic for the variable itself as well as the variable I “copied”.
with the exception of the =$SignBal*, which if added to the $AcctBegBal always returns a 0 (if THAT is the issue I would expect the beginning balance to ALWAYS be incorrect)
$BegBalance variable logic - works at group footer AccountSubaccount
=$SignBal * Sum(IIF(Prev([GLHistoryByPeriod.BranchID]) <> [GLHistoryByPeriod.BranchID], IsNull(
IIF([HistoryLast.FinPeriodID] = [#StartPeriod],
IIF(#UseMasterCalendar = True, [HistoryLast.TranBegBalance], [HistoryLast.FinBegBalance]),
IIF(#UseMasterCalendar = True, [HistoryLast.TranYtdBalance], [HistoryLast.FinYtdBalance]))
, 0), 0))
$AcctBegBal variable logic (works sporatically at group footer Account )
=Sum(IIF(Prev([GLHistoryByPeriod.BranchID]) <> [GLHistoryByPeriod.BranchID], IsNull(
IIF([HistoryLast.FinPeriodID] = [#StartPeriod],
IIF(#UseMasterCalendar = True, [HistoryLast.TranBegBalance], [HistoryLast.FinBegBalance]),
IIF(#UseMasterCalendar = True, [HistoryLast.TranYtdBalance], [HistoryLast.FinYtdBalance]))
, 0), 0))
Thank you in advance for any help or guidance offered!
Terrie
I need to make a smart contract using Plutus to divide an amount to 2 wallet unequally so I can define custom fees for each transaction. I am using this documentation. What I need is that I would like to split the amount to two unequal amounts and send each to a separate wallet. Assume a user wants to send 7$ to wallet B from his wallet A. The additional fee which I have defined before for each transaction is 2$. using code block below, How can I divide 9$ to 7$ and 2$, then send them to wallets B and C (C is my wallet).
validateSplit :: SplitData -> () -> ScriptContext -> Bool
validateSplit SplitData{recipient1, recipient2, amount} _ ScriptContext{scriptContextTxInfo} =
let half = Ada.divide amount 2 in
Ada.fromValue (valuePaidTo scriptContextTxInfo recipient1) >= half &&
Ada.fromValue (valuePaidTo scriptContextTxInfo recipient2) >= (amount - half)
Well if you know your fee beforehand, why not include it in the parameter list recipient1, recipient2, amount, fee. So then you can subtract it accordingly. Or if it is always 2 Ada and will always be 2 Ada, then simply hardcode it in the contract. How else should the contract know how much is the fee which goes to your wallet (C) and how much should go to the other wallet (B).
I was asked to assist with developing a report to retrieve a 25% sample of random transactions within a specific date range. I am not a programmer but I was able to devise the following fairly quickly:
SELECT TOP 25 PERCENT account.CID, account.ACCT, account.NAME, log.DATE, log.action_txt, log.field_nm, log.from_data, log.to_data, log.tran_id, log.init
FROM account INNER JOIN log ON account.ACCT = log.ACCT
GROUP BY account.CID, account.ACCT, account.NAME, log.DATE, log.action_txt, log.field_nm, log.from_data, log.to_data, log.tran_id, log.init
HAVING (((log.DATE) Between #2/7/2018# And #6/15/2018#) AND ((log.action_txt)="mod" Or (log.action_txt)="del") AND ((log.init)="J1X"
ORDER BY log.tran_dt
This returns 25% of the records within the date range. Each record row is unique but each account number potentially has multiple records on each day. In some cases the records have the same date and tran_id as well.
Upon further discussion with the requester, he actually wants to see all of the transactions for 25% of the accounts that have activity on each day within the date range. Thus if there were 100 accounts on 3/1/2018 with records in this table, he wants to see all of the transactions for 25 of those accounts; if there were 60 accounts on 3/2/2018 with records in this table, he wants to see all of the transactions for 15 of those accounts; and so on.
I was thinking that an Access module would work best in this scenario as I believe there are multiple parts to this. I figured that I need a function to loop through the date range and for each day:
1. Count the account numbers only one time
2. Return all of the transactions for 25% of the total accounts
But as I mentioned, I am not a programmer and I am exhausted from searching possible solutions for the many parts.
I think the key to your question is that you only really need a pseudo random selection of results for your report. So you can force the Random number generator to reorder your results based on a value in the record and the current time.
Something like this should work - I assume your actiontxt field is a text field and pull out the length of each field and apply that to current date/time to create a pseudo random number that can be sorted.
All I really do is change your ORDER BY line
See if this works for you
SELECT TOP 25 PERCENT
account.CID, account.ACCT, account.NAME, log.DATE, log.action_txt, log.field_nm, log.from_data,
log.to_data, log.tran_id, log.init
FROM account
INNER JOIN log ON account.ACCT = log.ACCT
GROUP BY account.CID, account.ACCT, account.NAME, log.DATE, log.action_txt, log.field_nm, log.from_data, log.to_data, log.tran_id, log.init
HAVING (((log.DATE) Between #2/7/2018# And #6/15/2018#) AND ((log.action_txt)="mod" Or (log.action_txt)="del") AND ((log.init)="J1X"
ORDER BY Rnd(CLng(Now()*Len(log.action_txt))-(Now()*Len(log.action_txt)));
Modified similar idea from other StackOverflow question and response
I have a query that gives a product sales report by whatever date range I specify.
Something like select whatever from wherever where date ordered between start date and end date order by product id.
My page then loop through the recordset and displays the results on the page in a list.
What I would like to do is provide a list showing PRODUCT A total sales = whatever, PRODUCT B total sales = whatever so on and so forth. So as the loop runs product a = product a + 1
I do this already with staff sales, but there are only 5 staff so I have managed to do this, but there are over 300 product codes.
What is the best way to proceed.
Possible solutions:
Do this in your application code by keeping track of the product code and running totals. When the product code changes, emit an extra row with the totals into the output.
Do something similar to #1, but use a separate GROUP BY query to get the totals.
Create a SELECT statement that UNIONs together two queries, one for the product detail lines and one with the summary information.
Use some product specific command (you don't say what database you're using) to accomplish #3 without having to do the UNION yourself. Both MySQL and SQL Server offer (different) ROLL UP clauses that can do what you want.
My site is new and as in the below text the "order number" has reached only 57. But without creating any products in real I want the product number to start at some 500. So if a customer buys a product tomorrow, he/she should get "order number" as 500.
I understand we can change the product number in field:order_id table uc_orders by creating a dummy record with order_id of 499 or so. But will it affect anything else?
Order Grand Total: Rs. 20.00 Payment
Method: Bank Transfer To: Reason
for payment: order number 57
Assuming you're using Drupal 6, the Ubercart FAQ on How do I set/reset the starting order number for my store? suggests using of the following:
alter table uc_orders auto_increment = 999;
I've used that technique on a couple of sites without any problems.