What is the structure of Field No. 54 (P54) in the the ISO 8583 Standard - iso8583

What is the structure of Field (P54) in the ISO 8583 Standard?
This field is about of the balance Amount that sent by the switch.

The values of the types of accounts and amount types and the conditions in which they are allowed vary by each instance and variation of ISO-8583 but the standard format is the following:
The data element breakdown, occurring up to six times for a total length up to a total length of 120.
Position Data 1-2
Account Type (n 2) 3-4 (Must match DE003 format)
Amount Type (An 2) 5-7 (See Table Below for a sample of SOME of the values)
Currency Code (n 3) 8-20 (ISO-3166-1 Numeric, just like DE049-DE051)
Amount (x + n 12)
The amount must not be greater than 999999999.
"X" must be 0, C, or D. C or 0 = Credit amount and D = Debit Amount
Some of Amount Types others really vary by specification and though these are all numeric the Healthcare transactions are AlphaNumeric values in the VISA specification for example. Note that most of these are actually not commonly used in PIN or Debit transactions except 01, 02, 40-43, 57, 58, and 91.
ISO Code Description
00 Unknown
01 Account ledger balance
02 Account available balance
03 Amount owing
04 Amount due
05 Available Credit Line
06-10 Reserved for ISO use
11-15 Reserved for national use
16 Credit line
17 POS balance
18-19 Reserved for private use
20 Amount remaining this cycle
21-30 Reserved for ISO use
31-35 Reserved for national use
36-39 Reserved for private use
40 Amount Cash / Cash Back / Negotiable Item including Scrip
41 Amount goods and services
42 Amount Check (Deposit Only)
43 Amount Cash (Deposit Only)
42-50 Reserved for ISO use
51-55 Reserved for national use
56 Hold amount
57 Pre-Authorized Amount.
58 Authorized amount. (Used for Response Code DE039 = 10 Authorized for
a Different Amount)
59 Floor Limit
60-79 Reserved for ISO use
80-89 Reserved for national use
91 Originally Requested Amount transaction in the currency amount of DE049.
92-93 Reserved for private use
Let me know if you need more explanation.
Christopher

Related

Formatting Number Field to Currency Using TO_CHAR returning hash characters

