Skip to content

Commit

Permalink
Shanu: Enhancements going on
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanu committed Dec 18, 2010
1 parent dc13224 commit b86c84d
Show file tree
Hide file tree
Showing 16 changed files with 142 additions and 83 deletions.
6 changes: 5 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
password="${db.password}"
src="@{src}"
onerror="@{onerror}"
delimiter=";"
delimiter=";"
/>
</sequential>
</macrodef>
Expand All @@ -38,6 +38,10 @@
<exec_sql src="sql/schema.sql" onerror="abort"/>
</target>

<target name="metadata">
<exec_sql src="sql/metadata.sql" onerror="abort"/>
</target>

<target name="setupdb" depends="drop.create.schema">
<dbdeploy driver="${db.driver}" url="${db.url}"
userid="app_user"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import com.breigns.vms.Shop
import com.breigns.vms.VoucherSetModel

import com.breigns.vms.VoucherCreationRequestModel
import com.breigns.vms.utility.DateUtils

class AdminController {
def adminService;
def dateUtil = new DateUtils()
def index = {
voucherReportPage()
}
Expand All @@ -33,7 +35,8 @@ class AdminController {
}
}
def invoiceNumber = adminService.createVouchersForTheClient(new VoucherCreationRequestModel(shopId: Long.parseLong(params['invoicedAt']),
clientId: Long.parseLong(params['clientId']), voucherList: voucherSet))
clientId: Long.parseLong(params['clientId']), voucherList: voucherSet,
validThru: dateUtil.getDateFromString(params['validThru']), remarks: params['remarks']))
/*adminService.createVouchersForTheClient(params['clientId'], Integer.parseInt(params['numberOfVouchers']),
Double.parseDouble(params['voucherValue']),invoicedAt,params['invoiceNumber'])*/
flash.message = 'Voucher(s) Created Successfully with the invoice number: ' + invoiceNumber
Expand All @@ -60,8 +63,9 @@ class AdminController {
def voucherList = adminService.getVouchersForSequence(clientId,
sequenceStart, sequenceEnd)
adminService.updateStatusForRangeOfSequence(clientId, sequenceStart, sequenceEnd, VoucherStatus.BARCODE_GENERATED)
response.setHeader("Content-Disposition", "attachment; barcode.txt")
render new BarCodeGenerator().generateZlpForBarcode(voucherList,file)
response.setContentType("application/octet-stream")
response.setHeader("Content-Disposition", "attachment; filename=barcode.txt")
render new BarCodeGenerator().generateZlpForBarcode(voucherList, file)
}

