Saturday, October 27, 2018

Import Trade Finance

Import Trade finance is, in the point of view of Importers, how importers get varieties of financings from banks.

2 ways to issue the L/C from the bank


One is Issuing L/C with full margin (Importer gives issuing bank 100% of L/C value to get L/C). For this, the bank has low risk but importers will have some problems of shortage of money.

One is Issuing L/C with credit facility, banks also have a low risk but importers won't have any problems of shortage of money.

Thus, Firms normally choose the second option.

However, Because issuing L/C for banks is a high-risk service. so banks normally categorize different companies, for some with high solvency, they will get a low margin high credit line, vice verse.

4 kinds of "Issuing L/C with credit facility"

1. One is Issuing L/C with goods controllable. For L/C at sight,  Either submit a full goods documents to issuing bank or appoint the issuing bank as consignee. For Usance L/C, as goods have been received so the bank has the full control. As goods are controlled, so importers have a low possibility to default.

  • L/C at sight: Beneficiary can get the money immediately from this L/C from issuing bank (within 5 days). 
  • Usance L/C: = Deferred payment, Beneficiary only can get the money in a future appointed date from this L/C from issuing bank (eg: 30, 60, 90 days) after submitting the application. 

2. One is Issuing L/C without goods controllable. Opposite of the 1st, Issuing bank has a high risk.

3. One is Issuing Back-To-Back L/C.  In 3 parties trade: Exporter->middleman->Importer


Original L/ C: Middleman (Beneficiary)----------Importer (Grantor)
Back-to-Back L/C: Exporter(Beneficiary)-----------Middleman(Grantor)

Back-to-Back L/C must be applied with original L/C and normally is Usance, Original L/C is normally at sight. As money is confirmed in the original L/C, so the bank has a low risk in issuing back-to-back L/C.

4. One is Issuing Usance L/C payable at sight. Beneficiary hope to get the money immediately(at sight), but exporter wants to defer the payment to a future date(Usance). So neither L/C at sight nor Usance L/C can satisfy this. Thus, Usance L/C payable at sight will let the issuing bank help to pay the beneficiary first and from that date of payment, the interest starts to accumulate until the Usance date. In the end, All the interest+princiapl will be deducted from  Exporter's account.


Thursday, October 4, 2018

Export Trade Finance : Factoring


Factors (Banks) buy in those account receivables (invoices) from exporting firms and then do sales control, bad debt guarantee, trade finance etc. This comprehensive post-sale service is called Factoring. Exporters can request the bank to provide full services or partial services.

Banks normally must join (Factors Chain International: FCI) to be qualified as a factor. FCI members themselves will do a paperless transaction via EDIFactoring (a digital system).

The content of Factoring service


  • Maintenance of the sales ledger
Each invoice, each transaction between exports and importers will be properly managed by banks' powerful accounting system. so exporter can anytime download and check online those properly managed accounts. No need to worry about that financial management stuff. This reduces a certain cost of exporters.
  • Collection from debtors
Collecting money from the buyers is a somewhat hard job for most companies. Bank has a powerful debt collecting technic to deal with those importers/importers' banks. This can help exporters a lot.
  • Credit control
Banks will use its own network to know the counterparty's credit risk. This can evaluate the debtors' credit on the fly anytime, which reduce the risk for exporters.
  • Full Protection from Bad debt 
  • Trade finance 

Exporters finishing the goods delivery or other services normally can submit the invoice(account receivables) to factors to get > 90% finance of invoice amount.

Varieties of Factoring service


  • Recoursed Factoring  vs Non-recourse factoring
  • Maturity Factoring vs Financed Factoring

In Maturity factoring,  banks will make a specific date in future to pay the exporters in a shot. That date is called maturity date. In Financed Factoring, once the bank receives the money, it will transfer the <= 90% amount received into exporter's account. the leftover 10% will be paid in the end.
  • Disclosed Factoring vs Undisclosed Factoring

In Disclosed Factoring, Suppliers/Exporters must inform all his clients in the paper to let them pay directly to the factor. In the undisclosed factoring, factor's involvement is a secret for the clients, they still pay the money to the exporter, the cost incurred will on the exporter side.

Why exporters/suppliers choose Factoring?


  • Increase exporter's sales, As exporter choose factoring service, he can provide more flexible payment methods like (Open Account), (Document against Acceptance) which makes the sales easier. 
  • Reduce risk, factor helps exporter do all the background research, debt chasing, account management and other services like a babysitter. 
  • Reduce cost
  • Convenience. Avoid the inconvenience of normal L/C proceduces.

Why Buyers/Importers like Factoring as well?


  • Reduce importing cost. No L/C needed. so don't need to submit those documents and pay some fees
  • Goods quality is guaranteed. Factor has the control.

Procedures of Factoring service

