Skip to content

Added item wise discounts #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ body{
}

div.container{
width: 800px;
width: 850px;
}

#imgInp{
Expand Down
Binary file added images/Add item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Trash item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 13 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<div class="input-container"><input type="text" ng-model="invoice.customer_info.address2"/></div>
<div class="input-container"><input type="text" ng-model="invoice.customer_info.postal"/></div>
<div class="input-container" data-ng-hide='printMode'>
<select ng-model='currencySymbol' ng-options='currency.symbol as currency.name for currency in availableCurrencies'></select>
<select ng-model='currencySymbol' ng-options='currency.symbol as currency.name for currency in availableCurrencies'></select>
</div>
</div>
<div class="col-xs-6 right">
Expand All @@ -55,16 +55,17 @@
<div class="items-table">
<div class="row header">
<div class="col-xs-1">&nbsp;</div>
<div class="col-xs-5">Description</div>
<div class="col-xs-3">Description</div>
<div class="col-xs-2">Quantity</div>
<div class="col-xs-2">Cost {{currencySymbol}}</div>
<div class="col-xs-2">Discount {{currencySymbol}}</div>
<div class="col-xs-2 text-right">Total</div>
</div>
<div class="row invoice-item" ng-repeat="item in invoice.items" ng-animate="'slide-down'">
<div class="col-xs-1 remove-item-container">
<a href ng-hide="printMode" ng-click="removeItem(item)" class="btn btn-danger">[X]</a>
<img src="images/Trash item.png" ng-hide="printMode" ng-click="removeItem(item)" />
</div>
<div class="col-xs-5 input-container">
<div class="col-xs-3 input-container">
<input ng-model="item.description" placeholder="Description" />
</div>
<div class="col-xs-2 input-container">
Expand All @@ -73,25 +74,28 @@
<div class="col-xs-2 input-container">
<input ng-model="item.cost" value="0.00" ng-required ng-validate="number" size="6" placeholder="Cost" />
</div>
<div class="col-xs-2 input-container">
<input ng-model="item.discount" value="0.00" ng-required ng-validate="number" size="6" placeholder="Discount" />
</div>
<div class="col-xs-2 text-right input-container">
{{item.cost * item.qty | currency: currencySymbol}}
{{(item.cost - item.discount) * item.qty | currency: currencySymbol}}
</div>
</div>
<div class="row invoice-item">
<div class="col-xs-12 add-item-container" ng-hide="printMode">
<a class="btn btn-primary" href ng-click="addItem()" >[+]</a>
<img src="images/Add item.png" ng-click="addItem()" />
</div>
</div>
<div class="row">
<div class="col-xs-10 text-right">Sub Total</div>
<div class="col-xs-10 text-right" style="padding-right: 50px;">Sub Total</div>
<div class="col-xs-2 text-right">{{invoiceSubTotal() | currency: currencySymbol}}</div>
</div>
<div class="row">
<div class="col-xs-10 text-right">Tax(%): <input ng-model="invoice.tax" ng-validate="number" style="width:43px"></div>
<div class="col-xs-2 text-right">{{calculateTax() | currency: currencySymbol}}</div>
</div>
<div class="row">
<div class="col-xs-10 text-right">Grand Total:</div>
<div class="col-xs-10 text-right" style="padding-right: 32px;">Grand Total:</div>
<div class="col-xs-2 text-right">{{calculateGrandTotal() | currency: currencySymbol}}</div>
</div>
</div>
Expand All @@ -103,7 +107,7 @@
</div>
</div>

<div ng-hide="printMode" class="copy noPrint">
<div ng-hide="Mode" class="copy noPrint">
<a href="https://jasdeep.ca/?utm_source=angular_invoicing">Jasdeep Singh</a> &amp;
<a href="https://github.com/manpreetrules">Manpreet Singh</a>
Made with
Expand Down
17 changes: 9 additions & 8 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ angular.module('invoicing', [])
postal: 'M5S 1B6'
},
items:[
{ qty: 10, description: 'Gadget', cost: 9.95 }
{ qty: 0, description: '', cost: 0, discount: 0 }
]
})

Expand Down Expand Up @@ -93,6 +93,10 @@ angular.module('invoicing', [])

service.all = function() {
return [
{
name: 'Indian Rupee (₹)',
symbol: '₹'
},
{
name: 'British Pound (£)',
symbol: '£'
Expand All @@ -105,10 +109,7 @@ angular.module('invoicing', [])
name: 'Euro (€)',
symbol: '€'
},
{
name: 'Indian Rupee (₹)',
symbol: '₹'
},

{
name: 'Norwegian krone (kr)',
symbol: 'kr '
Expand All @@ -129,7 +130,7 @@ angular.module('invoicing', [])
function($scope, $http, DEFAULT_INVOICE, DEFAULT_LOGO, LocalStorage, Currency) {

// Set defaults
$scope.currencySymbol = '$';
$scope.currencySymbol = '';
$scope.logoRemoved = false;
$scope.printMode = false;

Expand All @@ -151,7 +152,7 @@ angular.module('invoicing', [])
})()
// Adds an item to the invoice's items
$scope.addItem = function() {
$scope.invoice.items.push({ qty:0, cost:0, description:"" });
$scope.invoice.items.push({ qty:0, cost:0, description:"",discount:0 });
}

// Toggle's the logo
Expand Down Expand Up @@ -179,7 +180,7 @@ angular.module('invoicing', [])
$scope.invoiceSubTotal = function() {
var total = 0.00;
angular.forEach($scope.invoice.items, function(item, key){
total += (item.qty * item.cost);
total += (item.qty * (item.cost - item.discount));
});
return total;
};
Expand Down