def editVoucherPage = {
Expand All @@ -88,7 +92,7 @@ class AdminController {
def voucherInvoiceId = Long.parseLong(params['voucherInvoiceId'])
def shopId = Long.parseLong(params['newShopId'])
def voucherInvoice = adminService.updateVoucherInvoice(voucherInvoiceId, shopId)
flash.message = "Voucher Invoice Updated Successfully: New Invoice Number: "+voucherInvoice.invoiceNumber
flash.message = "Voucher Invoice Updated Successfully: New Invoice Number: " + voucherInvoice.invoiceNumber
render view: 'editVoucher', model: [clients: Client.listOrderByName(), shops: Shop.list()]
}

Expand Down
3 changes: 1 addition & 2 deletions grails-app/domain/com/breigns/vms/Purchase.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ class Purchase {
AppUser createdBy
Shop shoppedAt
Date dateCreated
List<Voucher> vouchers
Item item;
Double totalAmount
Double discount
Double netTotal

static hasMany = [vouchers:Voucher]
static constraints = {
totalAmount(nullable:true)
totalAmount(discount:true)
Expand Down
4 changes: 3 additions & 1 deletion grails-app/domain/com/breigns/vms/Voucher.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ class Voucher {
VoucherInvoice voucherInvoice
Shop soldAt;
Shop validatedAt;
static belongsTo = [client: Client]
Date validThru
static belongsTo = [client: Client,purchase:Purchase]
static fetchMode = [client: 'eager']
static constraints = {
barcodeAlpha(maxSize: 10, minSize: 10)
soldAt(nullable: true)
validatedAt(nullable: true)
purchase(nullable: true)
}

def getGeneratedSequence() {
Expand Down
4 changes: 4 additions & 0 deletions grails-app/domain/com/breigns/vms/VoucherInvoice.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ package com.breigns.vms
class VoucherInvoice {
Shop invoicedAt;
Integer invoiceNumber;
String remarks
Date dateCreated;
static constraints = {
remarks(nullable: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ class AdminService {
def client = Client.load(voucherCreateRequest.clientId)
def loggedInUser = AppUser.findByUsername(springSecurityService.getPrincipal().username)
def shop = Shop.load(voucherCreateRequest.shopId)
def validThru = voucherCreateRequest.validThru
def remarks = voucherCreateRequest.remarks
def voucherInvoiceNumber = VoucherInvoiceSequence.nextSequence(shop)
def voucherInvoice = new VoucherInvoice(invoicedAt: shop, invoiceNumber: voucherInvoiceNumber).save()
def voucherInvoice = new VoucherInvoice(invoicedAt: shop, invoiceNumber: voucherInvoiceNumber,remarks:remarks).save()
if (client) {
def voucherList = voucherCreateRequest.voucherList
int j = 0;
Expand All @@ -47,7 +49,7 @@ class AdminService {
}
def newVoucher = new Voucher(sequenceNumber: nextSequence,
barcodeAlpha: getRandomAlpha(), value: voucher.denomination, createdBy: loggedInUser,
status: VoucherStatus.CREATED, voucherInvoice: voucherInvoice, client: client)
status: VoucherStatus.CREATED, voucherInvoice: voucherInvoice, client: client,validThru:validThru)
client.addToVouchers(newVoucher.save())
j++;
if (j % 50 == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class VoucherService {
invoice.validate()
invoice.save()
vouchers.each {
it.purchase = invoice
it.soldAt = inuser.shop
it.status = VoucherStatus.SOLD;
it.save()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class BarCodeGenerator {
voucherList.eachWithIndex {value, index ->
if ((index + 1) % 2 != 0) {
def barcodeAlpha2 = voucherListSize > (index + 1) ? voucherList.getAt(index + 1).barcodeAlpha : ""
def sequenceNumber2 = voucherListSize > (index + 1) ? voucherList.getAt(index + 1).sequenceNumber : ""
def sequenceNumber2 = voucherListSize > (index + 1) ? voucherList.getAt(index + 1).generatedSequence : ""
def binding = ["BARCODE1": value.barcodeAlpha, "SEQUENCE1": value.
sequenceNumber, "BARCODE2": barcodeAlpha2,
generatedSequence, "BARCODE2": barcodeAlpha2,
"SEQUENCE2": sequenceNumber2]
writer.append(engine.createTemplate(templateFile).make(binding).toString())
}
Expand Down
11 changes: 11 additions & 0 deletions grails-app/utils/com/breigns/vms/utility/DateUtils.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.breigns.vms.utility

import java.text.SimpleDateFormat

class DateUtils {
def simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy")

def getDateFromString(dateAsString) {
simpleDateFormat.parse(dateAsString)
}
}
37 changes: 29 additions & 8 deletions grails-app/views/admin/createNewVoucher.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
$("#message_box").html('No Voucher In The List To Create')
return false;
}
if (!validateMandatoryFields(['validThru','remarks'])) {
$("#message_box").html('Valid Thru and Remarks Are Mandatory')
return false;
}
if (!validateDate('validThru')) {
$("#message_box").html('Valid Thru , Not A Valid Date')
return false;
}
$('#Create').attr('disabled', 'true')
return true;
}
Expand All @@ -66,13 +74,15 @@
</g:if>
</div>
<div>
<ul id="voucherAddition">
<li style="display:inline;padding:5px"><label>Number Of Vouchers</label></li>
<li style="display:inline;padding:5px"><g:textField name="numberOfVouchers"/></li>
<li style="display:inline;padding:5px"><label>Voucher Denomination</label></li>
<li style="display:inline;padding:5px"><g:textField name="denomination"/></li>
<li style="display:inline;padding:5px"><input type="button" value="Add To List" onclick="addToVoucherList()"/></li>
</ul>
<table>
<tr>
<td>No Of Vouchers</td>
<td><g:textField name="numberOfVouchers"/></td>
<td>Voucher Value</td>
<td><g:textField name="denomination"/></td>
<td><input type="button" value="Add To List" onclick="addToVoucherList()"/></td>
</tr>
</table>
</div>
<div id="voucherList" style="height:300px;overflow-y:auto">
<h3>Voucher Creation List</h3>
Expand All @@ -93,7 +103,18 @@
</g:each>
</table>
</div>
<div style="margin-left:80px;margin-top:10px;"><g:submitButton name="Create" value="Create Vouchers"/></div>
<div>
<table>
<tr>
<td>Valid Thru(dd/mm/yyyy)</td>
<td><g:textField name="validThru"/></td>
<td>Remarks</td>
<td><g:textArea name="remarks"/></td>
<td><g:submitButton name="Create" value="Create Vouchers"/></td>
</tr>
</table>

</div>

</div>
</g:form>
Expand Down
1 change: 1 addition & 0 deletions grails-app/views/admin/voucherReport.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
</table>
</div>
</div>
<div style="margin-bottom:0px; width:400px;height:200px;display:block;border:black dotted thin">Test</div>
</body>
</html>
1 change: 0 additions & 1 deletion grails-app/views/voucher/searchVoucher.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<ul class="leftNavUL">
<li>
<label>Bar Code:</label>

</li>
<li>
<g:textField name="barcode"></g:textField>
Expand Down
29 changes: 20 additions & 9 deletions grails-app/views/voucher/voucherDetails.gsp
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
<div id="message_box" style="text-align:center">
<g:if test="flash.message">
${flash.message}
</g:if>
</div>
<g:if test="${voucherFound}">
<div style="text-align:center">
<h3 style="margin:20px;">Voucher Found</h3>
</div>
<table>
<tr>
<td>Sequence Number</td>
<td style="text-align:left">Sequence Number</td>
<td><input disabled="true" value="${voucher.generatedSequence}"/></td>
<td style="text-align:center">Bar Code</td>
<td style="text-align:left">Bar Code</td>
<td><input disabled="true" value="${voucher.barcodeAlpha}"/></td>
</tr>
<tr>
<td>Value</td>
<td style="text-align:left">Value</td>
<td><input disabled="true" value="${voucher.value}"/></td>
<td style="text-align:center">Company Name</td>
<td style="text-align:left">Company Name</td>
<td><input disabled="true" value="${voucher.client.name}"/></td>
</tr>
<tr>
<td style="text-align:left">Valid Thru(dd/mm/yyyy)</td>
<td><input disabled="true" value= <g:formatDate date="${voucher.validThru}" format="dd/MM/yyyy"/>></td>
<td style="text-align:left">Remarks</td>
<td><textarea disabled="true">${voucher.voucherInvoice.remarks}</textarea></td>
</tr>
</table>
<g:hiddenField name="voucherId" value="${voucher.id}"/>
</g:if>
<g:elseif test="${voucherFound}">
<div id="message_box" style="text-align:center">
<g:if test="flash.message">
${flash.message}
</g:if>
</div>
</g:elseif>

56 changes: 4 additions & 52 deletions sql/001_BaseLine.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ create table item (id int8 not null, version int8 not null, description varchar(
create table purchase (id int8 not null, version int8 not null, created_by_id int8 not null, date_created timestamp not null, discount float8 not null, invoice_date timestamp not null, invoice_number int8 not null, item_id int8 not null, net_total float8 not null, shopped_at_id int8 not null, total_amount float8, primary key (id));
create table role (id int8 not null, version int8 not null, authority varchar(255) not null unique, description varchar(255) not null, primary key (id));
create table shop (id int8 not null, version int8 not null, name varchar(255) not null, primary key (id));
create table voucher (id int8 not null, version int8 not null, barcode_alpha varchar(10) not null, client_id int8 not null, created_by_id int8 not null, date_created date not null, last_updated timestamp not null, sequence_number int4 not null, sold_at_id int8, status varchar(255) not null, validated_at_id int8, value float8 not null, voucher_invoice_id int8 not null, primary key (id));
create table voucher_invoice (id int8 not null, version int8 not null, date_created timestamp not null, invoice_number int4 not null, invoiced_at_id int8 not null, primary key (id));
create table voucher (id int8 not null, version int8 not null, barcode_alpha varchar(10) not null, client_id int8 not null, created_by_id int8 not null, date_created date not null, last_updated timestamp not null, purchase_id int8, sequence_number int4 not null, sold_at_id int8, status varchar(255) not null, valid_thru timestamp not null, validated_at_id int8, value float8 not null, voucher_invoice_id int8 not null, primary key (id));
create table voucher_invoice (id int8 not null, version int8 not null, date_created timestamp not null, invoice_number int4 not null, invoiced_at_id int8 not null, remarks varchar(255), primary key (id));
create table voucher_invoice_sequence (id int8 not null, version int8 not null, last_squence_number int4 not null, shop_id int8 not null, primary key (id));
alter table app_user add constraint FK459C57295CDFF32F foreign key (shop_id) references shop;
alter table app_user_role add constraint FK9CE8F3CC33BC032F foreign key (role_id) references role;
Expand All @@ -18,58 +18,10 @@ alter table purchase add constraint FK67E90501C15CC36C foreign key (shopped_at_i
alter table purchase add constraint FK67E90501EAE57223 foreign key (created_by_id) references app_user;
alter table voucher add constraint FK26288EAEC44ED32 foreign key (voucher_invoice_id) references voucher_invoice;
alter table voucher add constraint FK26288EAEDE960761 foreign key (validated_at_id) references shop;
alter table voucher add constraint FK26288EAEA3C910CF foreign key (purchase_id) references purchase;
alter table voucher add constraint FK26288EAE95834DCF foreign key (client_id) references client;
alter table voucher add constraint FK26288EAECEC45A7 foreign key (sold_at_id) references shop;
alter table voucher add constraint FK26288EAEEAE57223 foreign key (created_by_id) references app_user;
alter table voucher_invoice add constraint FK3BA3EA9CF300A56A foreign key (invoiced_at_id) references shop;
alter table voucher_invoice_sequence add constraint FK7FB9EE045CDFF32F foreign key (shop_id) references shop;
create sequence hibernate_sequence;
--Data


insert into shop(id,version,name) values(1,1,'MG Trivandrum');
insert into shop(id,version,name) values(2,1,'MG Pathanamthitta');
insert into shop(id,version,name) values(3,1,'MG Kollam');
insert into shop(id,version,name) values(4,1,'MG Allappey');
insert into shop(id,version,name) values(5,1,'MG Kottayam');
insert into shop(id,version,name) values(6,1,'MG Thodupuzha');
insert into shop(id,version,name) values(7,1,'MG Cochin');
insert into shop(id,version,name) values(8,1,'MG Kodungaloor');
insert into shop(id,version,name) values(9,1,'MG Trichur');
insert into shop(id,version,name) values(10,1,'MG Palakkad');
insert into shop(id,version,name) values(11,1,'MG Edappal');
insert into shop(id,version,name) values(12,1,'MG Manjeri');
insert into shop(id,version,name) values(13,1,'MG Perinthalmanna');
insert into shop(id,version,name) values(14,1,'MG Tirur');
insert into shop(id,version,name) values(15,1,'MG Calicut');
insert into shop(id,version,name) values(16,1,'MG Vadakara');
insert into shop(id,version,name) values(17,1,'MG Sulthan Bathery');
insert into shop(id,version,name) values(18,1,'MG Thalesery');
insert into shop(id,version,name) values(19,1,'MG Kannur');
insert into shop(id,version,name) values(20,1,'MG Payyannur');
insert into shop(id,version,name) values(21,1,'MG Kanghangad');
insert into shop(id,version,name) values(22,1,'MG Kasargod');
insert into shop(id,version,name) values(23,1,'MG Coimbatore');
insert into shop(id,version,name) values(24,1,'MG Salem');
insert into shop(id,version,name) values(25,1,'MG Erode');
insert into shop(id,version,name) values(26,1,'MG Banglore');
insert into shop(id,version,name) values(27,1,'MG Banglore');
insert into shop(id,version,name) values(28,1,'MG Mysore');
insert into shop(id,version,name) values(29,1,'MG Mangalore');
insert into shop(id,version,name) values(30,1,'MG Hassan');
insert into shop(id,version,name) values(31,1,'MG Hyderabad');
insert into shop(id,version,name) values(32,1,'Breigns');

insert into role(id,version,authority,description) values (1,1,'ROLE_ADMIN','Admin User');
insert into role(id,version,authority,description) values (2,1,'ROLE_USER','Shop User');

INSERT INTO app_user(id, "version", account_expired, account_locked, date_created,enabled, first_name, last_name, last_updated, "password",
password_expired,username,shop_id)VALUES (0, 1, false, false, current_timestamp,true, 'Fanzeem', 'Ahmed', current_timestamp,'3723e615dd927e7534f2f4eafa71adae6df823219ee71265bae56ba5e6927f18', false,'admin',1);
insert into app_user_role(role_id, app_user_id )values(1,0);

INSERT INTO item (id, version, description,name,is_standard) values (1,1,'Gold Jewellery','GOLD',true);
INSERT INTO item (id, version, description,name,is_standard) values (2,1,'Diamond Jewellery','DIAMOND',true);
INSERT INTO item (id, version, description,name,is_standard) values (3,1,'Precious','Precious',true);
INSERT INTO item (id, version, description,name,is_standard) values (4,1,'Gold Coin','Gold Coin',true);
INSERT INTO item (id, version, description,name,is_standard) values (5,1,'Silver','Silver',true);
INSERT INTO item (id, version, description,name,is_standard) values (6,1,'Era','Era',true);
create sequence hibernate_sequence;
Loading

0 comments on commit b86c84d

Please sign in to comment.