1) Exporter signs export contract with an importer and agree on the payment type as D/A or O/A under Factoring. Then exporters go to Export factors to apply and also need to request to verify the credit line in the factor side.

2)  Export Factor(Exporter's Bank) submits all the relevant information to the Import Factor(Importer's Bank) and request to check & rectify the Factoring amount.

3) Import Factor does some background research and evaluation to the importer and decides whether to give this Factoring amount. (< 2 weeks)

4) Import Factor after initial verification will inform export factor the credit line and factoring amount of importer.

5)Export Factor will inform the exporter the verified factoring amount in written form and seek for agreement from the exporter. once exporter agrees on this amount, exporter factor will sign the factoring agreement with exporter formally.

6) Exporters ship the goods accordingly and transfer the creditor's right to the export factor signing <The Agreement on Transfer of Creditor’s Rights > with the factor, and send <Intrudoctory letter> to he Importer telling him that the creditor's right has been shifted to the factor and please pay as the factors' indication.

7) Export Factor will submit all the invoices/documents provided by the exporter to Import Factor, and at this stage, the exporter can ask for financing(<= 90% of invoice amount) from export factor.

8) Import factor will transfer the invoices/documents to the importer.

9) The importer will pay to import factor.

10) Import factor deducting some factoring fee will transfer the remainings to export factor.

11) Export factor deducting some factoring fees and financing amount requested from exporter before will transfer the remainings to exporter's account.



Factoring fee = Factoring rate * Factoring amount, Rate is (0.5% ~ 2%).
Trade financing interest calculation is similar to the rest, no need to discuss anymore.




Wednesday, September 19, 2018

Export Trade Finance - L/C Confimaton

Confirmed L/C / L/C Confirmation is that another bank (not issuing bank) independently take the responsibility of payment for the exporter/beneficiary.

L/C Confirmation is also a financing service provided by the bank for the exporters. However, L/C Confirmation is not like other financing services (eg. discount or negotiation) transferring the money physically into the exporter's account but a promise of payment in future. Thus, in the exporter's view, It's really hard to understand why it belongs to a financing service. However, From the bank's view, Confirmation has a financing functionality. Bank has to prepare the money to give exporters. So this money is a kind of account payable / paid.


Characters of L/C Confirmation


  • The beneficiary can avoid all risk from issuing bank/issuing bank country.
  • The beneficiary has a double guarantee now from 2 banks.
  • Exporters normally will add confirmation after receiving the L/C from the foreign issuing bank. 
  • No limit to the money used. 
  • Financing period is short ( < 180 days)
  • Only local negotiation bank or bank related to the L/C can do the confirmation service otherwise it's hard for other banks to tell the veracity of documents.
  • Confirming bank has no recourse to the beneficiary. 

Type of Confirmation


There're 2 types of confirmation service provided by the bank.

1. Open Confirmation: Issuing bank invites a bank in the exporter's country openly to add a confirmation to the L/C it provides to be the first responsible to pay. Normally, In the L/C, It will indicate in words "Please Add Confirmation".

2. Silent Confirmation: No invite from issuing bank, the local bank directly add confirmation to the L/C as the exporter's request. In this case, the local bank takes a higher risk from issuing bank/ issuing bank country. Under Export L/ C, Silent confirmation can also be categorized into 2 types based on the risk level (Absolute/Relative). And 2 types based on whether to give financing to the beneficiary (Funded/Unfunded).

  • Absolute Silent Confirmation: The local bank will buy in issuing bank's country risk and documentary risk. So the confirming bank will bear all risk once receiving the documents from the beneficiary including rejection to pay from issuing bank.
  • Relative Silent Confirmation: The local bank will buy in issuing bank's country risk but not the documentary risk. So the confirming bank will take all the risks, not including the rejection to pay from issuing bank due to the discrepancy of documents provided.

  • UnFunded Silent Confirmation: Confirming bank will pay, but only pay on the exact date that it promises to pay to the exporter. never pay in advance. 
  • Funded Silent Confirmation: As beneficiary's request, Confirming bank will pay once the beneficiary submits related documents.
In the real world, the silent confirmation is more commonly accepted by exporters. So here I will take silent confirmation as an example to explain further. 

Business Flows


  1. The exporter received the L/C from the foreign bank and submit an application (application form) to the local bank to do the silent confirmation.  
  2. The local bank accepts the application and signs a contract with the exporter if documents match. if documents mismatch, the bank will terminate the contract and sign termination contract. 
  3. The foreign bank (issuing bank) transfers money to the local bank along the time. 
  4. The local bank once receiving the money will auto-deduct the interests and fees and transfer the remainings into exporter's firm account. 

Difference between confirmation and forfeiting 


Similarity :

  1. No recourse for both 
  2. No limitation for Financing purpose of beneficiaries
  3. No credit line occupied for both 
  4. Both mostly depends on L/C


