Saturday, 7 March 2015

git ignore all files of a certain type

using a .gitignore you can ignore files from git.
These file will be not tracked using git.

1) info of excluded files
       cat .git/info/exclude


# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~



2) status of current .gitignore
cat .gitignore
.DS_Store
*.pyc
*.egg-info
*.swp
tags





3) edit .gitignore fiel, so that .~ files will not be tracked. (.~ is temporary files)
vi .gitignore

.DS_Store
*.pyc
*.egg-info
*.swp
*~
tags

Note: 
A gitignore file specifies intentionally untracked files that git should ignore. Files already tracked by git are not affected;
The purpose of gitignore files is to ensure that certain files not tracked by git remain untracked.
To ignore uncommitted changes in a file that is already tracked, use git update-index --assume-unchanged
To stop tracking a file that is currently tracked, use git rm --cached



other reference : http://www.tecmint.com/13-basic-cat-command-examples-in-linux/

Thursday, 5 March 2015

Why large companies use open source ERP




The main reason larger companies use open source Enterprise Resource Planning (ERP) systems is because they are cheaper and easier to customize.
 
In many cases, when you are implementing an open source ERP system for a large organization, a new interface shell is created outside of the core system to meet the business needs and line-up with the company organization. With commercial systems the existing interface is customized which makes upgrades difficult to say the least. A further reason that open source ERP is used is because you own the system and its full source content, there is no lock-in or dependency on the vendor, and you are more free on how you are going to implement the software. You can do this all by yourself or hire a provider.

Further, it saves your business costs in the long run. When an open source ERP is used there are typically no license or software maintenance costs. In many cases, the external consultants and programmer fees are lower. Most open source ERP software systems can use open source databases and operating systems, giving you a license-free option. Commercial ERP systems often need expensive commercial databases and operating systems.

Large company IT departments appreciate that an open source ERP has is of higher quality, because many independent, often passionate developers have looked at it, criticized its code, and contributed enhancements. Competition between developers is very common in open source software and improves quality. Open source is often built on other open source projects and database models, so open source does not re-invent the wheel, which is what often happens in commercial systems.
Open source ERP systems are easier to upgrade when customizations are properly implemented (outside the base system) than with commercial systems, and upgrades can therefore be done much more often (every three months to monthly) without disruption of the production system.
Are there disadvantages? Sure, but only a few.

Often documentation of the commercial system is better for the standard supplied system too. However, if you are going to modify the user interface anyway, this documentation will not help you much when you need to customize the system to suit your business needs. Another disadvantage could be that open source ERP is still relatively new in large organizations. Because of this, it is sometimes difficult to convince an accounting department or other decision maker to use open source software. Lastly, auditors may not be familiar with a new interface and do not know the system yet. However, training can be easily implemented to avoid these complications when deploying a new system.

Conclusion

If you want to easily customize the system to your needs, save substantial amounts of money, and avoid vendor locked-in, the choice is easy: go open source.

A version of this article posted on LinkedIn by Hans Bakker. Republished under Creative Commons

HTML table cellspacing, cellpadding attribute Attribute

1) The cellspacing attribute specifies the space, in pixels, between cells.
2) The cellpadding attribute specifies the space, in pixels, between the cell wall and the cell content.


 The cellspacing, cellpadiing attribute is not supported in HTML5.


syntax:
table cellspacing="50" cellpadding = "10"
end table

<p>Table with cellspacing:</p>
<table cellspacing="50" cellpadding = "10">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>


3) CSS Example To add padding to a table


<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
}

th, td {
    padding: 10px;
}
</style>
</head>
<body>

<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>

</body>
</html>
 

Thursday, 22 January 2015

Make A Cumulative Sum Column In MySql

MySql: Select Query- Make A Cumulative Sum Column



 
create database sam;
use sam;
CREATE TABLE account
(
transaction_id varchar(255),
acc_no varchar(255),
amount int
); 

