From b86c84d36353a7e666e7390b011c39169f630b2e Mon Sep 17 00:00:00 2001 From: Shanu Date: Sat, 18 Dec 2010 12:54:07 +0530 Subject: [PATCH] Shanu: Enhancements going on --- build.xml | 6 +- .../vms/controller/AdminController.groovy | 12 ++-- .../domain/com/breigns/vms/Purchase.groovy | 3 +- .../domain/com/breigns/vms/Voucher.groovy | 4 +- .../com/breigns/vms/VoucherInvoice.groovy | 4 ++ .../breigns/vms/service/AdminService.groovy | 6 +- .../breigns/vms/service/VoucherService.groovy | 1 + .../vms/utility/BarCodeGenerator.groovy | 4 +- .../com/breigns/vms/utility/DateUtils.groovy | 11 ++++ grails-app/views/admin/createNewVoucher.gsp | 37 +++++++++--- grails-app/views/admin/voucherReport.gsp | 1 + grails-app/views/voucher/searchVoucher.gsp | 1 - grails-app/views/voucher/voucherDetails.gsp | 29 +++++++--- sql/001_BaseLine.sql | 56 ++----------------- sql/metadata.sql | 47 ++++++++++++++++ .../vms/VoucherCreationRequestModel.groovy | 3 +- 16 files changed, 142 insertions(+), 83 deletions(-) create mode 100644 grails-app/utils/com/breigns/vms/utility/DateUtils.groovy create mode 100644 sql/metadata.sql diff --git a/build.xml b/build.xml index 0b2627a..75e52ca 100644 --- a/build.xml +++ b/build.xml @@ -25,7 +25,7 @@ password="${db.password}" src="@{src}" onerror="@{onerror}" - delimiter=";" + delimiter=";" /> @@ -38,6 +38,10 @@ + + + + vouchers Item item; Double totalAmount Double discount Double netTotal - + static hasMany = [vouchers:Voucher] static constraints = { totalAmount(nullable:true) totalAmount(discount:true) diff --git a/grails-app/domain/com/breigns/vms/Voucher.groovy b/grails-app/domain/com/breigns/vms/Voucher.groovy index 5fecd96..cfae96e 100644 --- a/grails-app/domain/com/breigns/vms/Voucher.groovy +++ b/grails-app/domain/com/breigns/vms/Voucher.groovy @@ -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() { diff --git a/grails-app/domain/com/breigns/vms/VoucherInvoice.groovy b/grails-app/domain/com/breigns/vms/VoucherInvoice.groovy index d765857..085e3d4 100644 --- a/grails-app/domain/com/breigns/vms/VoucherInvoice.groovy +++ b/grails-app/domain/com/breigns/vms/VoucherInvoice.groovy @@ -3,5 +3,9 @@ package com.breigns.vms class VoucherInvoice { Shop invoicedAt; Integer invoiceNumber; + String remarks Date dateCreated; + static constraints = { + remarks(nullable: true) + } } diff --git a/grails-app/services/com/breigns/vms/service/AdminService.groovy b/grails-app/services/com/breigns/vms/service/AdminService.groovy index c165b6a..00faf49 100644 --- a/grails-app/services/com/breigns/vms/service/AdminService.groovy +++ b/grails-app/services/com/breigns/vms/service/AdminService.groovy @@ -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; @@ -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) { diff --git a/grails-app/services/com/breigns/vms/service/VoucherService.groovy b/grails-app/services/com/breigns/vms/service/VoucherService.groovy index 0565f59..f7ba2ca 100644 --- a/grails-app/services/com/breigns/vms/service/VoucherService.groovy +++ b/grails-app/services/com/breigns/vms/service/VoucherService.groovy @@ -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() diff --git a/grails-app/utils/com/breigns/vms/utility/BarCodeGenerator.groovy b/grails-app/utils/com/breigns/vms/utility/BarCodeGenerator.groovy index 12ae030..c587f60 100644 --- a/grails-app/utils/com/breigns/vms/utility/BarCodeGenerator.groovy +++ b/grails-app/utils/com/breigns/vms/utility/BarCodeGenerator.groovy @@ -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()) } diff --git a/grails-app/utils/com/breigns/vms/utility/DateUtils.groovy b/grails-app/utils/com/breigns/vms/utility/DateUtils.groovy new file mode 100644 index 0000000..9c07a88 --- /dev/null +++ b/grails-app/utils/com/breigns/vms/utility/DateUtils.groovy @@ -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) + } +} diff --git a/grails-app/views/admin/createNewVoucher.gsp b/grails-app/views/admin/createNewVoucher.gsp index bfea3df..ce1ca9c 100644 --- a/grails-app/views/admin/createNewVoucher.gsp +++ b/grails-app/views/admin/createNewVoucher.gsp @@ -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; } @@ -66,13 +74,15 @@
-
    -
  • -
  • -
  • -
  • -
  • -
+ + + + + + + + +
No Of VouchersVoucher Value

Voucher Creation List

@@ -93,7 +103,18 @@
-
+
+ + + + + + + + +
Valid Thru(dd/mm/yyyy)Remarks
+ +
diff --git a/grails-app/views/admin/voucherReport.gsp b/grails-app/views/admin/voucherReport.gsp index f531e68..2f9a6b4 100644 --- a/grails-app/views/admin/voucherReport.gsp +++ b/grails-app/views/admin/voucherReport.gsp @@ -55,5 +55,6 @@ +
Test
\ No newline at end of file diff --git a/grails-app/views/voucher/searchVoucher.gsp b/grails-app/views/voucher/searchVoucher.gsp index 995ebfb..ca1f336 100644 --- a/grails-app/views/voucher/searchVoucher.gsp +++ b/grails-app/views/voucher/searchVoucher.gsp @@ -21,7 +21,6 @@
  • -
  • diff --git a/grails-app/views/voucher/voucherDetails.gsp b/grails-app/views/voucher/voucherDetails.gsp index 2ca3244..45ee0e0 100644 --- a/grails-app/views/voucher/voucherDetails.gsp +++ b/grails-app/views/voucher/voucherDetails.gsp @@ -1,23 +1,34 @@ -
    - - ${flash.message} - -
    +
    +

    Voucher Found

    +
    - + - + - + - + + + + + + +
    Sequence NumberSequence Number Bar CodeBar Code
    ValueValue Company NameCompany Name
    Valid Thru(dd/mm/yyyy)>Remarks
    + +
    + + ${flash.message} + +
    +
    diff --git a/sql/001_BaseLine.sql b/sql/001_BaseLine.sql index dac8f5b..bc386e8 100644 --- a/sql/001_BaseLine.sql +++ b/sql/001_BaseLine.sql @@ -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; @@ -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); \ No newline at end of file +create sequence hibernate_sequence; \ No newline at end of file diff --git a/sql/metadata.sql b/sql/metadata.sql new file mode 100644 index 0000000..6432151 --- /dev/null +++ b/sql/metadata.sql @@ -0,0 +1,47 @@ + +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); \ No newline at end of file diff --git a/src/groovy/com/breigns/vms/VoucherCreationRequestModel.groovy b/src/groovy/com/breigns/vms/VoucherCreationRequestModel.groovy index 1f66920..73b8784 100644 --- a/src/groovy/com/breigns/vms/VoucherCreationRequestModel.groovy +++ b/src/groovy/com/breigns/vms/VoucherCreationRequestModel.groovy @@ -4,5 +4,6 @@ class VoucherCreationRequestModel { Long shopId; Long clientId; List voucherList; - + Date validThru + String remarks }