Difference:

  1. Financing time is different. Silent confirmation's financing time is after exporter's submitting docs. Forfeiting's financing time is after getting the promise of payment from the foreign bank.
  2. Financing time range is different. confirmation is < 1 year. forfeiting can reach up to 10 years. 
  3. Money arrival time is different. forfeiting will get the money immediately. confirmation mostly will wait for half a month. 
  4. Interest and fee are different. Silent confirmation's fee and interest <forfeiting's. 
  5. Whether can be selldown is different. Silent confirmation normally can't be selldown. forfeiting can be involved in risk participation and selldown the risk. 
  6. Whether can be Tax refund is different. Silent confirmation has no tax refund. forfeiting has.


Friday, August 31, 2018

Export Trade Finance - Forfaiting

Forfaiting is the service that Forfaiter(exporter's local bank) totally buy the confirmed documents (L/C has been confirmed/promised to be paid by issuing bank/confirming bank) from exporters' hand. Forfeiting has no recourse anymore.

In other words, Forfaiting is providing financing to exporters after receiving the confirmation that the exporter's L/C is promised to be paid by issuing bank without recourse. which means if the issuing bank refuses to pay, then the local bank(forfaiter) can't get the money from exporters.

Why companies choose Forfaiting? 


  1. Exporters can have short-term financing without recourse. 
  2. Exporters don't need to be worried about any risk in their business and risk shifted to the bank. 
  3. Exporters can have immediate export rebates once Forfaiting service is done. 

Characters of Forfaiting


  1. Financing after confirmation from issuing bank.
  2. Forfeiting is expensive for exporters compared with discounting/negotiation
  3. No limitation to the money financed for exporters.
  4. The time range is different, normally <= 360 days, but some long-term trade can span across to 10 years.
  5. A limitation to the bank performing the Forfaiting service. Normally the local negotiation bank has the ability to do Forfaiting service otherwise, it's hard for the bank to tell the veracity of the trading background or some documents. On other hands, if a bank only performing the Forfaiting service rather than negotiation service, then they can't maximize the profit.

Flows



  1. Exporters apply for negotiation service/others in the local bank once they received L/C. 
  2. The foreign bank(Issuing bank) gives a confirmation/promise to local banks saying they'll pay.
  3. The local bank tells the exporter about (2). 
  4. Exporter applies for Forfaiting service. 
  5. The local bank accepts the application and signs the contract, then gives the money/finance to the exporter after deducting correspond expense + interest.
  6. The foreign bank pays the money stipulated on L/C to the local bank(forfaiter) as time goes. 
  7. The local bank receives the money and auto-deduct the financing cost from the exporter and closes the Forfaiting deal. 

Different Forfaitings


  • Direct buyout. The local bank buyout all the account receivables under the L/C provided by the exporter. Then all the profit is gained without sharing any proportion with other banks. In this case, it means the foreign bank has a good reputation where The country it's in and the economy the country has is stable. So local bank chooses to buy all. 
  • Indirect buyout(Risk participation). Bank A is doing Forfaiting with the exporter and have account receivables. Then Bank A sells this Forfaiting/account receivables to Bank B in a secondary market under his own concern(maybe afterward he thinks it has a risk). So Bank B is under an indirect buyout or it's normally called risk participation. Risk participation normally has 2 kinds: Funded and Unfunded
Funded Risk Participation

Bank B buy the Forfaiting/account receivables and pay the money immediately to bank A. From that time on, It's none of the business of Bank A anymore. All the risk or benefit shift to Bank B. 

Unfunded Risk Participation

Bank B buy the Forfaiting/account receivables and not pay the money to bank A. But compensate bank A  once foreign Bank refusing to pay or under bankruptcy.

Example: Bank A is primary forfeiter giving Exporter C forfeiting USD 18800.00.  Afterward, Bank A thinks this business has a big risk and negotiate with Bank B (secondary forfeiter) to do Unfunded Risk Participation to sell receivables. Bank B has a good relationship with the foreign issuing bank and thinks it's under control. So he agrees.  Bank B doesn't need to pay. Bank A gives money to Exporter C as normal. If in future, Foreign issuing bank refuses to pay / under bankruptcy, It's none of the business of Bank A/Exporter C. As Bank A does advanced payment to C. So Bank A has the recourse to Bank B but not to Exporter C.


Normally, For the secondary forfeiter under the funded risk participation, because he must pay the money in advance, so he will normally gain a good profit (The usual quote is: Libor + some margins), but under the unfunded, he doesn't need to do advanced payment, so has low profit.

Because Forfaiting is a financing service, So you can regard it as a loan. the quote is the interest rate you gotta pay the loan. which is also the profit the bank earns.


Difference between Forfaiting and Discount


  1. Time Range different. Forfaiting < 10 years, Discount < = 1 Year.
  2. Forfaiting has no recourse, Discount has. 
  3. The financial report is different. Discount is liability under the company balance sheet. Forfaiting is an account receivable. 
  4. Forfaiting can help the company get tax rebates in advance, but discount can't.
  5. Forifating has a higher expense and interest rate compared with discount. 


Wednesday, August 29, 2018

Export Trade Finance - Discount

Discount is that banks buy some forward documents that are promised to be paid. In this case, banks have the Recourse. Forward documents mostly mean the bank documents or documents that other banks guarantee to pay with their own credit. L/C is one of the forward documents. So Bank buys your L/C and gives you money.

In practice, as the technology develops, forgery is advanced. So this service for banks has a high risk. Thus Documentary L/C seldom can get a discount.

For discount under L/C, the bank in exporter side receives the notice from issuing bank/confirming bank. This Notice is normally called Bank Acceptance, Which is a document with issuing bank's stamp saying I will definitely pay the money in a near future. But Exporters can't wait as they are short of money. So the exporter's local bank will give a finance to the exporter upon receiving the notice. This financing method is called the discount. The local bank giving this finance is called discounting bank. 

Moreover, Normally exporters take the L/C / export documents as the mortgage to the local bank to get the discount. export documents including the delivery order of goodsSo the local bank can regard it as a future asset. in case they can't get the money, they can also sell goods/mortgage goods.

Discount is a financing method/loan. so exporter's must pay the interest as well which is the same as negotiation/packing loans we discussed before.


The similarity between discount and negotiation

  1. Both are short-term financing service 
  2. Both have recourse to the appliers.
  3. Both have similarities in financing amount, interest calculation,  and currencies. 
  4. Both have no limitation for the purpose of money usage. 

The difference between discount and negotiation


  1. Discount is under some forward documents under L/C. So money can't be received in short run. Negotiation is applicable for both short /long term L/C. 
  2. Financing time is different. Discount is financing upon confirmation from foreign banks. Negotiation is financing upon local exporters submitting some documents. so financing under negotiation should be faster and earlier than the discounting. 
  3. The risk is different. Discount has the confirmation from foreign banks(issuing/confirming banks). so the risk is under the country/political/war risk, as long as the issuing bank not bankrupted/with a bad reputation, discounting bank doesn't need to worry so much. Negotiation is financing upon the beneficiary submitting documents, so some extra risks are involved like careless risk from the clerk, payment rejection from issuing bank etc. 

Thursday, August 23, 2018

Export Trade Fiance - Negotiation under Documentary credit

Negotiation under Documentary credit is, under the export L/C, the beneficiary (Exporter) use some export documents as a mortgage to the local bank to do the financing before they receive the money from their buyers(importers).

Things to be noted:

  1. The exporter must get the L/C first then apply for this financing before they receive the money from buyers
  2. The mortgage must be the export documents.  Normally those export documents  the L/C issued from issuing bank, so it has the value.  Thus, the local bank in exporter side can still sell or do some secondary mortgage in the secondary market to distribute the risk.
Why exporters use this service?


The exporter can do some short-term financing to accelerate the capital turnover and increase the exportation scale as well.  It only takes the documents as mortgage, so it is comparatively easier to get the money for exporters under L/C.

In other aspects, under the circumstances of local currency appreciation, the negotiation can turn the foreign currency into local currency earlier, so it is also a way to avoid the FX risk.

For example, Chinese Firm A choose L/C as the settlement method,  exports to Turkey some fibers valued USD 1000000.00. on 20/07/2005, and submit the L/C to a local bank. Under this L/C, the payment criteria are after 180 days of the submission of L/C. On that day, the FX is USD100 = CNY826.46, and firm can enjoy the USD interest rate 5.5% pa.  When RMB appreciates, Firm A has 2 choices :


  1. Finance manager may think, even though the negotiation can turn the future-received USD into CNY to use now and avoid the FX risk. However, The company must pay the interest to the local bank (Interest cost). At that time, the USD/CNY 6-month forward FX settlement is discount. (6-month later's settlement price < current settlement price) . So compared with the current settlement price, the company has some loss. The finance manager decides not to use this service and collect the money when L/C matures. On 25/01/2006, Firm A received the money from the foreign bank. Due to an appreciation of RMB of 2 % on 21/07/2005. the exchange rate on 25/01/2006 is USD100=CNY800.06. And after deduction USD 1350 service charge from the bank, The money received in the end is (USD1000000.00 -USD1350.00) * 8.0006 = 7989799.19 yuan.
  2. Finance manager considered the interest cost if apply for the negotiation but can avoid the FX risk and increase the capital turnover. So on 21/07/2005, firm A does the negotiation. the total interest cost for this service is : 

USD 1000000.00 * 5.5% * 180/360 = USD27500.00

       The earning in the end is :
             (USD1000000.00 - USD1350.00 - USD27500.00) * 8.2646 = 8026166.29 yuan

So the comparison between choice 1 and choice 2 is

8026166.29 - 7989799.19 = 36367.10 yuan

So Choice 2 is better. And this hasn't added into the RMB saving interest benefit of 180 days.


Characters of Negotiation :


  1. This financing method is used after L/C is issued 
  2. This financing method's time is short, normally <= 360 days. However, for Big Equipment exportation, the receivables time is 3 ~ 5 years, so in practice, the negotiation service is also 3 ~ 5 years. So, multiple negotiations are involved, each of which is <= 360 days as well. 
  3. For banks to conduct this service, there is a limitation for the bank. Only negotiation bank/issuing bank/confirmation bank which is related to the L/C can conduct this service, otherwise, it's hard for other banks to tell the veracity of documents which involves a big risk. On the other side, if a bank only conducts the negotiation service for this L/C but not other correspondent services related to the L/C, (eg: L/C issuing, L/C processing), it can't maximize the profit for the bank. So banks only continue to do those negotiations for L/C issued himself.
  4. Bank has the right of recourse, normally, the prioritized money source is from L/C, if the company can't timely receive the money from foreign clients, the export company must pay the bank principal + interest or auto deduct from company's bank account by the bank.


Procedures of Negotiation:


  1. The export firm receives the L/C from foreign clients, then do the negotiation service from a local bank to get some financing.
  2. Firm and local bank sign contract/agreement for this. stipulating fee and conditions. 
  3. Bank from foreign client-side/Foreign Bank (L/C issuing bank/confirming bank) give the money to bank from exporter side (local bank/L/C Negotiation bank) when L/C matures. 
  4. The local bank receives the money from the foreign bank and helps the applicant (exporter) pay the principal + interest(fees) in this bank and transfer the remainings into exporter's private bank account and inform the exporter in the end. 


How to calculate the interest?

Banks conducting the negotiation service normally don't collect fees but only collect the interest.

Negotiation interest  = Neotiation amount * interet rate * days/360

Exporter's receivables = negotiation amount - negotiation interest - bank fees


How does bank calculate Negotiation amount : 

Negotiation amount, in theory, can be 100% of L/C invoice amount. However in practice banks normally collect the interest in the first place (give out the money to exporter after deducting the interest first), so it's < 100% of L/C.

Under some circumstance of export, invoices stipulate some discount/commission
the negotiation amount shouldn't include them. For example, in a commercial invoice,
Total amount : USD100000.00,
Commission: 2%
Maximum negotiation amount : USD98000.00

Under some circumstance of export, some country has stamp duty tax, the export invoice amount and L/C amount has differences. then the bank will consider the lower one of 2 amounts.

Export invoice: USD98000.00,
L/C invoice amount: 95000.00%
Maximum negotiation amount : USD95000.00

How does bank confirm the interest rate :

Financing interest rate = Libor + Margin (0.5% ~ 1.5 %)

Difference between Packing loan and Negotiation :


  1. Mortage is different, Packing loan takes the L/C as mortgage and negotiation take the documents as the mortgage.
  2. Loan Amount is different, packing loan's loan amount <= 90% of L/C. Negotiation's loan amount <= 100% of some export bill/invoices. 
  3. Usage is different. Packing loan's money can only be used for production/transportation... not some fix asset procurement. Negotiation's money has no limitation. 
  4. Pressure is different. Packing loan is a financing method before all the documents ready. So exporter's pressure is little and it's good. Negotiation is a financing method after all documents ready. Exporters must produce, transport ... first incurring some expenses documents. So exporters have certain pressure. 

Thursday, August 9, 2018

Convert HTML Table into EXCEL , MS Word , PDF in Java

Report generation in different formats is troublesome in most of the projects. However, there still is an easier way to do for experienced engineers. Here I will recommend a jar which can directly convert any HTML Table with CSS into 3 Main report formats (EXCEL, WORD, PDF). This project saves developers tons of efforts to manually write a utility class to parse the XPath in Apache POI or Doc4j and generate reports. here is the address :


Here is the code example :


public static void main(String[] args) throws FileNotFoundException, IOException {
  
 String html = IOUtils.toString(new FileInputStream("./Sample.html"));
  
 new ExcelExporter().exportHtml(html, new File("./report.xlsx"));
}

If you are using this jar, 3 points need to be noted :

1. CSS Style must be defined in the <Style> tag.


<style type="text/css">
.pNewCounter {
  background: #FFC000;
 }

table, tbody, tfoot, thead, tr, th, td, footer, header {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
 }
</style>


                    2. Date format data must have data-date-cell-format attribute                              


   <tr>
          <td>Creation Date</td>
   <td data-date-cell-format="dd/MM/yyyy">06/08/2018</td>
   </tr>


3. Text Data must have data-text-cell attribute



    <tr>
   <td>Offer Expiry Date</td>
   <td data-date-cell-format="dd/MM/yyyy">14/09/2018</td> 
  <td data-date-cell-format="dd/MM/yyyy">14/09/2018</td>
    </tr>
 
 
    <tr>
   <td>Offered Amount</td>
   <td data-text-cell='true' >3,500,000.00</td>
                <td data-text-cell='true' ><strong>3,600,000.00</strong></td>
   </tr>
 
 
    <tr>
   <td>Offered Amount (%) </td>
   <td data-text-cell='true' >35.000%</td>
                <td data-text-cell='true'><strong>36.000%</strong></td>
    </tr>


Sample HTML :

https://github.com/callow/html-exporter/blob/master/Sample.html






Friday, July 27, 2018

Credit Card Recognition

Credit Card recognition will be based on the modal from OpenCV,  It's not necessary to train our own modal based on data as the card number format are mostly all the same.

1.  download the OpenCV jar file and add into classpath or import as maven, then static import the OpenCV c++ library as below:


static {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    }


2. read the credit card image into the program into the Mat object


public static void main(String[] args) {
        Mat srcImage = loadImage("img/card.jpg");
}

public static  Mat loadImage(String path) {
 Mat newImage = Imgcodecs.imread(path);
 return newImage;
}



3. turn the card image into grey color (grey scale process)


public static void main(String[] args) {
 Mat srcImage = loadImage("img/card.jpg");
 Mat grey = grey(srcImage);
}

public static Mat grey(Mat srcMat) {
 Mat dest = new Mat (); 
 Imgproc.cvtColor(srcMat, dest, Imgproc.COLOR_RGB2GRAY);
 return dest;
}


4. turn the grey scale image into a black & white image. (binary process)


public static void main(String[] args) 
{
 Mat srcImage = loadImage("img/card.jpg");
 Mat grey = grey(srcImage);
 Mat binary = blackWhite(grey);
}

public static Mat blackWhite(Mat grayMat) {
  Mat binaryMat = new Mat(grayMat.height(),grayMat.width(),CvType.CV_8UC1);
         Imgproc.threshold(grayMat, binaryMat, 30, 200, Imgproc.THRESH_BINARY);
         return binaryMat;
}


5. Erode the black & white image to make the word bolder and clearer so as to be easy to be recognized.


public static void main(String[] args) {
 Mat srcImage = loadImage("img/card.jpg"); 
 Mat grey = grey(srcImage);
        Mat binary = blackWhite(grey);
 Mat erode = imageErode(binary);
}
public static Mat imageErode(Mat srcMat) {
 Mat destMat = new Mat();
 Mat element = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(3, 3));
        Imgproc.erode(srcMat,destMat,element);
        return destMat;
}


6. crop the key region to remove the noise.


public static void main(String[] args) {
 Mat srcImage = loadImage("img/card.jpg");
 Mat grey = grey(srcImage);
        Mat binary = blackWhite(grey);
 Mat erode = imageErode(binary);
        Mat adjust = filterAndcut(erode);
}
public static Mat  filterAndcut(Mat destMat) {
  int a =0, b=0, state = 0;
         for (int y = 0; y < destMat.height(); y++) //row
         {
             int count = 0;
             for (int x = 0; x < destMat.width(); x++) //column
             {
                 // get the row pixel value 
                 byte[] data = new byte[1];
                 destMat.get(y, x, data);
                 if (data[0] == 0)
                     count = count + 1;
             }
             if (state == 0)//not a valid row
             {
                 if (count >= 150)//find a valid row
                 {//valid row qualify a 10 pixel noise
                     a = y;
                     state = 1;
                 }
             }
             else if (state == 1)
             {
                 if (count <= 150)// find a valid row
                 {//valid row qualify a 10 pixel noise
                     b = y;
                     state = 2;
                 }
             }
         }
         System.out.println("filter upper bound "+Integer.toString(a));
         System.out.println("filter lower bound "+Integer.toString(b));


         //crop the valid region
         Rect rect = new Rect(0,a,destMat.width(),b - a);
         Mat resMat = new Mat(destMat,rect);
         return resMat;
 }


7. recognize and print the result.


public static void main(String[] args) {
  Mat srcImage = loadImage("img/card.jpg");
  Mat grey = grey(srcImage); 
  Mat binary = blackWhite(grey);
  Mat erode = imageErode(binary);
  Mat adjust = filterAndcut(erode);
  
  printResult(matToBufferImage(adjust)); 
}

public static BufferedImage matToBufferImage(Mat grayMat) {
 if (grayMat == null) {
      return null;
 }
 byte[] data1 = new byte[grayMat.rows() * grayMat.cols() * (int)(grayMat.elemSize())];
 grayMat.get(0, 0, data1);
 BufferedImage image1 = new BufferedImage(grayMat.cols(), grayMat.rows(),BufferedImage.TYPE_BYTE_GRAY);                           
 image1.getRaster().setDataElements(0, 0, grayMat.cols(), grayMat.rows(), data1);
 return image1;
}
public static void printResult(BufferedImage src) {
 ITesseract instance = new Tesseract();
 instance.setDatapath("F:/Tess4J-3.4.8-src/Tess4J/tessdata"); // Credit card trained data
 long startTime = System.currentTimeMillis();
 String ocrResult;
 try {
       ocrResult = instance.doOCR(src);
       System.out.println("OCR Result: \n" + ocrResult + "\n spend:" + (System.currentTimeMillis() - startTime) + "ms");
 } catch (TesseractException e) {
       e.printStackTrace();
 } 
}




That's all for this project.







JavaScript !function()

If you like to read some JavaScript plugin source code online you may frequently encounter something like this below :


so how do we interpret this?

If we print this out it is like this below, why? because an anonymous function is undefined, and !undefined is true, we don't care whether it returns true or false but care that the JavaScript engine can parse it perfectly. 

!function(){alert('sd')}()        // true

But you may wonder how does an anonymous function can call itself with no error.

We normally see the below formats more frequently :

(function(){alert('123')})()        // true
(function(){alert('123')}())        // true

Anyway whichever format it is, its main purpose to put a bracket around is to turn a function declaration into an Expression which can be parsed/ Run. for example


function a(){alert('zsd')}   // undefined

This is a function declaration if we put a bracket behind directly, JavaScript Engine certainly doesn't understand. so Syntax error will come.


function a(){alert('iifksp')}()  // SyntaxError: unexpected_token

This code makes the engine confused between function declaration and function call. However, putting a bracket around is different, it turns a function declaration into an expression, the engine will understand it is no more a function declaration but an expression, So this expression will be called when the code is run into this line.

In short, Any grammar that can help to make the engine clearly differentiate function declaration and expression will be accepted by Javascript. For example:


var i = function(){return 10}();        // undefined
1 && function(){return true}();        // true
1, function(){alert('as')}();        // undefined

Assignment Operators,  Logic Operators, and even a comma can tell then engine that this is not a function declaration but a function expression. The unary operator is said to be the fastest way to clear the ambiguity for the engine, exclamation mark (!) is just one of them. here come some examples:


!function(){alert('as')}()        // true
+function(){alert('as')}()        // NaN
-function(){alert('as')}()        // NaN
~function(){alert('as')}()        // -1
void function(){alert('as')}()        // undefined
new function(){alert('as')}()        // Object
delete function(){alert('as')}()        // true
(function(){alert('as')})()        // undefined
(function(){alert('as')}())        // undefined

More Examples  


Option Code
! !function(){;}()
+ +function(){;}()
- -function(){;}()
~ ~function(){;}()
-1 (function(){;})()
-2 (function(){;}())
void void function(){;}()
new new function(){;}()
delete delete function(){;}()
= var i = function(){;}()
&& 1 && function(){;}()
|| 0 || function(){;}()
& 1 & function(){;}()
| 1 | function(){;}()
^ 1 ^ function(){;}()
, 1, function(){;}()

Friday, March 23, 2018

Export Trade Fiance - Packing Finance(Under L/C)

Export Trade Finacing is basically for the sellers/exportors to finance for themselves. There are quite a lot of ways for them to get money from banks, for example packing fiance/Loan, Negotiation under documentary credit, Discount, Forfeiting, Confirmed L/C,  Factoring  etc. Among them , Packing Finance/Loan , Silent Confirmation, Forfeiting and several others occurs when both parties' dealing based on L/C.


Basis

Packing Loan: Exportors(choosing L/C as the way of transaction settlement) can apply for a certain amount of financing before their cargo loading upto the ship to export(Packing stage). Exportors just need to submit the L/C they received from buyer side's bank to the bank they plan to apply the loan from as a collateral to get the money.

Packing Loan initially  is invented to solve the  fiancing need for exportors in their packing stage. But nowadays, most of banks don't follow this. whatever reasons like : goods replenish, goods processing and other steps before the shippment of the goods . you all can appy for packing loan as long as your L/C is real!

Some Banks will need the L/C as a collateral to give the loan out. some just need to check the exportor's credit . but in Aisa, most of banks still need the L/C as a colateral.


Characteristic

  1. Exportor can only use this money to designated items. they can't use it to other investment e.g fix asset investment etc.
  2. Bank will keep the original L/C  as collateral to make sure the applier/Exporter do the presentation of documents in this bank so as to monitor all the way how's the L/C's status. 
  3. Packing loan's time is short. <= 36 days.
  4. With recourse. If exportor can't get the money from importor, bank have the right to deduct principal + interest from the exportor's other account directly

Documents Needed


  1. Company basic liscences and certificates . e.g: tax register liscense. business entity information...
  2. Fill the application form that bank provides
  3. Provide the company financial health evidence e.g Audited P/L, Balance sheet...
  4. Original L/C and contracts
  5. Deposit
  6. Others

Interest Calculation

Loan Amount: 


The Amount Exportor can get(Loan Amount)  = L/C Amount * Margin  

The Margin is set by the bank internally.normally the higher the credit of the exportor , the higher the margin will be . normally the margin is between 70%~90%,if A L/C is 1M , then normally the company can get 700K ~90K loan amount.

Annual Interest Rate:

Annual Interest rate is calculated based on different currencies .If Loan is USD, then use USD loan interest rate , if Loan is YEN, then use Yen loan  interest rate.The interest rate is synced with the central bank. Normally , The bank will choose the latest loan expiry date to let the exportor pay back the principal and interest rate together.

Foreign Currency Financing normally is based on the Inter-Bank Offer Rate (e.g: USD : Libor, YEN: Tibor) + Margin. For exmaple, For USD, Normally the interest rate = Libor + 0.5%~1.5%.For some companies with good credit/reputation, The bank also can only charge Libor + 0.25% as the interest.

Take the data from 28th April 2006 as a example, 12 month Libor is 5.28%, So the bank can choose the interest rate between 5.53% (5.28% + 0.25%)  ~ 6.78% (5.28% + 1.50%) to charge the exportor.

Of course , there're still some banks taking the approach of  20th century, No matter how long the loan they give, alwayse use 1 year walking capital interest rate to charge even though some are less than 1 year. For Example, 2006 April, 1 year foreign currency walking capital loan rate is 6.75%, then the annual interest rate the bank charge the exportor apply for the packing loan is 6.75% as well.

Libor : Currently is regaded as a basis rate of  floating rate(USD), It is regarded as a financing cost of  ( borrow money and re-lend out). The 3 month and 6 Month Libor are most universally used.

Packing Loan giving days:

Packing Loan giving days  = the day to apply for packing loan ~ the latest shipment date stipulated in L/C + 30 Days

For Example , The L/C beneficiary(Exportor) apply for a packing loan on 10/11/2013, The Lastest shipment date in L/C is 31/12/2013. So The Packing Loan giving days are  (10/11 ~ 31/12)  +30 days = 81days. That is between 10/11/2013  ~ 31/01/2004. Normally It is less than 1 year. So The bank will give the money to the exportor gradually within this period.


For Companies to consider


  1. Company should maintain a good credit and no bad records in the bank.
  2. make sure the issuing bank's country economy stability and no political risk, so the payment can be done successfully.
  3. Read the L/C clause carefully.The more complex the clause , the harder the beneficiary to follow.
  4. Make sure the L/C is irrevocable L/C as the bank only can give packing loan based on this.
  5. Choose the correct currency to save the cost.
Exportor can choose domestic currency or froeign currency from bank. company may need to consider the national foreign currency control policy. In Recent years, In China , The foreign Currency loan interest rate is lower than the RMB loan interest rate. So companies may consider to choose foreign currency as loan currency . when using RMB, they will convert the foreign currency into RMB to save the cost.


For example, If exportor need 1M RMB to buy raw material and apply for the packing loan.the company can choose foreign currency packing loand or RMB packing loan. In 2004, RMB loan interest rate is 4.65% and USD loan interest rate 2.98%. Exchange rate at that time is USD100 = CNY826.46 .If choose foreign currency packing loan for 90 days, the interest exportor need to pay :

$ 1M * 2.98% * 90/360 = $ 7649
$ 7649 = 61.7 K (RMB)

If choose RMB packing loan , company need to pay interest:

$ 1M * 8.264 * 4.65% * 90/360 = 96.1K (RMB)

So ,Choose USD packing loan is better.

For Banks to consider


  1. Understand application company's credit and capital situation 
  2. verify the L/C(By SWIFT)
  3. Understand Issuing Bank's credit and rate(Moody's Finth Rating).
  4. verify the clause of L/C
  5. Control the date of giving loan
  6. make sure the Risk Index and credit limit
Credit Limit(trade finance) = walking capital loan amount *   (1 / risk index)
For example:
    If bank of china gives the company A 1M USD loan limit, then A can transfer this 1M loan limit into guarantee limit:
    
guarantee limit  = 1M USD * (1/0.25) = 4M USD

Any Question About this Product Can leave your comments below.



Add Loading Spinner for web request.

when web page is busily loading. normally we need to add a spinner for the user to kill their waiting impatience. Here, 2 steps we need to d...