INSERT INTO account (transaction_id, acc_no, amount)
VALUES (1,100,1000); 
INSERT INTO account (transaction_id, acc_no, amount)
VALUES (2,100,50); 
INSERT INTO account (transaction_id, acc_no, amount)
VALUES (3,101,2000); 
INSERT INTO account (transaction_id, acc_no, amount)
VALUES (4,102,211); 

select * from account;
+----------------+--------+--------+
| transaction_id | acc_no | amount |
+----------------+--------+--------+
| 1                     | 100       |   1000 |
| 2                     | 100       |       50 |
| 3                     | 101       |   2000 |
| 4                     | 102       |     211 |
+----------------+--------+--------+
4 rows in set (0.00 sec)

 select
 transaction_id,
 amount,
 (@cum_sum:=@cum_sum+amount) as "cumulative"
from
account
JOIN (select @cum_sum := 0.0) B;

+----------------+--------+------------+
| transaction_id | amount | cumulative |
+----------------+--------+------------+
| 1                    |      1000 |       1000 |
| 2                    |          50 |       1050 |
| 3                    |      2000 |       3050 |
| 4                    |        211 |       3261 |
+----------------+--------+------------+

Wednesday, 21 January 2015

Unit Testing: How to write test cases?

Unit tests for test functions in isolation, i.e. you call a function with mock up-parameters and verify the results. Ideally, you check both success and failure response. A schematic example. Say you have a function like this:
def myfunc(a, b):
    return a / b
Then a unit test could be like this:
def test_myfunc():
    result = myfunc(4, 2)
    if result != 2:
        raise AssertionError("Wrong result: should have been 2, but was %s." % result)
So you're writing another function to call the function that is to be tested, with parameters for which you know the result, in order to prove that the function really returns the expected result.
Typically, you should have at least one test call for each distinct type of case - e.g. for myfunc() this would additionally be the cases where either parameter is 0.

Now, in order to write unit tests for any module, you need to look at each function and understand what results it should deliver for which input - and try to find a way to inspect and verify the result. Then identify the assertions (=expected results) for each type of case, and encode it as a test case

You do not need to test the overall functionality - all we need to know is whether the parts still do after the refactoring what they did before, the results are still correct, and no new bugs have been introduced (=regression testing)

ERPNext: Print Format Of Sales Invoice