I am running a simple sum and conversion to currency on a NUMBER field in an Oracle database.
My query is:
select
TO_CHAR(eve.data_entry_date, 'yyyy-mm'), wtc.description as WORK_TYPE,
TO_CHAR(sum(sev.amount),'$999,999.99') AS "Total Invoice Amount"
from
EVENT eve,
SOW_EVENT sev,
WORK_TYPE_CODE wtc,
SOW_WORK_TYPE_XREF swt,
WORK_TYPE_ITEM_CODE wti
where
eve.event_number_id = sev.event_number_id
and sev.WORK_TYPE_CODE = WORK_TYPE_CODE
and sev.event_number_id = swt.event_number_id
group by
TO_CHAR(eve.data_entry_date, 'yyyy-mm'), wtc.description
The query runs successfully, however the amounts showing up in the "Total Invoice Amount" column are returning hashes like:
Year-Month WORK_TYPE Total Invoice AMount
2019-01 Physical Work ############
2019-01 Technical Work ############
I had thought I just needed to resize the column, but that didn't work. When I just run:
sum(sev.amount)
it populates the amounts, just not formatted as currency as the 'amount' column is a number column. Any idea why I am getting the hashes when I format to currency?
From the documentation:
All number format models cause the number to be rounded to the specified number of significant digits. If a value has more significant digits to the left of the decimal place than are specified in the format, then pound signs (#) replace the value. This event typically occurs when you are using TO_CHAR with a restrictive number format string, causing a rounding operation.
Your format mask needs enough digit placeholders for the highest value you expect to see. At the moment the values seem to be above a million.

Accessing data from multiple rows

So I am having some troubles writing a sql query. It is a financial stock problem and we have two table, one named A and one named B. The dates are divided into periods, so we want to calculate the investment value for the next period based on some criteria of the current period.
For instance, to calculate the investment value of period 2, we first need to compare the price of stock of the first date of period 1 from table A with the strike price of the same date from table B, and then take the max price and divide it by the investment of first date which is given as 10,000. After that, you just simply do 10000/max(price,strike), and then multiply the value by 10000. I know how to get the max which can be done by either using CASE or max, but the difficulty I am facing is that how can I actually get the investment value of the previous period. The example above is an exception because we know the value of the first day. However, if you want to calculate the investment value for period 3, you will first need the value of period 2, and this is where I am stuck at.
EDIT
Table A
Date Price
1/16/15 206
2/20/15 208
3/20/15 205
Table B
Date Strike
1/16/15 195
2/20/15 201
3/20/15 206
For example, the number of shares on 2/20/2015 is 10000(206) = 48.54
And the investment value is 48.54 * 208 = 10096.
206 is the max of 206 and 195, and 208 is the max of 208 and 201.
Thanks in advance!

FIFO Capital Gains Calculations in Python

I'm trying to calculate capital gains on some earnings in python but having a bit of trouble figuring out the right data structures to use and the best approach for doing what I want to do because I need to account for long-term and short-term tax rate differences.
Below is a typical representation of the data:
Unfortunately, I don't think I can simply add and subtract dollar-cost averages because buying at 50 # $50 on Jan 1, 2017 50 # $50 on Feb 1, 2017 and selling 100 # $100 on Jan 15, 2018 results in long term cap gains (15%) for the first 50 units and short term cap gains (25%) on the second 50 units.
So it seems like with every sale, I still need to keep track of all prior sales # particular sale dates, but I also have to amend the first X records to reflect that these purchases have been partially/fully depleted.
I don't know how to do this or what data structure works best for this?

How to Convert a negative value received through a parameter to positive in the stored procedure code?

I have some concerns, I'm creating a stored procedure to work with a cafeteria system. The user on the cafeteria will send me through parameter an employee code and the amount consumed. So I far I have calculated this:
IF #Amount< #Subsidy (Subsidy being 20 Dollars per day)
BEGIN
UPDATE CreditSub
SET Subsidy = Subsidy - #Amount, Fecha = #CurrDate
WHERE Code = #Code;
END
IF #Amount > #Subsidy (Being credit 100)
BEGIN
UPDATE CreditSub
SET #AmountDif= #Amount - Subsidy, Subsidy= 0, Credit = Credit - #AmountDif, Date = #CurrDate
WHERE Code = #Code;
END
What I'm basically doing is a calculation that if the user insert less than 20 dollars it will run the first batch if is greater it's going to run the second deducting the 20 dollars of the subsidy plus deducting the rest of the credit (being 100 Dollars).
Now, if the user cancels the order, the value returned to me will be a negative value like "If the employee orders 70 dollars of food, then the order must be cancelled, the system will return -70 which I need to take and summarize part of it to the subsidy and part of it to the credit if the subsidy was not spent on that day. How do I split the values or rollback the last transaction converting the negative to positive?. Please ask me any questions, I need help here with this.
Thanks a billion!
Break out CreditSub into two tables by #Code. The Credit table will track the credit amount throughout the day--positive or negative won't matter. The Subsidy table would be populated once per day (or as needed) with the subsidy amount. Then at the end of the day, you can do the math when you populate your other table. If you need to know what the current subsidy amount is, just join the two tables and perform the necessary calculation to get the amount.

identifying trends and classifying using sql

i have a table xyz, with three columns rcvr_id,mth_id and tpv. rcvr_id is an id given to a customer, mth_id is a column which stores the month number( mth_id is calculated as (2012-1900) * 12 + 1,2,3.. ( depending on the month). So for example Dec 2011 will have month_id of 1344, Jan 2012 1345 etc. Tpv is a variable which shows the customers transaction amount.
Example table
rcvr_id mth_id tpv
1 1344 23
2 1344 27
3 1344 54
1 1345 98
3 1345 102
.
.
.
so on
P.S if a customer does not have a transaction in a given month, his row for that month wont exist.
Now, the question. Based on transactions for the months 1327 to 1350, i need to classify a customer as steady or sporadic.
Here is a description.
The above image is for 1 customer. i have millions of customers.
How do i go about it? I have no clue how to identify trends in sql .. or rather how to do it the best way possible.
ALSO i am working on teradata.
Ok i have found out how to get standard deviation. Now the important question is : How do i set a standard deviation limit on my own? i just cant randomly say "if standard dev is above 40% he is sporadic else steady". I thought of calculating average of standard deviation for all customers and if it is above that then he is sporadic else steady. But i feel there could be a better logic
I would suggest the STDDEV_POP function - a higher value indicates a greater variation in values.
select
rcvr_id, STDDEV_POP(tpv)
from yourtable
group by rcvr_id
STDDEV_POP is the function for Standard Deviation
If this doesn't differentiate enough, you may need to look at regression functions and variance.