{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
    {% if letter_head and not no_letterhead %}
    <div class="letter-head">{{ letter_head }}</div>
    {% endif %}
    {%- if doc.meta.is_submittable and doc.docstatus==0-%}
    <div class="alert alert-info text-center">
        <h4 style="margin: 0px;">{{ _("DRAFT") }}</h4></div>
    {%- endif -%}
    {%- if doc.meta.is_submittable and doc.docstatus==2-%}
    <div class="alert alert-danger text-center">
        <h4 style="margin: 0px;">{{ _("CANCELLED") }}</h4></div>
    {%- endif -%}
    {% if max_pages > 1 %}
    <p class="text-right">{{ _("Page #{0} of {1}").format(page_num, max_pages) }}</p>
    {% endif %}
{%- endmacro -%}

<small>
{{ add_header(0,1,doc,letter_head, no_letterhead) }}

<p class="text-center"><b>{{ _("Sales Invoice") }}</b></p><br>

<div class="row">       
     <div class="col-xs-6">           
        <div class="row">
            <div class="col-xs-5 text-right"><label>Customer Name:</label></div>
            <div class="col-xs-7 ">{{ doc.customer }} </div>
        </div>
        <div class="row">
            <div class="col-xs-5 text-right"><label>Billing Address</label></div>
            <div class="col-xs-7 ">{{ doc.address_display }}</div>
        </div>
        <div class="row">
            <div class="col-xs-5 text-right"><label>Payment Due Date</div>
            <div class="col-xs-7 ">{{ doc.due_date }}</div>
        </div>         
    </div>

    <div class="col-xs-6">
        <div class="row">
            <div class="col-xs-5 text-right"><label>Invoice No:</label></div>
            <div class="col-xs-7 ">{{ doc.name }} </div>
        </div>
        <div class="row">
            <div class="col-xs-5 text-right"> <label>DATE:</label> </div>
            <div class="col-xs-7 "> {{ doc.get_formatted("posting_date") }}<br> </div>
        </div>   
    </div>
           
</div>
       
<br>

<table class="table table-condensed table-hover table-bordered">
        <tr>
            <th>Sr</th>
            <th>Description</th>
            <th class="text-right">Qty</th>
            <th class="text-right">Rate</th>
            <th class="text-right">Amount</th>
        </tr>
        {%- for row in doc.entries -%}
        <tr>
            <td style="width: 3%;">{{ row.idx }}</td>
            <td style="width: 57%;">{{ row.description }}</td>
            <td style="width: 10%; text-align: right;">{{ row.qty }} {{ row.uom or row.stock_uom }}</td>
            <td style="width: 15%; text-align: right;">{{
                row.get_formatted("rate", doc) }}</td>
            <td style="width: 15%; text-align: right;">{{
                row.get_formatted("amount", doc) }}</td>
        </tr>
        {%- endfor -%}
    </tbody>
</table>
<table class="table table-condensed table-bordered">
  <tr>
    <td width="50%">
        <p>{% if doc.terms %} <b>{{ _("Auxiliary Information") }}: </b>{{ doc.terms or "" }}
        {%- endif -%}
    </p>
       <p style="font-size:12px">{% if doc.in_words_export %}
        <b>{{ _("Total Amount (In Words)") }}: </b><br>
            {{ doc.in_words_export }}
        {%- endif -%}
    </p><br><br>
    <table class="table table-condensed">
      <tr>
        <td height="100px"; valign="top">
            <b>{{ _("Received By:") }}</b>
        </td>
      </tr>
      <tr>
        <td>
            <b>{{ _("Customer Sign") }}</b>
        </td>
      </tr>
    </table>

    </td>
<td>
        <table class="table table-condensed">
            <tr>
                <td class="text-right" style="width: 30%">
                    {{ _("Net Total") }}
                </td>
                <td class="text-right">
                    {{ doc.get_formatted("net_total_export") }}
                </td>
            </tr>
            {%- for row in doc.other_charges -%}
            {%- if not row.included_in_print_rate -%}
            {%- if row.tax_amount -%}
            <tr height:100%>
                <td class="text-right" style="width: 70%">
                    {{ row.description }}
                </td>
                <td class="text-right">
                    {{ row.get_formatted("tax_amount", doc) }}
                </td>
            </tr>
            {%- endif -%}
            {%- endif -%}
            {%- endfor -%}
            {%- if doc.discount_amount -%}
            <tr>
                <td class="text-right" style="width: 70%">
                    {{ _("Discount") }}
                </td>
                <td class="text-right">
                    {{ doc.get_formatted("discount_amount") }}
                </td>
            </tr>
            {%- endif -%}
            <tr>
                <td class="text-right" style="width: 70%">
                    <big><b>{{ _("Grand Total") }}</b></big>
                </td>
                <td class="text-right">
                    <big><b>{{ doc.get_formatted("grand_total_export") }}</b></big>
                </td>
            </tr>
        </td>

        </table>

    </td>
  </tr>
</table>
{% if doc.get("other_charges", filters={"included_in_print_rate": 1}) %}
<hr>
<p><b>Taxes Included:</b></p>
<table class="table table-condensed no-border">
    <tbody>
        {%- for row in doc.other_charges -%}
        {%- if row.included_in_print_rate -%}
        <tr>
            <td class="text-right" style="width: 70%">

                {{ row.description }}
            </td>
            <td class="text-right">
                {{ row.get_formatted("tax_amount", doc) }}
            </td>
        <tr>
        {%- endif -%}
        {%- endfor -%}
    </tbody>
</table>
{%- endif -%}
<hr>
</small>

Monday, 19 January 2015

Delivery Note Print Format


{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
    {% if letter_head and not no_letterhead %}
    <div class="letter-head">{{ letter_head }}</div>
    {% endif %}
    {% if max_pages > 1 %}
    <p class="text-right">{{ _("Page #{0} of {1}").format(page_num, max_pages) }}</p>
    {% endif %}
{%- endmacro -%}


<p class="text-center"><b>{{ _("PRODUCT RELEASE") }}</b></p><br>

<div class="row">      
        <div class="col-xs-6">          
        <div class="row">
            <div class="col-xs-5 text-right"><label>SHIP TO:</label></div>
            <div class="col-xs-7 ">{{ doc.customer }} </div>
        </div>
        <div class="row">
            <div class="col-xs-5 text-right"></div>
            <div class="col-xs-7 ">{{ doc.shipping_address }}</div>
        </div>
         <div class="row">
            <div class="col-xs-5 text-right"><label>ATTN:</label></div>
            <div class="col-xs-7 "> {{ doc.contact_display }}</div></div>          
        </div>
     
        <div class="col-xs-6">
         <div class="row">
            <div class="col-xs-5 text-right"> <label>RELEASE DATE:</label> </div>
            <div class="col-xs-7 "> {{ doc.get_formatted("posting_date") }}<br>
            </div>
        </div>
         <div class="row">
          <div class="col-xs-5 text-right"> <label>RELEASE:</label></div>
            <div class="col-xs-7 "> {{ doc.name }} </div>
        </div>
         <div class="row">
            <div class="col-xs-5 text-right"> <label>SHIP DATE:</label> </div>
            <div class="col-xs-7 "> {{ doc.get_formatted("lr_date") }}<br> </div>
        </div>
     
         <div class="row">
            <div class="col-xs-5 text-right"><label>BUYER’S P.O.:</label>  </div>
            <div class="col-xs-7 "> {{ doc.po_no }} </div>
        </div>      
        <div class="row">
            <div class="col-xs-5 text-right"><label>SALE REP SM:</label>  </div>
            <div class="col-xs-7 "> </div>
        </div>
         <div class="row">
            <div class="col-xs-5 text-right"><label>SHIPPING TERMS:</label>  </div>
            <div class="col-xs-7 "> {{ doc.terms }}</div>
        </div>    
        </div>
         
        </div>
     
<br>
<table class="table table-condensed table-hover table-bordered">
        <tr>
            <th>Sr</th>
            <th class="text-right">Item</th>
            <th>Description</th>
            <th>Quantity</th>
        </tr>
        {%- for row in doc.delivery_note_details -%}
        <tr>
            <td style="width: 3%; text-align: right;">{{ row.idx }}</td>
            <td style="width: 10%; text-align: right;">{{ row.item_name }}</td>
            <td style="width: 37%; text-align: left;">
<b>Batch No: </b>{{ row.batch_no }}
<br><b>Quantity in Weight: </b>{{ row.quantity_in_weight }}{{ row.weight_uom }}
<br><b>Quantity : </b>{{ row.qty }} {{ row.stock_uom }}
<br><b>Net Weight: </b>{{ row.net_weight }}
</td>
          <td style="width: 20%;"> {{ row.quantity_in_weight}} {{ row.weight_uom }}</td>
        </tr>
        {%- endfor -%}
    </tbody>
</table>


<p class="text-left"><label>COMMENTS:</label></p>
<p class="text-left"><b>To Customer:</b></p>
<p class="text-left">Buyer to arrange trucking</p>
<p class="text-left">Trucker to bring pallet(s) for exchange; otherwise $10/pallet will be assessed on your invoice.</p><br>
<p class="text-left"><b>To Warehouse:  </b> </p>
<p class="text-left">Please inspect condition of packages prior to loading order.  Only release packages with label, seal, exterior, etc. intact.</p>
<p class="text-left"><b>Tracking: </b> </p><br>
<p class="text-left"><h5>We appreciate your business!<h5></p>
<p class="text-left"><h5>Thank you.</h5></p>


Note: Print Format, Don't write any external style