From 6699c75ed8ab6a7f332b096055d7781ef5a27a23 Mon Sep 17 00:00:00 2001 From: shameem_z Date: Thu, 20 Sep 2007 06:16:18 +0000 Subject: [PATCH] Initial commit of Posterita --- .../posterita/factory/AbstractFactory.java | 241 + .../factory/DBPropertiesManager.java | 88 + .../org/posterita/factory/DunningFactory.java | 86 + .../GenericProductAttributeFactory.java | 92 + .../GenericProductAttributeSetFactory.java | 70 + .../factory/GenericSystemObjectsFactory.java | 135 + .../org/posterita/factory/MenuGenerator.java | 93 + .../org/posterita/factory/POSMenuFactory.java | 568 ++ .../org/posterita/factory/ProcessFactory.java | 96 + .../factory/ProductAttributeFactory.java | 162 + .../factory/ProductAttributeSetFactory.java | 80 + .../factory/ProductAttributeUseFactory.java | 107 + .../factory/SystemObjectsFactory.java | 205 + .../org/posterita/factory/UserFactory.java | 92 + .../posterita/factory/UserRoleFactory.java | 86 + .../org/posterita/factory/WebProperties.java | 35 + .../org/posterita/form/AttachmentForm.java | 39 + .../org/posterita/form/AttributeForm.java | 41 + .../posterita/form/AttributeValuesForm.java | 39 + .../org/posterita/form/BPartnerInfoForm.java | 42 + .../src/main/org/posterita/form/BankForm.java | 40 + .../org/posterita/form/BlackListForm.java | 40 + .../posterita/form/CashBookDetailForm.java | 42 + .../src/main/org/posterita/form/CashForm.java | 41 + .../form/ChangeDocumentStatusForm.java | 37 + .../posterita/form/ChangePasswordForm.java | 41 + .../org/posterita/form/CommissionForm.java | 37 + .../posterita/form/CreateBPartnerForm.java | 42 + .../posterita/form/CreateBankAccountForm.java | 40 + .../org/posterita/form/CreateLocatorForm.java | 40 + .../form/CreateProductAttributeForm.java | 40 + .../form/CreateProductAttributeValueForm.java | 40 + .../org/posterita/form/CreateUserForm.java | 44 + .../posterita/form/CreateWarehouseForm.java | 41 + .../org/posterita/form/CreditCardForm.java | 43 + .../posterita/form/CurrenrPOSBalanceForm.java | 41 + .../form/CustomerAndCreditCardForm.java | 46 + .../main/org/posterita/form/CustomerForm.java | 48 + .../org/posterita/form/DateFilterForm.java | 42 + .../main/org/posterita/form/DocumentForm.java | 41 + .../posterita/form/DocumentHistoryForm.java | 41 + .../main/org/posterita/form/DunningForm.java | 42 + .../org/posterita/form/EditAttributeForm.java | 40 + .../org/posterita/form/EditPriceListForm.java | 39 + .../org/posterita/form/EditProductForm.java | 41 + .../main/org/posterita/form/GarmentForm.java | 41 + .../posterita/form/GeneralPaymentForm.java | 16 + .../posterita/form/GenericProductForm.java | 38 + .../org/posterita/form/InOutHistoryForm.java | 38 + .../org/posterita/form/InitCustomerForm.java | 40 + .../org/posterita/form/InventoryForm.java | 42 + .../posterita/form/InvoiceHistoryForm.java | 38 + .../org/posterita/form/InvokeOrderForm.java | 41 + .../src/main/org/posterita/form/ItemForm.java | 38 + .../main/org/posterita/form/LoginForm.java | 41 + .../org/posterita/form/LoginUserForm.java | 39 + .../main/org/posterita/form/MenuItemForm.java | 40 + .../main/org/posterita/form/OpenItemForm.java | 42 + .../main/org/posterita/form/OrderForm.java | 39 + .../org/posterita/form/OrderHistoryForm.java | 40 + .../org/posterita/form/OrderLineForm.java | 40 + .../src/main/org/posterita/form/OrgForm.java | 39 + .../main/org/posterita/form/OrgTypeForm.java | 40 + .../posterita/form/POSDescriptionForm.java | 42 + .../src/main/org/posterita/form/POSForm.java | 43 + .../org/posterita/form/POSHistoryForm.java | 65 + .../main/org/posterita/form/POSInfoForm.java | 41 + .../org/posterita/form/POSOrderLineForm2.java | 42 + .../org/posterita/form/POSProductForm.java | 18 + .../org/posterita/form/POSReportForm.java | 42 + .../main/org/posterita/form/POSStockForm.java | 42 + .../org/posterita/form/POSSupplierForm.java | 42 + .../posterita/form/PaymentAllocationForm.java | 42 + .../main/org/posterita/form/PaymentForm.java | 38 + .../posterita/form/PaymentHistoryForm.java | 38 + .../org/posterita/form/PaymentTermForm.java | 61 + .../org/posterita/form/PaymentTermForm2.java | 42 + .../org/posterita/form/PriceCheckForm.java | 37 + .../org/posterita/form/PriceListForm.java | 39 + .../posterita/form/ProductAttributeForm.java | 39 + .../form/ProductAttributeValueForm.java | 39 + .../posterita/form/ProductDetailInfoForm.java | 40 + .../main/org/posterita/form/ProductForm.java | 41 + .../org/posterita/form/ProductImageForm.java | 39 + .../posterita/form/ProductKeywordsForm.java | 39 + .../form/ProductRestrictionForm.java | 38 + .../org/posterita/form/ProductSearchForm.java | 41 + .../org/posterita/form/ProductStatusForm.java | 38 + .../org/posterita/form/RemoveSessionForm.java | 42 + .../main/org/posterita/form/ReportForm.java | 41 + .../org/posterita/form/ReportImageForm.java | 38 + .../form/ReportSummaryHistoryForm.java | 40 + .../src/main/org/posterita/form/RoleForm.java | 39 + .../form/SalesAnalysisReportForm.java | 39 + .../org/posterita/form/SalesReportForm.java | 39 + .../org/posterita/form/SearchProductForm.java | 39 + .../form/SetApplicationParametersForm.java | 37 + .../main/org/posterita/form/ShipperForm.java | 39 + .../posterita/form/SingleDateFilterForm.java | 44 + .../main/org/posterita/form/StockForm.java | 38 + .../form/SynchronizeCollectionsForm.java | 38 + .../src/main/org/posterita/form/TaxForm.java | 41 + .../src/main/org/posterita/form/UserForm.java | 40 + .../main/org/posterita/form/VendorForm.java | 19 + .../org/posterita/form/ViewBPartnerForm.java | 38 + .../org/posterita/form/ViewProductForm.java | 40 + .../main/org/posterita/form/ViewTaxForm.java | 40 + .../posterita/form/WarehouseDetailsForm.java | 38 + .../formatter/ArrayListFormatter.java | 51 + .../formatter/BigDecimalArrayFormatter.java | 49 + .../formatter/BigDecimalFormatter.java | 57 + .../posterita/formatter/BooleanFormatter.java | 50 + .../posterita/formatter/DefaultFormatter.java | 42 + .../posterita/formatter/DoubleFormatter.java | 48 + .../org/posterita/formatter/Formatter.java | 74 + .../posterita/formatter/IntegerFormatter.java | 47 + .../formatter/JulianDateFormatter.java | 82 + .../posterita/formatter/LongFormatter.java | 48 + .../posterita/formatter/PriceFormatter.java | 42 + .../posterita/formatter/PrintFormatter.java | 70 + .../formatter/ReflectionFormatter.java | 45 + .../SimpleCalendarDateFormatter.java | 84 + .../formatter/StringArrayFormatter.java | 48 + .../posterita/formatter/StringFormatter.java | 45 + .../posterita/formatter/TimeFormatter.java | 39 + .../keyname/AttributeValueKeyNamePair.java | 91 + .../keyname/BPartnerKeyNamePair.java | 52 + .../posterita/keyname/BankKeyNamePair.java | 48 + .../keyname/CBPartnerKeyNamePair.java | 108 + .../posterita/keyname/LocatorKeyNamePair.java | 102 + .../posterita/keyname/MenuKeyNamePair.java | 53 + .../org/posterita/keyname/OrgKeyNamePair.java | 62 + .../keyname/PriceListVersionKeyNamePair.java | 47 + .../keyname/ProductAttributeKeyNamePair.java | 50 + .../ProductAttributeSetKeyNamePair.java | 50 + .../ProductAttributeValueKeyNamePair.java | 51 + .../posterita/keyname/RegionKeyNamePair.java | 48 + .../posterita/keyname/RoleKeyNamePair.java | 50 + .../keyname/SalesRepKeyNamePair.java | 104 + .../keyname/WarehouseKeyNamePair.java | 71 + .../org/posterita/lib/PropertiesConstant.java | 129 + .../main/org/posterita/lib/UdiConstants.java | 93 + .../org/posterita/model/MBPartnerProduct.java | 43 + .../src/main/org/posterita/model/MBank.java | 44 + .../org/posterita/model/MBlackListCheque.java | 39 + .../org/posterita/model/MMAttachment.java | 81 + .../src/main/org/posterita/model/MMenu.java | 44 + .../main/org/posterita/model/MRoleMenu.java | 41 + .../org/posterita/model/MWebProperties.java | 43 + .../posterita/model/M_RevenueRecognition.java | 43 + .../posterita/model/TMKMBlackListCheque.java | 39 + .../main/org/posterita/model/TMKMCost.java | 40 + .../org/posterita/model/TMKMSequence.java | 43 + .../posterita/model/UDIBPartnerOrgLink.java | 50 + .../org/posterita/model/UDIMAssetGroup.java | 38 + .../org/posterita/model/UDIMAttachment.java | 46 + .../org/posterita/model/UDIMAttribute.java | 38 + .../model/UDIMAttributeInstance.java | 37 + .../org/posterita/model/UDIMAttributeSet.java | 37 + .../model/UDIMAttributeSetInstance.java | 39 + .../org/posterita/model/UDIMAttributeUse.java | 86 + .../posterita/model/UDIMAttributeValue.java | 38 + .../posterita/model/UDIMBPBankAccount.java | 40 + .../main/org/posterita/model/UDIMBPGroup.java | 40 + .../org/posterita/model/UDIMBPartner.java | 40 + .../posterita/model/UDIMBPartnerLocation.java | 42 + .../main/org/posterita/model/UDIMBank.java | 37 + .../org/posterita/model/UDIMBankAccount.java | 39 + .../main/org/posterita/model/UDIMCash.java | 58 + .../org/posterita/model/UDIMCashBook.java | 43 + .../org/posterita/model/UDIMCashLine.java | 44 + .../main/org/posterita/model/UDIMCharge.java | 42 + .../main/org/posterita/model/UDIMClient.java | 36 + .../org/posterita/model/UDIMCommission.java | 40 + .../posterita/model/UDIMCommissionLine.java | 40 + .../posterita/model/UDIMDiscountSchema.java | 36 + .../main/org/posterita/model/UDIMDocType.java | 41 + .../main/org/posterita/model/UDIMDunning.java | 41 + .../org/posterita/model/UDIMDunningLevel.java | 40 + .../org/posterita/model/UDIMDunningRun.java | 40 + .../main/org/posterita/model/UDIMInOut.java | 55 + .../org/posterita/model/UDIMInOutLine.java | 40 + .../model/UDIMInoutLineConfirmation.java | 39 + .../org/posterita/model/UDIMInventory.java | 57 + .../posterita/model/UDIMInventoryLine.java | 41 + .../main/org/posterita/model/UDIMInvoice.java | 61 + .../org/posterita/model/UDIMInvoiceLine.java | 39 + .../org/posterita/model/UDIMLocation.java | 45 + .../main/org/posterita/model/UDIMLocator.java | 39 + .../org/posterita/model/UDIMMailText.java | 38 + .../org/posterita/model/UDIMMovement.java | 65 + .../org/posterita/model/UDIMMovementLine.java | 34 + .../model/UDIMMovementLineOverride.java | 34 + .../main/org/posterita/model/UDIMOrder.java | 78 + .../org/posterita/model/UDIMOrderLine.java | 55 + .../src/main/org/posterita/model/UDIMOrg.java | 66 + .../main/org/posterita/model/UDIMOrgInfo.java | 39 + .../src/main/org/posterita/model/UDIMPOS.java | 42 + .../main/org/posterita/model/UDIMPayment.java | 53 + .../org/posterita/model/UDIMPaymentTerm.java | 41 + .../main/org/posterita/model/UDIMPeriod.java | 38 + .../posterita/model/UDIMPeriodControl.java | 37 + .../org/posterita/model/UDIMPriceList.java | 38 + .../posterita/model/UDIMPriceListVersion.java | 47 + .../posterita/model/UDIMPrintFormatItem.java | 40 + .../main/org/posterita/model/UDIMProcess.java | 37 + .../main/org/posterita/model/UDIMProduct.java | 52 + .../posterita/model/UDIMProductCategory.java | 47 + .../org/posterita/model/UDIMProductPrice.java | 37 + .../main/org/posterita/model/UDIMRegion.java | 39 + .../main/org/posterita/model/UDIMRequest.java | 41 + .../org/posterita/model/UDIMRequestType.java | 42 + .../posterita/model/UDIMRequestUpdate.java | 42 + .../model/UDIMRevenueRecognition.java | 37 + .../main/org/posterita/model/UDIMRole.java | 37 + .../main/org/posterita/model/UDIMShipper.java | 37 + .../main/org/posterita/model/UDIMStorage.java | 37 + .../main/org/posterita/model/UDIMStore.java | 43 + .../src/main/org/posterita/model/UDIMTax.java | 45 + .../org/posterita/model/UDIMTaxCategory.java | 37 + .../org/posterita/model/UDIMTransaction.java | 38 + .../src/main/org/posterita/model/UDIMUOM.java | 37 + .../main/org/posterita/model/UDIMUser.java | 38 + .../org/posterita/model/UDIMUserMail.java | 38 + .../posterita/model/UDIMUserOrgAccess.java | 38 + .../org/posterita/model/UDIMUserRoles.java | 37 + .../org/posterita/model/UDIMWarehouse.java | 38 + .../main/org/posterita/model/UDIMYear.java | 38 + .../org/posterita/model/UDIMinoutConfirm.java | 57 + .../main/org/posterita/model/UDIOrgType.java | 37 + .../src/main/org/posterita/model/UDIPO.java | 83 + .../main/org/posterita/model/UDIU_Menu.java | 123 + .../org/posterita/model/UDIU_RoleMenu.java | 38 + .../org/posterita/order/UDIOrderType.java | 26 + .../org/posterita/order/UDIOrderTypes.java | 195 + .../org/posterita/pos/taglib/ElementTag.java | 127 + .../org/posterita/process/UpdateRoleMenu.java | 119 + .../struts/admin/CheckSequenceAction.java | 67 + .../posterita/struts/admin/RoleAction.java | 196 + .../struts/attachment/AttachmentAction.java | 126 + .../attachment/ImageAttachmentAction.java | 54 + .../struts/attributes/AttributesAction.java | 136 + .../struts/bPartner/BPartnerAction.java | 229 + .../struts/bPartner/ViewBPartnerAction.java | 130 + .../org/posterita/struts/core/BaseAction.java | 135 + .../struts/core/BaseDispatchAction.java | 138 + .../org/posterita/struts/core/BaseForm.java | 963 ++++ .../posterita/struts/core/DefaultForm.java | 4674 +++++++++++++++++ .../struts/customer/CustomerAction.java | 760 +++ .../struts/customer/SalesAction.java | 94 + .../struts/inOut/ViewMinOutAction.java | 107 + .../struts/invoice/ViewInvoiceAction.java | 190 + .../struts/login/ChangePasswordAction.java | 78 + .../struts/login/GoToHomePageAction.java | 111 + .../posterita/struts/login/LoginAction.java | 480 ++ .../struts/login/POSLoginAction.java | 177 + .../struts/menu/CloseMenuAction.java | 89 + .../org/posterita/struts/menu/MenuAction.java | 318 ++ .../struts/order/CompletePOSOrderAction.java | 72 + .../struts/order/ViewOrderAction.java | 307 ++ .../posterita/struts/pos/BarcodeAction.java | 54 + .../struts/pos/BlackListedAction.java | 232 + .../struts/pos/BpartnerInfoAction.java | 98 + .../org/posterita/struts/pos/CashAction.java | 133 + .../posterita/struts/pos/CashBookAction.java | 383 ++ .../struts/pos/CommissionAction.java | 114 + .../struts/pos/CreditOrderAction.java | 721 +++ .../struts/pos/CustomPOSReportAction.java | 371 ++ .../struts/pos/CustomerReturnOrderAction.java | 78 + .../posterita/struts/pos/DocumentAction.java | 188 + .../posterita/struts/pos/DunningAction.java | 80 + .../pos/EditBulkProductFromFileAction.java | 265 + .../pos/FastMovingItemReportAction.java | 126 + .../posterita/struts/pos/GetReportAction.java | 103 + .../struts/pos/GoodsReceiveNoteAction.java | 90 + .../struts/pos/GoodsReturnNoteAction.java | 77 + .../struts/pos/ImportCustomerAction.java | 98 + .../struts/pos/ImportPOSProductAction.java | 111 + .../posterita/struts/pos/InventoryAction.java | 380 ++ .../org/posterita/struts/pos/POSAction.java | 50 + .../struts/pos/POSAttributesAction.java | 140 + .../struts/pos/POSDispatchAction.java | 46 + .../posterita/struts/pos/POSGoodsAction.java | 1390 +++++ .../posterita/struts/pos/POSInfoAction.java | 206 + .../posterita/struts/pos/POSOrderAction.java | 1533 ++++++ .../struts/pos/POSPriceListAction.java | 152 + .../struts/pos/POSProductAction.java | 870 +++ .../posterita/struts/pos/POSReportAction.java | 336 ++ .../posterita/struts/pos/POSRoleAction.java | 281 + .../struts/pos/POSSalesReportAction.java | 303 ++ .../posterita/struts/pos/POSStockAction.java | 135 + .../posterita/struts/pos/POSUserAction.java | 286 + .../struts/pos/PartialPOSOrderAction.java | 754 +++ .../posterita/struts/pos/PaymentAction.java | 132 + .../struts/pos/PaymentTermAction.java | 237 + .../struts/pos/SalesAnalysisReportAction.java | 173 + .../struts/pos/SearchCustomerAction.java | 123 + .../struts/pos/SearchPOSProductAction.java | 57 + .../struts/pos/SearchProductAction.java | 97 + .../struts/pos/SearchVendorAction.java | 123 + .../pos/SlowMovingItemReportAction.java | 125 + .../struts/pos/StockMovementReportAction.java | 205 + .../org/posterita/struts/pos/TaxAction.java | 247 + .../posterita/struts/pos/VendorAction.java | 275 + .../struts/product/PriceListAction.java | 241 + .../posterita/struts/stock/StockAction.java | 237 + .../struts/user/CreateUserAction.java | 116 + .../org/posterita/struts/user/UserAction.java | 262 + .../main/org/posterita/taglib/BankName.java | 92 + .../main/org/posterita/taglib/LinkAccess.java | 40 + .../org/posterita/taglib/OrderStatus.java | 128 + .../org/posterita/taglib/ProductName.java | 94 + .../main/org/posterita/user/WebUserInfo.java | 318 ++ .../util/AbstractPrintFormatter.java | 176 + .../org/posterita/util/BarcodeFormatter.java | 154 + .../org/posterita/util/IPrintFormatter.java | 33 + .../org/posterita/util/InvoiceFormatter.java | 308 ++ .../src/main/org/posterita/util/ListUtil.java | 44 + .../org/posterita/util/MinOutFormatter.java | 44 + .../org/posterita/util/OrderFormatter.java | 524 ++ .../src/main/org/posterita/util/PathInfo.java | 50 + .../org/posterita/util/PaymentFormatter.java | 43 + .../main/org/posterita/util/PoManager.java | 72 + .../org/posterita/util/RegenerateModels.java | 119 + .../util/TMKInvoicePrintFormatter.java | 439 ++ .../util/TMKOrderPrintFormatter.java | 641 +++ .../main/org/posterita/util/TmkPrintUtil.java | 71 + .../posterita/util/TmkPrinterConstants.java | 79 + .../action/DocumentHistoryAction.java | 136 + .../action/ViewCashPaymentAction.java | 101 + .../webstore/action/ViewPaymentAction.java | 109 + .../businesslogic/DocumentHistoryManager.java | 184 + .../businesslogic/PaymentManager.java | 258 + 333 files changed, 39293 insertions(+) create mode 100644 posterita/src/main/org/posterita/factory/AbstractFactory.java create mode 100644 posterita/src/main/org/posterita/factory/DBPropertiesManager.java create mode 100644 posterita/src/main/org/posterita/factory/DunningFactory.java create mode 100644 posterita/src/main/org/posterita/factory/GenericProductAttributeFactory.java create mode 100644 posterita/src/main/org/posterita/factory/GenericProductAttributeSetFactory.java create mode 100644 posterita/src/main/org/posterita/factory/GenericSystemObjectsFactory.java create mode 100644 posterita/src/main/org/posterita/factory/MenuGenerator.java create mode 100644 posterita/src/main/org/posterita/factory/POSMenuFactory.java create mode 100644 posterita/src/main/org/posterita/factory/ProcessFactory.java create mode 100644 posterita/src/main/org/posterita/factory/ProductAttributeFactory.java create mode 100644 posterita/src/main/org/posterita/factory/ProductAttributeSetFactory.java create mode 100644 posterita/src/main/org/posterita/factory/ProductAttributeUseFactory.java create mode 100644 posterita/src/main/org/posterita/factory/SystemObjectsFactory.java create mode 100644 posterita/src/main/org/posterita/factory/UserFactory.java create mode 100644 posterita/src/main/org/posterita/factory/UserRoleFactory.java create mode 100644 posterita/src/main/org/posterita/factory/WebProperties.java create mode 100644 posterita/src/main/org/posterita/form/AttachmentForm.java create mode 100644 posterita/src/main/org/posterita/form/AttributeForm.java create mode 100644 posterita/src/main/org/posterita/form/AttributeValuesForm.java create mode 100644 posterita/src/main/org/posterita/form/BPartnerInfoForm.java create mode 100644 posterita/src/main/org/posterita/form/BankForm.java create mode 100644 posterita/src/main/org/posterita/form/BlackListForm.java create mode 100644 posterita/src/main/org/posterita/form/CashBookDetailForm.java create mode 100644 posterita/src/main/org/posterita/form/CashForm.java create mode 100644 posterita/src/main/org/posterita/form/ChangeDocumentStatusForm.java create mode 100644 posterita/src/main/org/posterita/form/ChangePasswordForm.java create mode 100644 posterita/src/main/org/posterita/form/CommissionForm.java create mode 100644 posterita/src/main/org/posterita/form/CreateBPartnerForm.java create mode 100644 posterita/src/main/org/posterita/form/CreateBankAccountForm.java create mode 100644 posterita/src/main/org/posterita/form/CreateLocatorForm.java create mode 100644 posterita/src/main/org/posterita/form/CreateProductAttributeForm.java create mode 100644 posterita/src/main/org/posterita/form/CreateProductAttributeValueForm.java create mode 100644 posterita/src/main/org/posterita/form/CreateUserForm.java create mode 100644 posterita/src/main/org/posterita/form/CreateWarehouseForm.java create mode 100644 posterita/src/main/org/posterita/form/CreditCardForm.java create mode 100644 posterita/src/main/org/posterita/form/CurrenrPOSBalanceForm.java create mode 100644 posterita/src/main/org/posterita/form/CustomerAndCreditCardForm.java create mode 100644 posterita/src/main/org/posterita/form/CustomerForm.java create mode 100644 posterita/src/main/org/posterita/form/DateFilterForm.java create mode 100644 posterita/src/main/org/posterita/form/DocumentForm.java create mode 100644 posterita/src/main/org/posterita/form/DocumentHistoryForm.java create mode 100644 posterita/src/main/org/posterita/form/DunningForm.java create mode 100644 posterita/src/main/org/posterita/form/EditAttributeForm.java create mode 100644 posterita/src/main/org/posterita/form/EditPriceListForm.java create mode 100644 posterita/src/main/org/posterita/form/EditProductForm.java create mode 100644 posterita/src/main/org/posterita/form/GarmentForm.java create mode 100644 posterita/src/main/org/posterita/form/GeneralPaymentForm.java create mode 100644 posterita/src/main/org/posterita/form/GenericProductForm.java create mode 100644 posterita/src/main/org/posterita/form/InOutHistoryForm.java create mode 100644 posterita/src/main/org/posterita/form/InitCustomerForm.java create mode 100644 posterita/src/main/org/posterita/form/InventoryForm.java create mode 100644 posterita/src/main/org/posterita/form/InvoiceHistoryForm.java create mode 100644 posterita/src/main/org/posterita/form/InvokeOrderForm.java create mode 100644 posterita/src/main/org/posterita/form/ItemForm.java create mode 100644 posterita/src/main/org/posterita/form/LoginForm.java create mode 100644 posterita/src/main/org/posterita/form/LoginUserForm.java create mode 100644 posterita/src/main/org/posterita/form/MenuItemForm.java create mode 100644 posterita/src/main/org/posterita/form/OpenItemForm.java create mode 100644 posterita/src/main/org/posterita/form/OrderForm.java create mode 100644 posterita/src/main/org/posterita/form/OrderHistoryForm.java create mode 100644 posterita/src/main/org/posterita/form/OrderLineForm.java create mode 100644 posterita/src/main/org/posterita/form/OrgForm.java create mode 100644 posterita/src/main/org/posterita/form/OrgTypeForm.java create mode 100644 posterita/src/main/org/posterita/form/POSDescriptionForm.java create mode 100644 posterita/src/main/org/posterita/form/POSForm.java create mode 100644 posterita/src/main/org/posterita/form/POSHistoryForm.java create mode 100644 posterita/src/main/org/posterita/form/POSInfoForm.java create mode 100644 posterita/src/main/org/posterita/form/POSOrderLineForm2.java create mode 100644 posterita/src/main/org/posterita/form/POSProductForm.java create mode 100644 posterita/src/main/org/posterita/form/POSReportForm.java create mode 100644 posterita/src/main/org/posterita/form/POSStockForm.java create mode 100644 posterita/src/main/org/posterita/form/POSSupplierForm.java create mode 100644 posterita/src/main/org/posterita/form/PaymentAllocationForm.java create mode 100644 posterita/src/main/org/posterita/form/PaymentForm.java create mode 100644 posterita/src/main/org/posterita/form/PaymentHistoryForm.java create mode 100644 posterita/src/main/org/posterita/form/PaymentTermForm.java create mode 100644 posterita/src/main/org/posterita/form/PaymentTermForm2.java create mode 100644 posterita/src/main/org/posterita/form/PriceCheckForm.java create mode 100644 posterita/src/main/org/posterita/form/PriceListForm.java create mode 100644 posterita/src/main/org/posterita/form/ProductAttributeForm.java create mode 100644 posterita/src/main/org/posterita/form/ProductAttributeValueForm.java create mode 100644 posterita/src/main/org/posterita/form/ProductDetailInfoForm.java create mode 100644 posterita/src/main/org/posterita/form/ProductForm.java create mode 100644 posterita/src/main/org/posterita/form/ProductImageForm.java create mode 100644 posterita/src/main/org/posterita/form/ProductKeywordsForm.java create mode 100644 posterita/src/main/org/posterita/form/ProductRestrictionForm.java create mode 100644 posterita/src/main/org/posterita/form/ProductSearchForm.java create mode 100644 posterita/src/main/org/posterita/form/ProductStatusForm.java create mode 100644 posterita/src/main/org/posterita/form/RemoveSessionForm.java create mode 100644 posterita/src/main/org/posterita/form/ReportForm.java create mode 100644 posterita/src/main/org/posterita/form/ReportImageForm.java create mode 100644 posterita/src/main/org/posterita/form/ReportSummaryHistoryForm.java create mode 100644 posterita/src/main/org/posterita/form/RoleForm.java create mode 100644 posterita/src/main/org/posterita/form/SalesAnalysisReportForm.java create mode 100644 posterita/src/main/org/posterita/form/SalesReportForm.java create mode 100644 posterita/src/main/org/posterita/form/SearchProductForm.java create mode 100644 posterita/src/main/org/posterita/form/SetApplicationParametersForm.java create mode 100644 posterita/src/main/org/posterita/form/ShipperForm.java create mode 100644 posterita/src/main/org/posterita/form/SingleDateFilterForm.java create mode 100644 posterita/src/main/org/posterita/form/StockForm.java create mode 100644 posterita/src/main/org/posterita/form/SynchronizeCollectionsForm.java create mode 100644 posterita/src/main/org/posterita/form/TaxForm.java create mode 100644 posterita/src/main/org/posterita/form/UserForm.java create mode 100644 posterita/src/main/org/posterita/form/VendorForm.java create mode 100644 posterita/src/main/org/posterita/form/ViewBPartnerForm.java create mode 100644 posterita/src/main/org/posterita/form/ViewProductForm.java create mode 100644 posterita/src/main/org/posterita/form/ViewTaxForm.java create mode 100644 posterita/src/main/org/posterita/form/WarehouseDetailsForm.java create mode 100644 posterita/src/main/org/posterita/formatter/ArrayListFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/BigDecimalArrayFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/BigDecimalFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/BooleanFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/DefaultFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/DoubleFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/Formatter.java create mode 100644 posterita/src/main/org/posterita/formatter/IntegerFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/JulianDateFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/LongFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/PriceFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/PrintFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/ReflectionFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/SimpleCalendarDateFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/StringArrayFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/StringFormatter.java create mode 100644 posterita/src/main/org/posterita/formatter/TimeFormatter.java create mode 100644 posterita/src/main/org/posterita/keyname/AttributeValueKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/BPartnerKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/BankKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/CBPartnerKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/LocatorKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/MenuKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/OrgKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/PriceListVersionKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/ProductAttributeKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/ProductAttributeSetKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/ProductAttributeValueKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/RegionKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/RoleKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/SalesRepKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/keyname/WarehouseKeyNamePair.java create mode 100644 posterita/src/main/org/posterita/lib/PropertiesConstant.java create mode 100644 posterita/src/main/org/posterita/lib/UdiConstants.java create mode 100644 posterita/src/main/org/posterita/model/MBPartnerProduct.java create mode 100644 posterita/src/main/org/posterita/model/MBank.java create mode 100644 posterita/src/main/org/posterita/model/MBlackListCheque.java create mode 100644 posterita/src/main/org/posterita/model/MMAttachment.java create mode 100644 posterita/src/main/org/posterita/model/MMenu.java create mode 100644 posterita/src/main/org/posterita/model/MRoleMenu.java create mode 100644 posterita/src/main/org/posterita/model/MWebProperties.java create mode 100644 posterita/src/main/org/posterita/model/M_RevenueRecognition.java create mode 100644 posterita/src/main/org/posterita/model/TMKMBlackListCheque.java create mode 100644 posterita/src/main/org/posterita/model/TMKMCost.java create mode 100644 posterita/src/main/org/posterita/model/TMKMSequence.java create mode 100644 posterita/src/main/org/posterita/model/UDIBPartnerOrgLink.java create mode 100644 posterita/src/main/org/posterita/model/UDIMAssetGroup.java create mode 100644 posterita/src/main/org/posterita/model/UDIMAttachment.java create mode 100644 posterita/src/main/org/posterita/model/UDIMAttribute.java create mode 100644 posterita/src/main/org/posterita/model/UDIMAttributeInstance.java create mode 100644 posterita/src/main/org/posterita/model/UDIMAttributeSet.java create mode 100644 posterita/src/main/org/posterita/model/UDIMAttributeSetInstance.java create mode 100644 posterita/src/main/org/posterita/model/UDIMAttributeUse.java create mode 100644 posterita/src/main/org/posterita/model/UDIMAttributeValue.java create mode 100644 posterita/src/main/org/posterita/model/UDIMBPBankAccount.java create mode 100644 posterita/src/main/org/posterita/model/UDIMBPGroup.java create mode 100644 posterita/src/main/org/posterita/model/UDIMBPartner.java create mode 100644 posterita/src/main/org/posterita/model/UDIMBPartnerLocation.java create mode 100644 posterita/src/main/org/posterita/model/UDIMBank.java create mode 100644 posterita/src/main/org/posterita/model/UDIMBankAccount.java create mode 100644 posterita/src/main/org/posterita/model/UDIMCash.java create mode 100644 posterita/src/main/org/posterita/model/UDIMCashBook.java create mode 100644 posterita/src/main/org/posterita/model/UDIMCashLine.java create mode 100644 posterita/src/main/org/posterita/model/UDIMCharge.java create mode 100644 posterita/src/main/org/posterita/model/UDIMClient.java create mode 100644 posterita/src/main/org/posterita/model/UDIMCommission.java create mode 100644 posterita/src/main/org/posterita/model/UDIMCommissionLine.java create mode 100644 posterita/src/main/org/posterita/model/UDIMDiscountSchema.java create mode 100644 posterita/src/main/org/posterita/model/UDIMDocType.java create mode 100644 posterita/src/main/org/posterita/model/UDIMDunning.java create mode 100644 posterita/src/main/org/posterita/model/UDIMDunningLevel.java create mode 100644 posterita/src/main/org/posterita/model/UDIMDunningRun.java create mode 100644 posterita/src/main/org/posterita/model/UDIMInOut.java create mode 100644 posterita/src/main/org/posterita/model/UDIMInOutLine.java create mode 100644 posterita/src/main/org/posterita/model/UDIMInoutLineConfirmation.java create mode 100644 posterita/src/main/org/posterita/model/UDIMInventory.java create mode 100644 posterita/src/main/org/posterita/model/UDIMInventoryLine.java create mode 100644 posterita/src/main/org/posterita/model/UDIMInvoice.java create mode 100644 posterita/src/main/org/posterita/model/UDIMInvoiceLine.java create mode 100644 posterita/src/main/org/posterita/model/UDIMLocation.java create mode 100644 posterita/src/main/org/posterita/model/UDIMLocator.java create mode 100644 posterita/src/main/org/posterita/model/UDIMMailText.java create mode 100644 posterita/src/main/org/posterita/model/UDIMMovement.java create mode 100644 posterita/src/main/org/posterita/model/UDIMMovementLine.java create mode 100644 posterita/src/main/org/posterita/model/UDIMMovementLineOverride.java create mode 100644 posterita/src/main/org/posterita/model/UDIMOrder.java create mode 100644 posterita/src/main/org/posterita/model/UDIMOrderLine.java create mode 100644 posterita/src/main/org/posterita/model/UDIMOrg.java create mode 100644 posterita/src/main/org/posterita/model/UDIMOrgInfo.java create mode 100644 posterita/src/main/org/posterita/model/UDIMPOS.java create mode 100644 posterita/src/main/org/posterita/model/UDIMPayment.java create mode 100644 posterita/src/main/org/posterita/model/UDIMPaymentTerm.java create mode 100644 posterita/src/main/org/posterita/model/UDIMPeriod.java create mode 100644 posterita/src/main/org/posterita/model/UDIMPeriodControl.java create mode 100644 posterita/src/main/org/posterita/model/UDIMPriceList.java create mode 100644 posterita/src/main/org/posterita/model/UDIMPriceListVersion.java create mode 100644 posterita/src/main/org/posterita/model/UDIMPrintFormatItem.java create mode 100644 posterita/src/main/org/posterita/model/UDIMProcess.java create mode 100644 posterita/src/main/org/posterita/model/UDIMProduct.java create mode 100644 posterita/src/main/org/posterita/model/UDIMProductCategory.java create mode 100644 posterita/src/main/org/posterita/model/UDIMProductPrice.java create mode 100644 posterita/src/main/org/posterita/model/UDIMRegion.java create mode 100644 posterita/src/main/org/posterita/model/UDIMRequest.java create mode 100644 posterita/src/main/org/posterita/model/UDIMRequestType.java create mode 100644 posterita/src/main/org/posterita/model/UDIMRequestUpdate.java create mode 100644 posterita/src/main/org/posterita/model/UDIMRevenueRecognition.java create mode 100644 posterita/src/main/org/posterita/model/UDIMRole.java create mode 100644 posterita/src/main/org/posterita/model/UDIMShipper.java create mode 100644 posterita/src/main/org/posterita/model/UDIMStorage.java create mode 100644 posterita/src/main/org/posterita/model/UDIMStore.java create mode 100644 posterita/src/main/org/posterita/model/UDIMTax.java create mode 100644 posterita/src/main/org/posterita/model/UDIMTaxCategory.java create mode 100644 posterita/src/main/org/posterita/model/UDIMTransaction.java create mode 100644 posterita/src/main/org/posterita/model/UDIMUOM.java create mode 100644 posterita/src/main/org/posterita/model/UDIMUser.java create mode 100644 posterita/src/main/org/posterita/model/UDIMUserMail.java create mode 100644 posterita/src/main/org/posterita/model/UDIMUserOrgAccess.java create mode 100644 posterita/src/main/org/posterita/model/UDIMUserRoles.java create mode 100644 posterita/src/main/org/posterita/model/UDIMWarehouse.java create mode 100644 posterita/src/main/org/posterita/model/UDIMYear.java create mode 100644 posterita/src/main/org/posterita/model/UDIMinoutConfirm.java create mode 100644 posterita/src/main/org/posterita/model/UDIOrgType.java create mode 100644 posterita/src/main/org/posterita/model/UDIPO.java create mode 100644 posterita/src/main/org/posterita/model/UDIU_Menu.java create mode 100644 posterita/src/main/org/posterita/model/UDIU_RoleMenu.java create mode 100644 posterita/src/main/org/posterita/order/UDIOrderType.java create mode 100644 posterita/src/main/org/posterita/order/UDIOrderTypes.java create mode 100644 posterita/src/main/org/posterita/pos/taglib/ElementTag.java create mode 100644 posterita/src/main/org/posterita/process/UpdateRoleMenu.java create mode 100644 posterita/src/main/org/posterita/struts/admin/CheckSequenceAction.java create mode 100644 posterita/src/main/org/posterita/struts/admin/RoleAction.java create mode 100644 posterita/src/main/org/posterita/struts/attachment/AttachmentAction.java create mode 100644 posterita/src/main/org/posterita/struts/attachment/ImageAttachmentAction.java create mode 100644 posterita/src/main/org/posterita/struts/attributes/AttributesAction.java create mode 100644 posterita/src/main/org/posterita/struts/bPartner/BPartnerAction.java create mode 100644 posterita/src/main/org/posterita/struts/bPartner/ViewBPartnerAction.java create mode 100644 posterita/src/main/org/posterita/struts/core/BaseAction.java create mode 100644 posterita/src/main/org/posterita/struts/core/BaseDispatchAction.java create mode 100644 posterita/src/main/org/posterita/struts/core/BaseForm.java create mode 100644 posterita/src/main/org/posterita/struts/core/DefaultForm.java create mode 100644 posterita/src/main/org/posterita/struts/customer/CustomerAction.java create mode 100644 posterita/src/main/org/posterita/struts/customer/SalesAction.java create mode 100644 posterita/src/main/org/posterita/struts/inOut/ViewMinOutAction.java create mode 100644 posterita/src/main/org/posterita/struts/invoice/ViewInvoiceAction.java create mode 100644 posterita/src/main/org/posterita/struts/login/ChangePasswordAction.java create mode 100644 posterita/src/main/org/posterita/struts/login/GoToHomePageAction.java create mode 100644 posterita/src/main/org/posterita/struts/login/LoginAction.java create mode 100644 posterita/src/main/org/posterita/struts/login/POSLoginAction.java create mode 100644 posterita/src/main/org/posterita/struts/menu/CloseMenuAction.java create mode 100644 posterita/src/main/org/posterita/struts/menu/MenuAction.java create mode 100644 posterita/src/main/org/posterita/struts/order/CompletePOSOrderAction.java create mode 100644 posterita/src/main/org/posterita/struts/order/ViewOrderAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/BarcodeAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/BlackListedAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/BpartnerInfoAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/CashAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/CashBookAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/CommissionAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/CreditOrderAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/CustomPOSReportAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/CustomerReturnOrderAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/DocumentAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/DunningAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/EditBulkProductFromFileAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/FastMovingItemReportAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/GetReportAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/GoodsReceiveNoteAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/GoodsReturnNoteAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/ImportCustomerAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/ImportPOSProductAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/InventoryAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSAttributesAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSDispatchAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSGoodsAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSInfoAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSOrderAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSPriceListAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSProductAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSReportAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSRoleAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSSalesReportAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSStockAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/POSUserAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/PartialPOSOrderAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/PaymentAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/PaymentTermAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/SalesAnalysisReportAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/SearchCustomerAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/SearchPOSProductAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/SearchProductAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/SearchVendorAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/SlowMovingItemReportAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/StockMovementReportAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/TaxAction.java create mode 100644 posterita/src/main/org/posterita/struts/pos/VendorAction.java create mode 100644 posterita/src/main/org/posterita/struts/product/PriceListAction.java create mode 100644 posterita/src/main/org/posterita/struts/stock/StockAction.java create mode 100644 posterita/src/main/org/posterita/struts/user/CreateUserAction.java create mode 100644 posterita/src/main/org/posterita/struts/user/UserAction.java create mode 100644 posterita/src/main/org/posterita/taglib/BankName.java create mode 100644 posterita/src/main/org/posterita/taglib/LinkAccess.java create mode 100644 posterita/src/main/org/posterita/taglib/OrderStatus.java create mode 100644 posterita/src/main/org/posterita/taglib/ProductName.java create mode 100644 posterita/src/main/org/posterita/user/WebUserInfo.java create mode 100644 posterita/src/main/org/posterita/util/AbstractPrintFormatter.java create mode 100644 posterita/src/main/org/posterita/util/BarcodeFormatter.java create mode 100644 posterita/src/main/org/posterita/util/IPrintFormatter.java create mode 100644 posterita/src/main/org/posterita/util/InvoiceFormatter.java create mode 100644 posterita/src/main/org/posterita/util/ListUtil.java create mode 100644 posterita/src/main/org/posterita/util/MinOutFormatter.java create mode 100644 posterita/src/main/org/posterita/util/OrderFormatter.java create mode 100644 posterita/src/main/org/posterita/util/PathInfo.java create mode 100644 posterita/src/main/org/posterita/util/PaymentFormatter.java create mode 100644 posterita/src/main/org/posterita/util/PoManager.java create mode 100644 posterita/src/main/org/posterita/util/RegenerateModels.java create mode 100644 posterita/src/main/org/posterita/util/TMKInvoicePrintFormatter.java create mode 100755 posterita/src/main/org/posterita/util/TMKOrderPrintFormatter.java create mode 100644 posterita/src/main/org/posterita/util/TmkPrintUtil.java create mode 100644 posterita/src/main/org/posterita/util/TmkPrinterConstants.java create mode 100644 posterita/src/main/org/posterita/webstore/action/DocumentHistoryAction.java create mode 100644 posterita/src/main/org/posterita/webstore/action/ViewCashPaymentAction.java create mode 100644 posterita/src/main/org/posterita/webstore/action/ViewPaymentAction.java create mode 100644 posterita/src/main/org/posterita/webstore/businesslogic/DocumentHistoryManager.java create mode 100644 posterita/src/main/org/posterita/webstore/businesslogic/PaymentManager.java diff --git a/posterita/src/main/org/posterita/factory/AbstractFactory.java b/posterita/src/main/org/posterita/factory/AbstractFactory.java new file mode 100644 index 0000000000..8e9b3afff6 --- /dev/null +++ b/posterita/src/main/org/posterita/factory/AbstractFactory.java @@ -0,0 +1,241 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 11, 2005 by vishee + */ + +package org.posterita.factory; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Properties; +import java.util.Set; + +import org.compiere.model.PO; +import org.compiere.util.Env; + +import org.posterita.businesslogic.ClientManager; +import org.posterita.core.FactoryPropertiesManager; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ReloadFactoryException; +import org.posterita.lib.UdiConstants; +import org.posterita.model.UDIPO; + +public abstract class AbstractFactory +{ + private static final String KEY_SEPARATOR = "_"; + protected HashMap map; + protected static int[] clients; + + public static final String MENU_POSITION_TOP = "TOP"; + public static final String MENU_POSITION_LEFT = "LEFT"; + public static final String MENU_POSITION_RIGHT = "RIGHT"; + public static final String MENU_POSITION_DOWN = "DOWN"; + + + static + { + clients = ClientManager.getAvailableClientIds(); + } + + WebProperties pm = FactoryPropertiesManager.getProperty(); + + protected void initFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + clients = ClientManager.getAvailableClientIds(); + if (Env.getAD_Client_ID(ctx) == 0) //--> Client Independent PO + { + if (factory == null) + { + loadFactory(ctx); + } + else + { + loadFactory(ctx, factory); + } + } + else + { + // Catering for multiple clients. All clients should have factory objects loaded. + for (int i = 0; i < clients.length; i++) + { + Properties nCtx = getCtxClone(ctx, clients[i]); + if (factory == null) + { + loadFactory(nCtx); + } + else + { + loadFactory(nCtx, factory); + } + } + } + } + + protected abstract void loadFactory(Properties ctx) throws OperationException; + + protected abstract void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException; + + public static void reloadFactory(Properties ctx) throws ReloadFactoryException + { + + } + + /*private static Properties getCtxClone(Properties ctx) + { + return getCtxClone(ctx, Env.getAD_Client_ID(ctx)); + }*/ + + private static Properties getCtxClone(Properties ctx, int adClientId) + { + Properties nCtx = (Properties)ctx.clone(); + Env.setContext(nCtx, UdiConstants.CLIENT_ID_CTX_PARAM, adClientId); + Env.setContext(nCtx, UdiConstants.ORG_ID_CTX_PARAM, 0); + Env.setContext(nCtx, UdiConstants.USER_ORG_CTX_PARAM, 0); + Env.setContext(nCtx, UdiConstants.USER_ID_CTX_PARAM, 100); + return nCtx; + } + + protected void add(Properties ctx, String key, UDIPO po) throws OperationException + { + if (map == null) + { + map = new HashMap(); + } + + String idStr = pm.get(ctx, key); + + if (idStr == null) + { + po.save(); // UDIPO + pm.put(ctx, key, ""+po.getID()); + } + else + { + Class cl; + Class params[]; + Constructor constructor; + Object[] args; + PO loadedPO; + try + { + cl = Class.forName(po.getPO().getClass().getName()); + params = new Class[]{Properties.class, int.class, String.class}; + + constructor = cl.getConstructor(params); + args = new Object[]{ctx,Integer.valueOf(idStr),null}; + loadedPO = (PO) constructor.newInstance(args); + setFields(ctx, po.getPO(), loadedPO); + loadedPO.save(); + } + catch (ClassNotFoundException e) + { + throw new OperationException(e.getMessage()); + } + catch (SecurityException e) + { + throw new OperationException(e.getMessage()); + } + catch (NoSuchMethodException e) + { + throw new OperationException(e.getMessage()); + } + catch (IllegalArgumentException e) + { + throw new OperationException(e.getMessage()); + } + catch (InstantiationException e) + { + throw new OperationException(e.getMessage()); + } + catch (IllegalAccessException e) + { + throw new OperationException(e.getMessage()); + } + catch (InvocationTargetException e) + { + throw new OperationException(e.getMessage()); + } + + + if (loadedPO == null || loadedPO.get_ID() == 0) + { + po.save(); + pm.put(ctx, key, ""+po.getID()); + } + else + po.setPO(loadedPO); + } + + put(ctx, key, po); + } + + private void put(Properties ctx, String key, UDIPO po) + { + int adClientId = Env.getAD_Client_ID(ctx); + String nKey = key + KEY_SEPARATOR + String.valueOf(adClientId); + map.put(nKey, po); + } + + public UDIPO get(Properties ctx, String key) throws OperationException + { + if (map == null) + { + initFactory(ctx, null); + } + + int adClientId = Env.getAD_Client_ID(ctx); + String nKey = key + KEY_SEPARATOR + String.valueOf(adClientId); + UDIPO retPO = map.get(nKey); + + if (retPO == null) + throw new OperationException("Could not get PO with key: " + key); + + return retPO; + } + + protected void setFields(Properties ctx, PO fromPO, PO toPO) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException + { + + } + + public ArrayList getAllKeys(Properties ctx) throws OperationException + { + if (map == null) + loadFactory(ctx); + + Set keySet = map.keySet(); + + ArrayList keyList = new ArrayList(); + + for(Object objKey : keySet) + { + String key = (String)objKey; + int ind = key.lastIndexOf(KEY_SEPARATOR); + if(ind > 0) + { + key = key.substring(0, ind); + } + keyList.add(key); + } + + return keyList; + } +} diff --git a/posterita/src/main/org/posterita/factory/DBPropertiesManager.java b/posterita/src/main/org/posterita/factory/DBPropertiesManager.java new file mode 100644 index 0000000000..b42c1c0f9e --- /dev/null +++ b/posterita/src/main/org/posterita/factory/DBPropertiesManager.java @@ -0,0 +1,88 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 12-Oct-2005 + */ + + +package org.posterita.factory; + +import java.util.Properties; + +import org.compiere.util.Env; + +import org.posterita.exceptions.OperationException; +import org.posterita.model.MWebProperties; + + +public class DBPropertiesManager implements WebProperties +{ + + public void put(Properties ctx, String key, String value) + { + int [] propertieIds = MWebProperties.getAllIDs(MWebProperties.Table_Name," U_KEY='"+key+"' and AD_CLIENT_ID = "+Env.getAD_Client_ID(ctx),null); + + if(propertieIds.length==0) + { + MWebProperties webProperties = new MWebProperties(ctx,0,null); + webProperties.setU_Key(key); + webProperties.setU_Value(value); + webProperties.save(); + } + else + { + MWebProperties webProperties = new MWebProperties(ctx,propertieIds[0],null); + webProperties.setU_Value(value); + webProperties.save(); + } + } + + + public String get(Properties ctx, String key) throws OperationException + { + + int [] values; + + values = MWebProperties.getAllIDs(MWebProperties.Table_Name,"u_key ='"+key+"' and AD_CLIENT_ID = "+Env.getAD_Client_ID(ctx),null); + + if (values.length == 0) + { + return null; + } + + + MWebProperties webProperties = new MWebProperties(ctx,values[0],null); + + return webProperties.getU_Value(); + } + +// private boolean iskeyPresent(Properties ctx,String key) +// { +// boolean keyPresent = true; +// int [] propertieIds = MWebProperties.getAllIDs(MWebProperties.Table_Name," U_KEY='"+key+"' and AD_CLIENT_ID = "+Env.getAD_Client_ID(ctx),null); +// +// if(propertieIds.length==0) +// keyPresent = false; +// +// return keyPresent; +// } + + + +} diff --git a/posterita/src/main/org/posterita/factory/DunningFactory.java b/posterita/src/main/org/posterita/factory/DunningFactory.java new file mode 100644 index 0000000000..09c165fa20 --- /dev/null +++ b/posterita/src/main/org/posterita/factory/DunningFactory.java @@ -0,0 +1,86 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 30, 2006 + */ + + +package org.posterita.factory; + +import java.util.Properties; + +import org.posterita.businesslogic.DunningManager; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ReloadFactoryException; + + +public class DunningFactory extends AbstractFactory +{ + public static final String DUNNING_ID = "dunning.id"; + public static final String DUNNING_NAME="Dunning"; + public static final String DESCRIPTION="Include due an non-due invoices"; + public static final String DUNNING_LEVEL_NAME="Statement"; + public static final String PRINT_TEXT = "Statement "; + public static final String PRINT_NOTE="Please review your statement and submit due payments."; + + + private static DunningFactory singleton; + private DunningFactory() throws OperationException + { + + } + + public static DunningFactory getFactoryInstance(Properties ctx) throws OperationException + { + if (singleton == null) + singleton = new DunningFactory(); + + Properties nCtx = (Properties)ctx.clone(); + singleton.loadFactory(nCtx); + + return singleton; + } + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, singleton); + } + + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + factory.add(ctx,DUNNING_ID, + DunningManager.createDunningAndLevel + (ctx,DUNNING_NAME,DESCRIPTION,DUNNING_LEVEL_NAME,PRINT_TEXT,PRINT_NOTE,-9999)); + + } + + public static void reloadFactory(Properties ctx) throws ReloadFactoryException + { + try + { + DunningFactory nFactory = new DunningFactory(); + nFactory.initFactory(ctx, nFactory); + singleton = nFactory; + } + catch(OperationException ex) + { + throw new ReloadFactoryException("Could not reload DunningFactory", ex); + } + } + +} diff --git a/posterita/src/main/org/posterita/factory/GenericProductAttributeFactory.java b/posterita/src/main/org/posterita/factory/GenericProductAttributeFactory.java new file mode 100644 index 0000000000..0ffa71997f --- /dev/null +++ b/posterita/src/main/org/posterita/factory/GenericProductAttributeFactory.java @@ -0,0 +1,92 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package org.posterita.factory; + +import java.util.Properties; + +import org.posterita.businesslogic.ProductAttributeManager; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ReloadFactoryException; +import org.posterita.model.UDIMAttribute; +import org.posterita.model.UDIMAttributeSet; + + +public class GenericProductAttributeFactory extends AbstractFactory +{ + public static final String ATTRIBUTE_BRAND_ID = "attribute.brand.id"; + public static final String ATTRIBUTE_DESIGN_ID = "attribute.design.id"; + public static final String ATTRIBUTE_MODEL_ID = "attribute.model.id"; + public static final String ATTRIBUTE_COLOUR_ID = "attribute.colour.id"; + public static final String ATTRIBUTE_SIZE_ID = "attribute.size.id"; + + private static final String ATTRIBUTE_BRAND_NAME = "Brand"; + private static final String ATTRIBUTE_DESIGN_NAME = "Design"; + private static final String ATTRIBUTE_MODEL_NAME = "Model"; + private static final String ATTRIBUTE_COLOUR_NAME = "Colour"; + private static final String ATTRIBUTE_SIZE_NAME = "Size"; + + private static GenericProductAttributeFactory genericProductAttributeFactory; + private GenericProductAttributeFactory() + { + + } + + public static GenericProductAttributeFactory getFactoryInstance() + { + if (genericProductAttributeFactory == null) + genericProductAttributeFactory = new GenericProductAttributeFactory(); + + return genericProductAttributeFactory; + } + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, genericProductAttributeFactory); + } + + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + factory.add(ctx, ATTRIBUTE_BRAND_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_BRAND_NAME)); + factory.add(ctx, ATTRIBUTE_DESIGN_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_DESIGN_NAME)); + factory.add(ctx, ATTRIBUTE_MODEL_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_MODEL_NAME)); + factory.add(ctx, ATTRIBUTE_COLOUR_ID, ProductAttributeManager.createAttribute(ctx,ATTRIBUTE_COLOUR_NAME)); + factory.add(ctx, ATTRIBUTE_SIZE_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_SIZE_NAME)); + + UDIMAttributeSet tshirtAttributeSet = (UDIMAttributeSet) GenericProductAttributeSetFactory.getFactoryInstance().get(ctx, GenericProductAttributeSetFactory.ATTRIBUTE_SET_TSHIRT_ID); + ProductAttributeManager.createAttributeUse(ctx, tshirtAttributeSet, (UDIMAttribute)factory.get(ctx, ATTRIBUTE_BRAND_ID)); + ProductAttributeManager.createAttributeUse(ctx, tshirtAttributeSet, (UDIMAttribute)factory.get(ctx, ATTRIBUTE_DESIGN_ID)); + ProductAttributeManager.createAttributeUse(ctx, tshirtAttributeSet, (UDIMAttribute)factory.get(ctx, ATTRIBUTE_MODEL_ID)); + ProductAttributeManager.createAttributeUse(ctx, tshirtAttributeSet, (UDIMAttribute)factory.get(ctx, ATTRIBUTE_COLOUR_ID)); + ProductAttributeManager.createAttributeUse(ctx, tshirtAttributeSet, (UDIMAttribute)factory.get(ctx, ATTRIBUTE_SIZE_ID)); + } + + public static void reloadFactory(Properties ctx) throws ReloadFactoryException + { + try + { + GenericProductAttributeFactory nFactory = new GenericProductAttributeFactory(); + nFactory.initFactory(ctx, nFactory); + genericProductAttributeFactory = nFactory; + } + catch(OperationException ex) + { + throw new ReloadFactoryException("Could not reload GenericProductAttributeFactory", ex); + } + } + +} diff --git a/posterita/src/main/org/posterita/factory/GenericProductAttributeSetFactory.java b/posterita/src/main/org/posterita/factory/GenericProductAttributeSetFactory.java new file mode 100644 index 0000000000..347f880b90 --- /dev/null +++ b/posterita/src/main/org/posterita/factory/GenericProductAttributeSetFactory.java @@ -0,0 +1,70 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package org.posterita.factory; + +import java.util.Properties; + +import org.posterita.businesslogic.ProductAttributeSetManager; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ReloadFactoryException; + + +public class GenericProductAttributeSetFactory extends AbstractFactory +{ + private static GenericProductAttributeSetFactory genericProductAttributeSetFactory; + + public static final String ATTRIBUTE_SET_TSHIRT_ID = "attributeset.tshirt.id"; + private static final String ATTRIBUTE_SET_TSHIRT_NAME = "TShirt"; + + private GenericProductAttributeSetFactory() + { + + } + + public static GenericProductAttributeSetFactory getFactoryInstance() + { + if (genericProductAttributeSetFactory == null) + genericProductAttributeSetFactory = new GenericProductAttributeSetFactory(); + + return genericProductAttributeSetFactory; + } + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, genericProductAttributeSetFactory); + } + + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + factory.add(ctx, ATTRIBUTE_SET_TSHIRT_ID, ProductAttributeSetManager.createAttributeSet(ctx, ATTRIBUTE_SET_TSHIRT_NAME)); + } + + public static void reloadFactory(Properties ctx) throws ReloadFactoryException + { + try + { + GenericProductAttributeSetFactory nFactory = new GenericProductAttributeSetFactory(); + nFactory.initFactory(ctx, nFactory); + genericProductAttributeSetFactory = nFactory; + } + catch(OperationException ex) + { + throw new ReloadFactoryException("Could not reload GenericProductAttributeSetFactory", ex); + } + } +} diff --git a/posterita/src/main/org/posterita/factory/GenericSystemObjectsFactory.java b/posterita/src/main/org/posterita/factory/GenericSystemObjectsFactory.java new file mode 100644 index 0000000000..be9ce67101 --- /dev/null +++ b/posterita/src/main/org/posterita/factory/GenericSystemObjectsFactory.java @@ -0,0 +1,135 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + **/ +package org.posterita.factory; + +import java.util.Properties; + +import org.compiere.model.MTax; + +import org.posterita.core.SystemObjects; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ReloadFactoryException; +import org.posterita.lib.UdiConstants; +import org.posterita.model.UDIMAssetGroup; +import org.posterita.model.UDIMDiscountSchema; +import org.posterita.model.UDIMPriceList; +import org.posterita.model.UDIMPriceListVersion; +import org.posterita.model.UDIMProductCategory; +import org.posterita.model.UDIMTax; +import org.posterita.model.UDIMTaxCategory; + + +public class GenericSystemObjectsFactory extends AbstractFactory +{ + + public static final String PRODUCT_CATEGORY_TSHIRT_ID = "productCategory.tshirt.id"; + public static final String TAX_CATEGORY_DEFAULT_ID = "taxCategory.tshirt.default.id"; + + public static final String ASSET_GRP_ID = "assetgroup.tshirt.id"; + public static final String WEBSTORE_TAX_ID = "tax.webstore.default.id"; + public static final String WEBSTORE_SALES_PRICELIST_ID = "pricelist.webstore.sales.id"; + public static final String WEBSTORE_PURCHASE_PRICELIST_ID = "pricelist.webstore.purchase.id"; + public static final String PURCHASE_PRICELV_ID = "priceLV.tshirt.purchase.id"; + public static final String SALES_PRICELV_ID = "priceLV.tshirt.sales.id"; + public static final String DISCOUNT_SCHEMA_ID = "discountschema.tshirt.id"; + + private static GenericSystemObjectsFactory genericSystemsObjectFactory; + private GenericSystemObjectsFactory() + { + + } + + public static GenericSystemObjectsFactory getFactoryInstance() + { + if (genericSystemsObjectFactory == null) + genericSystemsObjectFactory = new GenericSystemObjectsFactory(); + + return genericSystemsObjectFactory; + } + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, genericSystemsObjectFactory); + } + + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + UDIMAssetGroup assetGroup = SystemObjects.getAssetGroup(ctx, "Tshirt Asset Group"); + factory.add(ctx, ASSET_GRP_ID, assetGroup); + assetGroup = (UDIMAssetGroup) factory.get(ctx, ASSET_GRP_ID); + + UDIMProductCategory productCategory = SystemObjects.getProductCategory(ctx, "TShirt"); + factory.add(ctx, PRODUCT_CATEGORY_TSHIRT_ID, productCategory); + productCategory = (UDIMProductCategory) factory.get(ctx, GenericSystemObjectsFactory.PRODUCT_CATEGORY_TSHIRT_ID); + productCategory.setA_Asset_Group_ID(assetGroup.getID()); + productCategory.save(); + + factory.add(ctx, TAX_CATEGORY_DEFAULT_ID, SystemObjects.getTaxCategory(ctx, "TShirt Tax Category")); + UDIMTaxCategory taxCategory = (UDIMTaxCategory) factory.get(ctx, TAX_CATEGORY_DEFAULT_ID); + + UDIMTax tax = SystemObjects.getTax(ctx, "Webstore", UdiConstants.COUNTRY_MAURITIUS, "Webstore Tax"); + tax.setC_Tax_Category_ID(taxCategory.getID()); + tax.getMTax().setIsTaxExempt(true); + tax.getMTax().setSOPOType(MTax.SOPOTYPE_SalesTax); + factory.add(ctx, WEBSTORE_TAX_ID, tax); + + UDIMPriceList salesPriceList = SystemObjects.getPriceList(ctx, "Webstore Sales Price List", UdiConstants.CURRENCY_USD); + factory.add(ctx, WEBSTORE_SALES_PRICELIST_ID, salesPriceList); + salesPriceList = (UDIMPriceList) factory.get(ctx, GenericSystemObjectsFactory.WEBSTORE_SALES_PRICELIST_ID); + + UDIMPriceList purchasePL = SystemObjects.getPriceList(ctx, "Purchase Price List", UdiConstants.CURRENCY_RUPEES); + factory.add(ctx, WEBSTORE_PURCHASE_PRICELIST_ID, purchasePL); + purchasePL = (UDIMPriceList) factory.get(ctx, GenericSystemObjectsFactory.WEBSTORE_PURCHASE_PRICELIST_ID); + + UDIMDiscountSchema discountSchema = SystemObjects.getDiscountSchema(ctx, "Tshirt Discount Schema"); + factory.add(ctx, DISCOUNT_SCHEMA_ID, discountSchema); + discountSchema = (UDIMDiscountSchema) factory.get(ctx, GenericSystemObjectsFactory.DISCOUNT_SCHEMA_ID); + + UDIMPriceListVersion purchasePLV = SystemObjects.getPriceListVersion(ctx, "Purchase Price List Version"); + purchasePLV.setM_DiscountSchema_ID(discountSchema.getID()); + purchasePLV.setM_PriceList_ID(purchasePL.getID()); + factory.add(ctx, GenericSystemObjectsFactory.PURCHASE_PRICELV_ID, purchasePLV); + purchasePLV = (UDIMPriceListVersion) factory.get(ctx, GenericSystemObjectsFactory.PURCHASE_PRICELV_ID); + + + UDIMPriceListVersion salesPLV = SystemObjects.getPriceListVersion(ctx, "Sales Price List Version"); + salesPLV.setM_DiscountSchema_ID(discountSchema.getID()); + salesPLV.setM_PriceList_ID(salesPriceList.getID()); + + factory.add(ctx, GenericSystemObjectsFactory.SALES_PRICELV_ID, salesPLV); + salesPLV = (UDIMPriceListVersion) factory.get(ctx, GenericSystemObjectsFactory.SALES_PRICELV_ID); + + } + + public static void reloadFactory(Properties ctx) throws ReloadFactoryException + { + try + { + GenericSystemObjectsFactory nFactory = new GenericSystemObjectsFactory(); + nFactory.initFactory(ctx, nFactory); + genericSystemsObjectFactory = nFactory; + } + catch(OperationException ex) + { + throw new ReloadFactoryException("Could not reload GenericSystemObjectsFactory", ex); + } + } + +} diff --git a/posterita/src/main/org/posterita/factory/MenuGenerator.java b/posterita/src/main/org/posterita/factory/MenuGenerator.java new file mode 100644 index 0000000000..7c8ad744c4 --- /dev/null +++ b/posterita/src/main/org/posterita/factory/MenuGenerator.java @@ -0,0 +1,93 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.factory; + +import java.util.Properties; + +import org.compiere.model.X_U_RoleMenu; +import org.compiere.util.Env; + +import org.posterita.businesslogic.MenuManager; +import org.posterita.exceptions.OperationException; +import org.posterita.model.UDIMRole; +import org.posterita.model.UDIU_RoleMenu; + + +public class MenuGenerator +{ + public static void createMenus(Properties ctx, UDIMRole role) throws OperationException + { + int menuIds[] = MenuManager.getMenuIdForOrganisation(ctx); + int roleId = role.getID(); + + for(int i = 0; i < menuIds.length; i++) + { + if(MenuGenerator.isRoleMenuPresent(ctx, roleId, menuIds[i])) + continue; + X_U_RoleMenu roleMenu = new X_U_RoleMenu(ctx, 0, null); + + roleMenu.setAD_Role_ID(roleId); + roleMenu.setU_Menu_ID(menuIds[i]); + UDIU_RoleMenu udiRoleMenu = new UDIU_RoleMenu(roleMenu); + udiRoleMenu.save(); + } + } + + private static boolean isRoleMenuPresent(Properties ctx, int roleId, int menuId) + { + boolean present = true; + + String sqlWhereClause = ""; + int adClientId = Env.getAD_Client_ID(ctx); + int adOrgId = Env.getAD_Org_ID(ctx); + + sqlWhereClause += "AD_CLIENT_ID=" + adClientId + " and AD_ORG_ID=" + adOrgId + " and U_MENU_ID=" + menuId + " and AD_ROLE_ID=" + roleId; + int ids[] = X_U_RoleMenu.getAllIDs(X_U_RoleMenu.Table_Name, sqlWhereClause, null); + + if(ids.length == 0) + present = false; + + return present; + } + + /** + * @param ctx + * @param role + * @throws OperationException + */ + public static void createSuperUserMenus(Properties ctx, UDIMRole role) throws OperationException + { + int menuIds[] = MenuManager.getMenuIdForSuperUser(ctx); + + int roleId = role.getID(); + + for(int i = 0; i < menuIds.length; i++) + { + if(MenuGenerator.isRoleMenuPresent(ctx, roleId, menuIds[i])) + continue; + X_U_RoleMenu roleMenu = new X_U_RoleMenu(ctx, 0, null); + + roleMenu.setAD_Role_ID(roleId); + roleMenu.setU_Menu_ID(menuIds[i]); + UDIU_RoleMenu udiRoleMenu = new UDIU_RoleMenu(roleMenu); + udiRoleMenu.save(); + } + } +} diff --git a/posterita/src/main/org/posterita/factory/POSMenuFactory.java b/posterita/src/main/org/posterita/factory/POSMenuFactory.java new file mode 100644 index 0000000000..ffe37499ae --- /dev/null +++ b/posterita/src/main/org/posterita/factory/POSMenuFactory.java @@ -0,0 +1,568 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.factory; + +import java.lang.reflect.InvocationTargetException; +import java.util.Properties; + +import org.compiere.model.PO; +import org.compiere.model.X_U_Menu; +import org.compiere.util.Env; +import org.posterita.Constants; +import org.posterita.businesslogic.MenuManager; +import org.posterita.exceptions.OperationException; +import org.posterita.lib.UdiConstants; +import org.posterita.model.UDIPO; +import org.posterita.model.UDIU_Menu; +import org.posterita.order.UDIOrderTypes; + +public class POSMenuFactory extends AbstractFactory +{ + + public static final String MENU_POSITION_TOP = "TOP"; + public static final String MENU_POSITION_LEFT = "LEFT"; + public static final String MENU_POSITION_RIGHT = "RIGHT"; + public static final String MENU_POSITION_DOWN = "DOWN"; + + public static final String PMENU_SALES_ID = "pmenu.order.id"; + + public static final String PMENU_CREDITSALES_ID = "pmenu.creditsales.id"; + public static final String PMENU_PURCHASES_ID = "pmenu.purchases.id"; + public static final String PMENU_STOCK_ID = "pmenu.stock.id"; + + + public static final String SMENU_POSORDER_ID = "smenu.posorder.id"; + public static final String SMENU_POSORDERWA_ID="smenu.posorderwa.id"; + public static final String SMENU_POSPARTIALORDER_ID = "smenu.pospartialorder.id"; + public static final String SMENU_INVOKEPOSPARTIALORDER_ID = "smenu.invokepospartialorder.id"; + public static final String SMENU_POSGOODRECNOTE_ID = "smenu.posgoodrecnote.id"; + public static final String SMENU_POSGOODRETNOTE_ID= "smenu.posgoodretnote.id"; + public static final String SMENU_CUSTRETORDER_ID="smenu.custretorder.id"; + public static final String SMENU_POSPARTIALHISTORYORDER_ID="smenu.pospartialposhistory.id"; + public static final String SMENU_CUSTRETOREDRFROMPOS_ID="smenu.custretorderfrompos.id"; + public static final String SMENU_POSORDERQUICK="smenu.posorderquick.id"; + public static final String SMENU_POSORDERCUSTOMERCOMPULSORY="smenu.posordercustomercompulsory.id"; + public static final String SMENU_CREDITORDER_ID = "smenu.creditorder.id"; + public static final String SMENU_SETTLE_PAYMENT_ID = "smenu.settlepayment.id"; + public static final String SMENU_CUSTOMER_RETURN_HISTORY_ID="smenu.customer.return.history.id"; + + + public static final String PMENU_REPORTS_ID="pmenu.reports.id"; + public static final String SMENU_POSSTOCKMOV="smenu.posstockmov.id"; + public static final String SMENU_SALESANALREP="smenu.salesanalrep.id"; + public static final String SMENU_FASTMOVITEMS="smenu.fastmovitems.id"; + public static final String SMENU_SLOWMOVITEMS="smenu.slowmovitems.id"; + public static final String SMENU_CUSTSALESREPORT="smenu.custsalesreport.id"; + public static final String SMENU_CASHBOOKREPORT="smenu.cashbookreport.id"; + public static final String SMENU_PERIODICASHBOOKDETAILS="smenu.periodiccashbookdetails.id"; + public static final String SMENU_NOIMAGEREPORT="smenu.noimagereport.id"; + + public static final String PMENU_ADMINISTRATION_ID="pmenu.administration.id"; + public static final String SMENU_USER_ID="smenu.user.id"; + + public static final String SMENU_VIEWROLE_ID="smenu.viewrole.id"; + public static final String SMENU_CREATEVENDOR_ID="smenu.createvendor.id"; + + public static final String SMENU_CURRENTTILLAMOUNT_ID="smenu.currenttillamout.id"; + public static final String SMENU_CLOSECASHBOOK_ID="smenu.closecashbook.id"; + public static final String SMENU_POSINFO_ID="smenu.posinfo.id"; + public static final String SMENU_MYSTOCK_ID="smenu.mystock.id"; + + public static final String SMENU_ORDERHISTORY_ID="smenu.orderhistory.id"; + public static final String SMENU_DOCUMENTHISTORY_ID="smenu.documenthistory.id"; + + public static final String SMENU_PRODUCTS="smenu.products.id"; + public static final String SMENU_VIEW_BPINFO="smenu.view.bp.info.id"; + public static final String SMENU_CUSTOMER="smenu.customer.id"; + public static final String SMENU_EDIT_BULK_PRODUCT="smenu.edit.bulk.product.id"; + public static final String SMENU_EDIT_BULK_PRICE="smenu.edit.bulk.price.id"; + public static final String SMENU_EDIT_ATTRIBUTE_VALUE="smenu.edit.attribute.value.id"; + public static final String SMENU_ADJUST_CASH_BOOK="smenu.adjust.cashbook.id"; + public static final String SMENU_SYNCHRONIZE_COLLECTIONS="smenu.synchronize.collections.id"; + public static final String PMENU_LOGOUT_ID="pmenu.logout.id"; + public static final String SMENU_CLOSE_POS_TILL="smenu.close.pos.till.id"; + public static final String SMENU_OPEN_CASH_DRAWER = "smenu.opencashdrawer.id"; + public static final String SMENU_UPDATE_PRODUCT_BY_CSV = "smenu.update.produc.csv.id"; + + public static final String SMENU_CHECK_SEQUENCE = "smenu.checkSequence.id"; + public static final String SMENU_PRINT_DUNNING_LETTERS_ID = "smenu.printDunningLetters.id"; + public static final String SMENU_VIEW_PAYMENT_ALLOCATION = "smenu.viewpaymentallocation.id"; + public static final String SMENU_VIEW_PAYMENT_TERM = "smenu.viewpaymentterm.id"; + public static final String SMENU_GENERATE_COMMISSION_ID = "smenu.generatecommission.id"; + public static final String SMENU_VIEW_GENERATED_COMMISSION_ID = "smenu.viewgeneratedcommission.id"; + public static final String SMENU_VIEW_TAX="smenu.tax.id"; + public static final String SMENU_CREDITMEMOFROMPOS_ID="smenu.creditmemo.from.creditorder.id"; + public static final String SMENU_CREATE_UNALLOCATED_PAYMENT_ID="smenu.create.unallocated.payment.id"; + public static final String SMENU_CREDIT_MEMO_HISTORY_ID="smenu.credit.memo.history.id"; + + public static final String MODULE_NAME = "POS"; + + private static final String SMENU_CASH_SALES_HISTORY_ID = "smenu.cash.sales.history.id"; + private static final String SMENU_CREDIT_SALES_HISTORY_ID = "smenu.credit.sales.history.id"; + private static final String SMENU_GOODSRECNOTEHISTORY_HISTORY_ID = "smenu.goods.received.note.history.id"; + private static final String SMENU_GOODSRETNOTEHISTORY_HISTORY_ID = "smenu.goods.returned.note.history.id"; + + private static final String SMENU_ADJUST_STOCK_ID = "smenu.adjust.stock.id"; + private static final String SMENU_INVENTORY_HISTORY_ID = "smenu.inventory.history.id"; + private static final String SMENU_ADJUST_INVENTORY_ID = "smenu.adjust.inventory.id"; + private static final String SMENU_VIEW_PREFERENCES = "smenu.viewpreferences.id"; + private static final String SMENU_VIEW_BPARTNERS = "smenu.bpartners.id"; + private static final String SMENU_PRICE_CHECK = "smenu.price.check"; + + + + private static POSMenuFactory singleton; + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, singleton); + } + + @Override + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + loadCashSalesMenu(ctx, factory); + loadCreditSalesMenu(ctx, factory); + loadPurchasesMenu(ctx, factory); + loadPerformanceAnalysisMenu(ctx, factory); + loadStockMenu(ctx, factory); + loadAdministrationMenu(ctx, factory); + + } + + + public static POSMenuFactory getFactoryInstance(Properties ctx) throws OperationException + { + if (singleton == null) + singleton = new POSMenuFactory(); + + Properties nCtx = (Properties)ctx.clone(); + nCtx.setProperty(UdiConstants.CLIENT_ID_CTX_PARAM, "0"); + nCtx.setProperty(UdiConstants.ORG_ID_CTX_PARAM, "0"); + singleton.loadFactory(nCtx); + + return singleton; + } + + + private void loadCashSalesMenu(Properties ctx, AbstractFactory factory) throws OperationException + { + UDIU_Menu pmenu_sales = MenuManager.createParentMenu(ctx, "pmenu.cash.sales", MODULE_NAME, 1000); + pmenu_sales.setPosition(MENU_POSITION_TOP); + pmenu_sales.setImageLink("images/pos/buttons/button_order.gif"); + + factory.add(ctx, PMENU_SALES_ID, pmenu_sales); + + factory.add(ctx, SMENU_POSORDER_ID, + MenuManager.createSubMenu(ctx, "smenu.cash.sales.multiple.payments", + "CreatePOSOrder.do", + MODULE_NAME, pmenu_sales.getID(), 1010, "sales.order")); + + factory.add(ctx, SMENU_POSORDERWA_ID, + MenuManager.createSubMenu(ctx, "smenu.cash.sales", + "CreatePOSOrderWithoutAdvanced.do", + MODULE_NAME, pmenu_sales.getID(), 1020, "sales.order")); + + factory.add(ctx, SMENU_POSORDERQUICK, + MenuManager.createSubMenu(ctx, "smenu.quick.cash.sales", + "CreatePOSOrder3.do", + MODULE_NAME, pmenu_sales.getID(), 1030, "sales.order")); + + + factory.add(ctx, SMENU_POSORDERCUSTOMERCOMPULSORY, + MenuManager.createSubMenu(ctx, "smenu.cash.sales.customer.complusory", + "CreatePOSOrder2.do", + MODULE_NAME, pmenu_sales.getID(), 1040, "sales.order")); + + factory.add(ctx, SMENU_CASH_SALES_HISTORY_ID, + MenuManager.createSubMenu(ctx, "smenu.cash.sales.history", + "ViewPOSHistoryAction.do?action=getPOSHistory&orderType="+UDIOrderTypes.POS_ORDER.getOrderType(), + MODULE_NAME, pmenu_sales.getID(), 1050, "sales.order")); + + + + factory.add(ctx, SMENU_POSPARTIALORDER_ID, + MenuManager.createSubMenu(ctx, "smenu.prepare.order", + "CreatePartialPOSOrder.do", + MODULE_NAME, pmenu_sales.getID(), 1060, "prepared.order")); + + factory.add(ctx, SMENU_INVOKEPOSPARTIALORDER_ID, + MenuManager.createSubMenu(ctx, "smenu.complete.prepared.order", + "InvokePartialPOSOrder.do", + MODULE_NAME, pmenu_sales.getID(), 1070, "prepared.order")); + + factory.add(ctx, SMENU_POSPARTIALHISTORYORDER_ID, + MenuManager.createSubMenu(ctx, "smenu.prepared.order.history", + "ViewPartialPOSOrderHistoryAction.do?action=initPartialPOSHistory", + MODULE_NAME, pmenu_sales.getID(), 1080, "prepared.order")); + + factory.add(ctx, SMENU_CUSTRETORDER_ID, + MenuManager.createSubMenu(ctx, "smenu.customer.returned.order", + "CustomerReturnOrder.do", + MODULE_NAME, pmenu_sales.getID(), 1090,"returned.order")); + + factory.add(ctx, SMENU_CUSTOMER_RETURN_HISTORY_ID, + MenuManager.createSubMenu(ctx, "smenu.customer.return.history.id", + "ViewPOSHistoryAction.do?action=getPOSHistory&orderType="+UDIOrderTypes.CUSTOMER_RETURN_ORDER.getOrderType(), + MODULE_NAME, pmenu_sales.getID(), 1170, "returned.order")); + + factory.add(ctx, SMENU_CUSTRETOREDRFROMPOS_ID, + MenuManager.createSubMenu(ctx, "smenu.invoke.customer.returned.order", + "GetCustomerReturnFromPOS.do", + MODULE_NAME, pmenu_sales.getID(), 1100,"returned.order")); + + + factory.add(ctx, SMENU_CURRENTTILLAMOUNT_ID, + MenuManager.createSubMenu(ctx, "smenu.current.money.in.terminal", + "GetCurrentTillAmount.do?action=getCurrentTillAmount", + MODULE_NAME, pmenu_sales.getID(), 1110,"till.management")); + + factory.add(ctx, SMENU_ADJUST_CASH_BOOK, + MenuManager.createSubMenu(ctx, "smenu.adjust.cashbook", + "AdjustCashBook.do", + MODULE_NAME, pmenu_sales.getID(), 1120,"cash.book")); + + factory.add(ctx, SMENU_PERIODICASHBOOKDETAILS, + MenuManager.createSubMenu(ctx, "smenu.cashbook.report", + "CashSummaryDate.do", + MODULE_NAME, pmenu_sales.getID(), 1130,"cash.book")); + + factory.add(ctx, SMENU_CASHBOOKREPORT, + MenuManager.createSubMenu(ctx, "smenu.cashbook.history", + "CashReportAction.do?action=initGetCashDetailsHistory", + MODULE_NAME, pmenu_sales.getID(), 1140,"cash.book")); + + factory.add(ctx, SMENU_CLOSE_POS_TILL, + MenuManager.createSubMenu(ctx, "smenu.close.till", + "InitClosePOSTillAction.do?action=initCloseTill", + MODULE_NAME, pmenu_sales.getID(), 1150,"till.management")); + + factory.add(ctx, SMENU_OPEN_CASH_DRAWER, + MenuManager.createSubMenu(ctx, "smenu.open.cashdrawer", + "javascript:openCashDrawer();", + MODULE_NAME, pmenu_sales.getID(), 1160,"till.management")); + + + } + + private void loadCreditSalesMenu(Properties ctx, AbstractFactory factory) throws OperationException + { + UDIU_Menu pmenu_creditsales = MenuManager.createParentMenu(ctx, "pmenu.credit.sales", MODULE_NAME, 2000); + pmenu_creditsales.setPosition(MENU_POSITION_TOP); + pmenu_creditsales.setImageLink("images/pos/buttons/button_order.gif"); + + factory.add(ctx, PMENU_CREDITSALES_ID, pmenu_creditsales); + + factory.add(ctx, SMENU_CREDITORDER_ID, + MenuManager.createSubMenu(ctx, "smenu.credit.sales", + "InitCreateCreditOrderAction.do?action=initCreateCreditOrder", + MODULE_NAME, pmenu_creditsales.getID(), 2010)); + + factory.add(ctx, SMENU_CREDITMEMOFROMPOS_ID, + MenuManager.createSubMenu(ctx, "smenu.creditmemo.from.creditorder.id", + "InvokeCreditOrder.do", + MODULE_NAME, pmenu_creditsales.getID(), 2020)); + + factory.add(ctx, SMENU_CREDIT_MEMO_HISTORY_ID, + MenuManager.createSubMenu(ctx, "smenu.credit.memo.history.id", + "ViewPOSHistoryAction.do?action=getPOSHistory&orderType="+UDIOrderTypes.CREDIT_MEMO.getOrderType(), + MODULE_NAME, pmenu_creditsales.getID(), 2080)); + + + + factory.add(ctx, SMENU_SETTLE_PAYMENT_ID, + MenuManager.createSubMenu(ctx, "smenu.settle.payment.credit.sales", + "InitGetBpartnerPaymentStatus.do?action=initGetBpartnerPaymentStatus", + MODULE_NAME, pmenu_creditsales.getID(), 2030)); + + factory.add(ctx, SMENU_PRINT_DUNNING_LETTERS_ID, + MenuManager.createSubMenu(ctx, "smenu.dunning.letters", + "InitPrintDunningAction.do?action=initPrintDunning", + MODULE_NAME, pmenu_creditsales.getID(), 2040)); + + + factory.add(ctx, SMENU_VIEW_PAYMENT_ALLOCATION, + MenuManager.createSubMenu(ctx, "smenu.payment.allocation.history", + "ViewPaymentAllocation.do", + MODULE_NAME, pmenu_creditsales.getID(), 2050)); + + factory.add(ctx, SMENU_CREDIT_SALES_HISTORY_ID, + MenuManager.createSubMenu(ctx, "smenu.credit.sales.history", + "ViewPOSHistoryAction.do?action=getPOSHistory&orderType=" + UDIOrderTypes.CREDIT_ORDER.getOrderType(), + MODULE_NAME, pmenu_creditsales.getID(), 2060)); + + factory.add(ctx, SMENU_CREATE_UNALLOCATED_PAYMENT_ID, + MenuManager.createSubMenu(ctx, "smenu.create.unallocated.payment.id", + "CreateUnallocatedPayment.do", + MODULE_NAME, pmenu_creditsales.getID(), 2070)); + + + } + + + private void loadPurchasesMenu(Properties ctx, AbstractFactory factory) throws OperationException + { + UDIU_Menu pmenu_purchases = MenuManager.createParentMenu(ctx, "pmenu.purchases", MODULE_NAME, 3000); + pmenu_purchases.setPosition(MENU_POSITION_TOP); + pmenu_purchases.setImageLink("images/pos/buttons/button_order.gif"); + + factory.add(ctx, PMENU_PURCHASES_ID, pmenu_purchases); + + factory.add(ctx, SMENU_POSGOODRECNOTE_ID, + MenuManager.createSubMenu(ctx, "smenu.goods.received.note", + "GetAllPOSVendor.do?action=getAllVendors&isSales=true", + MODULE_NAME, pmenu_purchases.getID(), 3010)); + + factory.add(ctx, SMENU_POSGOODRETNOTE_ID, + MenuManager.createSubMenu(ctx, "smenu.goods.returned.note", + "GetAllPOSVendor.do?action=getAllVendors&isSales=false", + MODULE_NAME, pmenu_purchases.getID(), 3020)); + + factory.add(ctx, SMENU_GOODSRECNOTEHISTORY_HISTORY_ID, + MenuManager.createSubMenu(ctx, "smenu.goods.received.note.history", + "ViewPOSHistoryAction.do?action=getPOSHistory&orderType=" + UDIOrderTypes.POS_GOODS_RECEIVE_NOTE.getOrderType(), + MODULE_NAME, pmenu_purchases.getID(), 3030)); + + factory.add(ctx, SMENU_GOODSRETNOTEHISTORY_HISTORY_ID, + MenuManager.createSubMenu(ctx, "smenu.goods.returned.note.history", + "ViewPOSHistoryAction.do?action=getPOSHistory&orderType=" + UDIOrderTypes.POS_GOODS_RETURN_NOTE.getOrderType(), + MODULE_NAME, pmenu_purchases.getID(), 3040)); + + } + + + + private void loadPerformanceAnalysisMenu(Properties ctx, AbstractFactory factory) throws OperationException + { + UDIU_Menu pmenu_reports = MenuManager.createParentMenu(ctx, "pmenu.performance.analysis", MODULE_NAME, 4000); + pmenu_reports.setPosition(MENU_POSITION_TOP); + pmenu_reports.setImageLink("images/pos/buttons/button_reports.gif"); + + factory.add(ctx, PMENU_REPORTS_ID, pmenu_reports); + + factory.add(ctx, SMENU_CUSTSALESREPORT, + MenuManager.createSubMenu(ctx, "smenu.performance.analysis.report", + "CustomPOSReportAction.do?action=initCustomReport", + MODULE_NAME, pmenu_reports.getID(), 4010)); + + + factory.add(ctx, SMENU_POSINFO_ID, + MenuManager.createSubMenu(ctx, "smenu.sales.report.per.terminal", + "POSInfoReport.do", + MODULE_NAME, pmenu_reports.getID(), 4020)); + + factory.add(ctx, SMENU_ORDERHISTORY_ID, + MenuManager.createSubMenu(ctx, "smenu.order.history", + "InitPOSHistoryAction.do?action=initPOSHistory", + MODULE_NAME, pmenu_reports.getID(), 4030)); + + + factory.add(ctx, SMENU_DOCUMENTHISTORY_ID, + MenuManager.createSubMenu(ctx, "smenu.document.history", + "DocumentHistoryAction.do?action=initHistory", + MODULE_NAME, pmenu_reports.getID(), 4040)); + + factory.add(ctx, SMENU_VIEW_BPINFO, + MenuManager.createSubMenu(ctx, "smenu.bpartner.sales.details", + "ViewBPartnerInfoAction.do?action=getBpartnerInfo", + MODULE_NAME, pmenu_reports.getID(), 4050)); + + } + + + + private void loadStockMenu(Properties ctx, AbstractFactory factory) throws OperationException + { + UDIU_Menu pmenu_stock = MenuManager.createParentMenu(ctx, "pmenu.stock", MODULE_NAME, 5000); + pmenu_stock.setPosition(MENU_POSITION_TOP); + pmenu_stock.setImageLink("images/pos/buttons/button_order.gif"); + + factory.add(ctx, PMENU_STOCK_ID, pmenu_stock); + + + factory.add(ctx, SMENU_POSSTOCKMOV, + MenuManager.createSubMenu(ctx, "smenu.stock.movement", + "StockMovementReport.do", + MODULE_NAME, pmenu_stock.getID(), 5010)); + + + factory.add(ctx, SMENU_MYSTOCK_ID, + MenuManager.createSubMenu(ctx, "smenu.stock", + "GetPOSStockAction.do?action=getPOSStock", + MODULE_NAME, pmenu_stock.getID(), 5020)); + + + factory.add(ctx, SMENU_FASTMOVITEMS, + MenuManager.createSubMenu(ctx, "smenu.fast.moving.items", + "CustomFastMovingItemsReport.do", + MODULE_NAME, pmenu_stock.getID(), 5030)); + + factory.add(ctx, SMENU_SLOWMOVITEMS, + MenuManager.createSubMenu(ctx, "smenu.slow.moving.items", + "CustomSlowMovingItemsReport.do", + MODULE_NAME, pmenu_stock.getID(), 5040)); + + factory.add(ctx, SMENU_ADJUST_STOCK_ID, + MenuManager.createSubMenu(ctx, "smenu.adjust.stock.id", + "ViewInventory.do", + MODULE_NAME, pmenu_stock.getID(), 5040)); + + factory.add(ctx, SMENU_INVENTORY_HISTORY_ID, + MenuManager.createSubMenu(ctx, "smenu.inventory.history.id", + "ViewInventoryHistoryAction.do?action=viewInventoryHistory", + MODULE_NAME, pmenu_stock.getID(), 5050)); + + factory.add(ctx, SMENU_ADJUST_INVENTORY_ID, + MenuManager.createSubMenu(ctx, "smenu.adjust.inventory.id", + "AdjustWholeInventoryAction.do?action=createWholeInventory", + MODULE_NAME, pmenu_stock.getID(), 5060)); + + } + + + private void loadAdministrationMenu(Properties ctx, AbstractFactory factory) throws OperationException + { + UDIU_Menu pmenu_administration = MenuManager.createParentMenu(ctx, "pmenu.administration", MODULE_NAME, 6000); + pmenu_administration.setPosition(MENU_POSITION_TOP); + pmenu_administration.setImageLink("images/pos/buttons/button_administration.gif"); + + factory.add(ctx, PMENU_ADMINISTRATION_ID, pmenu_administration); + + + + factory.add(ctx, SMENU_CUSTOMER, + MenuManager.createSubMenu(ctx, "smenu.customers", + //"ViewAllCustomers.do", + "POSCustomerAction.do?action=initSearchPOSCustomer", + MODULE_NAME, pmenu_administration.getID(), 6010)); + + factory.add(ctx, SMENU_CREATEVENDOR_ID, + MenuManager.createSubMenu(ctx, "smenu.vendors", + "SearchVendor.do?action=initSearchVendors", + MODULE_NAME, pmenu_administration.getID(), 6020)); + + /*factory.add(ctx, SMENU_USER_ID, + MenuManager.createSubMenu(ctx, "smenu.users", + "POSUserAction.do?action=listUsers&first=1", + MODULE_NAME, pmenu_administration.getID(), 6030)); + + + factory.add(ctx, SMENU_VIEWROLE_ID, + MenuManager.createSubMenu(ctx, "smenu.role", + "POSRoleAction.do?action=listRoles&first=1", + MODULE_NAME, pmenu_administration.getID(), 6040));*/ + + factory.add(ctx, SMENU_USER_ID, + MenuManager.createSubMenu(ctx, "smenu.users", + "ListPOSUsers.do", + MODULE_NAME, pmenu_administration.getID(), 6030)); + + + factory.add(ctx, SMENU_VIEWROLE_ID, + MenuManager.createSubMenu(ctx, "smenu.role", + "ListPOSRoles.do", + MODULE_NAME, pmenu_administration.getID(), 6040)); + + + factory.add(ctx, SMENU_PRODUCTS, + MenuManager.createSubMenu(ctx, "smenu.products", + "ViewAllPOSProduct.do", + MODULE_NAME, pmenu_administration.getID(), 6050)); + + factory.add(ctx, SMENU_EDIT_ATTRIBUTE_VALUE, + MenuManager.createSubMenu(ctx, "smenu.edit.product.attribute.value", + "InitViewAttributesAction.do?action=initViewAttributeValues", + MODULE_NAME, pmenu_administration.getID(), 6060)); + + + factory.add(ctx, SMENU_CHECK_SEQUENCE, + MenuManager.createSubMenu(ctx, "smenu.check.repair.database.integrity", + "CheckSequenceAction.do?action=checkSequence", + MODULE_NAME, pmenu_administration.getID(), 6080)); + + + factory.add(ctx, SMENU_GENERATE_COMMISSION_ID, + MenuManager.createSubMenu(ctx, "smenu.generate.commission", + "GenerateCommission.do", + MODULE_NAME, pmenu_administration.getID(), 6090)); + + factory.add(ctx, SMENU_VIEW_GENERATED_COMMISSION_ID, + MenuManager.createSubMenu(ctx, "smenu.view.last.generated.commission", + "ViewCommissionAction.do?action=viewCommission", + MODULE_NAME, pmenu_administration.getID(), 6100)); + + factory.add(ctx, SMENU_VIEW_PAYMENT_TERM, + MenuManager.createSubMenu(ctx, "smenu.payment.term", + "ViewAllPaymentTermAction.do?action=viewAllPaymentTerms", + MODULE_NAME, pmenu_administration.getID(), 6110)); + + factory.add(ctx, SMENU_VIEW_TAX, + MenuManager.createSubMenu(ctx, "smenu.tax", + "TaxAction.do?action=viewAllTax", + MODULE_NAME, pmenu_administration.getID(), 6120)); + + factory.add(ctx, SMENU_VIEW_PREFERENCES, + MenuManager.createSubMenu(ctx, "smenu.preferences", + "ViewPreferences.do", + MODULE_NAME, pmenu_administration.getID(), 6130)); + + factory.add(ctx, SMENU_VIEW_BPARTNERS, + MenuManager.createSubMenu(ctx, "smenu.bpartners", + "BusinessPartners.do", + MODULE_NAME, pmenu_administration.getID(), 6140)); + + factory.add(ctx, SMENU_PRICE_CHECK, + MenuManager.createSubMenu(ctx, "smenu.price.check", + "PriceCheck.do", + MODULE_NAME, pmenu_administration.getID(), 6150)); + } + + + public UDIPO get(Properties ctx, String key) throws OperationException + { + Properties nCtx = (Properties)ctx.clone(); + Env.setContext(nCtx, UdiConstants.CLIENT_ID_CTX_PARAM, "0"); + Env.setContext(nCtx, UdiConstants.ORG_ID_CTX_PARAM, "0"); + return super.get(nCtx, key); + } + + protected void setFields(Properties ctx, PO fromPO, PO toPO) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException + { + X_U_Menu fromUMenu = (X_U_Menu)fromPO; + X_U_Menu toUMenu = (X_U_Menu)toPO; + + toUMenu.setMenuLink(fromUMenu.getMenuLink()); + toUMenu.setName(fromUMenu.getName()); + toUMenu.setHasSubMenu(fromUMenu.isHasSubMenu()); + toUMenu.setModule(fromUMenu.getModule()); + toUMenu.setParentMenu_ID(fromUMenu.getParentMenu_ID()); + toUMenu.setImageLink(fromUMenu.getImageLink()); + toUMenu.setIsActive(fromUMenu.isActive()); + toUMenu.setPosition(fromUMenu.getPosition()); + toUMenu.setCategory(fromUMenu.getCategory()); + toUMenu.setSequence(fromUMenu.getSequence()); + } +} diff --git a/posterita/src/main/org/posterita/factory/ProcessFactory.java b/posterita/src/main/org/posterita/factory/ProcessFactory.java new file mode 100644 index 0000000000..724cdcd3b9 --- /dev/null +++ b/posterita/src/main/org/posterita/factory/ProcessFactory.java @@ -0,0 +1,96 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 6, 2005 by vishee + */ + +package org.posterita.factory; + +import java.util.Properties; + +import org.compiere.model.MProcess; +import org.compiere.process.SvrProcess; +import org.posterita.exceptions.OperationException; +import org.posterita.model.UDIMProcess; +import org.posterita.model.UDIPO; + + + +public class ProcessFactory extends AbstractFactory +{ + + + private static ProcessFactory singleton; + + + private ProcessFactory() throws OperationException + { + super(); + + } + + public static ProcessFactory getFactoryInstance(Properties ctx) throws Exception + { + if (singleton ==null) + singleton = new ProcessFactory(); + + return singleton; + } + + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, singleton); + } + + + + /* + * key - the value retrieved from properties file for the name of the process + * className - the class from which the process will run (eg com.udimu.process.MyProcess where MyProcess is the java file) + */ + private UDIPO createProcess(Properties ctx, String className) throws OperationException + { + + MProcess mProcess = new MProcess(ctx,0, null); + mProcess.setClassname(className); + mProcess.setDescription(className); + mProcess.setName(className); + mProcess.setValue(className); + + UDIMProcess process = new UDIMProcess(mProcess); + + return process; + + } + + public SvrProcess getSvrProcess(Properties ctx,String key) throws Exception + { + UDIMProcess p = (UDIMProcess) singleton.get(ctx, key); + Object arr[] = {}; + SvrProcess process = (SvrProcess) Class.forName(p.getClass().getName()).getConstructors()[0].newInstance(arr); // use better reflection + return process; + } + + @Override + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + // TODO Auto-generated method stub + + } +} diff --git a/posterita/src/main/org/posterita/factory/ProductAttributeFactory.java b/posterita/src/main/org/posterita/factory/ProductAttributeFactory.java new file mode 100644 index 0000000000..ec6819f310 --- /dev/null +++ b/posterita/src/main/org/posterita/factory/ProductAttributeFactory.java @@ -0,0 +1,162 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.factory; + +import java.util.Properties; + +import org.posterita.businesslogic.ProductAttributeManager; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ReloadFactoryException; +import org.posterita.model.UDIMAttributeSet; + + +public class ProductAttributeFactory extends AbstractFactory +{ + public static final String ATTRIBUTE_CAR_MAKE_ID = "attribute.car.make.id"; + public static final String ATTRIBUTE_CAR_MODEL_ID = "attribute.car.model.id"; + public static final String ATTRIBUTE_CAR_MODELGROUP_ID = "attribute.car.modelGroup.id"; + public static final String ATTRIBUTE_CAR_COLOUR_ID = "attribute.car.colour.id"; + public static final String ATTRIBUTE_CAR_YEAR_ID = "attribute.car.year.id"; + public static final String ATTRIBUTE_CAR_TRX_ID = "attribute.car.trx.id"; + + private static final String ATTRIBUTE_CAR_MAKE_NAME = "Make"; + private static final String ATTRIBUTE_CAR_MODEL_NAME = "Model"; + private static final String ATTRIBUTE_CAR_MODELGROUP_NAME = "Model Group"; + private static final String ATTRIBUTE_CAR_COLOUR_NAME = "Colour"; + private static final String ATTRIBUTE_CAR_YEAR_NAME = "Year"; + private static final String ATTRIBUTE_CAR_TRX_NAME = "Transmission"; + + public static final String ATTRIBUTE_BIKE_MAKE_ID = "attribute.bike.make.id"; + public static final String ATTRIBUTE_BIKE_MODEL_ID = "attribute.bike.model.id"; + public static final String ATTRIBUTE_BIKE_MODELGROUP_ID = "attribute.bike.modelGroup.id"; + public static final String ATTRIBUTE_BIKE_COLOUR_ID = "attribute.bike.colour.id"; + public static final String ATTRIBUTE_BIKE_YEAR_ID = "attribute.bike.year.id"; + public static final String ATTRIBUTE_BIKE_TRX_ID = "attribute.bike.trx.id"; + + private static final String ATTRIBUTE_BIKE_MAKE_NAME = "Make"; + private static final String ATTRIBUTE_BIKE_MODEL_NAME = "Model"; + private static final String ATTRIBUTE_BIKE_MODELGROUP_NAME = "Model Group"; + private static final String ATTRIBUTE_BIKE_COLOUR_NAME = "Colour"; + private static final String ATTRIBUTE_BIKE_YEAR_NAME = "Year"; + private static final String ATTRIBUTE_BIKE_TRX_NAME = "Transmission"; + + + private static ProductAttributeFactory pAttributeFactory; + private ProductAttributeFactory() throws OperationException + { + + } + + public static ProductAttributeFactory getFactoryInstance() throws OperationException + { + if (pAttributeFactory == null) + pAttributeFactory = new ProductAttributeFactory(); + + return pAttributeFactory; + } + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, pAttributeFactory); + } + + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + factory.add(ctx, ATTRIBUTE_CAR_MAKE_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_CAR_MAKE_NAME)); + factory.add(ctx, ATTRIBUTE_CAR_MODEL_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_CAR_MODEL_NAME)); + factory.add(ctx, ATTRIBUTE_CAR_MODELGROUP_ID, ProductAttributeManager.createAttribute(ctx,ATTRIBUTE_CAR_MODELGROUP_NAME)); + factory.add(ctx, ATTRIBUTE_CAR_COLOUR_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_CAR_COLOUR_NAME)); + factory.add(ctx, ATTRIBUTE_CAR_TRX_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_CAR_TRX_NAME)); + factory.add(ctx, ATTRIBUTE_CAR_YEAR_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_CAR_YEAR_NAME)); + + factory.add(ctx, ATTRIBUTE_BIKE_MAKE_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_BIKE_MAKE_NAME)); + factory.add(ctx, ATTRIBUTE_BIKE_MODEL_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_BIKE_MODEL_NAME)); + factory.add(ctx, ATTRIBUTE_BIKE_MODELGROUP_ID, ProductAttributeManager.createAttribute(ctx,ATTRIBUTE_BIKE_MODELGROUP_NAME)); + factory.add(ctx, ATTRIBUTE_BIKE_COLOUR_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_BIKE_COLOUR_NAME)); + factory.add(ctx, ATTRIBUTE_BIKE_TRX_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_BIKE_TRX_NAME)); + factory.add(ctx, ATTRIBUTE_BIKE_YEAR_ID, ProductAttributeManager.createAttribute(ctx, ATTRIBUTE_BIKE_YEAR_NAME)); + + UDIMAttributeSet carAttributeSet = (UDIMAttributeSet) ProductAttributeSetFactory.getFactoryInstance(ctx).get(ctx, ProductAttributeSetFactory.ATTRIBUTE_SET_CAR_ID); + ProductAttributeManager.createAttributeUse(ctx, carAttributeSet, ATTRIBUTE_CAR_MAKE_ID); + ProductAttributeManager.createAttributeUse(ctx, carAttributeSet, ATTRIBUTE_CAR_MODEL_ID ); + ProductAttributeManager.createAttributeUse(ctx, carAttributeSet, ATTRIBUTE_CAR_MODELGROUP_ID ); + ProductAttributeManager.createAttributeUse(ctx, carAttributeSet, ATTRIBUTE_CAR_COLOUR_ID ); + ProductAttributeManager.createAttributeUse(ctx, carAttributeSet, ATTRIBUTE_CAR_TRX_ID ); + ProductAttributeManager.createAttributeUse(ctx, carAttributeSet, ATTRIBUTE_CAR_YEAR_ID ); + + UDIMAttributeSet bikeAttributeSet = (UDIMAttributeSet) ProductAttributeSetFactory.getFactoryInstance(ctx).get(ctx, ProductAttributeSetFactory.ATTRIBUTE_SET_BIKE_ID); + ProductAttributeManager.createAttributeUse(ctx, bikeAttributeSet, ATTRIBUTE_BIKE_MAKE_ID); + ProductAttributeManager.createAttributeUse(ctx, bikeAttributeSet, ATTRIBUTE_BIKE_MODEL_ID ); + ProductAttributeManager.createAttributeUse(ctx, bikeAttributeSet, ATTRIBUTE_BIKE_MODELGROUP_ID ); + ProductAttributeManager.createAttributeUse(ctx, bikeAttributeSet, ATTRIBUTE_BIKE_COLOUR_ID ); + ProductAttributeManager.createAttributeUse(ctx, bikeAttributeSet, ATTRIBUTE_BIKE_TRX_ID ); + ProductAttributeManager.createAttributeUse(ctx, bikeAttributeSet, ATTRIBUTE_BIKE_YEAR_ID ); + + //create attribute for t-shirt here + //First need to create tshirt Attribute Set + //Then create the attributes which are needed + //We can use the model and colour attributes already created i.e the ones used by cars and bikes + //create attribute use + //Attribute Use: An Attribute Set can have many attributes + + /* + * + * eg a TShirt Attribute Set have attributes namely Model, Colour, Size and Design + * AttributeUse links the Attribute Set with the Attributes + * + * eg Table Structure for M_AttributeUse + * + * ----------------------------- + * | AttributeSet | Attribute | + * ----------------------------- + * | TShirt | Model | + * ----------------------------- + * | TShirt | Colour | + * ----------------------------- + * | TShirt | Size | + * ----------------------------- + * + * In this way we can dynamically add or remove attributes. + * + * Note: Product is linked to an AttributeSet. + * The AttributeSet has attributes(from AttributeUse) + * Attributes has AttributeValues. + * + * + */ + + + } + + public static void reloadFactory(Properties ctx) throws ReloadFactoryException + { + try + { + ProductAttributeFactory nFactory = new ProductAttributeFactory(); + nFactory.initFactory(ctx, nFactory); + pAttributeFactory = nFactory; + } + catch(OperationException ex) + { + throw new ReloadFactoryException("Could not reload ProductAttributeFactory", ex); + } + } + +} diff --git a/posterita/src/main/org/posterita/factory/ProductAttributeSetFactory.java b/posterita/src/main/org/posterita/factory/ProductAttributeSetFactory.java new file mode 100644 index 0000000000..5d976d0f3f --- /dev/null +++ b/posterita/src/main/org/posterita/factory/ProductAttributeSetFactory.java @@ -0,0 +1,80 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.factory; + +import java.util.Properties; + +import org.posterita.businesslogic.ProductAttributeSetManager; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ReloadFactoryException; + + +public class ProductAttributeSetFactory extends AbstractFactory +{ + private static ProductAttributeSetFactory pAttributeSetFactory; + + public static final String ATTRIBUTE_SET_CAR_ID = "attributeset.car.id"; + private static final String ATTRIBUTE_SET_CAR_NAME = "Car"; + + public static final String ATTRIBUTE_SET_BIKE_ID = "attributeset.bike.id"; + private static final String ATTRIBUTE_SET_BIKE_NAME ="Bike"; + + + private ProductAttributeSetFactory() throws OperationException + { + + } + + public static ProductAttributeSetFactory getFactoryInstance(Properties ctx) throws OperationException + { + if (pAttributeSetFactory == null) + pAttributeSetFactory = new ProductAttributeSetFactory(); + + return pAttributeSetFactory; + } + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, pAttributeSetFactory); + } + + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + factory.add(ctx, ATTRIBUTE_SET_CAR_ID, ProductAttributeSetManager.createAttributeSet(ctx, ATTRIBUTE_SET_CAR_NAME)); + factory.add(ctx, ATTRIBUTE_SET_BIKE_ID, ProductAttributeSetManager.createAttributeSet(ctx, ATTRIBUTE_SET_BIKE_NAME)); + } + + public static void reloadFactory(Properties ctx) throws ReloadFactoryException + { + try + { + ProductAttributeSetFactory nFactory = new ProductAttributeSetFactory(); + nFactory.initFactory(ctx, nFactory); + pAttributeSetFactory = nFactory; + } + catch(OperationException ex) + { + throw new ReloadFactoryException("Could not reload ProductAttributeSetFactory", ex); + } + } + + + +} diff --git a/posterita/src/main/org/posterita/factory/ProductAttributeUseFactory.java b/posterita/src/main/org/posterita/factory/ProductAttributeUseFactory.java new file mode 100644 index 0000000000..8a29670a5e --- /dev/null +++ b/posterita/src/main/org/posterita/factory/ProductAttributeUseFactory.java @@ -0,0 +1,107 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.factory; + +import java.util.Properties; + +import org.compiere.model.MAttributeUse; + +import org.posterita.exceptions.OperationException; +import org.posterita.model.UDIMAttribute; +import org.posterita.model.UDIMAttributeSet; +import org.posterita.model.UDIMAttributeUse; + + +public class ProductAttributeUseFactory extends AbstractFactory +{ + public static final String CAR_MAKE_ATTRIBUTE_USE_ID = "attributeuse.make.car.id"; + public static final String CAR_MODEL_ATTRIBUTE_USE_ID = "attributeuse.model.car.id"; + public static final String CAR_COLOUR_ATTRIBUTE_USE_ID = "attributeuse.colour.car.id"; + public static final String CAR_YEAR_ATTRIBUTE_USE_ID = "attributeuse.year.car.id"; + public static final String CAR_TRX_ATTRIBUTE_USE_ID = "attributeuse.trx.car.id"; + + public static final String BIKE_MAKE_ATTRIBUTE_USE_ID = "attributeuse.make.bike.id"; + public static final String BIKE_MODEL_ATTRIBUTE_USE_ID = "attributeuse.model.bike.id"; + public static final String BIKE_COLOUR_ATTRIBUTE_USE_ID = "attributeuse.colour.bike.id"; + public static final String BIKE_YEAR_ATTRIBUTE_USE_ID = "attributeuse.year.bike.id"; + public static final String BIKE_TRX_ATTRIBUTE_USE_ID = "attributeuse.bike.car.id"; + + private static ProductAttributeUseFactory productAttributeUseFactory; + private ProductAttributeUseFactory() throws OperationException + { + + } + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, productAttributeUseFactory); + } + + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + UDIMAttributeSet carAttributeSet = (UDIMAttributeSet) ProductAttributeSetFactory.getFactoryInstance(ctx).get(ctx, ProductAttributeSetFactory.ATTRIBUTE_SET_CAR_ID); + UDIMAttribute carMakeAttribute = (UDIMAttribute) ProductAttributeSetFactory.getFactoryInstance(ctx).get(ctx, ProductAttributeFactory.ATTRIBUTE_CAR_MAKE_ID); + UDIMAttribute carColourAttribute = (UDIMAttribute) ProductAttributeFactory.getFactoryInstance().get(ctx, ProductAttributeFactory.ATTRIBUTE_CAR_COLOUR_ID); + UDIMAttribute carModelAttribute = (UDIMAttribute) ProductAttributeFactory.getFactoryInstance().get(ctx, ProductAttributeFactory.ATTRIBUTE_CAR_MODEL_ID); + UDIMAttribute carTrxAttribute = (UDIMAttribute) ProductAttributeFactory.getFactoryInstance().get(ctx, ProductAttributeFactory.ATTRIBUTE_CAR_TRX_ID); + UDIMAttribute carYearAttribute = (UDIMAttribute) ProductAttributeFactory.getFactoryInstance().get(ctx, ProductAttributeFactory.ATTRIBUTE_CAR_YEAR_ID); + + factory.add(ctx, CAR_MAKE_ATTRIBUTE_USE_ID, createAttributeUse(ctx, carAttributeSet, carMakeAttribute)); + factory.add(ctx, CAR_COLOUR_ATTRIBUTE_USE_ID, createAttributeUse(ctx,carAttributeSet, carColourAttribute)); + factory.add(ctx, CAR_MODEL_ATTRIBUTE_USE_ID, createAttributeUse(ctx,carAttributeSet, carModelAttribute)); + factory.add(ctx, CAR_TRX_ATTRIBUTE_USE_ID, createAttributeUse(ctx,carAttributeSet, carTrxAttribute)); + factory.add(ctx, CAR_YEAR_ATTRIBUTE_USE_ID, createAttributeUse(ctx,carAttributeSet, carYearAttribute)); + + UDIMAttributeSet bikeAttributeSet = (UDIMAttributeSet) ProductAttributeSetFactory.getFactoryInstance(ctx).get(ctx, ProductAttributeSetFactory.ATTRIBUTE_SET_BIKE_ID); + UDIMAttribute bikeMakeAttribute = (UDIMAttribute) ProductAttributeSetFactory.getFactoryInstance(ctx).get(ctx, ProductAttributeFactory.ATTRIBUTE_BIKE_MAKE_ID); + UDIMAttribute bikeColourAttribute = (UDIMAttribute) ProductAttributeFactory.getFactoryInstance().get(ctx, ProductAttributeFactory.ATTRIBUTE_BIKE_COLOUR_ID); + UDIMAttribute bikeModelAttribute = (UDIMAttribute) ProductAttributeFactory.getFactoryInstance().get(ctx, ProductAttributeFactory.ATTRIBUTE_BIKE_MODEL_ID); + UDIMAttribute bikeTrxAttribute = (UDIMAttribute) ProductAttributeFactory.getFactoryInstance().get(ctx, ProductAttributeFactory.ATTRIBUTE_BIKE_TRX_ID); + UDIMAttribute bikeYearAttribute = (UDIMAttribute) ProductAttributeFactory.getFactoryInstance().get(ctx,ProductAttributeFactory.ATTRIBUTE_BIKE_YEAR_ID); + + factory.add(ctx, BIKE_MAKE_ATTRIBUTE_USE_ID, createAttributeUse(ctx, carAttributeSet, bikeMakeAttribute)); + factory.add(ctx, BIKE_COLOUR_ATTRIBUTE_USE_ID, createAttributeUse(ctx,bikeAttributeSet, bikeColourAttribute)); + factory.add(ctx, BIKE_MODEL_ATTRIBUTE_USE_ID, createAttributeUse(ctx,bikeAttributeSet, bikeModelAttribute)); + factory.add(ctx, BIKE_TRX_ATTRIBUTE_USE_ID, createAttributeUse(ctx,bikeAttributeSet, bikeTrxAttribute)); + factory.add(ctx,BIKE_YEAR_ATTRIBUTE_USE_ID, createAttributeUse(ctx,bikeAttributeSet, bikeYearAttribute)); + + + } + + public static ProductAttributeUseFactory getFactoryInstance(Properties ctx) throws Exception + { + if (productAttributeUseFactory == null) + productAttributeUseFactory = new ProductAttributeUseFactory(); + + return productAttributeUseFactory; + } + + private UDIMAttributeUse createAttributeUse(Properties ctx, UDIMAttributeSet attributeSet, UDIMAttribute attribute) + { + + MAttributeUse attributeUse = new MAttributeUse(ctx, 0, null); + attributeUse.setM_AttributeSet_ID(attributeSet.getID()); + attributeUse.setM_Attribute_ID(attribute.getID()); + attributeUse.setSeqNo(10); + UDIMAttributeUse udiAttributeUse = new UDIMAttributeUse(attributeUse); + + return udiAttributeUse; + } +} diff --git a/posterita/src/main/org/posterita/factory/SystemObjectsFactory.java b/posterita/src/main/org/posterita/factory/SystemObjectsFactory.java new file mode 100644 index 0000000000..d293c863a2 --- /dev/null +++ b/posterita/src/main/org/posterita/factory/SystemObjectsFactory.java @@ -0,0 +1,205 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.factory; + +import java.util.Properties; + +import org.compiere.model.MClient; + +import org.posterita.core.SystemObjects; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ReloadFactoryException; +import org.posterita.lib.UdiConstants; +import org.posterita.model.UDIMAssetGroup; +import org.posterita.model.UDIMDiscountSchema; +import org.posterita.model.UDIMPriceList; +import org.posterita.model.UDIMPriceListVersion; +import org.posterita.model.UDIMProductCategory; +import org.posterita.model.UDIMTax; +import org.posterita.model.UDIMTaxCategory; + + +public class SystemObjectsFactory extends AbstractFactory +{ + + public static final String PRODUCT_CATEGORY_CAR_ID = "productCategory.car.id"; + public static final String TAX_CATEGORY_DEFAULT_ID = "taxCategory.default.id"; + public static final String DEFAULT_BPGROUP_ID = "default.bpartner.group"; + public static final String CAR_ASSET_GRP_ID = "car.assetgroup.id"; + public static final String BIKE_ASSET_GRP_ID = "bike.assetgroup.id"; + public static final String DEFAULT_TAX_ID = "tax.default.id"; + public static final String SALES_PRICELIST_ID = "pricelist.sales.id"; + public static final String PURCHASE_PRICELIST_ID = "pricelist.purchase.id"; + public static final String WEBSTORE_SALES_PRICELIST_ID = "webstore.pricelist.sales.id"; + + public static final String PURCHASE_PRICELV_ID = "priceLV.purchase.id"; + public static final String SALES_PRICELV_ID = "priceLV.sales.id"; + public static final String DISCOUNT_SCHEMA_ID = "discountschema.id"; + public static final String WHOLESALE_PURCHASE_PRICELIST_ID="wholesale.priceList.purchase.id"; + public static final String WHOLESALE_PURCHASE_PRICELV_ID = "wholesale.priceLV.purchase.id"; + public static final String WEBSTORE_SALES_PRICELV_ID = "webstore.priceLV.sales.id"; + + + public static final String DEALER_TRANSFER_PRICELIST_ID = "dealer.transfer.pricelist.id"; + public static final String DEALER_TRANSFER_PRICELV_ID = "dealer.transfer.priceLV.id"; + + + public static final String PRODUCT_CATEGORY_USED_CAR_ID = "productCategory.usedCar.id"; + public static final String USED_CAR_ASSET_GRP_ID = "usedCar.assetgroup.id"; + + + public static final String PRODUCT_CATEGORY_BIKE_ID = "productCategory.bike.id"; + public static final String PRODUCT_CATEGORY_USED_BIKE_ID = "productCategory.usedbike.id"; + + public static final String REQUEST_TYPE_EMAIL = "request.type.email"; + + + private static SystemObjectsFactory systemObjectsFactory; + + private SystemObjectsFactory() throws OperationException + { + + } + + public static SystemObjectsFactory getFactoryInstance() throws OperationException + { + if (systemObjectsFactory == null) + systemObjectsFactory = new SystemObjectsFactory(); + + return systemObjectsFactory; + } + + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, systemObjectsFactory); + } + + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + + UDIMAssetGroup assetGroup = SystemObjects.getAssetGroup(ctx, "Car Asset Group"); + factory.add(ctx, CAR_ASSET_GRP_ID, assetGroup); + assetGroup = (UDIMAssetGroup) factory.get(ctx, CAR_ASSET_GRP_ID); + + UDIMProductCategory productCategory = SystemObjects.getProductCategory(ctx, "Car"); + productCategory.setA_Asset_Group_ID(assetGroup.getID()); + + factory.add(ctx, PRODUCT_CATEGORY_CAR_ID, productCategory); + + + factory.add(ctx, BIKE_ASSET_GRP_ID, SystemObjects.getAssetGroup(ctx, "Bike Asset Group")); + UDIMAssetGroup bikeAssetGroup = (UDIMAssetGroup) factory.get(ctx, BIKE_ASSET_GRP_ID); + + UDIMProductCategory bikeProductCategory = SystemObjects.getProductCategory(ctx, "Bike"); + bikeProductCategory.setA_Asset_Group_ID(bikeAssetGroup.getID()); + + UDIMProductCategory usedBikeProductCategory = SystemObjects.getProductCategory(ctx, "Used Bike"); + bikeProductCategory.setA_Asset_Group_ID(bikeAssetGroup.getID()); + + factory.add(ctx, PRODUCT_CATEGORY_BIKE_ID, bikeProductCategory); + factory.add(ctx, PRODUCT_CATEGORY_USED_BIKE_ID, usedBikeProductCategory); + + + factory.add(ctx, USED_CAR_ASSET_GRP_ID, SystemObjects.getAssetGroup(ctx, "Car Asset Group")); + UDIMAssetGroup usedCarAssetGroup = (UDIMAssetGroup) factory.get(ctx, USED_CAR_ASSET_GRP_ID); + + UDIMProductCategory usedCarProductCategory = SystemObjects.getProductCategory(ctx, "Used Car"); + usedCarProductCategory.setA_Asset_Group_ID(usedCarAssetGroup.getID()); + + factory.add(ctx, PRODUCT_CATEGORY_USED_CAR_ID, usedCarProductCategory); + + factory.add(ctx, TAX_CATEGORY_DEFAULT_ID, SystemObjects.getTaxCategory(ctx, "Default Tax Category")); + UDIMTaxCategory taxCategory = (UDIMTaxCategory) factory.get(ctx, TAX_CATEGORY_DEFAULT_ID); + + UDIMTax tax = SystemObjects.getTax(ctx, "Udi tax", UdiConstants.COUNTRY_MAURITIUS, "default udi tax"); + tax.setC_Tax_Category_ID(taxCategory.getID()); + factory.add(ctx, DEFAULT_TAX_ID, tax); + + factory.add(ctx, PURCHASE_PRICELIST_ID, SystemObjects.getPriceList(ctx, "Standard Purchase Price List", MClient.get(ctx).getC_Currency_ID())); + factory.add(ctx, SALES_PRICELIST_ID, SystemObjects.getPriceList(ctx, "Standard Sales Price List", MClient.get(ctx).getC_Currency_ID())); +// systemObjectsFactory.add(ctx, WEBSTORE_SALES_PRICELIST_ID, SystemObjects.getPriceList(ctx, "Webstore Sales Price List Euro", UdiConstants.CURRENCY_EURO)); + + factory.add(ctx, DISCOUNT_SCHEMA_ID, SystemObjects.getDiscountSchema(ctx, "Udi Discount Schema")); + + factory.add(ctx, WHOLESALE_PURCHASE_PRICELIST_ID, SystemObjects.getPriceList(ctx,"Wholesale Purchase Price List", MClient.get(ctx).getC_Currency_ID())); + factory.add(ctx, DISCOUNT_SCHEMA_ID, SystemObjects.getDiscountSchema(ctx, "Udi Discount Schema")); + + UDIMPriceList purchasePL = (UDIMPriceList) factory.get(ctx, PURCHASE_PRICELIST_ID); +// UDIMPriceList webstoreSalesPL = (UDIMPriceList) systemObjectsFactory.get(ctx, WEBSTORE_SALES_PRICELIST_ID); + UDIMPriceList salesPL = (UDIMPriceList) factory.get(ctx, SALES_PRICELIST_ID); + UDIMDiscountSchema discountSchema = (UDIMDiscountSchema) factory.get(ctx, DISCOUNT_SCHEMA_ID); + + UDIMPriceList WholesalePurchasePL = (UDIMPriceList) factory.get(ctx, WHOLESALE_PURCHASE_PRICELIST_ID); + + UDIMPriceListVersion purchasePLV = SystemObjects.getPriceListVersion(ctx, "Purchase Price List"); + purchasePLV.setM_DiscountSchema_ID(discountSchema.getID()); + purchasePLV.setM_PriceList_ID(purchasePL.getID()); + + factory.add(ctx, PURCHASE_PRICELV_ID, purchasePLV); + +// UDIMPriceListVersion webstoreSalesPLV = SystemObjects.getPriceListVersion(ctx, "Webstore Sales Price List"); +// webstoreSalesPLV.setM_DiscountSchema_ID(discountSchema.getID()); +// webstoreSalesPLV.setM_PriceList_ID(webstoreSalesPL.getID()); +// +// systemObjectsFactory.add(ctx, WEBSTORE_SALES_PRICELV_ID, webstoreSalesPLV); + + + + UDIMPriceListVersion WholesalePurchasePLV = SystemObjects.getPriceListVersion(ctx, "Wholesale Price List"); + WholesalePurchasePLV.setM_DiscountSchema_ID(discountSchema.getID()); + WholesalePurchasePLV.setM_PriceList_ID(WholesalePurchasePL.getID()); + + factory.add(ctx, WHOLESALE_PURCHASE_PRICELV_ID, WholesalePurchasePLV); + + UDIMPriceListVersion salesPLV = SystemObjects.getPriceListVersion(ctx, "Retail Price List"); + salesPLV.setM_DiscountSchema_ID(discountSchema.getID()); + salesPLV.setM_PriceList_ID(salesPL.getID()); + + factory.add(ctx, SALES_PRICELV_ID, salesPLV); + + UDIMPriceList dealerTransferPriceList = SystemObjects.getPriceList(ctx, "Standard Dealer Transfer Price List", MClient.get(ctx).getC_Currency_ID()); + factory.add(ctx, DEALER_TRANSFER_PRICELIST_ID, dealerTransferPriceList); + + UDIMPriceListVersion dealerTransferPLV = SystemObjects.getPriceListVersion(ctx, "Retail Price List"); + dealerTransferPLV.setM_DiscountSchema_ID(discountSchema.getID()); + dealerTransferPLV.setM_PriceList_ID(dealerTransferPriceList.getID()); + factory.add(ctx, DEALER_TRANSFER_PRICELV_ID, dealerTransferPLV); + + + /*UDIMRequestType emailRequestType = SystemObjects.getRequestType(ctx, "EMail"); + systemObjectsFactory.add(ctx, REQUEST_TYPE_EMAIL, emailRequestType);*/ + } + + public static void reloadFactory(Properties ctx) throws ReloadFactoryException + { + try + { + SystemObjectsFactory nFactory = new SystemObjectsFactory(); + nFactory.initFactory(ctx, nFactory); + systemObjectsFactory = nFactory; + } + catch(OperationException ex) + { + throw new ReloadFactoryException("Could not reload SystemObjectsFactory", ex); + } + } + +} diff --git a/posterita/src/main/org/posterita/factory/UserFactory.java b/posterita/src/main/org/posterita/factory/UserFactory.java new file mode 100644 index 0000000000..1add266e24 --- /dev/null +++ b/posterita/src/main/org/posterita/factory/UserFactory.java @@ -0,0 +1,92 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.factory; + +import java.util.Properties; + +import org.compiere.model.MBPartner; +import org.compiere.model.MOrg; +import org.compiere.model.MUser; +import org.compiere.util.Env; + +import org.posterita.core.SystemObjects; +import org.posterita.exceptions.OperationException; +import org.posterita.model.UDIMUser; +import org.posterita.model.UDIPO; + + +public class UserFactory extends AbstractFactory +{ + private static UserFactory singleton; + + public static final String SUPER_USER_ID = "superUser.id"; + public static String UDI_ADMIN_ID = "udiAdmin.id"; + public static String HSAFAUTO_ADMIN_ID = "hsafAuto.admin.id"; + public static String HSAFWING_ADMIN_ID = "hsafWing.Admin.id"; + + private UserFactory() throws OperationException + { + + } + + public static UserFactory getFactoryInstance() throws OperationException + { + if (singleton == null) + singleton = new UserFactory(); + + return singleton; + } + + protected void loadFactory(Properties ctx) throws OperationException + { + loadFactory(ctx, singleton); + } + + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + factory.add(ctx, SUPER_USER_ID, createUser(ctx, SystemObjects.getSuperUser(ctx))); + // singleton.add(UDI_ADMIN_ID, createUser(ctx, SystemObjects.getUdiAdmin(ctx))); + // singleton.add(HSAFAUTO_ADMIN_ID, createUser(ctx, SystemObjects.getHsafAuto(ctx))); + // singleton.add(HSAFWING_ADMIN_ID, createUser(ctx, SystemObjects.getHsafWing(ctx))); + + } + + private UDIPO createUser(Properties ctx, MUser mUser) throws OperationException + { + MUser user = new MUser(ctx, 0, null); + user.setName(mUser.getName()); + user.setPassword(mUser.getPassword()); + user.setEMail(mUser.getEMail()); + + int ad_org_id = Env.getAD_Org_ID(ctx); + MOrg org = new MOrg(ctx, ad_org_id, null); + + // Is it necessary, taking business partner of the organisation. + // Should create a bpartner for this user. + // DefaultUser, Should maybe call a manager here. + MBPartner bpartner = new MBPartner(ctx, org.getLinkedC_BPartner_ID(null), null); + + user.setC_BPartner_ID(bpartner.get_ID()); + + UDIMUser udiMuser = new UDIMUser(user); + + return udiMuser; + } +} diff --git a/posterita/src/main/org/posterita/factory/UserRoleFactory.java b/posterita/src/main/org/posterita/factory/UserRoleFactory.java new file mode 100644 index 0000000000..ae72dbaeaf --- /dev/null +++ b/posterita/src/main/org/posterita/factory/UserRoleFactory.java @@ -0,0 +1,86 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.factory; + +import java.util.Properties; + +import org.posterita.exceptions.OperationException; + + +public class UserRoleFactory extends AbstractFactory +{ + + @Override + protected void loadFactory(Properties ctx) throws OperationException + { + // TODO Auto-generated method stub + + } + + @Override + protected void loadFactory(Properties ctx, AbstractFactory factory) throws OperationException + { + // TODO Auto-generated method stub + + } + /*private static UserRoleFactory singleton; + + public static final String USER_ROLE_SUPER_USER_ID = "user.role.superUser.id"; + + private UserRoleFactory() throws OperationException + { + + } + + public static UserRoleFactory getFactoryInstance() throws Exception + { + if (singleton ==null) + singleton = new UserRoleFactory(); + + return singleton; + } + + protected void loadFactory(Properties ctx) throws OperationException + { + //TODO Change the key + singleton.add(ctx, USER_ROLE_SUPER_USER_ID, createUserRole(ctx,UserFactory.SUPER_USER_ID, RoleFactory.ROLE_SYSTEM_ADMINISTRATOR_ID)); + } + + private UDIPO createUserRole(Properties ctx, String userKey, String roleKey) throws OperationException + { + MUserRoles userRoles = new MUserRoles(ctx, 0, null); + + UserFactory userFactory = UserFactory.getFactoryInstance(); + UDIMUser udiMUser = (UDIMUser) userFactory.get(ctx, userKey); + + RoleFactory roleFactory = RoleFactory.getFactoryInstance(); + UDIMRole udiMRole = (UDIMRole) roleFactory.get(ctx, roleKey); + + userRoles.setAD_User_ID(udiMUser.getID()); + userRoles.setAD_Role_ID(udiMRole.getID()); + + UDIMUserRoles udiUserRoles = new UDIMUserRoles(userRoles); + + return udiUserRoles; + } + + */ + +} diff --git a/posterita/src/main/org/posterita/factory/WebProperties.java b/posterita/src/main/org/posterita/factory/WebProperties.java new file mode 100644 index 0000000000..f8e18d3df8 --- /dev/null +++ b/posterita/src/main/org/posterita/factory/WebProperties.java @@ -0,0 +1,35 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 12-Oct-2005 + */ + + +package org.posterita.factory; + +import java.util.Properties; + +import org.posterita.exceptions.OperationException; + +public interface WebProperties +{ + public void put(Properties ctx, String key, String value) throws OperationException; + public String get(Properties ctx, String key) throws OperationException; + +} diff --git a/posterita/src/main/org/posterita/form/AttachmentForm.java b/posterita/src/main/org/posterita/form/AttachmentForm.java new file mode 100644 index 0000000000..2fc2a45925 --- /dev/null +++ b/posterita/src/main/org/posterita/form/AttachmentForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Aug-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.AttachmentBean; +import org.posterita.struts.core.DefaultForm; + +public class AttachmentForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public AttachmentForm() + { + setBean(new AttachmentBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/AttributeForm.java b/posterita/src/main/org/posterita/form/AttributeForm.java new file mode 100644 index 0000000000..15b0de8ca3 --- /dev/null +++ b/posterita/src/main/org/posterita/form/AttributeForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jun 15, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.AttributeBean; +import org.posterita.struts.core.DefaultForm; + + +public class AttributeForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public AttributeForm() + { + setBean(new AttributeBean()); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/AttributeValuesForm.java b/posterita/src/main/org/posterita/form/AttributeValuesForm.java new file mode 100644 index 0000000000..d838092163 --- /dev/null +++ b/posterita/src/main/org/posterita/form/AttributeValuesForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on May 23, 2006 by ashley +* +*/ + +package org.posterita.form; + +import org.posterita.beans.AttributeValueDetailBean; +import org.posterita.struts.core.DefaultForm; + +public class AttributeValuesForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public AttributeValuesForm() + { + setBean(new AttributeValueDetailBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/BPartnerInfoForm.java b/posterita/src/main/org/posterita/form/BPartnerInfoForm.java new file mode 100644 index 0000000000..948ba2c066 --- /dev/null +++ b/posterita/src/main/org/posterita/form/BPartnerInfoForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 26, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.BPartnerInfoBean; +import org.posterita.struts.core.DefaultForm; + + +public class BPartnerInfoForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public BPartnerInfoForm() + { + setBean(new BPartnerInfoBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/BankForm.java b/posterita/src/main/org/posterita/form/BankForm.java new file mode 100644 index 0000000000..eea521bcd6 --- /dev/null +++ b/posterita/src/main/org/posterita/form/BankForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Jul-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.BankBean; +import org.posterita.struts.core.DefaultForm; + + +public class BankForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public BankForm() + { + setBean(new BankBean()); + addRequiredFields(new String[]{"bankName"}); + } +} diff --git a/posterita/src/main/org/posterita/form/BlackListForm.java b/posterita/src/main/org/posterita/form/BlackListForm.java new file mode 100644 index 0000000000..1fada75b88 --- /dev/null +++ b/posterita/src/main/org/posterita/form/BlackListForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Jul-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.BlackListedBean; +import org.posterita.struts.core.DefaultForm; + + +public class BlackListForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public BlackListForm() + { + setBean(new BlackListedBean()); + //addRequiredFields(new String[] {"bankName", "chequeNo"}); + } +} diff --git a/posterita/src/main/org/posterita/form/CashBookDetailForm.java b/posterita/src/main/org/posterita/form/CashBookDetailForm.java new file mode 100644 index 0000000000..fce58e1c02 --- /dev/null +++ b/posterita/src/main/org/posterita/form/CashBookDetailForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on May 5, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.CashBookDetailBean; +import org.posterita.struts.core.DefaultForm; + + +public class CashBookDetailForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public CashBookDetailForm() + { + setBean(new CashBookDetailBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/CashForm.java b/posterita/src/main/org/posterita/form/CashForm.java new file mode 100644 index 0000000000..9598d89877 --- /dev/null +++ b/posterita/src/main/org/posterita/form/CashForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Created on Sep 11, 2006 by ashley +* +*/ + +/** + @author ashley + */ + +package org.posterita.form; + +import org.posterita.beans.CashBean; +import org.posterita.struts.core.DefaultForm; + +public class CashForm extends DefaultForm +{ + private static final long serialVersionUID = 1L; + + public CashForm() + { + this.setBean(new CashBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/ChangeDocumentStatusForm.java b/posterita/src/main/org/posterita/form/ChangeDocumentStatusForm.java new file mode 100644 index 0000000000..1ed9047bda --- /dev/null +++ b/posterita/src/main/org/posterita/form/ChangeDocumentStatusForm.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.form; + +import org.posterita.beans.ChangeDocumentStatusBean; +import org.posterita.struts.core.DefaultForm; + + +public class ChangeDocumentStatusForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ChangeDocumentStatusForm() + { + setBean(new ChangeDocumentStatusBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/ChangePasswordForm.java b/posterita/src/main/org/posterita/form/ChangePasswordForm.java new file mode 100644 index 0000000000..be5ac9d6be --- /dev/null +++ b/posterita/src/main/org/posterita/form/ChangePasswordForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 29, 2005 by din + */ + +package org.posterita.form; + +import org.posterita.beans.ChangePasswordBean; +import org.posterita.struts.core.DefaultForm; + +public class ChangePasswordForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public ChangePasswordForm() + { + setBean(new ChangePasswordBean()); + addRequiredFields(new String[] {"oldPassword","newPassword","confirmPassword"}); + addMatchFields("newPassword","confirmPassword"); + } +} diff --git a/posterita/src/main/org/posterita/form/CommissionForm.java b/posterita/src/main/org/posterita/form/CommissionForm.java new file mode 100644 index 0000000000..a46ae818aa --- /dev/null +++ b/posterita/src/main/org/posterita/form/CommissionForm.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Nov 7, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.CommissionBean; +import org.posterita.struts.core.DefaultForm; + + +public class CommissionForm extends DefaultForm +{ + private static final long serialVersionUID = 1L; + + public CommissionForm() + { + this.setBean(new CommissionBean()); + } +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/CreateBPartnerForm.java b/posterita/src/main/org/posterita/form/CreateBPartnerForm.java new file mode 100644 index 0000000000..6316cc2c5c --- /dev/null +++ b/posterita/src/main/org/posterita/form/CreateBPartnerForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.BPartnerBean; +import org.posterita.struts.core.DefaultForm; + + +public class CreateBPartnerForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public CreateBPartnerForm() + { + setBean( new BPartnerBean()); + addRequiredFields(new String[]{"partnerName","name2","address1"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/CreateBankAccountForm.java b/posterita/src/main/org/posterita/form/CreateBankAccountForm.java new file mode 100644 index 0000000000..6ad931862f --- /dev/null +++ b/posterita/src/main/org/posterita/form/CreateBankAccountForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 26, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.BankAccountBean; +import org.posterita.struts.core.DefaultForm; + +public class CreateBankAccountForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public CreateBankAccountForm() + { + setBean(new BankAccountBean()); + addRequiredFields(new String[]{"bankId","accountNo","accountType","currentBalance"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/CreateLocatorForm.java b/posterita/src/main/org/posterita/form/CreateLocatorForm.java new file mode 100644 index 0000000000..9f6718e330 --- /dev/null +++ b/posterita/src/main/org/posterita/form/CreateLocatorForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Jul-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.LocatorBean; +import org.posterita.struts.core.DefaultForm; + + +public class CreateLocatorForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public CreateLocatorForm() + { + setBean(new LocatorBean()); + addRequiredFields(new String[]{"aisle","bin","level"}); + } +} diff --git a/posterita/src/main/org/posterita/form/CreateProductAttributeForm.java b/posterita/src/main/org/posterita/form/CreateProductAttributeForm.java new file mode 100644 index 0000000000..14527546f7 --- /dev/null +++ b/posterita/src/main/org/posterita/form/CreateProductAttributeForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 28, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.ProductAttributeBean; +import org.posterita.struts.core.DefaultForm; + +public class CreateProductAttributeForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public CreateProductAttributeForm() + { + setBean(new ProductAttributeBean()); + //addRequiredFields(new String[]{"attributeValue"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/CreateProductAttributeValueForm.java b/posterita/src/main/org/posterita/form/CreateProductAttributeValueForm.java new file mode 100644 index 0000000000..8bf7f3d4a7 --- /dev/null +++ b/posterita/src/main/org/posterita/form/CreateProductAttributeValueForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 28, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.ProductAttributeBean; +import org.posterita.struts.core.DefaultForm; + +public class CreateProductAttributeValueForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public CreateProductAttributeValueForm() + { + setBean(new ProductAttributeBean()); + addRequiredFields(new String[]{"attributeValue"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/CreateUserForm.java b/posterita/src/main/org/posterita/form/CreateUserForm.java new file mode 100644 index 0000000000..349d9ff95b --- /dev/null +++ b/posterita/src/main/org/posterita/form/CreateUserForm.java @@ -0,0 +1,44 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 29, 2005 by din + */ + +package org.posterita.form; + +import org.posterita.beans.UserBean; +import org.posterita.struts.core.DefaultForm; + + + +public class CreateUserForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public CreateUserForm() + { + setBean(new UserBean()); + addRequiredFields(new String[]{"username", "password", "confirmPassword","userPIN"}); + addMatchFields("password","confirmPassword"); + //addEmailValidation("email"); + } + +} diff --git a/posterita/src/main/org/posterita/form/CreateWarehouseForm.java b/posterita/src/main/org/posterita/form/CreateWarehouseForm.java new file mode 100644 index 0000000000..946f2da0f0 --- /dev/null +++ b/posterita/src/main/org/posterita/form/CreateWarehouseForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 26, 2005 by din + */ + +package org.posterita.form; + +import org.posterita.beans.WarehouseBean; +import org.posterita.struts.core.DefaultForm; + +public class CreateWarehouseForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + +public CreateWarehouseForm() + { + setBean(new WarehouseBean()); + addRequiredFields(new String [] {"warehouseName", "address1", "city", "postalAddress", "regionId", "isPublic"}); + + } + +} diff --git a/posterita/src/main/org/posterita/form/CreditCardForm.java b/posterita/src/main/org/posterita/form/CreditCardForm.java new file mode 100644 index 0000000000..9264cc421c --- /dev/null +++ b/posterita/src/main/org/posterita/form/CreditCardForm.java @@ -0,0 +1,43 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 02-Sep-2005 + */ + + +package org.posterita.form; + +import org.posterita.beans.CustomerBean; +import org.posterita.struts.core.DefaultForm; + + +public class CreditCardForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public CreditCardForm() + { + + setBean(new CustomerBean()); + addRequiredFields(new String[]{"creditCardNumber", "cvv", "creditCardExpMonth", "creditCardExpYear"}); + } +} diff --git a/posterita/src/main/org/posterita/form/CurrenrPOSBalanceForm.java b/posterita/src/main/org/posterita/form/CurrenrPOSBalanceForm.java new file mode 100644 index 0000000000..ab3c68060f --- /dev/null +++ b/posterita/src/main/org/posterita/form/CurrenrPOSBalanceForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on May 5, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.CurrentTillAmountBean; +import org.posterita.struts.core.DefaultForm; + + +public class CurrenrPOSBalanceForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + +public CurrenrPOSBalanceForm() + { + setBean(new CurrentTillAmountBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/CustomerAndCreditCardForm.java b/posterita/src/main/org/posterita/form/CustomerAndCreditCardForm.java new file mode 100644 index 0000000000..b5e2ed6a84 --- /dev/null +++ b/posterita/src/main/org/posterita/form/CustomerAndCreditCardForm.java @@ -0,0 +1,46 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 02-Sep-2005 + */ + + +package org.posterita.form; + +import org.posterita.beans.CustomerBean; +import org.posterita.struts.core.DefaultForm; + + +public class CustomerAndCreditCardForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public CustomerAndCreditCardForm() + { + setBean(new CustomerBean()); + + addRequiredFields(new String[]{"creditCardPayment","username","userSurname", "email", "address1","address2","city","countryId"}); + addCreditCardFieldsValidation("creditCardPayment"); + addCVVFieldsValidation("creditCardPayment"); + addCreditCardExpiryDateFieldsValidation("creditCardPayment"); + } +} diff --git a/posterita/src/main/org/posterita/form/CustomerForm.java b/posterita/src/main/org/posterita/form/CustomerForm.java new file mode 100644 index 0000000000..49d9e1daea --- /dev/null +++ b/posterita/src/main/org/posterita/form/CustomerForm.java @@ -0,0 +1,48 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 02-Sep-2005 + */ + + +package org.posterita.form; + +import org.posterita.beans.CustomerBean; +import org.posterita.struts.core.DefaultForm; + + +public class CustomerForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public CustomerForm() + { + + setBean(new CustomerBean()); + addRequiredFields(new String[]{ + "partnerName" + ,"surname" + ,"address1" + }); + + } +} diff --git a/posterita/src/main/org/posterita/form/DateFilterForm.java b/posterita/src/main/org/posterita/form/DateFilterForm.java new file mode 100644 index 0000000000..b7a829e6da --- /dev/null +++ b/posterita/src/main/org/posterita/form/DateFilterForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Created on Sep 11, 2006 by ashley +* +*/ + +/** + @author ashley + */ + +package org.posterita.form; + +import org.posterita.beans.DateFilterBean; +import org.posterita.struts.core.DefaultForm; + +public class DateFilterForm extends DefaultForm +{ + private static final long serialVersionUID = 1L; + + public DateFilterForm() + { + this.setBean(new DateFilterBean()); + addRequiredFields(new String[]{"fromDate", "toDate"}); + } +} diff --git a/posterita/src/main/org/posterita/form/DocumentForm.java b/posterita/src/main/org/posterita/form/DocumentForm.java new file mode 100644 index 0000000000..6bb16182a6 --- /dev/null +++ b/posterita/src/main/org/posterita/form/DocumentForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 12-Aug-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.DocumentBean; +import org.posterita.struts.core.DefaultForm; + + +public class DocumentForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public DocumentForm() + { + setBean(new DocumentBean()); + + } + +} diff --git a/posterita/src/main/org/posterita/form/DocumentHistoryForm.java b/posterita/src/main/org/posterita/form/DocumentHistoryForm.java new file mode 100644 index 0000000000..53d4883285 --- /dev/null +++ b/posterita/src/main/org/posterita/form/DocumentHistoryForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.DocumentHistoryBean; +import org.posterita.struts.core.DefaultForm; + + +public class DocumentHistoryForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public DocumentHistoryForm() + { + setBean( new DocumentHistoryBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/DunningForm.java b/posterita/src/main/org/posterita/form/DunningForm.java new file mode 100644 index 0000000000..276ca021b0 --- /dev/null +++ b/posterita/src/main/org/posterita/form/DunningForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 27, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.DunningBean; +import org.posterita.struts.core.DefaultForm; + + +public class DunningForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public DunningForm() + { + setBean( new DunningBean()); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/EditAttributeForm.java b/posterita/src/main/org/posterita/form/EditAttributeForm.java new file mode 100644 index 0000000000..b5677fbd66 --- /dev/null +++ b/posterita/src/main/org/posterita/form/EditAttributeForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on May 24, 2006 by ashley +* +*/ + +package org.posterita.form; + +import org.posterita.beans.AttributeValueDetailBean; +import org.posterita.struts.core.DefaultForm; + +public class EditAttributeForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public EditAttributeForm() + { + this.setBean(new AttributeValueDetailBean()); + this.addRequiredFields(new String[]{"newName"}); + } +} diff --git a/posterita/src/main/org/posterita/form/EditPriceListForm.java b/posterita/src/main/org/posterita/form/EditPriceListForm.java new file mode 100644 index 0000000000..715f9472a1 --- /dev/null +++ b/posterita/src/main/org/posterita/form/EditPriceListForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 20, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.EditPriceBean; +import org.posterita.struts.core.DefaultForm; + +public class EditPriceListForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public EditPriceListForm() + { + setBean(new EditPriceBean()); + addRequiredFields(new String[]{"price"}); + } +} diff --git a/posterita/src/main/org/posterita/form/EditProductForm.java b/posterita/src/main/org/posterita/form/EditProductForm.java new file mode 100644 index 0000000000..4f186b1ec3 --- /dev/null +++ b/posterita/src/main/org/posterita/form/EditProductForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 4, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.ProductBean; +import org.posterita.struts.core.DefaultForm; + +public class EditProductForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public EditProductForm() + { + setBean(new ProductBean()); + //addRequiredFields(new String[] {"productName","revenueRecognition","description"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/GarmentForm.java b/posterita/src/main/org/posterita/form/GarmentForm.java new file mode 100644 index 0000000000..4113912497 --- /dev/null +++ b/posterita/src/main/org/posterita/form/GarmentForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jun 30, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.ProductBean; +import org.posterita.struts.core.DefaultForm; + + +public class GarmentForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public GarmentForm() + { + setBean(new ProductBean()); + addRequiredFields(new String[] {"description","brandName","modelName","revenueRecognition","designName","colourName","purchasePriceStandard","salesPriceStandard"}); + } +} diff --git a/posterita/src/main/org/posterita/form/GeneralPaymentForm.java b/posterita/src/main/org/posterita/form/GeneralPaymentForm.java new file mode 100644 index 0000000000..adc5196f6d --- /dev/null +++ b/posterita/src/main/org/posterita/form/GeneralPaymentForm.java @@ -0,0 +1,16 @@ +package org.posterita.form; + +import org.posterita.beans.PaymentBean; +import org.posterita.struts.core.DefaultForm; + +public class GeneralPaymentForm extends DefaultForm +{ + private static final long serialVersionUID = 1L; + + public GeneralPaymentForm() + { + setBean(new PaymentBean()); + addRequiredFields(new String[]{"amount","bpartnerId"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/GenericProductForm.java b/posterita/src/main/org/posterita/form/GenericProductForm.java new file mode 100644 index 0000000000..83622e125d --- /dev/null +++ b/posterita/src/main/org/posterita/form/GenericProductForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.posterita.form; + +import org.posterita.beans.GenericProductBean; +import org.posterita.struts.core.DefaultForm; + + +public class GenericProductForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public GenericProductForm() + { + setBean(new GenericProductBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/InOutHistoryForm.java b/posterita/src/main/org/posterita/form/InOutHistoryForm.java new file mode 100644 index 0000000000..7e53bc3d30 --- /dev/null +++ b/posterita/src/main/org/posterita/form/InOutHistoryForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 16, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.InOutHistoryBean; +import org.posterita.struts.core.DefaultForm; + +public class InOutHistoryForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public InOutHistoryForm() + { + setBean(new InOutHistoryBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/InitCustomerForm.java b/posterita/src/main/org/posterita/form/InitCustomerForm.java new file mode 100644 index 0000000000..939e980658 --- /dev/null +++ b/posterita/src/main/org/posterita/form/InitCustomerForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jan 16, 2007 + */ + + +package org.posterita.form; + +import org.posterita.beans.CustomerBean; +import org.posterita.struts.core.DefaultForm; + + +public class InitCustomerForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public InitCustomerForm() + { + setBean(new CustomerBean()); + } +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/InventoryForm.java b/posterita/src/main/org/posterita/form/InventoryForm.java new file mode 100644 index 0000000000..acd773bb0f --- /dev/null +++ b/posterita/src/main/org/posterita/form/InventoryForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Dec 8, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.InventoryBean; +import org.posterita.struts.core.DefaultForm; + + +public class InventoryForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public InventoryForm() + { + setBean( new InventoryBean()); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/InvoiceHistoryForm.java b/posterita/src/main/org/posterita/form/InvoiceHistoryForm.java new file mode 100644 index 0000000000..ec6ce344c5 --- /dev/null +++ b/posterita/src/main/org/posterita/form/InvoiceHistoryForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 15, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.InvoiceHistoryBean; +import org.posterita.struts.core.DefaultForm; + +public class InvoiceHistoryForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public InvoiceHistoryForm() + { + setBean(new InvoiceHistoryBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/InvokeOrderForm.java b/posterita/src/main/org/posterita/form/InvokeOrderForm.java new file mode 100644 index 0000000000..71849dd110 --- /dev/null +++ b/posterita/src/main/org/posterita/form/InvokeOrderForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 11-Aug-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.OrderLineBean; +import org.posterita.struts.core.DefaultForm; + + +public class InvokeOrderForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public InvokeOrderForm() + { + setBean(new OrderLineBean()); + addRequiredFields(new String[]{"documentNo"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/ItemForm.java b/posterita/src/main/org/posterita/form/ItemForm.java new file mode 100644 index 0000000000..0f68c2d794 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ItemForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.form; + +import org.posterita.beans.ItemBean; +import org.posterita.struts.core.DefaultForm; + + +public class ItemForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ItemForm() + { + setBean(new ItemBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/LoginForm.java b/posterita/src/main/org/posterita/form/LoginForm.java new file mode 100644 index 0000000000..f876931e07 --- /dev/null +++ b/posterita/src/main/org/posterita/form/LoginForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.form; + +import org.posterita.beans.LoginBean; +import org.posterita.struts.core.DefaultForm; + + +public class LoginForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public LoginForm() + { + setBean(new LoginBean()); + //addRequiredFields(new String[] {"username", "password"}); + } + + +} diff --git a/posterita/src/main/org/posterita/form/LoginUserForm.java b/posterita/src/main/org/posterita/form/LoginUserForm.java new file mode 100644 index 0000000000..cab7de7cf1 --- /dev/null +++ b/posterita/src/main/org/posterita/form/LoginUserForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 15, 2005 by din + */ + +package org.posterita.form; + +import org.posterita.beans.LoginBean; + +import org.posterita.struts.core.DefaultForm; + +public class LoginUserForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public LoginUserForm() + { + setBean(new LoginBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/MenuItemForm.java b/posterita/src/main/org/posterita/form/MenuItemForm.java new file mode 100644 index 0000000000..8b2648220c --- /dev/null +++ b/posterita/src/main/org/posterita/form/MenuItemForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Jul-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.MenuItemBean; +import org.posterita.struts.core.DefaultForm; + + +public class MenuItemForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public MenuItemForm() + { + setBean(new MenuItemBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/OpenItemForm.java b/posterita/src/main/org/posterita/form/OpenItemForm.java new file mode 100644 index 0000000000..70b0e723c2 --- /dev/null +++ b/posterita/src/main/org/posterita/form/OpenItemForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 17, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.OpenItemBean; +import org.posterita.struts.core.DefaultForm; + + +public class OpenItemForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public OpenItemForm() + { + setBean( new OpenItemBean()); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/OrderForm.java b/posterita/src/main/org/posterita/form/OrderForm.java new file mode 100644 index 0000000000..2189fdcb17 --- /dev/null +++ b/posterita/src/main/org/posterita/form/OrderForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.form; + +import org.posterita.beans.OrderBean; +import org.posterita.struts.core.DefaultForm; + +public class OrderForm extends DefaultForm +{ + private static final long serialVersionUID = 1L; + + public OrderForm() + { + this.setBean(new OrderBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/OrderHistoryForm.java b/posterita/src/main/org/posterita/form/OrderHistoryForm.java new file mode 100644 index 0000000000..c95be9b137 --- /dev/null +++ b/posterita/src/main/org/posterita/form/OrderHistoryForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 04-Aug-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.OrderHistoryBean; +import org.posterita.struts.core.DefaultForm; + + +public class OrderHistoryForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public OrderHistoryForm() + { + setBean(new OrderHistoryBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/OrderLineForm.java b/posterita/src/main/org/posterita/form/OrderLineForm.java new file mode 100644 index 0000000000..1fcb12f9ea --- /dev/null +++ b/posterita/src/main/org/posterita/form/OrderLineForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 11-Aug-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.OrderLineBean; +import org.posterita.struts.core.DefaultForm; + + +public class OrderLineForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public OrderLineForm() + { + setBean(new OrderLineBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/OrgForm.java b/posterita/src/main/org/posterita/form/OrgForm.java new file mode 100644 index 0000000000..ddcb771a77 --- /dev/null +++ b/posterita/src/main/org/posterita/form/OrgForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.form; + +import org.posterita.beans.OrgBean; +import org.posterita.struts.core.DefaultForm; + + +public class OrgForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public OrgForm() + { + setBean(new OrgBean()); + addRequiredFields(new String[]{"orgName","address1","city","postalAddress"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/OrgTypeForm.java b/posterita/src/main/org/posterita/form/OrgTypeForm.java new file mode 100644 index 0000000000..a752a7340a --- /dev/null +++ b/posterita/src/main/org/posterita/form/OrgTypeForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.form; + +import org.posterita.beans.UDIBean; +import org.posterita.struts.core.DefaultForm; + + +public class OrgTypeForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public OrgTypeForm() + { + setBean(new UDIBean()); + addRequiredFields(new String[] {"orgType"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/POSDescriptionForm.java b/posterita/src/main/org/posterita/form/POSDescriptionForm.java new file mode 100644 index 0000000000..bc8553015f --- /dev/null +++ b/posterita/src/main/org/posterita/form/POSDescriptionForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on May 5, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.POSDescriptionBean; +import org.posterita.struts.core.DefaultForm; + + +public class POSDescriptionForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public POSDescriptionForm() + { + setBean(new POSDescriptionBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/POSForm.java b/posterita/src/main/org/posterita/form/POSForm.java new file mode 100644 index 0000000000..487b69f68a --- /dev/null +++ b/posterita/src/main/org/posterita/form/POSForm.java @@ -0,0 +1,43 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 22-Mar-2006 + */ + + +package org.posterita.form; + + +import org.posterita.beans.POSBean; +import org.posterita.struts.core.DefaultForm; + + +public class POSForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + +public POSForm() + { + setBean(new POSBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/POSHistoryForm.java b/posterita/src/main/org/posterita/form/POSHistoryForm.java new file mode 100644 index 0000000000..3414f75b38 --- /dev/null +++ b/posterita/src/main/org/posterita/form/POSHistoryForm.java @@ -0,0 +1,65 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on May 15, 2006 + */ + + +package org.posterita.form; + +import java.util.Calendar; + +import org.posterita.beans.POSHistoryBean; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + + +public class POSHistoryForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public POSHistoryForm() throws OperationException + { + setBean(new POSHistoryBean()); + initForm(); + } + + private void initForm() throws OperationException + { + try + { + Calendar cal = Calendar.getInstance(); + POSHistoryBean bean = (POSHistoryBean) getBean(); + + bean.setMonth(Integer.valueOf(cal.get(Calendar.MONTH) + 1)); + bean.setYear(Integer.valueOf(cal.get(Calendar.YEAR))); + + month = bean.getMonth().toString(); + year = bean.getYear().toString(); + } + catch (ApplicationException e) + { + throw new OperationException(e); + } + } + +} diff --git a/posterita/src/main/org/posterita/form/POSInfoForm.java b/posterita/src/main/org/posterita/form/POSInfoForm.java new file mode 100644 index 0000000000..0d0c343b1f --- /dev/null +++ b/posterita/src/main/org/posterita/form/POSInfoForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on May 5, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.POSInfoBean; +import org.posterita.struts.core.DefaultForm; + + +public class POSInfoForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + +public POSInfoForm() + { + setBean(new POSInfoBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/POSOrderLineForm2.java b/posterita/src/main/org/posterita/form/POSOrderLineForm2.java new file mode 100644 index 0000000000..d54f0dba31 --- /dev/null +++ b/posterita/src/main/org/posterita/form/POSOrderLineForm2.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 11-Aug-2005 by alok + * + */ +package org.posterita.form; + +import org.posterita.beans.OrderLineBean; +import org.posterita.struts.core.DefaultForm; + + +public class POSOrderLineForm2 extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public POSOrderLineForm2() + { + setBean(new OrderLineBean()); + + addRequiredFields(new String[] {"bpartnerId"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/POSProductForm.java b/posterita/src/main/org/posterita/form/POSProductForm.java new file mode 100644 index 0000000000..3a2bd724b9 --- /dev/null +++ b/posterita/src/main/org/posterita/form/POSProductForm.java @@ -0,0 +1,18 @@ +package org.posterita.form; + +import org.posterita.beans.ProductBean; +import org.posterita.struts.core.DefaultForm; + +public class POSProductForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public POSProductForm() + { + setBean(new ProductBean()); + addRequiredFields(new String[] {"productName","purchasePriceStandard","description","salesPriceStandard","salesPriceLimit","salesPriceList"}); + } +} diff --git a/posterita/src/main/org/posterita/form/POSReportForm.java b/posterita/src/main/org/posterita/form/POSReportForm.java new file mode 100644 index 0000000000..912dfdc0aa --- /dev/null +++ b/posterita/src/main/org/posterita/form/POSReportForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on May 11, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.POSReportBean; +import org.posterita.struts.core.DefaultForm; + + +public class POSReportForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public POSReportForm() + { + setBean(new POSReportBean()); + } + + } diff --git a/posterita/src/main/org/posterita/form/POSStockForm.java b/posterita/src/main/org/posterita/form/POSStockForm.java new file mode 100644 index 0000000000..9e976155ea --- /dev/null +++ b/posterita/src/main/org/posterita/form/POSStockForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on May 8, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.POSStockBean; +import org.posterita.struts.core.DefaultForm; + + +public class POSStockForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public POSStockForm() + { + setBean(new POSStockBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/POSSupplierForm.java b/posterita/src/main/org/posterita/form/POSSupplierForm.java new file mode 100644 index 0000000000..7992f1ccc9 --- /dev/null +++ b/posterita/src/main/org/posterita/form/POSSupplierForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on May 8, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.POSSupplierBean; +import org.posterita.struts.core.DefaultForm; + + +public class POSSupplierForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public POSSupplierForm() + { + setBean(new POSSupplierBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/PaymentAllocationForm.java b/posterita/src/main/org/posterita/form/PaymentAllocationForm.java new file mode 100644 index 0000000000..5dc9f3bede --- /dev/null +++ b/posterita/src/main/org/posterita/form/PaymentAllocationForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 30, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.PaymentAllocationBean; +import org.posterita.struts.core.DefaultForm; + + +public class PaymentAllocationForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public PaymentAllocationForm() + { + setBean( new PaymentAllocationBean()); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/PaymentForm.java b/posterita/src/main/org/posterita/form/PaymentForm.java new file mode 100644 index 0000000000..f7c492fbf4 --- /dev/null +++ b/posterita/src/main/org/posterita/form/PaymentForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 08-Dec-2006 14:08:03 by praveen + * + */ + +package org.posterita.form; + +import org.posterita.beans.PaymentBean; +import org.posterita.struts.core.DefaultForm; + +public class PaymentForm extends DefaultForm +{ + private static final long serialVersionUID = 1L; + + public PaymentForm() + { + setBean(new PaymentBean()); + addRequiredFields(new String[]{"amount", "allocateAmount"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/PaymentHistoryForm.java b/posterita/src/main/org/posterita/form/PaymentHistoryForm.java new file mode 100644 index 0000000000..da7e594264 --- /dev/null +++ b/posterita/src/main/org/posterita/form/PaymentHistoryForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 15, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.PaymentHistoryBean; +import org.posterita.struts.core.DefaultForm; + +public class PaymentHistoryForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public PaymentHistoryForm() + { + setBean(new PaymentHistoryBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/PaymentTermForm.java b/posterita/src/main/org/posterita/form/PaymentTermForm.java new file mode 100644 index 0000000000..3f17a3610f --- /dev/null +++ b/posterita/src/main/org/posterita/form/PaymentTermForm.java @@ -0,0 +1,61 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Nov 1, 2006 + */ + + +package org.posterita.form; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionMapping; + +import org.posterita.beans.PaymentTermBean; +import org.posterita.struts.core.DefaultForm; + + +public class PaymentTermForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public PaymentTermForm() + { + setBean(new PaymentTermBean()); + } + + public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) + { + //some custom validation + + if("true".equalsIgnoreCase(getFixedDueDate())) + { + addRequiredFields(new String[]{"paymentTermName","fixedMonthDay","fixedMonthOffset","fiedMonthCutoff"}); + } + else + { + addRequiredFields(new String[]{"paymentTermName","netDays"}); + } + + return super.validate(mapping, request); + } +} diff --git a/posterita/src/main/org/posterita/form/PaymentTermForm2.java b/posterita/src/main/org/posterita/form/PaymentTermForm2.java new file mode 100644 index 0000000000..92e81d4d56 --- /dev/null +++ b/posterita/src/main/org/posterita/form/PaymentTermForm2.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Dec 28, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.PaymentTermBean; +import org.posterita.struts.core.DefaultForm; + + +public class PaymentTermForm2 extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public PaymentTermForm2() + { + setBean(new PaymentTermBean()); + } + + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/PriceCheckForm.java b/posterita/src/main/org/posterita/form/PriceCheckForm.java new file mode 100644 index 0000000000..50efbb09cc --- /dev/null +++ b/posterita/src/main/org/posterita/form/PriceCheckForm.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +package org.posterita.form; + +import org.posterita.struts.core.DefaultForm; + +public class PriceCheckForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public PriceCheckForm() + { + addRequiredFields(new String[]{"barCode"}); + } +} diff --git a/posterita/src/main/org/posterita/form/PriceListForm.java b/posterita/src/main/org/posterita/form/PriceListForm.java new file mode 100644 index 0000000000..f1c3f48979 --- /dev/null +++ b/posterita/src/main/org/posterita/form/PriceListForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 19, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.PriceListBean; +import org.posterita.struts.core.DefaultForm; + +public class PriceListForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public PriceListForm() + { + setBean(new PriceListBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/ProductAttributeForm.java b/posterita/src/main/org/posterita/form/ProductAttributeForm.java new file mode 100644 index 0000000000..d52b076249 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ProductAttributeForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 1, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.ProductAttributeBean; +import org.posterita.struts.core.DefaultForm; + +public class ProductAttributeForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ProductAttributeForm() + { + setBean(new ProductAttributeBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/ProductAttributeValueForm.java b/posterita/src/main/org/posterita/form/ProductAttributeValueForm.java new file mode 100644 index 0000000000..fb77ea3732 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ProductAttributeValueForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 1, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.ProductAttributeBean; +import org.posterita.struts.core.DefaultForm; + +public class ProductAttributeValueForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ProductAttributeValueForm() + { + setBean(new ProductAttributeBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/ProductDetailInfoForm.java b/posterita/src/main/org/posterita/form/ProductDetailInfoForm.java new file mode 100644 index 0000000000..5450c915a6 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ProductDetailInfoForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.form; + +import org.posterita.beans.ProductDetailsBean; +import org.posterita.struts.core.DefaultForm; + +public class ProductDetailInfoForm extends DefaultForm +{ + private static final long serialVersionUID = 1L; + + public ProductDetailInfoForm() + { + this.setBean(new ProductDetailsBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/ProductForm.java b/posterita/src/main/org/posterita/form/ProductForm.java new file mode 100644 index 0000000000..61e0055fc8 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ProductForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 4, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.ProductBean; +import org.posterita.struts.core.DefaultForm; + +public class ProductForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public ProductForm() + { + setBean(new ProductBean()); + addRequiredFields(new String[] {"productName","revenueRecognition","description"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/ProductImageForm.java b/posterita/src/main/org/posterita/form/ProductImageForm.java new file mode 100644 index 0000000000..b756529f8a --- /dev/null +++ b/posterita/src/main/org/posterita/form/ProductImageForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Mar 14, 2006 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.ProductImageBean; +import org.posterita.struts.core.DefaultForm; + +public class ProductImageForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ProductImageForm() + { + setBean(new ProductImageBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/ProductKeywordsForm.java b/posterita/src/main/org/posterita/form/ProductKeywordsForm.java new file mode 100644 index 0000000000..31a9a5e036 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ProductKeywordsForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on May 12, 2006 by ashley +* +*/ + +package org.posterita.form; + +import org.posterita.beans.ProductKeywordsBean; +import org.posterita.struts.core.DefaultForm; + +public class ProductKeywordsForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ProductKeywordsForm() + { + setBean(new ProductKeywordsBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/ProductRestrictionForm.java b/posterita/src/main/org/posterita/form/ProductRestrictionForm.java new file mode 100644 index 0000000000..78e03dc431 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ProductRestrictionForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 30, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.ProductRestrictionBean; +import org.posterita.struts.core.DefaultForm; + +public class ProductRestrictionForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ProductRestrictionForm() + { + setBean(new ProductRestrictionBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/ProductSearchForm.java b/posterita/src/main/org/posterita/form/ProductSearchForm.java new file mode 100644 index 0000000000..15521f2867 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ProductSearchForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on May 17, 2006 by ashley +* +*/ + +package org.posterita.form; + +import org.posterita.beans.ProductSearchBean; +import org.posterita.struts.core.DefaultForm; + +public class ProductSearchForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ProductSearchForm() + { + //this.setIsActive("true"); + //this.setIsWebstoreFeatured("true"); + setBean(new ProductSearchBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/ProductStatusForm.java b/posterita/src/main/org/posterita/form/ProductStatusForm.java new file mode 100644 index 0000000000..3d60c8af3a --- /dev/null +++ b/posterita/src/main/org/posterita/form/ProductStatusForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Feb 9, 2006 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.ProductStatusBean; +import org.posterita.struts.core.DefaultForm; + +public class ProductStatusForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ProductStatusForm() + { + setBean(new ProductStatusBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/RemoveSessionForm.java b/posterita/src/main/org/posterita/form/RemoveSessionForm.java new file mode 100644 index 0000000000..6aeabffa14 --- /dev/null +++ b/posterita/src/main/org/posterita/form/RemoveSessionForm.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jan 26, 2007 + */ + + +package org.posterita.form; + +import org.posterita.beans.RemoveSessionBean; +import org.posterita.struts.core.DefaultForm; + + + +public class RemoveSessionForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public RemoveSessionForm() + { + setBean(new RemoveSessionBean()); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/ReportForm.java b/posterita/src/main/org/posterita/form/ReportForm.java new file mode 100644 index 0000000000..0edcf525a1 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ReportForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.form; + +import org.posterita.beans.ReportBean; +import org.posterita.struts.core.DefaultForm; + + +public class ReportForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ReportForm() + { + //initForm(); + setBean(new ReportBean()); + addRequiredFields(new String[]{"fromDate", "toDate"}); + + } + +} diff --git a/posterita/src/main/org/posterita/form/ReportImageForm.java b/posterita/src/main/org/posterita/form/ReportImageForm.java new file mode 100644 index 0000000000..3d8f00dc34 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ReportImageForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.form; + +import org.posterita.beans.ReportImageBean; +import org.posterita.struts.core.DefaultForm; + + +public class ReportImageForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ReportImageForm() + { + setBean(new ReportImageBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/ReportSummaryHistoryForm.java b/posterita/src/main/org/posterita/form/ReportSummaryHistoryForm.java new file mode 100644 index 0000000000..4297ae1311 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ReportSummaryHistoryForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Created on Sep 11, 2006 by ashley +* +*/ + +/** + @author ashley + */ + +package org.posterita.form; + +import org.posterita.struts.core.DefaultForm; + +public class ReportSummaryHistoryForm extends DefaultForm +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + +} diff --git a/posterita/src/main/org/posterita/form/RoleForm.java b/posterita/src/main/org/posterita/form/RoleForm.java new file mode 100644 index 0000000000..c1369691b3 --- /dev/null +++ b/posterita/src/main/org/posterita/form/RoleForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 16, 2005 by praveen + * + */ +package org.posterita.form; + +import org.posterita.beans.RoleBean; +import org.posterita.struts.core.DefaultForm; + +public class RoleForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public RoleForm() + { + setBean(new RoleBean()); + addRequiredFields(new String[]{"name"}); + } +} diff --git a/posterita/src/main/org/posterita/form/SalesAnalysisReportForm.java b/posterita/src/main/org/posterita/form/SalesAnalysisReportForm.java new file mode 100644 index 0000000000..a13a3b9c26 --- /dev/null +++ b/posterita/src/main/org/posterita/form/SalesAnalysisReportForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 14-Jul-2006 13:57:30 by praveen + * + */ + +package org.posterita.form; + +import org.posterita.beans.SalesAnalysisReportBean; +import org.posterita.struts.core.DefaultForm; + +public class SalesAnalysisReportForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public SalesAnalysisReportForm() + { + setBean(new SalesAnalysisReportBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/SalesReportForm.java b/posterita/src/main/org/posterita/form/SalesReportForm.java new file mode 100644 index 0000000000..bf61183015 --- /dev/null +++ b/posterita/src/main/org/posterita/form/SalesReportForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.form; + +import org.posterita.beans.ReportBean; +import org.posterita.struts.core.DefaultForm; + + +public class SalesReportForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public SalesReportForm() + { + //initForm(); + setBean(new ReportBean()); + } + +} diff --git a/posterita/src/main/org/posterita/form/SearchProductForm.java b/posterita/src/main/org/posterita/form/SearchProductForm.java new file mode 100644 index 0000000000..910b99de31 --- /dev/null +++ b/posterita/src/main/org/posterita/form/SearchProductForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on Apr 27, 2006 by ashley +* +*/ + +package org.posterita.form; + +import org.posterita.beans.StockBean; +import org.posterita.struts.core.DefaultForm; + +public class SearchProductForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public SearchProductForm() + { + setBean(new StockBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/SetApplicationParametersForm.java b/posterita/src/main/org/posterita/form/SetApplicationParametersForm.java new file mode 100644 index 0000000000..3645e1cbc7 --- /dev/null +++ b/posterita/src/main/org/posterita/form/SetApplicationParametersForm.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * */ +package org.posterita.form; + +import org.posterita.beans.ApplicationParametersBean; +import org.posterita.struts.core.DefaultForm; + + +public class SetApplicationParametersForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public SetApplicationParametersForm() + { + setBean(new ApplicationParametersBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/ShipperForm.java b/posterita/src/main/org/posterita/form/ShipperForm.java new file mode 100644 index 0000000000..7c63026af5 --- /dev/null +++ b/posterita/src/main/org/posterita/form/ShipperForm.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.form; + +import org.posterita.beans.ShipperBean; +import org.posterita.struts.core.DefaultForm; + + +public class ShipperForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ShipperForm() + { + setBean(new ShipperBean()); + addRequiredFields(new String[] {"name"}); + } + +} diff --git a/posterita/src/main/org/posterita/form/SingleDateFilterForm.java b/posterita/src/main/org/posterita/form/SingleDateFilterForm.java new file mode 100644 index 0000000000..7f1a64ce5e --- /dev/null +++ b/posterita/src/main/org/posterita/form/SingleDateFilterForm.java @@ -0,0 +1,44 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Nov 7, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.ReportBean; +import org.posterita.struts.core.DefaultForm; + + +public class SingleDateFilterForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public SingleDateFilterForm() + { + //initForm(); + setBean(new ReportBean()); + addRequiredFields(new String[]{"fromDate"}); + + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/StockForm.java b/posterita/src/main/org/posterita/form/StockForm.java new file mode 100644 index 0000000000..1b83cd5022 --- /dev/null +++ b/posterita/src/main/org/posterita/form/StockForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.form; + +import org.posterita.beans.StockBean; +import org.posterita.struts.core.DefaultForm; + + +public class StockForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public StockForm() + { + setBean(new StockBean()); + addRequiredFields(new String[] {"checkbox"}); + } +} diff --git a/posterita/src/main/org/posterita/form/SynchronizeCollectionsForm.java b/posterita/src/main/org/posterita/form/SynchronizeCollectionsForm.java new file mode 100644 index 0000000000..b3dcb5654a --- /dev/null +++ b/posterita/src/main/org/posterita/form/SynchronizeCollectionsForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ +/** + @author ashley + */ + +package org.posterita.form; + +import org.posterita.beans.SynchronizeCollectionBean; +import org.posterita.struts.core.DefaultForm; + +public class SynchronizeCollectionsForm extends DefaultForm +{ + private static final long serialVersionUID = 1L; + + public SynchronizeCollectionsForm() + { + this.setBean(new SynchronizeCollectionBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/TaxForm.java b/posterita/src/main/org/posterita/form/TaxForm.java new file mode 100644 index 0000000000..c4c8b5869c --- /dev/null +++ b/posterita/src/main/org/posterita/form/TaxForm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Nov 28, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.TaxBean; +import org.posterita.struts.core.DefaultForm; + + +public class TaxForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public TaxForm() + { + setBean(new TaxBean()); + // addRequiredFields(new String[] {"taxName","taxRate"}); + } +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/UserForm.java b/posterita/src/main/org/posterita/form/UserForm.java new file mode 100644 index 0000000000..f483d0e9f8 --- /dev/null +++ b/posterita/src/main/org/posterita/form/UserForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.form; + +import org.posterita.beans.UserBean; +import org.posterita.struts.core.DefaultForm; + + +public class UserForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public UserForm() + { + setBean(new UserBean()); + addRequiredFields(new String[]{"password", "confirmPassword","userPIN"}); + addMatchFields("password","confirmPassword"); + } + +} diff --git a/posterita/src/main/org/posterita/form/VendorForm.java b/posterita/src/main/org/posterita/form/VendorForm.java new file mode 100644 index 0000000000..d728dea7de --- /dev/null +++ b/posterita/src/main/org/posterita/form/VendorForm.java @@ -0,0 +1,19 @@ +package org.posterita.form; + +import org.posterita.beans.VendorBean; +import org.posterita.struts.core.DefaultForm; + +public class VendorForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public VendorForm() + { + setBean(new VendorBean()); + addRequiredFields(new String[]{"partnerName"}); + + } +} diff --git a/posterita/src/main/org/posterita/form/ViewBPartnerForm.java b/posterita/src/main/org/posterita/form/ViewBPartnerForm.java new file mode 100644 index 0000000000..d1efc12b0a --- /dev/null +++ b/posterita/src/main/org/posterita/form/ViewBPartnerForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 22, 2005 by din + */ + +package org.posterita.form; + +import org.posterita.beans.BPartnerBean; +import org.posterita.struts.core.DefaultForm; + +public class ViewBPartnerForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ViewBPartnerForm() + { + setBean(new BPartnerBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/ViewProductForm.java b/posterita/src/main/org/posterita/form/ViewProductForm.java new file mode 100644 index 0000000000..e8b0280e9f --- /dev/null +++ b/posterita/src/main/org/posterita/form/ViewProductForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 17, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.ProductBean; +import org.posterita.struts.core.DefaultForm; + + +public class ViewProductForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ViewProductForm() + { + setBean(new ProductBean()); + } +} diff --git a/posterita/src/main/org/posterita/form/ViewTaxForm.java b/posterita/src/main/org/posterita/form/ViewTaxForm.java new file mode 100644 index 0000000000..bb83285f8d --- /dev/null +++ b/posterita/src/main/org/posterita/form/ViewTaxForm.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Nov 30, 2006 + */ + + +package org.posterita.form; + +import org.posterita.beans.TaxBean; +import org.posterita.struts.core.DefaultForm; + + +public class ViewTaxForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public ViewTaxForm() + { + setBean(new TaxBean()); + } +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/form/WarehouseDetailsForm.java b/posterita/src/main/org/posterita/form/WarehouseDetailsForm.java new file mode 100644 index 0000000000..8633e8d97b --- /dev/null +++ b/posterita/src/main/org/posterita/form/WarehouseDetailsForm.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 9, 2005 by din + */ + +package org.posterita.form; + +import org.posterita.beans.WarehouseBean; +import org.posterita.struts.core.DefaultForm; + +public class WarehouseDetailsForm extends DefaultForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public WarehouseDetailsForm() + { + setBean(new WarehouseBean()); + } +} diff --git a/posterita/src/main/org/posterita/formatter/ArrayListFormatter.java b/posterita/src/main/org/posterita/formatter/ArrayListFormatter.java new file mode 100644 index 0000000000..d5804b57dd --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/ArrayListFormatter.java @@ -0,0 +1,51 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Aug-2005 by alok + * + */ + +package org.posterita.formatter; + +import java.util.ArrayList; + + +public class ArrayListFormatter extends Formatter +{ + + public Object format(Object target) + { + if (target == null) + return new ArrayList(); + + return target; + } + + public Object unformat(Object target) + { + ArrayList temp = (ArrayList) target; + + if (target == null || temp.size() == 0 ) + return null; + + return target; + } + + + +} diff --git a/posterita/src/main/org/posterita/formatter/BigDecimalArrayFormatter.java b/posterita/src/main/org/posterita/formatter/BigDecimalArrayFormatter.java new file mode 100644 index 0000000000..64ff52d949 --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/BigDecimalArrayFormatter.java @@ -0,0 +1,49 @@ +package org.posterita.formatter; + +import java.math.BigDecimal; + +public class BigDecimalArrayFormatter extends Formatter +{ + // return String[] + public Object format(Object value) + { + if (value == null) + return new String[]{}; + + BigDecimal values[] = (BigDecimal[])value; + + String retVal[] = new String[values.length]; + + for (int i = 0; i < values.length; i++) + { + retVal[i] = values[i].toPlainString(); + } + + return retVal; + } + + // return BigDecimal[] + public Object unformat(Object object) + { + if (object == null) + { + return null; + } + + String values[] = (String[])object; + + if (values.length == 0) + { + return null; + } + + BigDecimal retVal[] = new BigDecimal[values.length]; + + for (int i = 0; i < values.length; i++) + { + retVal[i] = new BigDecimal(values[i]); + } + + return retVal; + } +} diff --git a/posterita/src/main/org/posterita/formatter/BigDecimalFormatter.java b/posterita/src/main/org/posterita/formatter/BigDecimalFormatter.java new file mode 100644 index 0000000000..d90b1e55cc --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/BigDecimalFormatter.java @@ -0,0 +1,57 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 18-Aug-2006 16:45:26 by praveen + * + */ + +package org.posterita.formatter; + +import java.math.BigDecimal; + +public class BigDecimalFormatter extends Formatter +{ + + //converts a BigDecimal to String + public Object format(Object value) + { + if(value == null) + { + return ""; + } + + BigDecimal valuebd = (BigDecimal) value; + + BigDecimal db = valuebd.setScale(2, BigDecimal.ROUND_HALF_UP); + + return db.toString(); + } + + //converts a String to BigDecimal + public Object unformat(Object object) + { + String string = (String) object; + if(string == null || string.trim().length() <1) + return null; + + BigDecimal bd = new BigDecimal(string).setScale(2, BigDecimal.ROUND_HALF_UP); + + return bd; + } + +} diff --git a/posterita/src/main/org/posterita/formatter/BooleanFormatter.java b/posterita/src/main/org/posterita/formatter/BooleanFormatter.java new file mode 100644 index 0000000000..69221d258e --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/BooleanFormatter.java @@ -0,0 +1,50 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Jul-2005 by alok + * + */ +package org.posterita.formatter; + + +public class BooleanFormatter extends Formatter +{ + + //converts Boolean to String + public Object format(Object target) + { + if (target == null) + return Boolean.toString(false); + + Boolean bool = (Boolean) target; + return bool.toString(); + } + + //convert String to Boolean + public Object unformat(Object target) + { + String string = (String) target; + + if(string == null || string.trim().length() <1) + return Boolean.valueOf(false); + + return Boolean.valueOf(string); + + } + +} diff --git a/posterita/src/main/org/posterita/formatter/DefaultFormatter.java b/posterita/src/main/org/posterita/formatter/DefaultFormatter.java new file mode 100644 index 0000000000..2bde2bb1bc --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/DefaultFormatter.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Aug-2005 by alok + * + */ + +package org.posterita.formatter; + + +public class DefaultFormatter extends Formatter +{ + + public Object format(Object target) + { + if (target == null) + return ""; + else + return target.toString(); + } + + public Object unformat(Object target) + { + return target; + } + +} diff --git a/posterita/src/main/org/posterita/formatter/DoubleFormatter.java b/posterita/src/main/org/posterita/formatter/DoubleFormatter.java new file mode 100644 index 0000000000..5329fbe5c1 --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/DoubleFormatter.java @@ -0,0 +1,48 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Aug-2005 by alok + * + */ +package org.posterita.formatter; + + +public class DoubleFormatter extends Formatter +{ + + public Object format(Object value) + { + if (value == null) + return ""; + + Double dbl = (Double) value; + return dbl.toString(); + + + } + + public Object unformat(Object object) + { + String string = (String) object; + if(string == null || string.trim().length() <1) + return null; + + return new Double(string); + } + +} diff --git a/posterita/src/main/org/posterita/formatter/Formatter.java b/posterita/src/main/org/posterita/formatter/Formatter.java new file mode 100644 index 0000000000..ecc218903d --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/Formatter.java @@ -0,0 +1,74 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Aug-2005 by alok + * + */ +package org.posterita.formatter; + +import java.math.BigDecimal; +import java.util.ArrayList; + +import org.posterita.core.JulianDate; +import org.posterita.core.SimpleCalendarDate; +import org.posterita.exceptions.FormattingException; + + +public abstract class Formatter +{ + + public String getErrorKey() + { + return "error.key"; + } + + public static Formatter getFormatter(Class type) + { + if (type == null) + return new DefaultFormatter(); + if (String.class.isAssignableFrom(type)) + return new StringFormatter(); + if (Integer.class.isAssignableFrom(type)) + return new IntegerFormatter(); + if (Long.class.isAssignableFrom(type)) + return new LongFormatter(); + if (ArrayList.class.isAssignableFrom(type)) + return new ArrayListFormatter(); + if (Double.class.isAssignableFrom(type)) + return new DoubleFormatter(); + if (String[].class.isAssignableFrom(type)) + return new StringArrayFormatter(); + if (JulianDate.class.isAssignableFrom(type)) + return new JulianDateFormatter(); + if (SimpleCalendarDate.class.isAssignableFrom(type)) + return new SimpleCalendarDateFormatter(); + if (Boolean.class.isAssignableFrom(type)) + return new BooleanFormatter(); + if (BigDecimal.class.isAssignableFrom(type)) + return new BigDecimalFormatter(); + if (BigDecimal[].class.isAssignableFrom(type)) + return new BigDecimalArrayFormatter(); + + return new DefaultFormatter(); + } + + public abstract Object format(Object target) throws FormattingException; + + public abstract Object unformat(Object target) throws FormattingException; + +} diff --git a/posterita/src/main/org/posterita/formatter/IntegerFormatter.java b/posterita/src/main/org/posterita/formatter/IntegerFormatter.java new file mode 100644 index 0000000000..a0423b5793 --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/IntegerFormatter.java @@ -0,0 +1,47 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Aug-2005 by alok + * + */ +package org.posterita.formatter; + + +public class IntegerFormatter extends Formatter +{ + + public Object format(Object value) + { + if (value == null) + return ""; + + Integer integer = (Integer) value; + + return integer.toString(); + } + + public Object unformat(Object object) throws NumberFormatException + { + String string = (String) object; + if(string == null || string.trim().length() <1) + return null; + + return Integer.valueOf(string); + } + +} diff --git a/posterita/src/main/org/posterita/formatter/JulianDateFormatter.java b/posterita/src/main/org/posterita/formatter/JulianDateFormatter.java new file mode 100644 index 0000000000..6179d6ba17 --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/JulianDateFormatter.java @@ -0,0 +1,82 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Aug-2005 by alok + * + */ + +package org.posterita.formatter; + +import java.text.DateFormat; +import java.text.ParseException; +import java.util.Date; + +import org.posterita.core.JulianDate; + + +public class JulianDateFormatter extends Formatter +{ + public Object format(Object value) + { + if (value==null) + return ""; + + JulianDate julianDate = (JulianDate) value; + + DateFormat mediumDF = DateFormat.getDateInstance(DateFormat.MEDIUM); + + String string = mediumDF.format(julianDate.getJavaDate()); + + return string; + } + + + + /* (non-Javadoc) + * @see com.shortletting.formatter.Formatter#unformat(java.lang.Object) + */ + public Object unformat(Object target) + { + if (target == null) + return null; + String value = (String) target; + + DateFormat mediumDF = DateFormat.getDateInstance(DateFormat.MEDIUM); + + Date date = new Date(); + + try + { + date = mediumDF.parse(value); + } + catch (ParseException e) + { + //throw new RunTimeException("Fatal Error converting dates"); + /* + * @TODO silent exception needs to be logged. + */ + e.printStackTrace(); + } + + JulianDate julDate = new JulianDate(date); + + return julDate; + } + + +} diff --git a/posterita/src/main/org/posterita/formatter/LongFormatter.java b/posterita/src/main/org/posterita/formatter/LongFormatter.java new file mode 100644 index 0000000000..71ea4d7ae9 --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/LongFormatter.java @@ -0,0 +1,48 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Aug-2005 by alok + * + */ +package org.posterita.formatter; + + +public class LongFormatter extends Formatter +{ + + public Object format(Object value) + { + if (value == null) + return ""; + + Long dbl = (Long) value; + return dbl.toString(); + + + } + + public Object unformat(Object object) + { + String string = (String) object; + if(string == null || string.trim().length() <1) + return null; + + return new Long(string); + } + +} diff --git a/posterita/src/main/org/posterita/formatter/PriceFormatter.java b/posterita/src/main/org/posterita/formatter/PriceFormatter.java new file mode 100644 index 0000000000..a785f63a8b --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/PriceFormatter.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on Feb 3, 2006 by ashley +* +*/ + +package org.posterita.formatter; + +import java.math.BigDecimal; +import java.text.DecimalFormat; + +public class PriceFormatter +{ + + + public static String format(BigDecimal price, String priceFormat) + { + DecimalFormat format = new DecimalFormat(priceFormat); + + double dblPrice = price.doubleValue(); + + String strPrice = format.format(dblPrice); + + return strPrice; + } +} diff --git a/posterita/src/main/org/posterita/formatter/PrintFormatter.java b/posterita/src/main/org/posterita/formatter/PrintFormatter.java new file mode 100644 index 0000000000..737d037120 --- /dev/null +++ b/posterita/src/main/org/posterita/formatter/PrintFormatter.java @@ -0,0 +1,70 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 24, 2006 + */ + + +package org.posterita.formatter; + +import java.util.Properties; + +import org.compiere.model.MAttributeInstance; +import org.compiere.model.MAttributeValue; +import org.compiere.model.MProduct; + + +public class PrintFormatter extends Formatter +{ + + public Object format(Object target) + { + if(target==null) + return null; + + MProduct product = (MProduct)target; + int attributeSetInstanceId = product.getM_AttributeSetInstance_ID(); + Properties ctx = product.getCtx(); + + String whereClause="AD_CLIENT_ID="+product.getAD_Client_ID()+" and M_ATTRIBUTESETINSTANCE_ID="+attributeSetInstanceId; + int [] attributeValuesIds = MAttributeInstance.getAllIDs(MAttributeInstance.Table_Name,whereClause,null); + + MAttributeValue attrValue=null; + + String productName=""; + + for(int i=0;i keyNamePairs = new ArrayList(); + + int ad_client_id = Env.getAD_Client_ID(ctx); + + String sql = "select attrIns.m_attributevalue_id,attrVal.name ATTRIBUTE_VALUE " + + "from M_PRODUCT prod,M_ATTRIBUTEINSTANCE attrIns ,M_attribute attr,M_attributeValue attrVal " + + "where prod.M_ATTRIBUTESETINSTANCE_id = attrIns.M_ATTRIBUTESETINSTANCE_id " + + "and attr.m_attribute_id = attrIns.m_attribute_id " + + "and attrIns.m_attributevalue_id = attrVal.m_attributevalue_id " + + "and attr.name = '" + attributeName + "' " + + "and attr.AD_CLIENT_ID = " + ad_client_id; + + PreparedStatement pstmt = null; + + System.out.println("Query for attributeValueKeyNamePair : " + sql); + + try + { + pstmt = DB.prepareStatement(sql, null); + ResultSet rs = pstmt.executeQuery(); + KeyNamePair pair = null; + + + while(rs.next()) + { + pair = new KeyNamePair(rs.getInt(1),rs.getString(2)); + keyNamePairs.add(pair); + } + + rs.close(); + } + catch (SQLException e) + { + throw new SystemException(e); + } + finally + { + try + { + pstmt.close(); + } + catch (Exception ex) + { + } + + pstmt = null; + } + + return keyNamePairs; + } +} diff --git a/posterita/src/main/org/posterita/keyname/BPartnerKeyNamePair.java b/posterita/src/main/org/posterita/keyname/BPartnerKeyNamePair.java new file mode 100644 index 0000000000..ddae3243c3 --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/BPartnerKeyNamePair.java @@ -0,0 +1,52 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 6, 2005 by praveen + * + */ +package org.posterita.keyname; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.MBPartner; +import org.compiere.util.Env; + +import org.posterita.core.KeyNamePairUtil; +import org.posterita.exceptions.OperationException; + + +public class BPartnerKeyNamePair extends KeyNamePairUtil +{ + public static ArrayList getKeyNamePairs(Properties ctx) throws OperationException + { + String sql = "ad_client_id=" + Env.getAD_Client_ID(ctx) + " and ad_org_id=" + Env.getAD_Org_ID(ctx) + " and isactive = 'Y'"; + + try + { + return getData(ctx, MBPartner.Table_Name, sql); + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + } + +} + diff --git a/posterita/src/main/org/posterita/keyname/BankKeyNamePair.java b/posterita/src/main/org/posterita/keyname/BankKeyNamePair.java new file mode 100644 index 0000000000..e2e209e727 --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/BankKeyNamePair.java @@ -0,0 +1,48 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.keyname; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.util.Env; + +import org.posterita.core.KeyNamePairUtil; +import org.posterita.exceptions.OperationException; +import org.posterita.model.MBank; + + +public class BankKeyNamePair extends KeyNamePairUtil +{ + public static ArrayList getKeyNamePairs(Properties ctx) throws OperationException + { + String sql = "ad_client_id=" + Env.getAD_Client_ID(ctx) + " and ad_org_id=" + Env.getAD_Org_ID(ctx) + " and isactive = 'Y'"; + + try + { + return getData(ctx, MBank.Table_Name, sql); + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + } +} diff --git a/posterita/src/main/org/posterita/keyname/CBPartnerKeyNamePair.java b/posterita/src/main/org/posterita/keyname/CBPartnerKeyNamePair.java new file mode 100644 index 0000000000..7e93c70cf0 --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/CBPartnerKeyNamePair.java @@ -0,0 +1,108 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 6, 2005 by praveen + * + */ +package org.posterita.keyname; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.MOrg; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.KeyNamePair; + +import org.posterita.exceptions.SystemException; + + +public class CBPartnerKeyNamePair +{ + public static ArrayList getKeyNamePairs(Properties ctx) throws SystemException + { + ArrayList bpList = new ArrayList(); + + int ad_client_id = Env.getAD_Client_ID(ctx); + int ad_org_id = Env.getAD_Org_ID(ctx); + + MOrg org = new MOrg(ctx,ad_org_id,null); + + String orgType = ""; + + /* if(org.isAutomobile()) + { + orgType = " and isAutomobile = 'Y'"; + } + else + { + orgType = " and isMotorcycle = 'Y'"; + }*/ + + String sql = "select bp.C_BPARTNER_ID,bp.NAME" + + " from AD_ORG org, C_BPARTNER bp" + + " where org.AD_CLIENT_ID = " + ad_client_id + + " and org.isRetailer = 'Y'" + + " and org.AD_CLIENT_ID = bp.AD_CLIENT_ID" + + " and org.AD_ORG_ID = bp.AD_ORG_ID" + + " and bp.isactive = 'Y'"; + + sql = sql + orgType; + + PreparedStatement pstmt = null; + + pstmt = DB.prepareStatement(sql,null); + ResultSet rs; + KeyNamePair pair = null; + + try + { + rs = pstmt.executeQuery(); + + while (rs.next()) + { + pair = new KeyNamePair(rs.getInt(1),rs.getString(2)); + bpList.add(pair); + } + + rs.close(); + } + catch (SQLException e) + { + throw new SystemException(e.getMessage()); + } + finally + { + try + { + pstmt.close(); + } + catch(Exception e) + {} + + pstmt = null; + } + + return bpList; + } + +} + diff --git a/posterita/src/main/org/posterita/keyname/LocatorKeyNamePair.java b/posterita/src/main/org/posterita/keyname/LocatorKeyNamePair.java new file mode 100644 index 0000000000..7d87f0af41 --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/LocatorKeyNamePair.java @@ -0,0 +1,102 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on Sep 22, 2005 by ashley +* +*/ + +package org.posterita.keyname; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.MLocator; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.KeyNamePair; + +import org.posterita.exceptions.OperationException; + +public class LocatorKeyNamePair +{ + public static ArrayList getKeyNamePair(Properties ctx) throws OperationException + { + ArrayList list = new ArrayList(); + + PreparedStatement prepStmt = null; + + try + { + int adOrgId = Env.getAD_Org_ID(ctx); + int adClientId = Env.getAD_Client_ID(ctx); + + String sqlStatement = "select M_LOCATOR_ID, VALUE from " + MLocator.Table_Name + " where AD_ORG_ID=" + adOrgId + " and AD_CLIENT_ID=" + adClientId + " and isactive = 'Y'"; + + prepStmt = DB.prepareStatement(sqlStatement, null); + ResultSet rs = prepStmt.executeQuery(); + + while(rs.next()) + { + int id = rs.getInt(1); + String name = rs.getString(2); + + KeyNamePair keyPair = new KeyNamePair(id, name); + list.add(keyPair); + } + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + + return list; + } + + public static KeyNamePair getKeyNamePair(Properties ctx, int locatorId) throws OperationException + { + PreparedStatement prepStmt = null; + KeyNamePair keyPair = null; + try + { + int adOrgId = Env.getAD_Org_ID(ctx); + int adClientId = Env.getAD_Client_ID(ctx); + + String sqlStatement = "select M_LOCATOR_ID, VALUE from " + MLocator.Table_Name + " where AD_ORG_ID=" + adOrgId + " and AD_CLIENT_ID=" + adClientId + " and M_LOCATOR_ID=" + locatorId; + + prepStmt = DB.prepareStatement(sqlStatement, null); + ResultSet rs = prepStmt.executeQuery(); + + while(rs.next()) + { + int id = rs.getInt(1); + String name = rs.getString(2); + + keyPair = new KeyNamePair(id, name); + } + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + + return keyPair; + } +} diff --git a/posterita/src/main/org/posterita/keyname/MenuKeyNamePair.java b/posterita/src/main/org/posterita/keyname/MenuKeyNamePair.java new file mode 100644 index 0000000000..f43694cf29 --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/MenuKeyNamePair.java @@ -0,0 +1,53 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on Jul 28, 2005 by Fred + */ + +package org.posterita.keyname; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.X_U_Menu; +import org.compiere.util.Env; + +import org.posterita.core.KeyNamePairUtil; +import org.posterita.exceptions.OperationException; + +public class MenuKeyNamePair extends KeyNamePairUtil +{ + public static ArrayList getKeyNamePairs(Properties ctx) throws OperationException + + { + String sql = "ad_client_id=" + Env.getAD_Client_ID(ctx) + "and ad_org_id="+ Env.getAD_Org_ID(ctx) + " and parentmenu_id is not null order by parentmenu_id"; + //+ " and isClosable= 'Y' "; + try + { + return getData(ctx, X_U_Menu.Table_Name,sql); + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + } + + +} diff --git a/posterita/src/main/org/posterita/keyname/OrgKeyNamePair.java b/posterita/src/main/org/posterita/keyname/OrgKeyNamePair.java new file mode 100644 index 0000000000..aaf7e4f411 --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/OrgKeyNamePair.java @@ -0,0 +1,62 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 2, 2005 by din + */ + +package org.posterita.keyname; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.X_AD_Org; +import org.compiere.util.Env; + +import org.posterita.businesslogic.OrganisationManager; +import org.posterita.core.KeyNamePairUtil; +import org.posterita.exceptions.OperationException; + +public class OrgKeyNamePair extends KeyNamePairUtil +{ + public static ArrayList getKeyNamePairs(Properties ctx) throws OperationException + { + String isAuto = "N"; + String isMoto = "N"; + + /* if(OrganisationManager.getMyOrg(ctx).isAutomobile()) + { + isAuto = "Y"; + } + + if(OrganisationManager.getMyOrg(ctx).isMotorcycle()) + { + isMoto = "Y"; + }*/ + + String sql = "AD_CLIENT_ID =" + Env.getAD_Client_ID(ctx) + "and ISAUTOMOBILE ='"+ isAuto +"' and ISMOTORCYCLE ='"+ isMoto +"'" + " and isactive = 'Y'"; + try + { + return getData(ctx, X_AD_Org.Table_Name,sql); + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + } +} diff --git a/posterita/src/main/org/posterita/keyname/PriceListVersionKeyNamePair.java b/posterita/src/main/org/posterita/keyname/PriceListVersionKeyNamePair.java new file mode 100644 index 0000000000..c71ccd146a --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/PriceListVersionKeyNamePair.java @@ -0,0 +1,47 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 19, 2005 by praveen + * + */ +package org.posterita.keyname; + +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.MPriceListVersion; +import org.compiere.util.Env; +import org.compiere.util.KeyNamePair; + +public class PriceListVersionKeyNamePair +{ + public static ArrayList getKeyNamePairs(Properties ctx) + { + ArrayList list = new ArrayList(); + int id[] = MPriceListVersion.getAllIDs(MPriceListVersion.Table_Name,"AD_Client_id = "+Env.getAD_Client_ID(ctx),null); + + for(int i=0; i getKeyNamePairs(Properties ctx, int attributeId, int productcategoryId) throws OperationException + { + String sql = "ad_client_id=" + Env.getAD_Client_ID(ctx) + " and m_attribute_id=" + attributeId + " and m_product_category_id=" + productcategoryId + " and isactive = 'Y'"; + + try + { + return getData(ctx, MAttributeValue.Table_Name, sql); + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + } + +} diff --git a/posterita/src/main/org/posterita/keyname/RegionKeyNamePair.java b/posterita/src/main/org/posterita/keyname/RegionKeyNamePair.java new file mode 100644 index 0000000000..aba9278260 --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/RegionKeyNamePair.java @@ -0,0 +1,48 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.keyname; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.MRegion; + +import org.posterita.core.KeyNamePairUtil; +import org.posterita.exceptions.OperationException; +import org.posterita.lib.UdiConstants; + + +public class RegionKeyNamePair extends KeyNamePairUtil +{ + public static ArrayList getKeyNamePairs(Properties ctx) throws OperationException + { + String sql = "c_country_id = " + UdiConstants.COUNTRY_SOUTH_AFRICA + " and isactive = 'Y'"; + + try + { + return getData(ctx, MRegion.Table_Name,sql); + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + } +} diff --git a/posterita/src/main/org/posterita/keyname/RoleKeyNamePair.java b/posterita/src/main/org/posterita/keyname/RoleKeyNamePair.java new file mode 100644 index 0000000000..8ced214270 --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/RoleKeyNamePair.java @@ -0,0 +1,50 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 1, 2005 by din + */ + +package org.posterita.keyname; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.MRole; +import org.compiere.util.Env; + +import org.posterita.core.KeyNamePairUtil; +import org.posterita.exceptions.OperationException; + +public class RoleKeyNamePair extends KeyNamePairUtil +{ + public static ArrayList getKeyName(Properties ctx) throws OperationException + { + String sql = "ad_client_id=" + Env.getAD_Client_ID(ctx) + "and ad_org_id=" + Env.getAD_Org_ID(ctx) + " and isactive = 'Y'"; + + try + { + return getData(ctx, MRole.Table_Name,sql); + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + + } +} diff --git a/posterita/src/main/org/posterita/keyname/SalesRepKeyNamePair.java b/posterita/src/main/org/posterita/keyname/SalesRepKeyNamePair.java new file mode 100644 index 0000000000..024fbe8172 --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/SalesRepKeyNamePair.java @@ -0,0 +1,104 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 6, 2005 by praveen + * + */ +package org.posterita.keyname; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.MOrg; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.KeyNamePair; + +import org.posterita.exceptions.SystemException; + + +public class SalesRepKeyNamePair +{ + /** + * returns an arraylist of keyname pairs. + * key -> user_id + * name -> username + */ + public static ArrayList getKeyNamePairs(Properties ctx) throws SystemException + { + ArrayList srList = new ArrayList(); + + int ad_client_id = Env.getAD_Client_ID(ctx); + int ad_org_id = Env.getAD_Org_ID(ctx); + + new MOrg(ctx,ad_org_id,null); + + + String sql = "select c_bpartner_id,name " + + "from c_bpartner " + + "where issalesrep = 'Y' " + + "and isactive = 'Y' " + + "and ad_client_id = ? " + + "and ad_org_id = ? "; + + + PreparedStatement pstmt = null; + + pstmt = DB.prepareStatement(sql, null); + ResultSet rs; + KeyNamePair pair = null; + + try + { + pstmt.setInt(1,ad_client_id); + pstmt.setInt(2,ad_org_id); + + rs = pstmt.executeQuery(); + + while (rs.next()) + { + pair = new KeyNamePair(rs.getInt(1),rs.getString(2)); + srList.add(pair); + } + + rs.close(); + } + catch (SQLException e) + { + throw new SystemException(e.getMessage()); + } + finally + { + try + { + pstmt.close(); + } + catch(Exception e) + {} + + pstmt = null; + } + + return srList; + } + +} + diff --git a/posterita/src/main/org/posterita/keyname/WarehouseKeyNamePair.java b/posterita/src/main/org/posterita/keyname/WarehouseKeyNamePair.java new file mode 100644 index 0000000000..9f44840e5c --- /dev/null +++ b/posterita/src/main/org/posterita/keyname/WarehouseKeyNamePair.java @@ -0,0 +1,71 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 29-Jul-2005 by alok + * + */ +package org.posterita.keyname; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.util.Env; + +import org.posterita.core.KeyNamePairUtil; +import org.posterita.exceptions.OperationException; + + +public class WarehouseKeyNamePair extends KeyNamePairUtil +{ + public static ArrayList getKeyNamePair(Properties ctx) throws OperationException + { + ArrayList list = new ArrayList(); + + try + { + list = getData(ctx,"M_WAREHOUSE","AD_ORG_ID="+ Env.getAD_Org_ID(ctx) + " and ad_client_Id=" + Env.getAD_Client_ID(ctx)+ " and isactive = 'Y'"); + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + + return list; + + } + + public static ArrayList getKeyNamePair(Properties ctx,int warehouseId) throws OperationException + { + ArrayList list = new ArrayList(); + + + + try + { + list = getData(ctx,"M_WAREHOUSE","AD_ORG_ID="+ Env.getAD_Org_ID(ctx) + " and ad_client_Id=" + Env.getAD_Client_ID(ctx)+ " and isactive = 'Y' and m_warehouse_id<>"+warehouseId); + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + + return list; + + } +} diff --git a/posterita/src/main/org/posterita/lib/PropertiesConstant.java b/posterita/src/main/org/posterita/lib/PropertiesConstant.java new file mode 100644 index 0000000000..541673bbde --- /dev/null +++ b/posterita/src/main/org/posterita/lib/PropertiesConstant.java @@ -0,0 +1,129 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Mar-2005 by fred + * + */ +package org.posterita.lib; + + +public class PropertiesConstant +{ + + public static final String CLIENT_NAME = "client.name"; + public static final String CLIENT_ID = "client.id"; + public static final String NTIER_HOME = "ntier.home"; + public static final String DCS_HOME = "dcs.home"; + //public static final String HONDA_HEAD_OFFICE_AUTO_ID = "honda.headoffice.auto.id"; + public static final String HONDA_HEAD_OFFICE_MOTO_ID = "honda.headoffice.moto.id"; + + public static final String AUTO_METALLIC_PRICE_ID = "auto.metallic.price.list.id"; + public static final String MOTO_METALLIC_PRICE_ID = "wing.metallic.price.list.id"; + public static final String PRODUCT_CATEGORY_CAR = "productCategory.car.id"; + public static final String FACTORY_HOME = "factory.home"; + public static final String UDI_HOME = "udi.home"; + public static final String LOGO_HOME="logo.home"; + public static final String CSV_HOME="csv.home"; + + public static final String ATTRIBUTE_SET_CAR = "car.attributeSet.id"; + public static final String BPARTNER_HSAF_ID = "bpartner.hsaf.id"; + public static final String USER_ROLE_SUPER_USER_ID = "user.role.superUser.id"; + public static final String ROLE_MENU_SUPER_USER_ID = "role.menu.superUser.id"; + public static final String SUPER_USER_ID = "superUser.id"; + public static final String USER_ROLE_UDI_ADMIN_ID = "user.role.udiAdmin.id"; + public static final String ROLE_MENU_UDI_ADMIN_ID = "role.menu.udiAdmin.id"; + public static final String UDI_ADMIN_ID = "udiAdmin.id"; + //public static final String HSAFAUTO_ADMIN_ID = "hsafAuto.admin.id"; + public static final String HSAFWING_ADMIN_ID = "hsafWing.Admin.id"; + public static final String ATTRIBUTE_SET_VIN_NO="vinNo.attributeVinNo.id"; + public static final String MODEL_ATTRIBUTE = "attribute.model.id"; + public static final String COLOUR_ATTRIBUTE = "attribute.colour.id"; + public static final String TRX_ATTRIBUTE = "attribute.transmisson.id"; + public static final String YEAR_ATTRIBUTE = "attribute.year.id"; + public static final String VIN_NO_ATTRIBUTE = "attribute.vinNo.id"; + public static final String UOM_EACH = "uom.each"; + public static final String TAX_CATEGORY_DEFAULT = "taxCategory.default.id"; + public static final String DEFAULT_BPGROUP = "default.bpartner.group"; + + //ROLES + public static final String ROLE_DEALER_PRINCIPAL_ID = "role.dealer.principal.id"; + public static final String ROLE_SALES_MANAGER_ID = "role.sales.manager.id"; + public static final String ROLE_SALES_PERSON_ID = "role.sales.person.id"; + public static final String ROLE_STOCK_CONTROLLER_ID = "role.stock.controller.id"; + public static final String ROLE_TEST_ID = "role.test.id"; + public static final String ROLE_SYSTEM_ADMINISTRATOR_ID = "role.system.administrator.id"; + public static final String ROLE_UDI_ADMIN_ID = "role.udiAdmin.id"; + public static final String ROLE_HSAFAUTO_ADMIN_ID = "role.hsafAutoAdmin.id"; + public static final String ROLE_HSAFWING_ADMIN_ID = "role.hsafWingAdmin.id"; + //MENUS + public static final String PMENU_HOME_ID = "pmenu.home.id"; + public static final String PMENU_CREATEMENU_ID = "pmenu.createmenu.id"; + //testing + public static final String SMENU_ORGANISATION_ID = "smenu.organisation.id"; + //end of test + public static final String SMENU_WAREHOUSE_ID= "smenu.warehouse.id"; + public static final String SMENU_CREATEUSER_ID= "smenu.createuser.id"; + public static final String PMENU_STOCK_INQUIRY_ID = "pmenu.stock.inquiry.id"; + public static final String SMENU_INQUIRY_ID = "smenu.inquiry.id"; + public static final String SMENU_MY_STOCK_ID = "smenu.my.stock.id"; + + public static final String PMENU_DEALER_ORDER_ID = "pmenu.dealer.order.id"; + public static final String SMENU_CREATE_ORDER_ID = "smenu.create.order.id"; + + public static final String PMENU_NATIS_RELEASE_ID = "pmenu.natis.release.id"; + public static final String SMENU_RELEASE_VEHICLE_ID = "smenu.release.vehicle.id"; + + public static final String PMENU_ALLOCATIONS_ID = "pmenu.allocations.id"; + + public static final String PMENU_DEALER_TRANSFER_ID = "pmenu.dealer.transfer.id"; + public static final String PMENU_DEALER_ADMIN_ID = "pmenu.dealer.admin.id"; + public static final String PMENU_MESSAGES_ID = "pmenu.messages.id"; + public static final String SMENU_MESSAGESINBOX_ID="smenu.messagesinbox.id"; + public static final String SMENU_MESSAGESSENT_ID = "smenu.messagessent.id"; + public static final String SMENU_MESSAGESCOMPOSE_ID = "smenu.messagescompose.id"; + public static final String PMENU_LOGOUT_ID = "pmenu.logout.id"; + public static final String CAR_ASSET_GRP = "car.assetgroup.id"; + + public static final String SSL_CERT_PATH = "ssl.cert.path"; + public static final String NATIS_POST_PROCESSOR = "natis.post.processor"; + public static final String NATIS_OPERATIONAL_MODE = "natis.operational.mode"; + public static final String NATIS_URL = "natis.url"; + public static final String SMTP_SERVER = "smtp.server"; + + public static final String FTP_SERVER_URL = "ftp.server.url"; + public static final String FTP_USERNAME = "ftp.user.name"; + public static final String FTP_PASSWORD = "ftp.user.password"; + + public static final String NATIS_AUTOMATION_TIME = "natis.automation.time"; + + public static final String FTP_IMPORT_AUTOMATION = "ftp.import.automation"; + public static final String FTP_IMPORT_TIME = "ftp.import.time"; + + public static final String WEBSTORE_AUTOMATED_IMPORT = "webstore.automated.import"; + public static final String WEBSTORE_AUTOMATED_TIME = "webstore.automated.time"; + public static final String WEBSTORE_IMAGE_FOLDER_TOBEPROCESSED = "webstore.folder.tobeprocessed"; + public static final String WEBSTORE_IMAGE_FOLDER_PROCESSED = "webstore.folder.processed"; + public static final String WEBSTORE_IMAGE_FOLDER_ERRORS = "webstore.folder.errors"; + public static final String WEBSTORE_IMAGE_COLLECTION_FOLDER = "webstore.collection.folder"; + public static final String WEBSTORE_IMAGE_INACTIVE_FOLDER = "webstore.inactive.folder"; + + public static final String APPLICATION_TYPE = "application.type"; + public static final String SMTP_AUTH = "smtp.authorisation"; + public static final String SMTP_USERNAME = "smtp.username"; + public static final String SMTP_PASSWORD = "smtp.password"; +} diff --git a/posterita/src/main/org/posterita/lib/UdiConstants.java b/posterita/src/main/org/posterita/lib/UdiConstants.java new file mode 100644 index 0000000000..e14b5bb6cc --- /dev/null +++ b/posterita/src/main/org/posterita/lib/UdiConstants.java @@ -0,0 +1,93 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.lib; + +import org.compiere.util.Env; + + +public class UdiConstants +{ + public static final String ACCOUNTING_FILE="/config/accounting/AccountingUS.csv"; + //public static int CURRENCY_EURO=102; + public static final int CURRENCY_USD=100; + public static final int COUNTRY_SOUTH_AFRICA=305; + public static final int COUNTRY_MAURITIUS = 245; + public static final int COUNTRY_US = 100; + public static final int CURRENCY_RUPEES = 280; + + public static final int UOM_EACH_ID = 100; + + public static String POS_VERSION = ""; + public static String INVALID_LICENSING_REASON = ""; + + public static final String THUMBNAIL_IMAGE_PREFIX = "THUMB-"; + public static final String FULL_IMAGE_PREFIX = "FULL-"; + public static final String FULL_IMAGE = "fullImage"; + public static final String THUMBNAIL = "thumbnail"; + public static final String DEFAULT_IMAGE = "Default"; + public static final String IMAGE_EXTENSION = ".jpg"; + public static final String IMPORT_AUTOMATATION_ON = "ON"; + + public static final String CLIENT_ID_CTX_PARAM = "#AD_Client_ID"; + public static final String ORG_ID_CTX_PARAM = "#AD_Org_ID"; + public static final String CSS = "webParam5"; + public static final String FORWARD = "webParam6"; + public static final String MODULE_NAME_CTX_PARAM = "#ModuleName"; + public static final String WEBPARAM6 = "webParam6"; + public static final String PRICELIST_CTX_PARAM = "#M_PriceList_ID"; + public static final String PRICELIST_VERSION_CTX_PARAM = "#M_Pricelist_Version_ID"; + public static final String PRODUCT_CATEGORY_CTX_PARAM = "#M_Product_Category_ID"; + public static final String USER_ID_CTX_PARAM = "#AD_User_ID"; + public static final String USER_ORG_CTX_PARAM = "#User_Org"; + public static final String LANGUAGE_CTX_PARAM = "#AD_Language"; + + public static final String WEBSTORE_DEFAULT_AD_ORG_ID_CTX_PARAM = "#AD_Org_ID_WebStoreDefault"; + + public static final String WAREHOUSE_CTX_PARAM = "#M_Warehouse_ID"; + + public static final String WEBSTORE_APP_SUFFIX = "WEBSTORE"; + + public static final String REQUEST_UPDATE_EMAIL_PREFIX = "`EMAIL`"; + public static final String REQUEST_UPDATE_EMAIL_EXT = ".txt"; + + public static final String PRINTFORMAT_ITEM_LOGO = "Logo"; + public static final String FIDELITY_BACKGROUND_IMAGE = "Fidelity"; + + + public static final String PAYMENTRULE_MIXED = "T"; + + + public static final String SHIPMENT_CHARGE = "Shipment Charge"; + + /** Set Payment Rule. + How you pay the invoice */ + public static final String POS_ID = Env.POS_ID; + public static final String POS_PURCHASE_PL = "#POSPurchasePL"; + public static final String POS_PURCHASE_PL_VERSION = "#POSPurchasePLVersion"; + public static final String WEB_USER_ROLE = "WebStoreUserRole"; + public static final String ORIGINAL_IMAGE = "originalImage"; + public static final String TAMAK_ADMIN_ROLE = "posterita Admin"; + public static final String TAMAK_USER_ROLE = "posterita User"; + public static final String WEBSTORE_USER_ROLE = "WebStoreUserRole"; + + + public static final String EMAIL_FOOTER_MESSAGE = "Powered by Tamak ICT - CRM Module for Compiere ERP/CRM"; + +} diff --git a/posterita/src/main/org/posterita/model/MBPartnerProduct.java b/posterita/src/main/org/posterita/model/MBPartnerProduct.java new file mode 100644 index 0000000000..97a6b41547 --- /dev/null +++ b/posterita/src/main/org/posterita/model/MBPartnerProduct.java @@ -0,0 +1,43 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on May 10, 2006 + */ + + +package org.posterita.model; + +import java.util.Properties; + +import org.compiere.model.X_C_BPartner_Product; + + +public class MBPartnerProduct extends X_C_BPartner_Product +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public MBPartnerProduct(Properties ctx, int C_BpartnerProduct_ID, String m_trxName) + { + super(ctx, C_BpartnerProduct_ID, m_trxName); + + } +} diff --git a/posterita/src/main/org/posterita/model/MBank.java b/posterita/src/main/org/posterita/model/MBank.java new file mode 100644 index 0000000000..3fee235faf --- /dev/null +++ b/posterita/src/main/org/posterita/model/MBank.java @@ -0,0 +1,44 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 07-Jul-2005 by alok + * + */ +package org.posterita.model; + +import java.util.Properties; + +import org.compiere.model.X_C_Bank; + + +public class MBank extends X_C_Bank +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public MBank(Properties ctx, int C_Bank_ID, String m_trxName) + { + super(ctx, C_Bank_ID, m_trxName); + + } + + +} diff --git a/posterita/src/main/org/posterita/model/MBlackListCheque.java b/posterita/src/main/org/posterita/model/MBlackListCheque.java new file mode 100644 index 0000000000..f6775d1f6f --- /dev/null +++ b/posterita/src/main/org/posterita/model/MBlackListCheque.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 07-Jul-2005 by alok + * + */ +package org.posterita.model; + +import java.util.Properties; + +import org.compiere.model.X_U_BlackListCheque; + +public class MBlackListCheque extends X_U_BlackListCheque +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public MBlackListCheque(Properties ctx, int U_BlackListCheque_ID, String trxName) + { + super(ctx, U_BlackListCheque_ID, trxName); + } +} diff --git a/posterita/src/main/org/posterita/model/MMAttachment.java b/posterita/src/main/org/posterita/model/MMAttachment.java new file mode 100644 index 0000000000..6af9c714fc --- /dev/null +++ b/posterita/src/main/org/posterita/model/MMAttachment.java @@ -0,0 +1,81 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on May 10, 2006 by ashley +* +*/ + +package org.posterita.model; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.Properties; + +import org.compiere.model.MAttachment; +import org.compiere.util.DB; + +import org.posterita.exceptions.OperationException; + +public class MMAttachment extends MAttachment +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + @SuppressWarnings("unused") + private MMAttachment(Properties ctx, int AD_Table_ID, int Record_ID, String trxName) + { + super(ctx, AD_Table_ID, Record_ID, trxName); + } + + public static MAttachment get (Properties ctx, int AD_Table_ID, int Record_ID, String trxName) throws OperationException + { + MAttachment retValue = null; + PreparedStatement pstmt = null; + String sql = "SELECT * FROM AD_Attachment WHERE AD_Table_ID=? AND Record_ID=?"; + try + { + pstmt = DB.prepareStatement (sql, trxName); + pstmt.setInt (1, AD_Table_ID); + pstmt.setInt (2, Record_ID); + ResultSet rs = pstmt.executeQuery (); + if (rs.next ()) + retValue = new MAttachment (ctx, rs, trxName); + rs.close (); + pstmt.close (); + pstmt = null; + } + catch (Exception e) + { + throw new OperationException("Cannot get attachment!!!", e); + } + try + { + if (pstmt != null) + pstmt.close (); + pstmt = null; + } + catch (Exception e) + { + pstmt = null; + } + return retValue; + } // get +} diff --git a/posterita/src/main/org/posterita/model/MMenu.java b/posterita/src/main/org/posterita/model/MMenu.java new file mode 100644 index 0000000000..d1831803bf --- /dev/null +++ b/posterita/src/main/org/posterita/model/MMenu.java @@ -0,0 +1,44 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.model; + +import java.util.Properties; + +import org.compiere.model.X_U_Menu; + +public class MMenu extends X_U_Menu +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + public MMenu(Properties ctx, int U_Menu_ID, String trxName) + { + super(ctx, U_Menu_ID, trxName); + } +} diff --git a/posterita/src/main/org/posterita/model/MRoleMenu.java b/posterita/src/main/org/posterita/model/MRoleMenu.java new file mode 100644 index 0000000000..aa853c1add --- /dev/null +++ b/posterita/src/main/org/posterita/model/MRoleMenu.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 27-Jul-2005 by alok + * + */ +package org.posterita.model; + +import java.util.Properties; + +import org.compiere.model.X_U_RoleMenu; + + +public class MRoleMenu extends X_U_RoleMenu +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public MRoleMenu(Properties ctx, int U_RoleMenu_ID, String trxName) + { + super(ctx, U_RoleMenu_ID, trxName); + } + +} diff --git a/posterita/src/main/org/posterita/model/MWebProperties.java b/posterita/src/main/org/posterita/model/MWebProperties.java new file mode 100644 index 0000000000..e9de489e79 --- /dev/null +++ b/posterita/src/main/org/posterita/model/MWebProperties.java @@ -0,0 +1,43 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 12-Oct-2005 + */ + + +package org.posterita.model; + +import java.util.Properties; + +import org.compiere.model.X_U_Web_Properties; + + +public class MWebProperties extends X_U_Web_Properties +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public MWebProperties(Properties ctx, int uWebProperties , String trxName) + { + super(ctx,uWebProperties,trxName); + } + +} diff --git a/posterita/src/main/org/posterita/model/M_RevenueRecognition.java b/posterita/src/main/org/posterita/model/M_RevenueRecognition.java new file mode 100644 index 0000000000..640242b571 --- /dev/null +++ b/posterita/src/main/org/posterita/model/M_RevenueRecognition.java @@ -0,0 +1,43 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jun 12, 2006 + */ + + +package org.posterita.model; + +import java.util.Properties; + +import org.compiere.model.X_C_RevenueRecognition; + + +public class M_RevenueRecognition extends X_C_RevenueRecognition +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public M_RevenueRecognition(Properties ctx, int C_REVENUERECOGNITION_ID, String trxName) + { + super(ctx, C_REVENUERECOGNITION_ID, trxName); + } +} + + diff --git a/posterita/src/main/org/posterita/model/TMKMBlackListCheque.java b/posterita/src/main/org/posterita/model/TMKMBlackListCheque.java new file mode 100644 index 0000000000..90d90473f2 --- /dev/null +++ b/posterita/src/main/org/posterita/model/TMKMBlackListCheque.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 07-Jul-2005 by alok + * + */ + +package org.posterita.model; + + + +public class TMKMBlackListCheque extends UDIPO +{ + + public TMKMBlackListCheque(MBlackListCheque mBlackListCheque) + { + super(mBlackListCheque); + } + + public MBlackListCheque getMBlackListCheque() + { + return (MBlackListCheque) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/TMKMCost.java b/posterita/src/main/org/posterita/model/TMKMCost.java new file mode 100644 index 0000000000..95ffe4dcb3 --- /dev/null +++ b/posterita/src/main/org/posterita/model/TMKMCost.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 9, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MCost; + + +public class TMKMCost extends UDIPO +{ + public TMKMCost(MCost cost) + { + super(cost); + } + + public MCost getMCost() + { + return (MCost) getPO(); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/model/TMKMSequence.java b/posterita/src/main/org/posterita/model/TMKMSequence.java new file mode 100644 index 0000000000..017812a014 --- /dev/null +++ b/posterita/src/main/org/posterita/model/TMKMSequence.java @@ -0,0 +1,43 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Created on Oct 11, 2006 by ashley +* +*/ + +/** + @author ashley + */ + +package org.posterita.model; + +import org.compiere.model.MSequence; + +public class TMKMSequence extends UDIPO +{ + public TMKMSequence(MSequence sequence) + { + super(sequence); + } + + public MSequence getMSequence() + { + return (MSequence) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIBPartnerOrgLink.java b/posterita/src/main/org/posterita/model/UDIBPartnerOrgLink.java new file mode 100644 index 0000000000..a8fe9628ab --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIBPartnerOrgLink.java @@ -0,0 +1,50 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 24-Jun-2005 by alok + * + */ +package org.posterita.model; + +import java.util.Properties; + +import org.compiere.process.BPartnerOrgLink; +import org.compiere.process.ProcessInfo; +import org.compiere.util.Trx; + +import org.posterita.exceptions.OperationException; + + +public class UDIBPartnerOrgLink +{ + private BPartnerOrgLink link; + + public UDIBPartnerOrgLink(BPartnerOrgLink link) + { + this.link = link; + } + + public void startProcess(Properties ctx,ProcessInfo pi ,Trx trx) throws OperationException + { + + if (!link.startProcess(ctx,pi,trx)) + throw new OperationException("BPartnerOrgLink failed"); + + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMAssetGroup.java b/posterita/src/main/org/posterita/model/UDIMAssetGroup.java new file mode 100644 index 0000000000..dce0ecf1cb --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMAssetGroup.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MAssetGroup; + + +public class UDIMAssetGroup extends UDIPO +{ + + public UDIMAssetGroup(MAssetGroup po) + { + super(po); + } + + public MAssetGroup getMAssetGroup() + { + return (MAssetGroup) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMAttachment.java b/posterita/src/main/org/posterita/model/UDIMAttachment.java new file mode 100644 index 0000000000..1970993392 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMAttachment.java @@ -0,0 +1,46 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 05-Jul-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MAttachment; + +/** + * @author alok + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class UDIMAttachment extends UDIPO +{ + + + public UDIMAttachment(MAttachment attachment) + { + super(attachment); + } + + public MAttachment getMAttachment() + { + return (MAttachment) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMAttribute.java b/posterita/src/main/org/posterita/model/UDIMAttribute.java new file mode 100644 index 0000000000..c259e52541 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMAttribute.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.model; + +import org.compiere.model.MAttribute; + + +public class UDIMAttribute extends UDIPO +{ + + public UDIMAttribute(MAttribute po) + { + super(po); + } + + public MAttribute getAttribute() + { + return (MAttribute) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMAttributeInstance.java b/posterita/src/main/org/posterita/model/UDIMAttributeInstance.java new file mode 100644 index 0000000000..6602fae593 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMAttributeInstance.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MAttributeInstance; + +public class UDIMAttributeInstance extends UDIPO +{ + + public UDIMAttributeInstance(MAttributeInstance instance) + { + super(instance); + } + + public MAttributeInstance getMAttributeInstance() + { + return (MAttributeInstance) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMAttributeSet.java b/posterita/src/main/org/posterita/model/UDIMAttributeSet.java new file mode 100644 index 0000000000..a7113d7160 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMAttributeSet.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MAttributeSet; + +public class UDIMAttributeSet extends UDIPO +{ + + public UDIMAttributeSet(MAttributeSet attributeSet) + { + super(attributeSet); + } + + public MAttributeSet getAttributeSet() + { + return (MAttributeSet) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMAttributeSetInstance.java b/posterita/src/main/org/posterita/model/UDIMAttributeSetInstance.java new file mode 100644 index 0000000000..6515da9eb9 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMAttributeSetInstance.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MAttributeSetInstance; + +public class UDIMAttributeSetInstance extends UDIPO +{ + + public UDIMAttributeSetInstance(MAttributeSetInstance attributeSetInstance) + { + super(attributeSetInstance); + } + + + public MAttributeSetInstance getAttributeSetInstance() + { + return (MAttributeSetInstance) getPO(); + } + + +} diff --git a/posterita/src/main/org/posterita/model/UDIMAttributeUse.java b/posterita/src/main/org/posterita/model/UDIMAttributeUse.java new file mode 100644 index 0000000000..4ba25321d3 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMAttributeUse.java @@ -0,0 +1,86 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +import org.compiere.model.MAttributeUse; +import org.compiere.util.DB; + +import org.posterita.exceptions.OperationException; + +public class UDIMAttributeUse extends UDIPO +{ + + public UDIMAttributeUse(MAttributeUse attributeUse) + { + super(attributeUse); + } + + public MAttributeUse getMAttributeUse() + { + return (MAttributeUse) getPO(); + } + + public static int[] getAllIDs (String TableName, String WhereClause, String trxName) throws OperationException + { + ArrayList list = new ArrayList(); + StringBuffer sql = new StringBuffer("SELECT "); + sql.append("M_ATTRIBUTE").append("_ID FROM ").append(TableName); + if (WhereClause != null && WhereClause.length() > 0) + sql.append(" WHERE ").append(WhereClause); + + PreparedStatement pstmt = null; + + try + { + pstmt = DB.prepareStatement(sql.toString(), trxName); + ResultSet rs = pstmt.executeQuery(); + while (rs.next()) + list.add(Integer.valueOf(rs.getInt(1))); + rs.close(); + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + finally + { + try + { + pstmt.close(); + } + catch(Exception e) + {} + + pstmt = null; + } + + // Convert to array + int[] retValue = new int[list.size()]; + for (int i = 0; i < retValue.length; i++) + retValue[i] = ((Integer)list.get(i)).intValue(); + return retValue; + } // getAllIDs + +} diff --git a/posterita/src/main/org/posterita/model/UDIMAttributeValue.java b/posterita/src/main/org/posterita/model/UDIMAttributeValue.java new file mode 100644 index 0000000000..d6646c27a2 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMAttributeValue.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MAttributeValue; + +public class UDIMAttributeValue extends UDIPO +{ + + public UDIMAttributeValue(MAttributeValue po) + { + super(po); + } + + public MAttributeValue getMAttributeValue() + { + return (MAttributeValue) getPO(); + } + + +} diff --git a/posterita/src/main/org/posterita/model/UDIMBPBankAccount.java b/posterita/src/main/org/posterita/model/UDIMBPBankAccount.java new file mode 100644 index 0000000000..22237a6f63 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMBPBankAccount.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 14-Jul-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MBPBankAccount; + + +public class UDIMBPBankAccount extends UDIPO +{ + + public UDIMBPBankAccount(MBPBankAccount bpBankAccount) + { + super(bpBankAccount); + } + + public MBPBankAccount getMBPBankAccount() + { + return (MBPBankAccount) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMBPGroup.java b/posterita/src/main/org/posterita/model/UDIMBPGroup.java new file mode 100644 index 0000000000..ac22c9f811 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMBPGroup.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 27-Jun-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MBPGroup; + + +public class UDIMBPGroup extends UDIPO +{ + + public UDIMBPGroup(MBPGroup po) + { + super(po); + } + + public MBPGroup getMBPGroup() + { + return (MBPGroup) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMBPartner.java b/posterita/src/main/org/posterita/model/UDIMBPartner.java new file mode 100644 index 0000000000..e2c101d87d --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMBPartner.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 22-Jun-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MBPartner; + + +public class UDIMBPartner extends UDIPO +{ + + public UDIMBPartner(MBPartner partner) + { + super(partner); + } + + public MBPartner getMBPartner() + { + return (MBPartner) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMBPartnerLocation.java b/posterita/src/main/org/posterita/model/UDIMBPartnerLocation.java new file mode 100644 index 0000000000..c5fd823d15 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMBPartnerLocation.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 24-Jun-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MBPartnerLocation; + + + +public class UDIMBPartnerLocation extends UDIPO +{ + + public UDIMBPartnerLocation(MBPartnerLocation po) + { + super(po); + } + + public MBPartnerLocation getMBPartnerLocation() + { + return (MBPartnerLocation) getPO(); + } + + +} diff --git a/posterita/src/main/org/posterita/model/UDIMBank.java b/posterita/src/main/org/posterita/model/UDIMBank.java new file mode 100644 index 0000000000..5457b31df8 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMBank.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 07-Jul-2005 by alok + * + */ +package org.posterita.model; + + +public class UDIMBank extends UDIPO +{ + public UDIMBank(MBank bank) + { + super(bank); + } + + public MBank getMBank() + { + return (MBank) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMBankAccount.java b/posterita/src/main/org/posterita/model/UDIMBankAccount.java new file mode 100644 index 0000000000..f8391bad1c --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMBankAccount.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 07-Jul-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MBankAccount; + + +public class UDIMBankAccount extends UDIPO +{ + + public UDIMBankAccount(MBankAccount bankAccount) + { + super(bankAccount); + } + + public MBankAccount getMBankAccount() + { + return (MBankAccount) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMCash.java b/posterita/src/main/org/posterita/model/UDIMCash.java new file mode 100644 index 0000000000..370a65f91d --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMCash.java @@ -0,0 +1,58 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 06-Apr-2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MCash; + +import org.posterita.exceptions.OperationException; + +public class UDIMCash extends UDIPO +{ + + public UDIMCash(MCash cash) + { + super(cash); + } + + public MCash getCash() + { + return (MCash) getPO(); + } + + public void processIt(String docAction) throws OperationException + { + + boolean processed = getCash().processIt(docAction); + + if (!processed) + throw new OperationException("Cannot process Cash Journal to " + getCash().getProcessMsg()+" "+ docAction); + + getCash().save(); + + } + + + + +} diff --git a/posterita/src/main/org/posterita/model/UDIMCashBook.java b/posterita/src/main/org/posterita/model/UDIMCashBook.java new file mode 100644 index 0000000000..d542814083 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMCashBook.java @@ -0,0 +1,43 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.model; + +import org.compiere.model.MCashBook; + +public class UDIMCashBook extends UDIPO +{ + + public UDIMCashBook(MCashBook cashBook) + { + super(cashBook); + } + + public MCashBook getMCashBook() + { + return (MCashBook) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMCashLine.java b/posterita/src/main/org/posterita/model/UDIMCashLine.java new file mode 100644 index 0000000000..89691064df --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMCashLine.java @@ -0,0 +1,44 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jun 29, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MCashLine; + + +public class UDIMCashLine extends UDIPO +{ + public UDIMCashLine(MCashLine cashLine) + { + super(cashLine); + } + + public MCashLine getMCashLine() + { + return (MCashLine) getPO(); + } + + + + + +} diff --git a/posterita/src/main/org/posterita/model/UDIMCharge.java b/posterita/src/main/org/posterita/model/UDIMCharge.java new file mode 100644 index 0000000000..cf4989e49c --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMCharge.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.model; + +import org.compiere.model.MCharge; + +public class UDIMCharge extends UDIPO +{ + + public UDIMCharge(MCharge charge) + { + super(charge); + } + + public MCharge getMCharge() + { + return (MCharge) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMClient.java b/posterita/src/main/org/posterita/model/UDIMClient.java new file mode 100644 index 0000000000..e869dd5a9a --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMClient.java @@ -0,0 +1,36 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MClient; + +public class UDIMClient extends UDIPO +{ + + public UDIMClient(MClient po) + { + super(po); + } + + public MClient getMClient() + { + return (MClient) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMCommission.java b/posterita/src/main/org/posterita/model/UDIMCommission.java new file mode 100644 index 0000000000..6ef4bacc37 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMCommission.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Nov 6, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MCommission; + + +public class UDIMCommission extends UDIPO +{ + + public UDIMCommission(MCommission commission) + { + super(commission); + } + + public MCommission getMCommission() + { + return (MCommission) getPO(); + } +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/model/UDIMCommissionLine.java b/posterita/src/main/org/posterita/model/UDIMCommissionLine.java new file mode 100644 index 0000000000..a2a39711d5 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMCommissionLine.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Nov 6, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MCommissionLine; + + +public class UDIMCommissionLine extends UDIPO +{ + + public UDIMCommissionLine(MCommissionLine commissionLine) + { + super(commissionLine); + } + + public MCommissionLine getMCommissionLine() + { + return (MCommissionLine) getPO(); + } +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/model/UDIMDiscountSchema.java b/posterita/src/main/org/posterita/model/UDIMDiscountSchema.java new file mode 100644 index 0000000000..42b211968a --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMDiscountSchema.java @@ -0,0 +1,36 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MDiscountSchema; + +public class UDIMDiscountSchema extends UDIPO +{ + + public UDIMDiscountSchema(MDiscountSchema po) + { + super(po); + } + + public MDiscountSchema getMDiscountSchema() + { + return (MDiscountSchema) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMDocType.java b/posterita/src/main/org/posterita/model/UDIMDocType.java new file mode 100644 index 0000000000..0aa08a0fad --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMDocType.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 01-Jul-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MDocType; + + +public class UDIMDocType extends UDIPO +{ + + + public UDIMDocType(MDocType po) + { + super(po); + } + + public MDocType getMDocType() + { + return (MDocType) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMDunning.java b/posterita/src/main/org/posterita/model/UDIMDunning.java new file mode 100644 index 0000000000..0536109052 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMDunning.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 27, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MDunning; + + +public class UDIMDunning extends UDIPO +{ + + public UDIMDunning(MDunning dunning) + { + super(dunning); + } + + public MDunning getMDunning() + { + return (MDunning) getPO(); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/model/UDIMDunningLevel.java b/posterita/src/main/org/posterita/model/UDIMDunningLevel.java new file mode 100644 index 0000000000..b7c957e0ad --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMDunningLevel.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 27, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MDunningLevel; + + +public class UDIMDunningLevel extends UDIPO +{ + + public UDIMDunningLevel(MDunningLevel dunningLevel) + { + super(dunningLevel); + } + + public MDunningLevel getMDunningLevel() + { + return (MDunningLevel)getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMDunningRun.java b/posterita/src/main/org/posterita/model/UDIMDunningRun.java new file mode 100644 index 0000000000..c495f83932 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMDunningRun.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 27, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MDunningRun; + + +public class UDIMDunningRun extends UDIPO +{ + + public UDIMDunningRun(MDunningRun dunningRun) + { + super(dunningRun); + } + + public MDunningRun getMDunningRun() + { + return (MDunningRun) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMInOut.java b/posterita/src/main/org/posterita/model/UDIMInOut.java new file mode 100644 index 0000000000..329e00d1d1 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMInOut.java @@ -0,0 +1,55 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 08-Jul-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MInOut; + +import org.posterita.exceptions.OperationException; + + +public class UDIMInOut extends UDIPO +{ + public UDIMInOut(MInOut inOut) + { + super(inOut); + } + + public MInOut getMInOut() + { + return (MInOut) getPO(); + } + + public void processIt(String docAction) throws OperationException + { + MInOut inOut = getMInOut(); + + boolean processed = inOut.processIt(docAction); + + inOut.setProcessed(processed); + + inOut.save(); + + if (!processed) + throw new OperationException("Cannot process inOut to: " + docAction + " "+inOut.getProcessMsg()); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMInOutLine.java b/posterita/src/main/org/posterita/model/UDIMInOutLine.java new file mode 100644 index 0000000000..6014b94816 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMInOutLine.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 08-Jul-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MInOutLine; + + +public class UDIMInOutLine extends UDIPO +{ + + public UDIMInOutLine(MInOutLine inOutLine) + { + super(inOutLine); + } + + public MInOutLine getMInOutLine() + { + return (MInOutLine) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMInoutLineConfirmation.java b/posterita/src/main/org/posterita/model/UDIMInoutLineConfirmation.java new file mode 100644 index 0000000000..83f8ec0335 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMInoutLineConfirmation.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MInOutLineConfirm; + + +public class UDIMInoutLineConfirmation extends UDIPO +{ + + + public UDIMInoutLineConfirmation(MInOutLineConfirm po) + { + super(po); + } + + public MInOutLineConfirm getMInOutLineConfirm() + { + return (MInOutLineConfirm) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMInventory.java b/posterita/src/main/org/posterita/model/UDIMInventory.java new file mode 100644 index 0000000000..2105c90179 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMInventory.java @@ -0,0 +1,57 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Dec 4, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MInventory; + +import org.posterita.exceptions.OperationException; + + +public class UDIMInventory extends UDIPO +{ + public UDIMInventory(MInventory inventory) + { + super(inventory); + } + + public MInventory getMInventory() + { + return (MInventory) getPO(); + } + + public void processIt(String docAction) throws OperationException + { + MInventory inventory = getMInventory(); + + boolean processed = inventory.processIt(docAction); + + inventory.setProcessed(processed); + + inventory.save(); + + if (!processed) + throw new OperationException("Cannot process inventory to: " + docAction + " "+inventory.getProcessMsg()); + } + +} + \ No newline at end of file diff --git a/posterita/src/main/org/posterita/model/UDIMInventoryLine.java b/posterita/src/main/org/posterita/model/UDIMInventoryLine.java new file mode 100644 index 0000000000..e6929a4ee9 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMInventoryLine.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Dec 11, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MInventoryLine; + + +public class UDIMInventoryLine extends UDIPO +{ + public UDIMInventoryLine(MInventoryLine inventoryLine) + { + super(inventoryLine); + } + + public MInventoryLine getMInventoryLine() + { + return (MInventoryLine) getPO(); + } + +} + \ No newline at end of file diff --git a/posterita/src/main/org/posterita/model/UDIMInvoice.java b/posterita/src/main/org/posterita/model/UDIMInvoice.java new file mode 100644 index 0000000000..f515def536 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMInvoice.java @@ -0,0 +1,61 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 05-Jul-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MInvoice; + +import org.posterita.exceptions.OperationException; + + +public class UDIMInvoice extends UDIPO +{ + public UDIMInvoice (MInvoice invoice) + { + super(invoice); + } + + public MInvoice getInvoice() + { + return (MInvoice) getPO(); + } + + + + public void processIt(String docAction) throws OperationException + { + MInvoice invoice = getInvoice(); + boolean processed = invoice.processIt(docAction); + invoice.setProcessed(processed); + + invoice.save(); + + if (!processed) + throw new OperationException("Cannot process invoice to: " + docAction + " "+invoice.getProcessMsg()); + } + + + + + + + +} diff --git a/posterita/src/main/org/posterita/model/UDIMInvoiceLine.java b/posterita/src/main/org/posterita/model/UDIMInvoiceLine.java new file mode 100644 index 0000000000..69fc2b8681 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMInvoiceLine.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 05-Jul-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MInvoiceLine; + + +public class UDIMInvoiceLine extends UDIPO +{ + public UDIMInvoiceLine(MInvoiceLine invoiceLine) + { + super(invoiceLine); + } + + public MInvoiceLine getMInvoiceLine() + { + return (MInvoiceLine) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMLocation.java b/posterita/src/main/org/posterita/model/UDIMLocation.java new file mode 100644 index 0000000000..82a22ee7c9 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMLocation.java @@ -0,0 +1,45 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 22-Jun-2005 by alok + * + */ +package org.posterita.model; +import org.compiere.model.MLocation; + + +public class UDIMLocation extends UDIPO +{ + + public UDIMLocation(MLocation po) + { + super(po); + } + + public MLocation getMLocation() + { + return (MLocation) getPO(); + } + +} + + + + + + diff --git a/posterita/src/main/org/posterita/model/UDIMLocator.java b/posterita/src/main/org/posterita/model/UDIMLocator.java new file mode 100644 index 0000000000..6a04797212 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMLocator.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 22-Jun-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MLocator; + +public class UDIMLocator extends UDIPO +{ + + public UDIMLocator(MLocator po) + { + super(po); + } + + public MLocator getMLocator() + { + return (MLocator) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMMailText.java b/posterita/src/main/org/posterita/model/UDIMMailText.java new file mode 100644 index 0000000000..c4c8c66827 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMMailText.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ +package org.posterita.model; + +import org.compiere.model.MMailText; + +public class UDIMMailText extends UDIPO +{ + + public UDIMMailText(MMailText mailText) + { + super(mailText); + } + + public MMailText getMMailText() + { + return (MMailText) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMMovement.java b/posterita/src/main/org/posterita/model/UDIMMovement.java new file mode 100644 index 0000000000..67c6d9823e --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMMovement.java @@ -0,0 +1,65 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MMovement; + +import org.posterita.exceptions.OperationException; + + +public class UDIMMovement extends UDIPO +{ + public UDIMMovement(MMovement movement) + { + super(movement); + } + + public MMovement getMMovement() + { + return (MMovement) getPO(); + } + + public void processIt(String docAction) throws OperationException + { + MMovement movement = getMMovement(); + + boolean processed = movement.processIt(docAction); + movement.setProcessed(processed); + + movement.save(); + + if (!processed) + throw new OperationException("Cannot process movement to: " + docAction + " "+movement.getProcessMsg()); + } + + public boolean voidIt() throws OperationException + { + MMovement movement = getMMovement(); + + boolean isVoided = movement.voidIt(); + + if (isVoided == false) + throw new OperationException("cannot void material movement"); + + return true; + + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMMovementLine.java b/posterita/src/main/org/posterita/model/UDIMMovementLine.java new file mode 100644 index 0000000000..5fcd35fdb8 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMMovementLine.java @@ -0,0 +1,34 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + + + + +public class UDIMMovementLine extends UDIPO +{ + + public UDIMMovementLine(UDIMMovementLineOverride parent) + { + super(parent); + } + + +} diff --git a/posterita/src/main/org/posterita/model/UDIMMovementLineOverride.java b/posterita/src/main/org/posterita/model/UDIMMovementLineOverride.java new file mode 100644 index 0000000000..fef5fccd7e --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMMovementLineOverride.java @@ -0,0 +1,34 @@ +package org.posterita.model; + +import org.compiere.model.MMovement; +import org.compiere.model.MMovementLine; +import org.compiere.util.DB; + +public class UDIMMovementLineOverride extends MMovementLine +{ + + /** + * Override the beforeSave method of MMovementLine as the query picks a wrong table name + */ + private static final long serialVersionUID = 1L; + + public UDIMMovementLineOverride(MMovement parent) + { + super(parent); + + } + + protected boolean beforeSave (boolean newRecord) + { + // Set Line No + if (getLine() == 0) + { + String sql = "SELECT COALESCE(MAX(Line),0)+10 AS DefaultValue FROM M_MovementLine WHERE M_Movement_ID=?"; + int ii = DB.getSQLValue (get_TrxName(), sql, getM_Movement_ID()); + setLine (ii); + } + return true; + } // beforeSave + + +} diff --git a/posterita/src/main/org/posterita/model/UDIMOrder.java b/posterita/src/main/org/posterita/model/UDIMOrder.java new file mode 100644 index 0000000000..96c0f09b93 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMOrder.java @@ -0,0 +1,78 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 28-Jun-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MOrder; +import org.compiere.model.MOrderLine; +import org.compiere.process.DocumentEngine; + +import org.posterita.exceptions.OperationException; + + +public class UDIMOrder extends UDIPO +{ + + public UDIMOrder(MOrder order) + { + super(order); + } + + + public void prepareIt() throws OperationException + { + String status = ((MOrder)getPO()).prepareIt(); + if(status.equals(DocumentEngine.STATUS_Invalid)) + { + throw new OperationException("Could not Prepare the order: " + ((MOrder)getPO()).getProcessMsg()); + } + } + + public void processIt(String docAction) throws OperationException + { + + boolean processed = ((MOrder)getPO()).processIt(docAction); + + ((MOrder)getPO()).setProcessed(processed); + + ((MOrder)getPO()).save(); + + if (!processed) + throw new OperationException("Cannot process Order to: " + docAction + " "+((MOrder)getPO()).getProcessMsg()); + } + + + public MOrder getOrder() + { + return ((MOrder)getPO()); + } + + public int getC_DocTypeTarget_ID() + { + return ((MOrder)getPO()).getC_DocTypeTarget_ID(); + } + + public MOrderLine[] getLines() + { + return ((MOrder)getPO()).getLines(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMOrderLine.java b/posterita/src/main/org/posterita/model/UDIMOrderLine.java new file mode 100644 index 0000000000..c85d0252c7 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMOrderLine.java @@ -0,0 +1,55 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 28-Jun-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MOrderLine; + +public class UDIMOrderLine extends UDIPO implements Comparable +{ + + public UDIMOrderLine(MOrderLine orderLine) + { + super(orderLine); + } + + + public int getMAttributeSetInstance_ID() + { + return ((MOrderLine)getPO()).getM_AttributeSetInstance_ID(); + } + + + public MOrderLine getMOrderLine() + { + return ((MOrderLine)getPO()); + } + + public int compareTo(Object o) + { + + + Integer attributeSetInstanceID = Integer.valueOf(this.getMAttributeSetInstance_ID()); + Integer attributeSetInstanceID2 = Integer.valueOf(this.getMAttributeSetInstance_ID()); + + return (attributeSetInstanceID.compareTo(attributeSetInstanceID2)); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMOrg.java b/posterita/src/main/org/posterita/model/UDIMOrg.java new file mode 100644 index 0000000000..0baeb9ed15 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMOrg.java @@ -0,0 +1,66 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 21-Jun-2005 by alok + * + */ +package org.posterita.model; + + +import java.util.Properties; + +import org.compiere.model.MOrg; +import org.compiere.model.MOrgInfo; + + +public class UDIMOrg extends UDIPO +{ + + public UDIMOrg(MOrg org) + { + super(org); + } + + public MOrg getMOrg() + { + return (MOrg) getPO(); + } + + public String getName() + { + return getMOrg().getName(); + } + + public int getLinkedC_BPartner_ID() + { + return getMOrg().getLinkedC_BPartner_ID(null); + } + + public Properties getCtx() + { + return getMOrg().getCtx(); + } + + public MOrgInfo getOrgInfo() + { + return getMOrg().getInfo(); + } + + + +} diff --git a/posterita/src/main/org/posterita/model/UDIMOrgInfo.java b/posterita/src/main/org/posterita/model/UDIMOrgInfo.java new file mode 100644 index 0000000000..4c9a3126ec --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMOrgInfo.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 22-Jun-2005 by alok + * + */ +package org.posterita.model; +import org.compiere.model.MOrgInfo; + + +public class UDIMOrgInfo extends UDIPO +{ + + public UDIMOrgInfo(MOrgInfo info) + { + super(info); + } + + + public MOrgInfo getMOrgInfo() + { + return (MOrgInfo) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMPOS.java b/posterita/src/main/org/posterita/model/UDIMPOS.java new file mode 100644 index 0000000000..44a9d3d21a --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMPOS.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.model; + +import org.compiere.model.MPOS; + +public class UDIMPOS extends UDIPO +{ + + public UDIMPOS(MPOS mpos) + { + super(mpos); + } + + public MPOS getMPOS() + { + return (MPOS) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMPayment.java b/posterita/src/main/org/posterita/model/UDIMPayment.java new file mode 100644 index 0000000000..b7bd5afc2b --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMPayment.java @@ -0,0 +1,53 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MPayment; + +import org.posterita.exceptions.OperationException; + + +public class UDIMPayment extends UDIPO +{ + + public UDIMPayment(MPayment payment) + { + super(payment); + } + + public MPayment getMPayment() + { + return (MPayment) getPO(); + } + + public void processIt(String docAction) throws OperationException + { + MPayment payment = getMPayment(); + boolean processed = payment.processIt(docAction); + payment.setProcessed(processed); + + payment.save(); + + if (!processed) + throw new OperationException("Cannot process payment to: " + docAction + " "+payment.getProcessMsg()); + } + + +} diff --git a/posterita/src/main/org/posterita/model/UDIMPaymentTerm.java b/posterita/src/main/org/posterita/model/UDIMPaymentTerm.java new file mode 100644 index 0000000000..2c8f8676a4 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMPaymentTerm.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 31, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MPaymentTerm; + + +public class UDIMPaymentTerm extends UDIPO +{ + + public UDIMPaymentTerm(MPaymentTerm paymentTerm) + { + super(paymentTerm); + } + + public MPaymentTerm getMPaymentTerm() + { + return (MPaymentTerm) getPO(); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/model/UDIMPeriod.java b/posterita/src/main/org/posterita/model/UDIMPeriod.java new file mode 100644 index 0000000000..4a019f39d7 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMPeriod.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 4, 2005 by praveen + * + */ +package org.posterita.model; + +import org.compiere.model.MPeriod; + +public class UDIMPeriod extends UDIPO +{ + public UDIMPeriod(MPeriod period) + { + super(period); + } + + public MPeriod getMPeriod() + { + return (MPeriod) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMPeriodControl.java b/posterita/src/main/org/posterita/model/UDIMPeriodControl.java new file mode 100644 index 0000000000..298e40d47d --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMPeriodControl.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MPeriodControl; + +public class UDIMPeriodControl extends UDIPO +{ + + public UDIMPeriodControl(MPeriodControl po) + { + super(po); + } + + public MPeriodControl getMPeriodControl() + { + return (MPeriodControl) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMPriceList.java b/posterita/src/main/org/posterita/model/UDIMPriceList.java new file mode 100644 index 0000000000..be4f8106aa --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMPriceList.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MPriceList; + +public class UDIMPriceList extends UDIPO +{ + + public UDIMPriceList(MPriceList po) + { + super(po); + } + + public MPriceList getMPriceList() + { + return (MPriceList) getPO(); + } + +} + diff --git a/posterita/src/main/org/posterita/model/UDIMPriceListVersion.java b/posterita/src/main/org/posterita/model/UDIMPriceListVersion.java new file mode 100644 index 0000000000..b44921d014 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMPriceListVersion.java @@ -0,0 +1,47 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MPriceListVersion; + +public class UDIMPriceListVersion extends UDIPO +{ + + public UDIMPriceListVersion(MPriceListVersion priceListVersion) + { + super(priceListVersion); + } + + public MPriceListVersion getMPriceListVersion() + { + return (MPriceListVersion) getPO(); + } + + public void setM_DiscountSchema_ID(int discountSchemaID) + { + getMPriceListVersion().setM_DiscountSchema_ID(discountSchemaID); + } + + public void setM_PriceList_ID(int priceListID) + { + getMPriceListVersion().setM_PriceList_ID(priceListID); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMPrintFormatItem.java b/posterita/src/main/org/posterita/model/UDIMPrintFormatItem.java new file mode 100644 index 0000000000..e165918190 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMPrintFormatItem.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Created on Oct 3, 2006 by ashley +* +*/ + +/** + @author ashley + */ + +package org.posterita.model; + +import org.compiere.print.MPrintFormatItem; + +public class UDIMPrintFormatItem extends UDIPO +{ + + public UDIMPrintFormatItem(MPrintFormatItem po) + { + super(po); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMProcess.java b/posterita/src/main/org/posterita/model/UDIMProcess.java new file mode 100644 index 0000000000..3bd4a12fc9 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMProcess.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.model; + +import org.compiere.model.MProcess; + + +public class UDIMProcess extends UDIPO +{ + public UDIMProcess(MProcess process) + { + super(process); + } + + public MProcess getMProcess() + { + return (MProcess) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMProduct.java b/posterita/src/main/org/posterita/model/UDIMProduct.java new file mode 100644 index 0000000000..690b8e55b0 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMProduct.java @@ -0,0 +1,52 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MProduct; + +import org.posterita.exceptions.OperationException; + +public class UDIMProduct extends UDIPO +{ + + public UDIMProduct (MProduct product) + { + super(product); + } + + public MProduct getMProduct() + { + return (MProduct) getPO(); + } + + + public void save(String trxName) throws OperationException + { + + boolean saved = getMProduct().save(trxName); + + if (!saved) + throw new OperationException("connot save product "); + } + + + } + + diff --git a/posterita/src/main/org/posterita/model/UDIMProductCategory.java b/posterita/src/main/org/posterita/model/UDIMProductCategory.java new file mode 100644 index 0000000000..ce8d594ca8 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMProductCategory.java @@ -0,0 +1,47 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MProductCategory; + +public class UDIMProductCategory extends UDIPO +{ + + public UDIMProductCategory(MProductCategory productCategory) + { + super(productCategory); + } + + public MProductCategory getProductCategory() + { + return (MProductCategory) getPO(); + } + + public int getA_Asset_Group_ID() + { + return getProductCategory().getA_Asset_Group_ID(); + } + + public void setA_Asset_Group_ID(int assetGroupID) + { + getProductCategory().setA_Asset_Group_ID(assetGroupID); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMProductPrice.java b/posterita/src/main/org/posterita/model/UDIMProductPrice.java new file mode 100644 index 0000000000..3e4040f5cf --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMProductPrice.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MProductPrice; + +public class UDIMProductPrice extends UDIPO +{ + + public UDIMProductPrice(MProductPrice productPrice) + { + super(productPrice); + } + + public MProductPrice getMProductPrice() + { + return (MProductPrice) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMRegion.java b/posterita/src/main/org/posterita/model/UDIMRegion.java new file mode 100644 index 0000000000..7bad097001 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMRegion.java @@ -0,0 +1,39 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 22-Jun-2005 by alok + * + */ +package org.posterita.model; +import org.compiere.model.MRegion; + + +public class UDIMRegion extends UDIPO +{ + + public UDIMRegion(MRegion region) + { + super(region); + } + + public MRegion getMRegion() + { + return (MRegion) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMRequest.java b/posterita/src/main/org/posterita/model/UDIMRequest.java new file mode 100644 index 0000000000..5b764e1697 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMRequest.java @@ -0,0 +1,41 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.model; + +import org.compiere.model.MRequest; + +public class UDIMRequest extends UDIPO +{ + public UDIMRequest(MRequest request) + { + super(request); + } + + public MRequest getMRequest() + { + return (MRequest) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMRequestType.java b/posterita/src/main/org/posterita/model/UDIMRequestType.java new file mode 100644 index 0000000000..23eb0ea41d --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMRequestType.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.model; + +import org.compiere.model.MRequestType; + +public class UDIMRequestType extends UDIPO +{ + + public UDIMRequestType(MRequestType requestType) + { + super(requestType); + } + + public MRequestType getMRequestType() + { + return (MRequestType) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMRequestUpdate.java b/posterita/src/main/org/posterita/model/UDIMRequestUpdate.java new file mode 100644 index 0000000000..b569df3434 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMRequestUpdate.java @@ -0,0 +1,42 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.model; + +import org.compiere.model.MRequestUpdate; + +public class UDIMRequestUpdate extends UDIPO +{ + + public UDIMRequestUpdate(MRequestUpdate mRequestUpdate) + { + super(mRequestUpdate); + } + + public MRequestUpdate getMRequestUpdate() + { + return (MRequestUpdate) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMRevenueRecognition.java b/posterita/src/main/org/posterita/model/UDIMRevenueRecognition.java new file mode 100644 index 0000000000..9603de2e80 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMRevenueRecognition.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ +package org.posterita.model; + +import org.compiere.model.MRevenueRecognition; + +public class UDIMRevenueRecognition extends UDIPO +{ + + public UDIMRevenueRecognition(MRevenueRecognition po) + { + super(po); + } + + public MRevenueRecognition getMRevenueRecognition() + { + return (MRevenueRecognition) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMRole.java b/posterita/src/main/org/posterita/model/UDIMRole.java new file mode 100644 index 0000000000..e4320980ab --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMRole.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 22-Jun-2005 by alok + * + */ +package org.posterita.model; +import org.compiere.model.MRole; + + +public class UDIMRole extends UDIPO +{ + public UDIMRole(MRole role) + { + super(role); + } + + public MRole getMRole() + { + return (MRole) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMShipper.java b/posterita/src/main/org/posterita/model/UDIMShipper.java new file mode 100644 index 0000000000..33d0f7879d --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMShipper.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.model; + +import org.compiere.model.MShipper; + + +public class UDIMShipper extends UDIPO +{ + public UDIMShipper(MShipper shipper) + { + super(shipper); + } + + public MShipper getMShipper() + { + return (MShipper) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMStorage.java b/posterita/src/main/org/posterita/model/UDIMStorage.java new file mode 100644 index 0000000000..612f81193b --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMStorage.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MStorage; + + +public class UDIMStorage extends UDIPO +{ + + public UDIMStorage(MStorage storage) + { + super(storage); + } + + public MStorage getMStorage() + { + return (MStorage) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMStore.java b/posterita/src/main/org/posterita/model/UDIMStore.java new file mode 100644 index 0000000000..7f4455612e --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMStore.java @@ -0,0 +1,43 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +/** + @author ashley + */ + +package org.posterita.model; + +import org.compiere.model.MStore; + +public class UDIMStore extends UDIPO +{ + + public UDIMStore(MStore mstore) + { + super(mstore); + } + + public MStore getMStore() + { + return (MStore) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMTax.java b/posterita/src/main/org/posterita/model/UDIMTax.java new file mode 100644 index 0000000000..0259ed46ab --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMTax.java @@ -0,0 +1,45 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 01-Jul-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MTax; + + +public class UDIMTax extends UDIPO +{ + + public UDIMTax(MTax tax) + { + super(tax); + } + + public void setC_Tax_Category_ID(int taxCategoryID) + { + getMTax().setC_TaxCategory_ID(taxCategoryID); + } + + public MTax getMTax() + { + return (MTax) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMTaxCategory.java b/posterita/src/main/org/posterita/model/UDIMTaxCategory.java new file mode 100644 index 0000000000..45c148ec70 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMTaxCategory.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MTaxCategory; + + +public class UDIMTaxCategory extends UDIPO +{ + public UDIMTaxCategory(MTaxCategory taxCategory) + { + super(taxCategory); + } + + + public MTaxCategory getMTaxCategory() + { + return (MTaxCategory) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMTransaction.java b/posterita/src/main/org/posterita/model/UDIMTransaction.java new file mode 100644 index 0000000000..5f4704aef0 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMTransaction.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ +package org.posterita.model; + +import org.compiere.model.MTransaction; + +public class UDIMTransaction extends UDIPO +{ + + public UDIMTransaction(MTransaction mtransaction) + { + super(mtransaction); + } + + public MTransaction getMTransaction() + { + return (MTransaction) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMUOM.java b/posterita/src/main/org/posterita/model/UDIMUOM.java new file mode 100644 index 0000000000..f77aa080c5 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMUOM.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import org.compiere.model.MUOM; + +public class UDIMUOM extends UDIPO +{ + + public UDIMUOM(MUOM po) + { + super(po); + } + + public MUOM getMUOM() + { + return (MUOM) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMUser.java b/posterita/src/main/org/posterita/model/UDIMUser.java new file mode 100644 index 0000000000..3bcb55a517 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMUser.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 22-Jun-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MUser; + +public class UDIMUser extends UDIPO +{ + public UDIMUser(MUser user) + { + super(user); + } + + public MUser getMUser() + { + return (MUser) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMUserMail.java b/posterita/src/main/org/posterita/model/UDIMUserMail.java new file mode 100644 index 0000000000..fe52c7d380 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMUserMail.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 22-Jun-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MUserMail; + +public class UDIMUserMail extends UDIPO +{ + public UDIMUserMail(MUserMail userMail) + { + super(userMail); + } + + public MUserMail getMUserMail() + { + return (MUserMail) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMUserOrgAccess.java b/posterita/src/main/org/posterita/model/UDIMUserOrgAccess.java new file mode 100644 index 0000000000..d424431e17 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMUserOrgAccess.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ +package org.posterita.model; + +import org.compiere.model.MUserOrgAccess; + +public class UDIMUserOrgAccess extends UDIPO +{ + + public UDIMUserOrgAccess(MUserOrgAccess po) + { + super(po); + } + + public MUserOrgAccess getMUserOrgAccess() + { + return (MUserOrgAccess) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMUserRoles.java b/posterita/src/main/org/posterita/model/UDIMUserRoles.java new file mode 100644 index 0000000000..f71cc3cd67 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMUserRoles.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.model; + +import org.compiere.model.MUserRoles; + + +public class UDIMUserRoles extends UDIPO +{ + + public UDIMUserRoles(MUserRoles po) + { + super(po); + } + + public MUserRoles getMUserRoles() + { + return (MUserRoles) getPO(); + } +} diff --git a/posterita/src/main/org/posterita/model/UDIMWarehouse.java b/posterita/src/main/org/posterita/model/UDIMWarehouse.java new file mode 100644 index 0000000000..bd194f520c --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMWarehouse.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 22-Jun-2005 by alok + * + */ +package org.posterita.model; + +import org.compiere.model.MWarehouse; + +public class UDIMWarehouse extends UDIPO +{ + public UDIMWarehouse(MWarehouse po) + { + super(po); + } + + public MWarehouse getMWarehouse() + { + return (MWarehouse) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMYear.java b/posterita/src/main/org/posterita/model/UDIMYear.java new file mode 100644 index 0000000000..cab65b3bd4 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMYear.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 4, 2005 by praveen + * + */ +package org.posterita.model; + +import org.compiere.model.MYear; + +public class UDIMYear extends UDIPO +{ + public UDIMYear(MYear po) + { + super(po); + } + + public MYear getMYear() + { + return (MYear) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIMinoutConfirm.java b/posterita/src/main/org/posterita/model/UDIMinoutConfirm.java new file mode 100644 index 0000000000..eb74c3d46c --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIMinoutConfirm.java @@ -0,0 +1,57 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 18, 2006 + */ + + +package org.posterita.model; + +import org.compiere.model.MInOutConfirm; + +import org.posterita.exceptions.OperationException; + + +public class UDIMinoutConfirm extends UDIPO +{ + + public UDIMinoutConfirm(MInOutConfirm inOutConfirm) + { + super(inOutConfirm); + } + + public MInOutConfirm getMInOutConfirm() + { + return (MInOutConfirm) getPO(); + } + + public void processIt(String docAction) throws OperationException + { + MInOutConfirm inOutConfirm = getMInOutConfirm(); + + boolean processed = inOutConfirm.processIt(docAction); + + inOutConfirm.setProcessed(processed); + + inOutConfirm.save(); + + if (!processed) + throw new OperationException("Cannot process inOutConfirm to: " + docAction + " "+inOutConfirm.getProcessMsg()); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/model/UDIOrgType.java b/posterita/src/main/org/posterita/model/UDIOrgType.java new file mode 100644 index 0000000000..0ba11ba2bf --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIOrgType.java @@ -0,0 +1,37 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.model; + +import org.compiere.model.X_AD_OrgType; + + +public class UDIOrgType extends UDIPO +{ + public UDIOrgType(X_AD_OrgType orgType) + { + super(orgType); + } + + public X_AD_OrgType getX_AD_OrgType() + { + return (X_AD_OrgType) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIPO.java b/posterita/src/main/org/posterita/model/UDIPO.java new file mode 100644 index 0000000000..00dcd3eb78 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIPO.java @@ -0,0 +1,83 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.model; + +import java.util.Properties; + +import org.compiere.model.PO; + +import org.posterita.exceptions.OperationException; + +public abstract class UDIPO +{ + private PO po; + private Properties ctx; + + public Properties getCtx() + { + return ctx; + } + + + public UDIPO(PO po) + { + this.po = po; + this.ctx = po.getCtx(); + } + + public int getID() + { + return po.get_ID(); + } + + public int getAD_Org_ID() + { + return po.getAD_Org_ID(); + } + + public void save() throws OperationException + { + boolean saved = po.save(); + + if (!saved) + throw new OperationException("Cannot save PO object, Class: " + po.getClass().getName()); + } + +// public void save(String trxname) throws OperationException +// { +// boolean saved = po.save(trxname); +// +// if (!saved) +// throw new OperationException("connot save po object "); +// } + + + public PO getPO() + { + return po; + } + + public void setPO(PO po) + { + this.po = po; + } + + +} diff --git a/posterita/src/main/org/posterita/model/UDIU_Menu.java b/posterita/src/main/org/posterita/model/UDIU_Menu.java new file mode 100644 index 0000000000..b9b146d5d5 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIU_Menu.java @@ -0,0 +1,123 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.model; + +import org.compiere.model.X_U_Menu; +import org.posterita.exceptions.OperationException; + + +public class UDIU_Menu extends UDIPO +{ + public UDIU_Menu(X_U_Menu menu) + { + super(menu); + } + + public String getImageLink() + { + return getMenu().getImageLink(); + } + + public X_U_Menu getMenu() + { + return (X_U_Menu) getPO(); + } + + public int getMenuId() + { + return getMenu().get_ID(); + } + + public String getMenuLink() + { + return getMenu().getMenuLink(); + } + + public String getModule() + { + return getMenu().getModule(); + } + + public String getName() + { + return getMenu().getName(); + } + + public int getParentMenuId() + { + return getMenu().getParentMenu_ID(); + } + + public String getPosition() + { + return getMenu().getPosition(); + } + + public boolean isActive() + { + return getMenu().isActive(); + } + + public void setActive(boolean isActive) + { + getMenu().setIsActive(isActive); + } + + public void setImageLink(String imageLink) + { + getMenu().setImageLink(imageLink); + } + + public void setParentMenuId(int parentMenuId) + { + getMenu().setParentMenu_ID(parentMenuId); + } + + public void setPosition(String position) + { + getMenu().setPosition(position); + } + + public String getDescription() + { + return getMenu().getDescription(); + } + + public String getCategory() + { + return getMenu().getCategory(); + } + + public void setCategory(String category) + { + getMenu().setCategory(category); + } + + public void setName(String name) + { + getMenu().setName(name); + } + + public void save() throws OperationException + { + super.save(); + } + +} diff --git a/posterita/src/main/org/posterita/model/UDIU_RoleMenu.java b/posterita/src/main/org/posterita/model/UDIU_RoleMenu.java new file mode 100644 index 0000000000..889f10f598 --- /dev/null +++ b/posterita/src/main/org/posterita/model/UDIU_RoleMenu.java @@ -0,0 +1,38 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.model; + +import org.compiere.model.X_U_RoleMenu; + + +public class UDIU_RoleMenu extends UDIPO +{ + + public UDIU_RoleMenu(X_U_RoleMenu po) + { + super(po); + } + + public X_U_RoleMenu getX_U_RoleMenu() + { + return (X_U_RoleMenu) getPO(); + } + +} diff --git a/posterita/src/main/org/posterita/order/UDIOrderType.java b/posterita/src/main/org/posterita/order/UDIOrderType.java new file mode 100644 index 0000000000..a29436670a --- /dev/null +++ b/posterita/src/main/org/posterita/order/UDIOrderType.java @@ -0,0 +1,26 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.order; + + +public interface UDIOrderType +{ + public String getOrderType(); +} diff --git a/posterita/src/main/org/posterita/order/UDIOrderTypes.java b/posterita/src/main/org/posterita/order/UDIOrderTypes.java new file mode 100644 index 0000000000..76efdd1819 --- /dev/null +++ b/posterita/src/main/org/posterita/order/UDIOrderTypes.java @@ -0,0 +1,195 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.order; + + +public class UDIOrderTypes +{ + private UDIOrderTypes() + { + + } + + + public static final UDIOrderType CREDIT_ORDER = new CreditOrder(); + + public static final UDIOrderType CREDIT_ORDER_NO_SHIPMENT = new CreditOrderNoShipment(); + + public static final UDIOrderType CUSTOMER_RETURN_ORDER = new CustomerReturnOrder(); + + public static final UDIOrderType POS_ORDER = new POSOrder(); + + public static final UDIOrderType POS_GOODS_RECEIVE_NOTE = new POSGoodsReceiveNote(); + + public static final UDIOrderType POS_GOODS_RETURN_NOTE = new POSGoodsReturnNote(); + + public static final UDIOrderType WEBSTORE_ORDER = new WebstoreOrder(); + + public static final UDIOrderType CREDIT_MEMO = new CreditMemo(); + + + + public static class POSGoodsReceiveNote implements UDIOrderType + { + + public String getOrderType() + { + return "POS Goods Received Note"; + } + + } + + public static class CreditMemo implements UDIOrderType + { + + public String getOrderType() + { + return "Credit Memo"; + } + + } + + public static class POSGoodsReturnNote implements UDIOrderType + { + + public String getOrderType() + { + return "POS Goods Returned Note"; + } + + } + + public static class POSOrder implements UDIOrderType + { + + public String getOrderType() + { + return "POS Order"; + } + + } + + public static class DealerOrder implements UDIOrderType + { + + public String getOrderType() + { + return "Dealer Order"; + } + + } + + + + public static class DealerTransfer implements UDIOrderType + { + + public String getOrderType() + { + return "Dealer Transfer"; + } + + } + + + public static class SpecialColourOrder implements UDIOrderType + { + + public String getOrderType() + { + return "Special Colour Order"; + } + + } + + public static class WholesaleOrder implements UDIOrderType + { + + public String getOrderType() + { + return "WholeSale Order"; + } + + } + + public static class CustomerOrder implements UDIOrderType + { + + public String getOrderType() + { + return "Customer Order"; + } + + } + + + public static class AllocationOrder implements UDIOrderType + { + public String getOrderType() + { + return "Allocation Order"; + } + + } + + public static class UsedCarPurchaseOrder implements UDIOrderType + { + public String getOrderType() + { + return "Used Car Purchase Order"; + } + } + + public static class CreditOrder implements UDIOrderType + { + public String getOrderType() + { + return "Credit Order"; + } + } + + public static class CreditOrderNoShipment implements UDIOrderType + { + public String getOrderType() + { + return "Credit Order no Shipment"; + } + } + + public static class CustomerReturnOrder implements UDIOrderType + { + + public String getOrderType() + { + return "Customer Returned Order"; + } + + } + + public static class WebstoreOrder implements UDIOrderType + { + + public String getOrderType() + { + return "Webstore Order"; + } + + } +} diff --git a/posterita/src/main/org/posterita/pos/taglib/ElementTag.java b/posterita/src/main/org/posterita/pos/taglib/ElementTag.java new file mode 100644 index 0000000000..32b2056ae1 --- /dev/null +++ b/posterita/src/main/org/posterita/pos/taglib/ElementTag.java @@ -0,0 +1,127 @@ +/* + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Created on Nov 15, 2006 by ashley +* +*/ + +/** + @author ashley + */ + +package org.posterita.pos.taglib; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.tagext.TagSupport; + +import org.compiere.wstore.JSPEnv; + +import org.posterita.core.bean.ElementBean; +import org.posterita.core.businesslogic.ElementManager; + +public class ElementTag extends TagSupport +{ + private static final long serialVersionUID = 1L; + + private String columnName; + private boolean printing = false; + private boolean textOnly = false; + + public int doStartTag() throws JspException + { + Properties ctx = JSPEnv.getCtx((HttpServletRequest)pageContext.getRequest()); + + ElementBean elementBean = ElementManager.getMsg(ctx, columnName); + + String disp = ""; + + if (isPrinting()) + { + disp = elementBean.getPrintName(); + } + else + { + disp = elementBean.getName(); + } + + try + { + JspWriter out = pageContext.getOut(); + if (this.isTextOnly()) + { + out.write(elementBean.getName()); + } + else + { + String help = ((elementBean.getHelp() != null) ? elementBean.getHelp() : ""); + out.print(""); + out.print(disp); + out.print(""); + } + } + catch (Exception e) + { + throw new JspException(e); + } + + return (SKIP_BODY); + } + + public int doEndTag() throws JspException + { + return EVAL_PAGE; + } + + public String getColumnName() + { + return columnName; + } + + public void setColumnName(String columnName) + { + this.columnName = columnName; + } + + public boolean isPrinting() + { + return printing; + } + + public void setPrinting(boolean printing) + { + this.printing = printing; + } + + public boolean isTextOnly() { + return textOnly; + } + + public void setTextOnly(boolean textOnly) { + this.textOnly = textOnly; + } +} diff --git a/posterita/src/main/org/posterita/process/UpdateRoleMenu.java b/posterita/src/main/org/posterita/process/UpdateRoleMenu.java new file mode 100644 index 0000000000..21595e6f22 --- /dev/null +++ b/posterita/src/main/org/posterita/process/UpdateRoleMenu.java @@ -0,0 +1,119 @@ +package org.posterita.process; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.Properties; +import java.util.logging.Level; + +import org.compiere.process.ProcessInfoParameter; +import org.compiere.process.SvrProcess; +import org.compiere.util.DB; +import org.posterita.model.MRoleMenu; + +public class UpdateRoleMenu extends SvrProcess +{ + private int p_role_id = 0; + + @Override + protected void prepare() + { + ProcessInfoParameter[] para = getParameter(); + for (int i = 0; i < para.length; i++) + { + String name = para[i].getParameterName(); + + if (para[i].getParameter() == null) + ; + else if (name.equals("AD_Role_ID")) + { + p_role_id = para[i].getParameterAsInt(); + } + else + { + log.log(Level.SEVERE, "Unknown Parameter: " + name); + } + } + + } + + private MRoleMenu addUpdateRole(Properties ctx, int roleId, int menuId, boolean active, String trxName) + { + String whereClause = "AD_Role_ID=" + roleId + " AND U_Menu_ID=" + menuId; + + int roleMenuIds[] = MRoleMenu.getAllIDs(MRoleMenu.Table_Name, whereClause, trxName); + + + MRoleMenu roleMenu; + if ( roleMenuIds.length == 1) + { + roleMenu = new MRoleMenu(ctx, roleMenuIds[0],trxName); + } + else if ( roleMenuIds.length == 0) + { + roleMenu = new MRoleMenu(ctx, 0,trxName); + } + else + { + throw new IllegalStateException("More than one role menu defined."); + } + + roleMenu.setAD_Role_ID(roleId); + roleMenu.setU_Menu_ID(menuId); + roleMenu.setIsActive(active); + + if (!roleMenu.save()) + { + throw new IllegalStateException("Could not create/update role menu, RoleMenuId: " + roleMenu.get_ID()); + } + + return roleMenu; + } + + @Override + protected String doIt() throws Exception + { + if (p_role_id == 0) + { + throw new Exception("No Role defined or cannot assign menus to System Administrator"); + } + + String sqlStmt = "SELECT U_Menu_ID, IsActive FROM U_Menu"; + + PreparedStatement pstmt = null; + + try + { + pstmt = DB.prepareStatement(sqlStmt, get_TrxName()); + ResultSet rs = pstmt.executeQuery(); + + while (rs.next()) + { + int menuId = rs.getInt(1); + boolean active = "Y".equals(rs.getString(2)); + addUpdateRole(getCtx(), p_role_id, menuId, active, get_TrxName()); + } + commit(); + } + catch (Exception ex) + { + rollback(); + throw ex; + } + finally + { + if (pstmt != null) + { + try + { + pstmt.close(); + } + catch (Exception ex) + { + log.log(Level.SEVERE, "Could not close prepared statement"); + } + } + } + + return "Role updated successfully"; + } +} diff --git a/posterita/src/main/org/posterita/struts/admin/CheckSequenceAction.java b/posterita/src/main/org/posterita/struts/admin/CheckSequenceAction.java new file mode 100644 index 0000000000..3a0aa67f4e --- /dev/null +++ b/posterita/src/main/org/posterita/struts/admin/CheckSequenceAction.java @@ -0,0 +1,67 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 09-Feb-2006 + */ + + +package org.posterita.struts.admin; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.posterita.core.TmkJSPEnv; + +import org.posterita.businesslogic.CheckSequenceManager; +import org.posterita.exceptions.SequenceUpdateException; +import org.posterita.struts.core.BaseDispatchAction; + + +public class CheckSequenceAction extends BaseDispatchAction +{ + public static final String CHECK_SEQUENCE="checkSequence"; + public ActionForward checkSequence(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + try + { + CheckSequenceManager.runProcess(ctx); + } + catch(SequenceUpdateException e) + { + postGlobalError("error.update.sequence",request); + return mapping.getInputForward(); + } + + + return mapping.findForward(CHECK_SEQUENCE); + + } +} diff --git a/posterita/src/main/org/posterita/struts/admin/RoleAction.java b/posterita/src/main/org/posterita/struts/admin/RoleAction.java new file mode 100644 index 0000000000..5ffdc96331 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/admin/RoleAction.java @@ -0,0 +1,196 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 16, 2005 by praveen + * + */ +package org.posterita.struts.admin; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MRole; +import org.compiere.util.Trx; +import org.posterita.core.TmkJSPEnv; + +import org.posterita.Constants; +import org.posterita.beans.RoleBean; +import org.posterita.businesslogic.MenuManager; +import org.posterita.businesslogic.RoleManager; +import org.posterita.core.MenuItem; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.RoleAlreadyExistsException; +import org.posterita.exceptions.SystemException; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + +public class RoleAction extends BaseDispatchAction +{ + public static final String CREATE_ROLE = "createRole"; + public static final String INIT_ROLE = "initRole"; + public static final String LIST_ROLES = "listRoles"; + public static final String VIEW_ROLE = "viewRole"; + public static final String DELETE_ROLE = "deleteRole"; + + public ActionForward createRole(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + RoleBean bean = (RoleBean) df.getBean(); + + + //Create Role and assign menus + MRole role; + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + trx.start(); + try + { + role = RoleManager.createRole(ctx,bean.getName(),bean.getIsAccessAllOrgs(), bean.getCheckBox(), bean.getCanCreateOrder(), bean.getCanAlterOrder(), bean.getCanViewOrder(), trx.getTrxName()); + ArrayList menus = MenuManager.getMenus(ctx, role.get_ID()); + MenuItem rootItem = MenuManager.buildMenuTree(ctx, menus); + + request.getSession().setAttribute(Constants.ROLE,bean); + request.getSession().setAttribute(Constants.ROLE_MENUS, rootItem.getSubMenus()); + trx.commit(); + } + catch (RoleAlreadyExistsException e) + { + trx.rollback(); + postGlobalError("error.role.already.exists",request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return mapping.findForward(CREATE_ROLE); + + } + + public ActionForward initRole(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + //ArrayList menuList = MenuKeyNamePair.getKeyNamePairs(ctx); + + //String menu = MenuItem.getMenu(ctx, null); + + //request.getSession().setAttribute(Constants.MENUS,menu); + + ArrayList menus = MenuManager.getMenusForOrganisationType(ctx); + MenuItem rootItem = MenuManager.buildMenuTree(ctx, menus); + + //request.getSession().setAttribute(Constants.ROLE,bean); + request.getSession().setAttribute(Constants.ROLE_MENUS, rootItem.getSubMenus()); + + return mapping.findForward(CREATE_ROLE); + + } + + public ActionForward listRoles(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, SystemException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList roles = RoleManager.getAllRoles(ctx); + + request.getSession().setAttribute(Constants.ALL_ROLES,roles); + + return mapping.findForward(LIST_ROLES); + + } + + public ActionForward deleteRole(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, SystemException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + Integer roleId = Integer.valueOf(df.getRoleId()); + + RoleManager.deleteRole(ctx,roleId.intValue()); + + return mapping.findForward(DELETE_ROLE); + } + + + public ActionForward viewRole(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, SystemException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + Integer roleId = Integer.valueOf(df.getRoleId()); + + RoleBean bean = RoleManager.getRole(ctx,roleId.intValue()); + + //ArrayList menus = MenuItem.getMenu(ctx,roleId.intValue()); + + //request.getSession().setAttribute(Constants.MENUS,menus); + + ArrayList menus = MenuManager.getMenus(ctx, roleId.intValue()); + MenuItem rootItem = MenuManager.buildMenuTree(ctx, menus); + + request.getSession().setAttribute(Constants.ROLE,bean); + request.getSession().setAttribute(Constants.ROLE_MENUS, rootItem.getSubMenus()); + + request.getSession().setAttribute(Constants.ROLE,bean); + + return mapping.findForward(VIEW_ROLE); + + } + + + +} diff --git a/posterita/src/main/org/posterita/struts/attachment/AttachmentAction.java b/posterita/src/main/org/posterita/struts/attachment/AttachmentAction.java new file mode 100644 index 0000000000..00b713248e --- /dev/null +++ b/posterita/src/main/org/posterita/struts/attachment/AttachmentAction.java @@ -0,0 +1,126 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Aug-2005 by alok + * + */ +package org.posterita.struts.attachment; + +import java.io.FileNotFoundException; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.upload.FormFile; +import org.compiere.util.Trx; +import org.posterita.core.TmkJSPEnv; + +import org.posterita.Constants; +import org.posterita.beans.AttachmentBean; +import org.posterita.businesslogic.AttachmentManager; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + +public class AttachmentAction extends BaseDispatchAction +{ + public static final String CREATE_ATTACHMENT = "createAttachment"; + public ActionForward createAttachment(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + + AttachmentBean bean = (AttachmentBean) df.getBean(); + + FormFile logo = (FormFile) df.getLogo(); + + Trx trx = Trx.get(Trx.createTrxName(TrxPrefix.getPrefix()), true); + + + try + { + trx.start(); + AttachmentManager.attachImage(ctx,logo,bean.getLogoName()); + trx.commit(); + } + catch (FileNotFoundException e) + { + trx.rollback(); + postGlobalError("error.source.file.notpresent", request); + mapping.getInputForward(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.file.save", request); + mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return mapping.findForward(CREATE_ATTACHMENT); + + } + + public static final String GET_ATTACHMENT = "getAttachment"; + + public ActionForward getAttachment(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + AttachmentBean bean = (AttachmentBean) df.getBean(); + String logo = AttachmentManager.getImage(ctx,bean.getLogoName()); + + request.getSession().setAttribute(Constants.GET_LOGO,logo); + + return mapping.findForward(GET_ATTACHMENT); + + } + +} + + + + + + + + + + + + + + diff --git a/posterita/src/main/org/posterita/struts/attachment/ImageAttachmentAction.java b/posterita/src/main/org/posterita/struts/attachment/ImageAttachmentAction.java new file mode 100644 index 0000000000..07e5a51c3b --- /dev/null +++ b/posterita/src/main/org/posterita/struts/attachment/ImageAttachmentAction.java @@ -0,0 +1,54 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Mar 13, 2006 by praveen + * + */ +package org.posterita.struts.attachment; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.exceptions.ApplicationException; +import org.posterita.struts.core.BaseDispatchAction; + +public class ImageAttachmentAction extends BaseDispatchAction +{ + public ActionForward getImage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return null; + } + + public ActionForward getThumbnailImage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return null; + } + +} diff --git a/posterita/src/main/org/posterita/struts/attributes/AttributesAction.java b/posterita/src/main/org/posterita/struts/attributes/AttributesAction.java new file mode 100644 index 0000000000..57f1fee753 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/attributes/AttributesAction.java @@ -0,0 +1,136 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 26-Aug-2005 by alok + * + */ + +package org.posterita.struts.attributes; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.KeyNamePair; +import org.compiere.util.Trx; +import org.posterita.core.TmkJSPEnv; + +import org.posterita.Constants; +import org.posterita.beans.AttributeValueDetailBean; +import org.posterita.businesslogic.AttributeValuesManager; +import org.posterita.core.TrxPrefix; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; +import org.posterita.businesslogic.WBProductManager; + +public class AttributesAction extends BaseDispatchAction +{ + public static final String INIT_VIEW_ATTRIBUTEVALUES = "initViewAttributeValues"; + public ActionForward initViewAttributeValues(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList attributeList = AttributeValuesManager.getAttributes(ctx); + + request.getSession().setAttribute(Constants.ATTRIBUTE_LIST, attributeList); + + return mapping.findForward(INIT_VIEW_ATTRIBUTEVALUES); + } + + public static final String LIST_ATTRIBUTEVALUES = "listAttributeValues"; + public ActionForward listAttributeValues(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm)form; + + AttributeValueDetailBean attrValBean = (AttributeValueDetailBean)df.getBean(); + + ArrayList attributeValuesList =null; + if(attrValBean.getAttributeId()!=null) + { + attributeValuesList= AttributeValuesManager.getAttributeValues(ctx, attrValBean.getAttributeId().intValue()); + request.setAttribute(Constants.ATTRIBUTE_VALUES_LIST, attributeValuesList); + } + + return mapping.findForward(LIST_ATTRIBUTEVALUES); + } + + + + public static final String INITEDIT_ATTRIBUTEVALUE = "initEditAttributeValue"; + public ActionForward initEditAttributeValue(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(INITEDIT_ATTRIBUTEVALUE); + } + + public static final String EDIT_ATTRIBUTEVALUE = "editAttributeValue"; + public ActionForward editAttributeValue(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm)form; + + AttributeValueDetailBean attrBean = (AttributeValueDetailBean)df.getBean(); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + trx.start(); + + try + { + int newAttrValueId = AttributeValuesManager.changeAttributeValue(ctx, attrBean.getAttributeValueId().intValue(), attrBean.getNewName(), trx.getTrxName()); + WBProductManager.updateProductsAttribute(ctx, attrBean.getAttributeValueId().intValue(), newAttrValueId, attrBean.getAttributeId().intValue(), trx.getTrxName()); + trx.commit(); + } + catch(Exception ex) + { + trx.rollback(); + postGlobalError("error.updating.attribute", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + + return mapping.findForward(EDIT_ATTRIBUTEVALUE); + } + +} diff --git a/posterita/src/main/org/posterita/struts/bPartner/BPartnerAction.java b/posterita/src/main/org/posterita/struts/bPartner/BPartnerAction.java new file mode 100644 index 0000000000..343b6f81f3 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/bPartner/BPartnerAction.java @@ -0,0 +1,229 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ +package org.posterita.struts.bPartner; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MOrg; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.BPartnerBean; +import org.posterita.businesslogic.BPartnerManager; +import org.posterita.businesslogic.OrganisationManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BPartnerAlreadyExistsException; +import org.posterita.exceptions.OperationException; +import org.posterita.form.CreateBPartnerForm; +import org.posterita.keyname.RegionKeyNamePair; +import org.posterita.lib.UdiConstants; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + + +public class BPartnerAction extends BaseDispatchAction +{ + public static final String CREATE_BPARTNER = "createBPartner"; + public static final String GET_REGION = "getRegion"; + + public ActionForward getRegion(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList region = RegionKeyNamePair.getKeyNamePairs(ctx); + request.getSession().setAttribute(Constants.REGIONS,region); + + return mapping.findForward(GET_REGION); + + } + + public ActionForward createBPartner(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + DefaultForm df = (DefaultForm) form; + + BPartnerBean bean = (BPartnerBean) df.getBean(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + MOrg parentOrg = OrganisationManager.getMyOrg(ctx); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + trx.start(); + + try + { + int countryId =UdiConstants.COUNTRY_SOUTH_AFRICA; + BPartnerManager.createBPartner(ctx, parentOrg.getLinkedC_BPartner_ID(null), bean.getPartnerName(),bean.getName2(),bean.getIsCustomer().booleanValue(),bean.getIsVendor().booleanValue(),bean.getIsEmployee().booleanValue(),bean.getIsSalesRep().booleanValue(),bean.getAddress1(),bean.getAddress2(),bean.getPostalAddress(), bean.getRegionId(), bean.getCity(),bean.getPhone(),bean.getFax(),countryId, true, true, trx.getTrxName()); + + request.getSession().setAttribute(Constants.BUSINESSPARTNER,bean); + trx.commit(); + } + catch(BPartnerAlreadyExistsException exp) + { + trx.rollback(); + postGlobalError("error.bp.alreadyexist", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + + return mapping.findForward(CREATE_BPARTNER); + } + + + + //------------------------------------------------------------------------------------------------------- + + public static final String INIT_EDIT_BPARTNER_DETAILS = "initEditBpartnerDetails"; + public ActionForward initEditBpartnerDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + CreateBPartnerForm bPf = (CreateBPartnerForm) form; + + int bPartnerId = Integer.parseInt(bPf.getBpartnerId()); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + BPartnerBean bean = new BPartnerBean(); + + try + { + trx.start(); + bean = BPartnerManager.getBpartner(ctx,bPartnerId, trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.get.partner.detail", request); + mapping.getInputForward(); + } + finally + { + trx.close(); + } + + bPf.populate(bean); + + ArrayList region = RegionKeyNamePair.getKeyNamePairs(ctx); + request.getSession().setAttribute(Constants.REGIONS,region); + + return mapping.findForward(INIT_EDIT_BPARTNER_DETAILS); + } + + public static final String EDIT_BPARTNER_DETAILS = "editBpartnerDetails"; + public ActionForward editBpartnerDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + BPartnerBean bean = (BPartnerBean) df.getBean(); + + + BPartnerManager.editBPartner(ctx, bean.getBpartnerId().intValue(), bean.getPartnerName(),bean.getName2(),bean.getIsCustomer().booleanValue(),bean.getIsVendor().booleanValue(),bean.getIsEmployee().booleanValue(),bean.getIsSalesRep().booleanValue(),bean.getAddress1(),bean.getAddress2(),bean.getPostalAddress(),bean.getCity(),bean.getPhone(),null,bean.getFax(),0,null); + + + return mapping.findForward(EDIT_BPARTNER_DETAILS); + } + + public static final String ACTIVATE_BPARTNER = "activateBPartner"; + public ActionForward activateBPartner(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + int bpartnerId = Integer.parseInt(df.getBpartnerId()); + boolean isActive = Boolean.parseBoolean(df.getIsActive()); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + + try + { + trx.start(); + BPartnerManager.activateBPartner(ctx,bpartnerId,isActive,trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.activate.partner", request); + mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return mapping.findForward(ACTIVATE_BPARTNER); + } + + public static final String SEARCH_BPARTNER = "searchBPartner"; + public ActionForward searchBPartner(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + + ArrayList bplist = new ArrayList(); + + bplist = BPartnerManager.searchBpartners(ctx,df.getName(),null); + + request.getSession().setAttribute(Constants.ALLBUSINESSPARTNERS,bplist); + return mapping.findForward(SEARCH_BPARTNER); + } + +} diff --git a/posterita/src/main/org/posterita/struts/bPartner/ViewBPartnerAction.java b/posterita/src/main/org/posterita/struts/bPartner/ViewBPartnerAction.java new file mode 100644 index 0000000000..86232d6039 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/bPartner/ViewBPartnerAction.java @@ -0,0 +1,130 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 18, 2005 by Alok + */ + +package org.posterita.struts.bPartner; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Trx; +import org.posterita.core.TmkJSPEnv; + +import org.posterita.Constants; +import org.posterita.beans.BPartnerBean; +import org.posterita.businesslogic.BPartnerManager; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + +public class ViewBPartnerAction extends BaseDispatchAction +{ + public static final String GET_ALL_BPARTNERS = "getAllBpartners"; + public ActionForward getAllBpartners(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException + { + ActionForward fwd = init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + + ArrayList bpartners = new ArrayList(); + + try + { + trx.start(); + bpartners = BPartnerManager.getAllBpartners(ctx, trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.getall.partners", request); + mapping.getInputForward(); + } + finally + { + trx.close(); + } + + request.getSession().setAttribute(Constants.ALLBUSINESSPARTNERS, bpartners); + + return mapping.findForward(GET_ALL_BPARTNERS); + + } + + public static final String VIEW_BPARTNER_DETAILS = "viewBpartnerDetails"; + public ActionForward viewBpartnerDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + BPartnerBean bean = (BPartnerBean) df.getBean(); + + ArrayList bpartners = (ArrayList) request.getSession().getAttribute(Constants.ALLBUSINESSPARTNERS); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + + try + { + trx.start(); + + if(bpartners == null) + bpartners = BPartnerManager.getAllBpartners(ctx, trx.getTrxName()); + + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.get.partner.detail", request); + mapping.getInputForward(); + } + finally + { + trx.close(); + } + + bean = BPartnerManager.getBpartner(ctx, bean.getBpartnerId(), bpartners); + + request.getSession().setAttribute(Constants.BUSINESSPARTNERSDETAILS, bean); + + + return mapping.findForward(VIEW_BPARTNER_DETAILS); + + } + +} diff --git a/posterita/src/main/org/posterita/struts/core/BaseAction.java b/posterita/src/main/org/posterita/struts/core/BaseAction.java new file mode 100644 index 0000000000..3478f70dea --- /dev/null +++ b/posterita/src/main/org/posterita/struts/core/BaseAction.java @@ -0,0 +1,135 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.core; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.Globals; +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.action.ActionServlet; +import org.apache.struts.config.ModuleConfig; +import org.apache.struts.util.RequestUtils; + +import org.posterita.exceptions.ApplicationException; +import org.posterita.user.WebUserInfo; + + +public class BaseAction extends Action +{ + + public static final String LOGIN_HOME = "loginHome"; + public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException + { + WebUserInfo userInfo = (WebUserInfo) request.getSession().getAttribute(WebUserInfo.NAME); + + if (userInfo == null) + return mapping.findForward(LOGIN_HOME); + else + return null; + + + + } + + protected void postGlobalError(String errorKey, HttpServletRequest request) + { + postGlobalError(errorKey, null, request); + } + + protected void postComplexGlobalError(String errorKey, Object[] args,HttpServletRequest request) + { + + ActionMessage message = (args.length == 0 ? + new ActionMessage(errorKey): + new ActionMessage(errorKey, args)); + + ActionMessages messages = new ActionMessages(); + messages.add(ActionMessages.GLOBAL_MESSAGE, message); + saveErrors(request, messages); + + + + } + + protected void postGlobalError(String errorKey, Object arg, HttpServletRequest request) + { + //TODO Replace this code + ActionMessage message = (arg == null ? + new ActionMessage(errorKey): + new ActionMessage(errorKey, arg)); + + ActionMessages messages = new ActionMessages(); + messages.add(ActionMessages.GLOBAL_MESSAGE, message); + saveErrors(request, messages); + + // workflow + //TODO Integrate this code when workflow works + //WorkFlowManager.removeLastWorkFlowAction(request); + } + + protected ActionForm getForm(String formName, String path, HttpServletRequest request) + { + return getForm(formName, path, request, getServlet()); + } + + protected ActionForm getForm(String formName, String path, HttpServletRequest request, ActionServlet servlet) + { + // check if the form is in the request scope + ActionForm form = (ActionForm) request.getAttribute(formName); + + // check if the form is in the session scope + if (form == null) + { + form = (ActionForm) request.getSession().getAttribute(formName); + } + // if not found in any of these create one and set it in the appropriate scope. + if(form == null) + { + ModuleConfig appConfig = (ModuleConfig) request.getAttribute(Globals.MODULE_KEY); + + ActionMapping mapping = (ActionMapping) appConfig.findActionConfig(path); + + form = RequestUtils.createActionForm(request,mapping,appConfig, servlet); + + String key = mapping.getAttribute(); + + if (!key.equals(formName)) + throw new RuntimeException("error.baseAction.InvalidFormName"); + + if(mapping.getScope().equals("request")) + request.setAttribute(key, form); + else + request.getSession().setAttribute(key, form); + + } + return form; + + } + +} diff --git a/posterita/src/main/org/posterita/struts/core/BaseDispatchAction.java b/posterita/src/main/org/posterita/struts/core/BaseDispatchAction.java new file mode 100644 index 0000000000..f341f11633 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/core/BaseDispatchAction.java @@ -0,0 +1,138 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.core; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.actions.DispatchAction; +import org.compiere.util.Env; +import org.compiere.util.WebSessionCtx; +import org.posterita.core.TmkJSPEnv; + +import org.posterita.Constants; +import org.posterita.businesslogic.ApplicationManager; +import org.posterita.core.MenuItem; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.DefaultStoreException; +import org.posterita.lib.UdiConstants; + +public class BaseDispatchAction extends DispatchAction +{ + BaseAction act = new BaseAction(); + + public static final String LOGIN_HOME = "loginHome"; + public static final String APPLICATION_ERROR = "applicationError"; + public static final String CHOOSE_APPLICATION = "chooseApplication"; + public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException + { + Object webSessionCtx = request.getSession().getAttribute(WebSessionCtx.NAME); + + DefaultForm df = (DefaultForm) form; + + if (df != null) + if ((request.getSession().getAttribute(Constants.MENUS) != null) && (df.getMenuId() != null)) + { + MenuItem menuItem = (MenuItem) request.getSession().getAttribute(Constants.MENUS); + + Integer menuId = Integer.valueOf(df.getMenuId()); + ArrayList list = menuItem.getBreadCrumb(menuId.intValue()); + + request.getSession().setAttribute(Constants.BREADCRUMB, list); + } + + + if (webSessionCtx == null) // Session Timeout + { + try + { + ApplicationManager.changeApplication(request, response); + + Properties ctx = TmkJSPEnv.getCtx(request); + String forward = Env.getContext(ctx, UdiConstants.WEBPARAM6); + + return mapping.findForward(forward); + } + catch(DefaultStoreException ex) + { + postGlobalError("error.store.default", ex.getMessage(), request); + return mapping.findForward(CHOOSE_APPLICATION); + } + catch(Exception ex) + { + return mapping.findForward(APPLICATION_ERROR); + } + } + else + return null; + } + + + + protected void postGlobalError(String errorKey, HttpServletRequest request) + { + act.postGlobalError(errorKey, null, request); + } + + protected void postGlobalError(String errorKey, Object arg, HttpServletRequest request) + { + act.postGlobalError(errorKey, arg, request); + } + + protected ActionForm getForm(String formName, String path, HttpServletRequest request) + { + return act.getForm(formName, path, request, getServlet()); + } + + + public Object getAttribute(HttpServletRequest request, Class vo) + { + Object object = request.getSession().getAttribute(getClass().getName()+vo.getName()); + request.getSession().setAttribute(getClass().getName()+vo.getName(),null); + return object; + } + + protected void postComplexGlobalError(String errorKey, Object[] args,HttpServletRequest request) + { + + ActionMessage message = (args.length == 0 ? + new ActionMessage(errorKey): + new ActionMessage(errorKey, args)); + + ActionMessages messages = new ActionMessages(); + messages.add(ActionMessages.GLOBAL_MESSAGE, message); + saveErrors(request, messages); + + + + } + +} diff --git a/posterita/src/main/org/posterita/struts/core/BaseForm.java b/posterita/src/main/org/posterita/struts/core/BaseForm.java new file mode 100644 index 0000000000..7413edab70 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/core/BaseForm.java @@ -0,0 +1,963 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ +package org.posterita.struts.core; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.struts.Globals; +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.util.MessageResources; +import org.compiere.model.MPayment; + +import org.posterita.core.EmailValidator; +import org.posterita.core.JulianDate; +import org.posterita.core.Range; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.FormattingException; +import org.posterita.formatter.Formatter; + + + +/** + * An abstract base class for ActionForms that adds support for automatic formatting + * and unformatting of string values and for the transfer of the resulting values + * between itself and the given bean. The populate() method provides + * and entry point to this functionality, while the keysToSkip method allows + * subclasses to specify fields that should not be populated. + *

+ * + * Additional methods are provided to allow subclasses to override formatting defaults. + * The DefaultString() method allows callers to specify overrides for the default + * string used to represent a null for a given property. Similarly, + * the setFormatterype() method allows callers to specify a + * formatting type other than the default for a given property. + *

+ * Developers can also specify validation rules by invoking addRange() + * to add a range validation or addRequiredFields() to add required field validations + * for an array of property names. + * + */ +public class BaseForm extends ActionForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + private Map defaultStringMap = new HashMap(); + private Map formatMap = new HashMap(); + MessageResources resources = null; + + public final static int TO_OBJECT = 0; + public final static int TO_STRING = 1; + public final static int MIN_LENGTH = 6; + + public final static String REQUIRED = "required"; + public final static String RANGE = "range"; + public final static String STRING_NUMBER="stringNumber"; + public final static String EMAIL_VALID = "emailValid"; + public final static String MIN_LENGTH_VALID = "minLengthValid"; + public final static String MATCH_FIELDS = "matchFields"; + public final static String DATE_FIELDS_VALID = "dateValid"; + public final static String IMAGE_FILE_EXT_VALID = "imageFileValid"; + public static final String YEAR_VALID = "yearValid"; + public static final String CREDITCARD_VALID = "creditcardValid"; + public static final String CVV_VALID = "cvvValid"; + public static final String EXPIRY_DATE_VALID = "expiryDateValid"; + private static final String ACCOUNT_VALID = "accountValid"; + private int currentYear = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR); + private int currentMonth = java.util.Calendar.getInstance().get(java.util.Calendar.MONTH) + 1; + + private transient Object bean; + private Map validationMap = new HashMap(); + + public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) + { + /* + * This is where you need to get the country specific details. + */ + + resources = (MessageResources)request.getAttribute(Globals.MESSAGES_KEY); + + ActionErrors errors = populate(this.bean, TO_OBJECT); + return errors; + + } + + public ActionErrors populate(Object vo) + { + return populate(vo,TO_STRING); + } + + /* + * field1 does not contain the value of the field but contains the name of the field. + */ + public void addMatchFields(String key, String otherFieldName) + { + addValidationRule(key, MATCH_FIELDS, otherFieldName); + } + + public void addDateFieldsValidation(String key, String otherKey) + { + addValidationRule(key, DATE_FIELDS_VALID, otherKey); + } + + public void addCreditCardFieldsValidation(String key) + { + addValidationRule(key, CREDITCARD_VALID, Boolean.TRUE); + } + + public void addAccountFieldValidation(String key) + { + addValidationRule(key, ACCOUNT_VALID, Boolean.TRUE); + } + + public void addCVVFieldsValidation(String key) + { + addValidationRule(key, CVV_VALID, Boolean.TRUE); + } + + public void addCreditCardExpiryDateFieldsValidation(String key) + { + addValidationRule(key, EXPIRY_DATE_VALID, Boolean.TRUE); + } + + @SuppressWarnings("unchecked") + public void addValidationRule(String key, String rule, Object value) + { + Map values =(Map) validationMap.get(key); + if (values == null) + { + values = new HashMap(); + validationMap.put(key,values); + } + + values.put(rule, value); + } + + + public void addRequiredFields(String[] keys) + { + for (int i=0; i< keys.length; i++) + { + addValidationRule(keys[i],REQUIRED, Boolean.TRUE); + } + } + + + public void addRange(String key, Comparable min, Comparable max) + { + Range range = new Range(min,max); + addValidationRule(key,RANGE, range); + } + + public void addEmailValidation(String key) + { + addValidationRule(key,EMAIL_VALID,Boolean.TRUE); + } + + public void addYearValidation(String key) + { + addValidationRule(key, YEAR_VALID, Boolean.TRUE ); + } + + public void addValidateCustomerNumber(String key) + { + addValidationRule(key,STRING_NUMBER,Boolean.TRUE); + } + + + public void addImageFileExtensionValidation(String key) + { + addValidationRule(key, IMAGE_FILE_EXT_VALID, Boolean.TRUE); + } + + public void addMinLengthValidation(String key, Integer min, Integer max) + { + Range range = new Range(min, max); + addValidationRule(key,MIN_LENGTH_VALID,range); + } + + public Object getBean() throws ApplicationException + { + return bean; + } + + public void setBean(Object bean) + { + this.bean = bean; + } + + + + public ActionErrors populate(Object vo, int mode) + { + String errorMsg = "Unable to format values from bean: "+ vo; + + //Object source = (mode == TO_STRING ? bean : this); + Object target = (mode == TO_STRING ? vo : this); + + + Map valueMap = mapRepresentation(target, mode); + + ActionErrors errors = new ActionErrors(); + + + if(mode == TO_STRING) + { + setBean(vo); + } + + Iterator keyIter = valueMap.keySet().iterator(); + + while(keyIter.hasNext()) + { + String currKey = (String) keyIter.next(); + Object currValue = valueMap.get(currKey); + + try + { + ActionErrors currErrors = populateProperty(vo,currKey, currValue, mode, valueMap); + errors.add(currErrors); + + } + catch(InstantiationException ie) + { + throw new FormattingException(errorMsg, ie); + } + catch(IllegalAccessException iae) + { + throw new FormattingException(errorMsg, iae); + } + catch(InvocationTargetException ite) + { + throw new FormattingException(errorMsg,ite); + } + catch(NoSuchMethodException nsme) + { + //throw new FormattingException(errorMsg,nsme); + // There can be some assymetry in the form and the bean so do not treat this as an exception. + } + + } + + return errors; + } + + /** + * @param target + * @param mode + * @return + */ + public Map mapRepresentation(Object vo, int mode) + { + String errorMsg = "Unable to format values from bean: "+ vo; + + + Map valueMap = null; + + try + { + valueMap = PropertyUtils.describe(vo); + } + catch(IllegalAccessException iae) + { + throw new FormattingException(errorMsg, iae); + } + catch(InvocationTargetException ite) + { + throw new FormattingException(errorMsg, ite); + } + catch(NoSuchMethodException nsme) + { + throw new FormattingException(errorMsg,nsme); + } + + Iterator keyIter = keysToSkip().iterator(); + + while(keyIter.hasNext()) + { + String key = (String) keyIter.next(); + valueMap.remove(key); + } + + return valueMap; + } + + protected Object convert(Class type, String key, Object obj, int mode) + throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, NumberFormatException + { + Object convertedObj = null; + Formatter formatter = getFormatter(key, type); + + try + { + switch(mode) + { + case TO_OBJECT: + convertedObj = formatter.unformat(obj); + break; + case TO_STRING: + if (obj == null) + convertedObj = (String) defaultStringMap.get(key); + else + convertedObj = formatter.format(obj); + + /** + * This let's the toDate being converted into endDay, endMonth and endYear + * note that the String here are sensitive. + */ + + if (key.equals("toDate")) + { + JulianDate dateValue = (JulianDate) obj; + if (dateValue != null) + { + PropertyUtils.setSimpleProperty(this, "endDay", ""+dateValue.getDay()); + PropertyUtils.setSimpleProperty(this, "endMonth", ""+dateValue.getMonth()); + PropertyUtils.setSimpleProperty(this, "endYear", ""+dateValue.getYear()); + } + else + { + PropertyUtils.setSimpleProperty(this, "endDay", ""); + PropertyUtils.setSimpleProperty(this, "endMonth", ""); + PropertyUtils.setSimpleProperty(this, "endYear", ""); + } + + } + if (key.equals("fromDate")) + { + JulianDate dateValue = (JulianDate) obj; + if (dateValue != null) + { + PropertyUtils.setSimpleProperty(this, "startDay", ""+dateValue.getDay()); + PropertyUtils.setSimpleProperty(this, "startMonth", ""+dateValue.getMonth()); + PropertyUtils.setSimpleProperty(this, "startYear", ""+dateValue.getYear()); + } + else + { + PropertyUtils.setSimpleProperty(this, "startDay", ""); + PropertyUtils.setSimpleProperty(this, "startMonth", ""); + PropertyUtils.setSimpleProperty(this, "startYear", ""); + } + } + + break; + + default: + throw new RuntimeException("Unknown mode:" + mode); + + } + } + catch(FormattingException e) + { + e.setFormatter(formatter); + throw e; + } + + return convertedObj; + } + + + protected Object getKeyStringValue(String key, int mode) + { + Object target = (mode == TO_STRING ? this.bean : this); + Map valueMap = mapRepresentation(target, mode); + + Object currValue = valueMap.get(key); + + return currValue; + + } + + + protected ActionErrors populateProperty(Object vo, String key, Object obj, int mode, Map valueMap) + throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException + { + + Object target = (mode == TO_STRING? this : vo); + Class type = PropertyUtils.getPropertyType(vo, key); + ActionErrors errors = new ActionErrors(); + + Object value = null; + + if (mode == TO_STRING) + { + value = convert(type, key, obj, mode); + } + else + { + try + { + String errorKey = null; + + value = convert(type, key, obj, mode); + + errorKey = validateRequired(key, obj); + + if (errorKey == null) + errorKey = validateRange(key, value); + if (errorKey == null) + errorKey = validateEmail(key,value); + if (errorKey == null) + errorKey = validateLength(key, obj); + if (errorKey == null) + errorKey = validateImageFileExtension(key, obj); + if (errorKey == null) + errorKey = validateMatchFields(key,value, vo, valueMap); + if (errorKey == null) + errorKey = validateCustomerNumber(key, value); + if (errorKey == null) + errorKey = validateMatchFields(key,value, vo, valueMap); + if (errorKey == null) + errorKey = validateDateFields(key,value, vo, valueMap); + if (errorKey == null) + errorKey = validateCreditCardExpiryDateFields(key,value, vo, valueMap); + if (errorKey !=null) + errors.add(key, new ActionMessage(errorKey,key)); + + //This part is placed here because validateCreditCardField method may return an errorKey + //As we are reusing the same variable to store an error message + //the error is added above in the ActionMessage and then variable errorKey is reused here + errorKey = validateCVVField(key,value, vo, valueMap); + if (errorKey !=null) + errors.add(key, new ActionMessage(errorKey,key)); + + errorKey = validateAccountField(key,value, vo, valueMap); + if (errorKey !=null) + errors.add(key, new ActionMessage(errorKey,key)); + + errorKey = validateCreditCardField(key,value, vo, valueMap); + if (errorKey !=null) + errors.add(key, new ActionMessage(errorKey,key)); + + + } + catch(FormattingException e) + { + String errorKey = e.getFormatter().getErrorKey(); + errors.add(key, new ActionMessage(errorKey, key)); + } + catch (NumberFormatException nfe) + { + String errorKey; + + if (resources.getMessage("error.numberformatexception."+key) == null) + errorKey = "error.numberformatexception"; + else + errorKey = "error.numberformatexception."+key; + + errors.add(key, new ActionMessage(errorKey,key)); + } + + } + + PropertyUtils.setSimpleProperty(target, key, value); + + return errors; + + } + + private String validateAccountField(String key, Object value, Object vo, Map valueMap) + { + Map rules = (Map) validationMap.get(key); + + if (rules == null) + return null; + + if (!rules.containsKey(ACCOUNT_VALID)) + return null; + + if (value == null) + return null; + + + if (value.equals(MPayment.TENDERTYPE_CreditCard)) + { + String accountName = (String) valueMap.get("accountName"); + + if (accountName == null || accountName.equals("")) + return "error.required.accountName"; + } + + return null; + + + } + + private String validateCreditCardExpiryDateFields(String key, Object value, Object vo, Map valueMap) + { + Map rules = (Map) validationMap.get(key); + + if (rules == null) + return null; + + if (!rules.containsKey(EXPIRY_DATE_VALID)) + return null; + + if (value == null) + return null; + + + if (value.equals(MPayment.TENDERTYPE_CreditCard)) + { + String creditCardExpYear = (String) valueMap.get("creditCardExpYear"); + + if (creditCardExpYear == null || creditCardExpYear.equals("")) + return "error.required.creditCardExpYear"; + + if (Integer.parseInt(creditCardExpYear) == currentYear) + { + + + String creditCardExpMonth = (String) valueMap.get("creditCardExpMonth"); + + if (creditCardExpMonth == null || creditCardExpMonth.equals("")) + return "error.required.creditCardExpMonth"; + + if (Integer.parseInt(creditCardExpMonth) < currentMonth) + return "error.creditCardExpMonth"; + } + + } + + return null; + + } + + private String validateCustomerNumber(String key, Object value) + { + + Map rules = (Map) validationMap.get(key); + + if(rules == null) + return null; + + Boolean bool = (Boolean) rules.get(STRING_NUMBER); + + if (bool == null) + { + return null; + } + + String str = (String) value; + + boolean isNumber = true; + try + { + // Double numb = new Double(str); + } + catch(NumberFormatException e) + { + isNumber = false; + } + + + if (!isNumber) + { + + if (resources.getMessage("error.customer.id.numberformat."+key) == null) + return "error.customer.id.numberformat"; + else + return "error.customer.id.numberformat."+key; + } + else + + if (str.length()!=13) + { + + if (resources.getMessage("error.customer.id.length."+key) == null) + return "error.customer.id.length"; + else + return "error.customer.id.length."+key; + } + else + return null; + + } + + + private String validateRange(String key, Object value) + { + + Map rules = (Map) validationMap.get(key); + + if(rules == null) + return null; + + Range range = (Range) rules.get(RANGE); + + if (range == null) + { + return null; + } + + if(!range.isInRange((Comparable) value)) + { + if (resources.getMessage("error.range."+key) == null) + return "error.range"; + else + return "error.range."+key; + } + else + return null; + } + + private String validateEmail(String key, Object value) + { + Map rules = (Map) validationMap.get(key); + + if(rules == null) + return null; + + Boolean email_valid = (Boolean) rules.get(EMAIL_VALID); + + if (email_valid == null) + return null; + + String email = (String) value; + if(!EmailValidator.isValidEmail(email)) + return "error.email"; + else + return null; + + } + + private String validateImageFileExtension(String key, Object value) + { + Map rules = (Map) validationMap.get(key); + + if (rules == null) + return null; + + Boolean imageFile_valid = (Boolean) rules.get(IMAGE_FILE_EXT_VALID); + + if (imageFile_valid == null) + return null; + + //String imageFile = (String) value; + + /* if(!FileExtensionChecker.isValidFileExtention(imageFile)) + return "error.fileNotSupportedException"; + else*/ + return null; + + } + + private String validateMatchFields(String key, Object value, Object vo, Map valueMap) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException + { + Map rules = (Map) validationMap.get(key); + + if((rules == null)) + return null; + + if (!rules.containsKey(MATCH_FIELDS)) + return null; + + String otherField = (String) rules.get(MATCH_FIELDS); + + Class typeOfOtherField = PropertyUtils.getPropertyType(vo, otherField); + String currOtherFieldValue = (String) valueMap.get(otherField); + + if (otherField == null) + { + return null; + } + else + { + Object obj = convert(typeOfOtherField, otherField, currOtherFieldValue, TO_OBJECT); + if(!value.equals(obj)) + { + if (resources.getMessage("error.match."+key) == null) + return "error.match"; + else + return "error.match."+key; + } + else + return null; + + } + } + + private String validateLength(String key, Object value) + { + Map rules = (Map) validationMap.get(key); + + if(rules == null) + return null; + + Range range = (Range) rules.get(MIN_LENGTH_VALID); + + if (range == null) + return null; + + String str = (String) value; + Integer len = Integer.valueOf(str.length()); + + if(!range.isInRange(len)) + { + if (resources.getMessage("error.minlength."+key) == null) + return "error.minlength"; + else + return "error.minlength."+key; + } + else + return null; + + } + +// private String validateYear(String key, Object obj) +// { +// Map rules = (Map) validationMap.get(key); +// +// if (rules == null) +// return null; +// +// Boolean year_valid = (Boolean) rules.get(YEAR_VALID); +// +// String year = (String) obj; +// +// if (year.length()!= 4) +// return "error.year.length.invalid"; +// +// return null; +// +// +// } + + private String validateRequired(String key, Object obj) + { + // This was added because of the String[] + if (obj!=null && !String.class.isAssignableFrom(obj.getClass())) + { + return null; + } + + String value = (String) obj; + Map rules = (Map) validationMap.get(key); + + if(rules == null) + return null; + + Boolean required = (Boolean) rules.get(REQUIRED); + + if (required == null) + return null; + + boolean isRequired = required.booleanValue(); + boolean isBlank =(value == null || value.trim().equals("")); + + if(isRequired && isBlank) + { + if (resources.getMessage("error.required."+key) == null) + return "error.required"; + else + return "error.required."+key; + } + + else + return null; + } + + private String validateCreditCardField(String key, Object value, Object vo, Map valueMap) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException + { + Map rules = (Map) validationMap.get(key); + + if (rules == null) + return null; + + if (!rules.containsKey(CREDITCARD_VALID)) + return null; + + if (value == null) + return null; + + if (value.equals(MPayment.TENDERTYPE_CreditCard)) + { + String creditCardNumber = (String) valueMap.get("creditCardNumber"); + + if (creditCardNumber == null || creditCardNumber.equals("")) + return "error.required.creditCardNumber"; + + } + + return null; + + } + + private String validateCVVField(String key, Object value, Object vo, Map valueMap) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException + { + Map rules = (Map) validationMap.get(key); + + if (rules == null) + return null; + + if (!rules.containsKey(CVV_VALID)) + return null; + + if (value == null) + return null; + + if (value.equals(MPayment.TENDERTYPE_CreditCard)) + { + String cvv = (String) valueMap.get("cvv"); + + if (cvv == null || cvv.equals("")) + return "error.required.cvv"; + + } + + return null; + + } + + private String validateDateFields(String key, Object value, Object vo, Map valueMap) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException + { + Map rules = (Map) validationMap.get(key); + + if (rules == null) + return null; + + if (!rules.containsKey(DATE_FIELDS_VALID)) + return null; + + String otherKey = (String) rules.get(DATE_FIELDS_VALID); + + String otherValue = (String) valueMap.get(otherKey); + + if (value == null && otherValue == null) + return null; + + if (value == null) + return "error.date.prior.today"; + + if (otherValue == null) + return "error.date.prior.today"; + + Class otherType = PropertyUtils.getPropertyType(vo, otherKey); + + + JulianDate toDate = (JulianDate) convert(otherType, otherKey, otherValue, TO_OBJECT); + + JulianDate fromDate = (JulianDate) value; + + Range range = new Range(JulianDate.getToday(), toDate); + + if (!range.isInRange(fromDate)) + return "error.date.prior.today"; + else + return null; + + } + + + protected Formatter getFormatter(String key, Class type) + { + Formatter formatType = (Formatter) formatMap.get(key); + + if (formatType == null) + { + return Formatter.getFormatter(type); + } + + return formatType; + } + + public void setDefaultString(String key, String value) + { + defaultStringMap.put(key,value); + } + /* + * This is where you can override the way things are formatted. + */ + public void setFormatterType(String key, Class type) + { + if(!Formatter.class.isAssignableFrom(type)) + throw new FormattingException(type + "must be a Formatter"); + + formatMap.put(key,type); + } + + protected Map mapRepresentation(Object bean) + { + String errorMsg = "Unable to format values from bean: " + bean; + Map valueMap = null; + + try + { + valueMap = PropertyUtils.describe(bean); + } + catch(IllegalAccessException iae) + { + throw new FormattingException(errorMsg,iae); + } + catch(InvocationTargetException ite) + { + throw new FormattingException(errorMsg,ite); + } + catch(NoSuchMethodException nsme) + { + throw new FormattingException(errorMsg,nsme); + } + + Iterator keyIter = keysToSkip().iterator(); + + while(keyIter.hasNext()) + { + String key = (String) keyIter.next(); + valueMap.remove(key); + } + return valueMap; + } + + protected ArrayList keysToSkip() + { + ArrayList keysToSkip = new ArrayList(); + + // Don't popluate "class" field inherited from Object + + keysToSkip.add("class"); + keysToSkip.add("servletWrapper"); + keysToSkip.add("multipartRequestHandler"); + keysToSkip.add("bean"); + keysToSkip.add("properties"); + keysToSkip.add("checkBoxLists"); + keysToSkip.add("file"); + keysToSkip.add("minValue"); + keysToSkip.add("maxValue"); + + + return keysToSkip; + } + + + +} diff --git a/posterita/src/main/org/posterita/struts/core/DefaultForm.java b/posterita/src/main/org/posterita/struts/core/DefaultForm.java new file mode 100644 index 0000000000..aca62287b6 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/core/DefaultForm.java @@ -0,0 +1,4674 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.struts.core; + +import java.math.BigDecimal; +import java.util.ArrayList; + +import org.apache.struts.upload.FormFile; +import org.compiere.model.MInOut; + +import org.posterita.beans.AttributeValuesPair; +import org.posterita.beans.OrderLineBean; +import org.posterita.beans.PaymentBean; +import org.posterita.beans.ProductImageBean; +import org.posterita.beans.UDIBean; + + +public class DefaultForm extends BaseForm +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + + + protected String aaCardnumber; + protected String blackListedId; + protected String blackListedBankName; + protected String blackListedChequeNo; + + protected String forward; + protected String accountNo; + protected String accountType; + protected String accountName; + protected String address1; + protected String address2; + protected String agreement; + protected String aisle; + protected String allocationId; + protected String allocationStatus; + protected String attribute; + protected String attributeId; + protected String attributeSetId; + protected String attributeSetInstanceId; + protected Integer [] sernoAttributeSetInstanceIds; + protected String attributeValue; + protected String attributeValueId; + protected String bankId; + protected String bankName; + protected String bin; + protected String bpartnerId; + + protected String customSize; + protected String documentId; + protected String documentNo; + protected String documentType; + protected String email; + protected String endDay; + protected String endHour; + protected String endMinute; + protected String endMonth; + protected String endYear; + protected String engineNo; + protected String engineNumber; + protected String fax; + protected FormFile file; + protected FormFile image; + protected String day; + protected String fromDate; + protected String fromOrderLineId; + protected String grandTotal; + protected String id; + protected String invoiceId; + protected String isAccessAllOrgs= "false"; + protected String isActive="false"; + protected String isApproved; + protected String isAvailableForBackOrder="true"; + protected String isAutomobile; + protected String isCustomer="true"; + protected String isDefault = "true"; + protected String isDelivered; + protected String isEmployee="true"; + protected String isInvoiced; + protected String isMotorcycle; + protected String isNatisReleased; + protected String isPublic="false"; + protected String isQtyReserved; + + protected Integer [] checkBox; + protected String checkNo; + protected String city; + protected String colour; + protected String compiereDocStatus; + protected String confirmEmail; + protected String confirmPassword; + protected String counterOrderStatusInfo; + protected String counterOrgID; + protected String counterOrgName; + protected String currentBalance; + protected String custIdNumber; + protected String dateCreated; + protected String dateOrdered; + protected String datePromised; + protected String dateTrx; + protected String description; + protected String docStatus; + protected String docStatusCode; + + + protected String isReceipt; + protected String isRetailer ="true"; + protected String isSalesRep="false"; + protected String isSotrx; + protected String isVendor="true"; + protected String isVisible; + protected String isWholesaler="true"; + protected String level; + protected ArrayList list; + protected String locationId; + protected String locatorId; + protected FormFile logo; + protected String logoName; + protected String maintenanceContractNumber; + protected String make; + protected String makeAttributeValueId; + protected String menuId; + protected String menuItemName; + protected String menuLink; + protected String message; + protected String messageID; + protected String mobile; + protected String model; + protected String modelGroup; + protected String month; + protected String movementDate; + protected String movementDescription; + protected String name; + protected String natisApplicationDate; + protected String natisControlNumber; + protected String natisReleaseId; + protected String newEmail; + protected String newPassword; + protected String oldPassword; + + protected PaymentBean paymentBeanIndex; + protected String orderId; + protected ArrayList orderLineBean; + protected String orderLineId; + protected OrderLineBean orderLineIndexed; + protected ArrayList orderLineList = new ArrayList(); + protected String orderStatusInfo; + protected String orderType; + protected String orgId; + protected String allocatedAmount; + protected String OrgID; + protected String orgName; + protected String orgType; + protected String orgUser; + protected String parentMenuId; + protected String partnerId; + protected String partnerName=""; + protected String password; + protected String payAmt; + protected String paymentId; + protected String phone; + protected String phone2; + protected String poReference; + protected String POReference; + protected String postalAddress; + protected String postalAddress1; + protected String postalCity; + protected String postalCode; + protected String postalPostalCode; + protected String prefOrderLineId; + protected String price; + protected String priceEntered; + protected String priceList; + protected String priceListVersionId; + + protected AttributeValuesPair productAttributes; + protected String productAttributeSetInstanceId; + protected String productCategoryId; + protected String productId; + + protected String productName; + protected String qty; + protected String qtyReserved; + protected String [] qtyTargeted; + protected String quantity; + protected String read; + protected Integer refToQuote; + protected String region; + protected String regionId; + protected String registerNumber; + protected String reserveStatus; + protected String roleId; + protected String roleName; + protected String routingNumber; + protected String sernoAttributeSetInstance; + protected String sotrxFlag; + protected String startDay; + protected String startHour; + protected String startMinute; + protected String startMonth; + protected String startYear; + protected String stdPurchasePrice; + protected String stdSalesPrice; + protected String subject; + protected String submit; + + protected String surname; + protected Integer[] targetId; + protected String termsAgreement; + protected String toDate; + protected String toOrderLineId; + protected String totalLines; + protected String transmission; + protected String transmissionAttributeValueId; + protected String userId; + protected String username; + protected String value; + protected String vinNumber; + protected String warehouseId; + protected String warehouseName; + protected String warehouseType; + protected String year; + protected String yearAttributeValueId; + protected String first; + protected String licensingDistrictId; + protected String licensingDistrict; + protected String tradeInOrderlineId; + protected String passportNo; + protected String companyRegNo; + protected ArrayList showroomTrafficBean; + + protected String sales; + protected String traffic; + protected String prospects; + + protected String modelId; + protected String trxId; + protected String trx; + protected String modelCode; + protected String modelCodeId; + protected String dealerCode; + protected String dealerCodeId; + protected String name2; + protected String isAllocationWarehouse="false"; + protected String canAlterOrder; + protected String canCreateOrder; + protected String canViewOrder; + protected String salesRepId; + + protected String imagePath; + protected String imageTitle; + protected String altText; + protected String dateFrom; + protected String dateTo; + + protected String weekNo; + protected String startDate; + protected String endDate; + protected String financeOption; + protected String status; + + protected String newVinNumber; + protected String countryOfImpCode; + protected String enginePower; + protected String mainColourCode; + protected String natisModelNo; + protected String noOfWheels; + protected String tare; + protected String unitNumber; + protected String isTradeIn = "true"; + + protected String attributesetinstanceIdFrom; + protected String attributesetinstanceIdTo; + protected String releasedBy; + protected Integer productIds[]; + protected String ETA; + protected String ETAFilter; + + protected String engineCapacity; + protected String colourCodeHES; + protected String colourName; + protected String natisModelDescription; + protected Integer orderIds[]; + + protected String colourCodeMatchId; + protected String modelMatchID; + protected String natisModelDesc; + protected String modelDesc; + protected String trans; + protected String showActiveOnly = "true"; + protected String updateAttrValueId; + protected String active; + protected String visible; + protected String beginingBalance; + protected String statementDifference; + protected String endingBalance; + protected String amount; + protected String trxType; + protected String amountGiven; + protected String amountRefunded; + protected Integer cashBookId; + protected String cashId; + protected String cashLineId; + protected String cashBookName; + protected String chequeNo; + protected String creditCardType; + protected String creditCardNumber; + protected String creditCardNumberEncrypted; + protected String creditCardExpMonth; + protected String creditCardExpMonthName; + protected String creditCardExpYear; + protected Integer orderLineIds[]; + protected Integer [] posOrderLineIds; + protected Integer [] bpartnerIds; + protected Integer [] invoiceIds; + + private String qtySmall; + private String qtyMedium; + private String qtyLarge; + private String qtyXLarge; + private String clientName; + protected String transferAmount; + protected String cashBookIds; + protected String designAttributeValueId; + protected String modelAttributeValueId; + protected String sizeAttributeValueId; + protected String colourAttributeValueId; + protected String shoppingCartItemId; + protected String keyword; + protected String searchText; + protected String backOrder; + + protected String fieldName; + protected String applicationName; + protected String isWebstoreFeatured="false"; + protected String isNotWebstoreFeatured; + protected String imageName; + + protected String posId; + protected String purchasePriceList; + protected String purchasePriceLimit; + protected String purchasePriceStandard; + protected String salesPriceList; + protected String salesPriceLimit; + protected String salesPriceStandard; + protected String barCode; + protected String trackingNo; + protected String reportType; + protected String noOfProductsRequired; + protected String qtyAndItem; + protected String [] discountPercent; + protected String [] actualPrice; + protected String userSurname; + protected String countryId; + protected String countryName; + + protected String newName; + protected ArrayList productsList = new ArrayList(); + protected ProductImageBean productsIndexed; + protected String paymentByCash; + protected String paymentByCard; + protected String paymentByChq; + protected String isSales; + protected String ifAdd="true"; + + protected String brandName; + protected String modelName; + protected String designName; + protected String sizeName; + protected String productCategory; + protected String productClassification; + protected String [] sizes; + protected String revenueRecognition; + protected String cvv; + protected String creditCardPayment; + protected String shipmentMethod = MInOut.DELIVERYVIARULE_Pickup; + protected String shipTo; + protected String billTo; + protected String shipperId; + protected String paymentMethod; + + protected String revenueRecoId; + protected String isTextileProduct; + protected String qtyFilter; + protected ArrayList attributeValueList; + protected String [] attributeValueIds; + protected String attributeSetName; + protected String attributeName; + + + protected String requestId; + protected String fromAddress; + protected String toAddresses; + protected String ccAddresses; + protected String bccAddresses; + protected String textMessage; + protected String toUserId; + protected String priority; + protected String title; + protected String chargeId; + protected String statusId; + protected String totalActualPrice; + protected String productType="I"; + protected String qtyNumberFilter; + protected String taxCategoryId; + protected String taxCategoryName; + protected String endingBalanceAsString; + protected String beginingBalanceAsString; + protected String vendorName; + protected String timePeriod; + protected String chartType; + protected String salesGroup; + protected String taxRate; + protected String state; + protected String accountId; + protected String dateRange; + protected String reportName; + protected String orderGrandTotal; + protected String transferAllAmount; + protected String adjustmentAmount; + + protected String differenceAmt; + protected String tillGrandTotal; + protected String cashTotal; + protected String cardTotal; + protected String chequeTotal; + protected String creatingFromOrder; + protected String transferType; + protected String priceQtyFilter; + protected String deliveryViaRule; + protected String userPIN; + protected String paymentRule; + protected String cardDifference; + protected String chequeDifference; + + + protected String isSelfService; + protected String documentNote; + protected String currencySymbole; + protected String userDiscount; + + + + + protected String invoiceDate; + protected String netDays; + protected String daysDue; + protected String dueDate; + protected String discountDate; + protected String discountAmt; + protected String invoiceGrandTotal; + protected String paidAmt; + protected String openAmt; + protected String currencyId; + protected String paymentTermId; + protected String invoiceScheduleId; + + protected String invoicedAmt; + protected String pastDue91_plus; + protected String pastDue61_90; + protected String pastDue31_60; + protected String pastDue1_30; + protected String pastDue8_30; + protected String pastDue1_7; + protected String pastDueAmt; + protected String dueAmt; + protected String due0; + protected String due1_7; + protected String due8_30; + protected String due0_30; + protected String due31_60; + protected String due61_90; + protected String due91_PLUS; + + + protected String paymentAmt; + protected String overUnderPayment; + protected String writeOffAmt; + + protected String invoiceNo; + protected String paymentTermName; + + protected String dunningLevelId; + protected String dunningLevelName; + protected String dunningPrintText; + protected String dunningPrintNote; + protected String BP_Group_ID ; + protected String dunningId; + protected String dunningName; + protected String creditLimit; + protected String creditStatus; + protected String creditUsed; + public String docBasisType; + protected String amtMultiplier; + protected String frequencyType; + protected String commissionAmtId; + protected String subtractAmt; + + protected String taxName; + protected String taxId; + protected String isTaxExempted; + + protected Integer [] paymentIds; + + + protected String inventoryLineId; + protected String inventoryId; + protected String qtyBook; + protected String qtyCount; + + protected String afterDelivery; + protected String fixedDueDate; + protected String nextBusinessday; + protected String fixedMonthDay; + protected String fixedMonthOffset; + protected String fiedMonthCutoff; + protected String toBeShipped; + protected String discountDay1; + protected String discountDay2; + protected String discountAmt1; + protected String discountAmt2; + protected String [] allocateAmount; + protected String group1; + protected String group2; + protected Integer [] inventoryIds; + + + protected String isFullAccess; + protected String historyType; + + protected String birthdate; + protected String openDrawer="true"; + + + + public String getHistoryType() + { + return historyType; + } + + + public void setHistoryType(String historyType) + { + this.historyType = historyType; + } + + public Integer[] getPaymentIds() { + return paymentIds; + } + + + public void setPaymentIds(Integer[] paymentIds) { + this.paymentIds = paymentIds; + } + + + public DefaultForm() + { + setBean(new UDIBean()); + } + + + public String getOrderGrandTotal() { + return orderGrandTotal; + } + public void setOrderGrandTotal(String orderGrandTotal) { + this.orderGrandTotal = orderGrandTotal; + } + public String getSalesGroup() { + return salesGroup; + } + public void setSalesGroup(String salesGroup) { + this.salesGroup = salesGroup; + } + + public String getBeginingBalanceAsString() { + return beginingBalanceAsString; + } + public void setBeginingBalanceAsString(String beginingBalanceAsString) { + this.beginingBalanceAsString = beginingBalanceAsString; + } + public String getEndingBalanceAsString() { + return endingBalanceAsString; + } + public void setEndingBalanceAsString(String endingBalanceAsString) { + this.endingBalanceAsString = endingBalanceAsString; + } + public String getAttributeName() { + return attributeName; + } + public void setAttributeName(String attributeName) { + this.attributeName = attributeName; + } + + public String getAttributeSetName() { + return attributeSetName; + } + public void setAttributeSetName(String attributeSetName) { + this.attributeSetName = attributeSetName; + } + + + + + + public String getBillTo() + { + return billTo; + } + + + + + public void setBillTo(String billTo) + { + this.billTo = billTo; + } + + + + + public String getShipmentMethod() + { + return shipmentMethod; + } + + + + + public void setShipmentMethod(String shipmentMethod) + { + this.shipmentMethod = shipmentMethod; + } + + + + + public String getShipTo() + { + return shipTo; + } + + + + + public void setShipTo(String shipTo) + { + this.shipTo = shipTo; + } + + + + + public String[] getActualPrice() { + return actualPrice; + } + public void setActualPrice(String[] actualPrice) { + this.actualPrice = actualPrice; + } + + public String[] getDiscountPercent() { + return discountPercent; + } + public void setDiscountPercent(String[] discountPercent) { + this.discountPercent = discountPercent; + } + public String getQtyAndItem() { + return qtyAndItem; + } + public void setQtyAndItem(String qtyAndItem) { + this.qtyAndItem = qtyAndItem; + } + public String getIsTradeIn() + { + return isTradeIn; + } + + public void setIsTradeIn(String isTradeIn) + { + this.isTradeIn = isTradeIn; + } + + public String getLicensingDistrictId() { + return licensingDistrictId; + } + public void setLicensingDistrictId(String licensingDistrictId) { + this.licensingDistrictId = licensingDistrictId; + } + public String getIsAvailableForBackOrder() { + return isAvailableForBackOrder; + } + public void setIsAvailableForBackOrder(String isAvailableForBackOrder) { + this.isAvailableForBackOrder = isAvailableForBackOrder; + } + public String getAaCardnumber() { + return aaCardnumber; + } + public String getAccountNo() { + return accountNo; + } + public String getAccountType() { + return accountType; + } + public String getAddress1() { + return address1; + } + public String getAddress2() { + return address2; + } + + public String getAgreement() + { + return agreement; + } + public String getAisle() { + return aisle; + } + + + public String getAllocationId() + { + return allocationId; + } + + + + public String getAllocationStatus() + { + return allocationStatus; + } + public String getAttribute() { + return attribute; + } + public String getAttributeId() { + return attributeId; + } + public String getAttributeSetId() { + return attributeSetId; + } + public String getAttributeSetInstanceId() + { + return attributeSetInstanceId; + } + public String getAttributeValue() { + return attributeValue; + } + public String getBankId() { + return bankId; + } + public String getBankName() { + return bankName; + } + public String getBin() { + return bin; + } + public String getBpartnerId() { + return bpartnerId; + } + + public Integer[] getCheckBox() + { + return checkBox; + } + + public String getCheckNo() { + return checkNo; + } + public String getCity() { + return city; + } + public String getColour() { + return colour; + } + public String getColourAttributeValueId() { + return colourAttributeValueId; + } + + public String getCompiereDocStatus() + { + return compiereDocStatus; + } + + public String getConfirmEmail() { + return confirmEmail; + } + public String getConfirmPassword() { + return confirmPassword; + } + public String getCounterOrderStatusInfo() { + return counterOrderStatusInfo; + } + public String getCounterOrgID() { + return counterOrgID; + } + public String getCounterOrgName() { + return counterOrgName; + } + public String getCurrentBalance() { + return currentBalance; + } + public String getCustIdNumber() { + return custIdNumber; + } + public String getDateCreated() { + return dateCreated; + } + public String getDateOrdered() { + return dateOrdered; + } + public String getDatePromised() { + return datePromised; + } + public String getDateTrx() { + return dateTrx; + } + + public String getDescription() { + return description; + } + + public String getDocStatus() { + return docStatus; + } + public String getDocStatusCode() { + return docStatusCode; + } + public String getDocumentId() { + return documentId; + } + public String getDocumentNo() { + return documentNo; + } + public String getDocumentType() { + return documentType; + } + public String getEmail() { + return email; + } + + public String getEndDay() { + return endDay; + } + public String getEndHour() { + return endHour; + } + public String getEndMinute() { + return endMinute; + } + public String getEndMonth() { + return endMonth; + } + public String getEndYear() { + return endYear; + } + + + public String getEngineNo() { + return engineNo; + } + + + public String getEngineNumber() + { + return engineNumber; + } + public FormFile getFile() + { + return file; + } + + public String getFromDate() { + return fromDate; + } + + public String getFromOrderLineId() + { + return fromOrderLineId; + } + + public String getGrandTotal() { + return grandTotal; + } + public String getId() { + return id; + } + + public String getInvoiceId() { + return invoiceId; + } + public String getIsAccessAllOrgs() { + return isAccessAllOrgs; + } + public String getIsActive() { + return isActive; + } + public String getIsApproved() { + return isApproved; + } + public String getIsAutomobile() { + return isAutomobile; + } + public String getIsCustomer() { + return isCustomer; + } + public String getIsDefault() { + return isDefault; + } + public String getIsDelivered() { + return isDelivered; + } + public String getIsEmployee() { + return isEmployee; + } + public String getIsInvoiced() { + return isInvoiced; + } + public String getIsMotorcycle() { + return isMotorcycle; + } + public String getIsNatisReleased() { + return isNatisReleased; + } + public String getIsPublic() { + return isPublic; + } + + + public String getIsQtyReserved() { + return isQtyReserved; + } + + public String getIsReceipt() { + return isReceipt; + } + public String getIsRetailer() { + return isRetailer; + } + public String getIsSalesRep() { + return isSalesRep; + } + public String getIsSotrx() { + return isSotrx; + } + public String getIsVendor() { + return isVendor; + } + public String getIsWholesaler() { + return isWholesaler; + } + public String getLevel() { + return level; + } + public ArrayList getList() + { + return list; + } + + public String getLocationId() { + return locationId; + } + + + public String getLocatorId() + { + return locatorId; + } + + public FormFile getLogo() + { + return logo; + } + public String getLogoName() + { + return logoName; + } + public String getMaintenanceContractNumber() { + return maintenanceContractNumber; + } + + public String getMake() + { + return make; + } + + public String getMakeAttributeValueId() + { + return makeAttributeValueId; + } + + public String getMenuId() { + return menuId; + } + public String getMenuItemName() { + return menuItemName; + } + public String getMenuLink() { + return menuLink; + } + public String getMessage() { + return message; + } + public String getMessageID() { + return messageID; + } + public String getMobile() { + return mobile; + } + public String getModel() { + return model; + } + public String getModelAttributeValueId() { + return modelAttributeValueId; + } + + public String getModelGroup() { + return modelGroup; + } + public String getMonth() { + return month; + } + + public String getMovementDate() + { + return movementDate; + } + + public String getMovementDescription() + { + return movementDescription; + } + public String getName() { + return name; + } + public String getNatisApplicationDate() + { + return natisApplicationDate; + } + public String getNatisControlNumber() + { + return natisControlNumber; + } + public String getNatisReleaseId() + { + return natisReleaseId; + } + public String getNewEmail() { + return newEmail; + } + public String getNewPassword() { + return newPassword; + } + public String getOldPassword() { + return oldPassword; + } + public String getOrderId() { + return orderId; + } + public ArrayList getOrderLineBean() + { + return orderLineBean; + } + + public String getOrderLineId() + { + return orderLineId; + } + public OrderLineBean getOrderLineIndexed() + { + return orderLineIndexed; + } + + public OrderLineBean getOrderLineIndexed(int index) + { + while (index >= orderLineList.size()) + orderLineList.add(new OrderLineBean()); + return (OrderLineBean) orderLineList.get(index); + } + + public ArrayList getOrderLineList() + { + return orderLineList; + } + + public String getOrderStatusInfo() { + return orderStatusInfo; + } + + + public String getOrderType() + { + return orderType; + } + public String getOrgId() + { + return orgId; + } + public String getOrgID() { + return OrgID; + } + public String getOrgName() { + return orgName; + } + public String getOrgType() { + return orgType; + } + public String getOrgUser() { + return orgUser; + } + public String getParentMenuId() { + return parentMenuId; + } + public String getPartnerId() { + return partnerId; + } + public String getPartnerName() { + return partnerName; + } + public String getPassword() { + return password; + } + public String getPayAmt() { + return payAmt; + } + public String getPaymentId() { + return paymentId; + } + + public String getPhone1() { + return phone; + } + public String getPhoneNo() { + return phone2; + } + public String getPoReference() { + return poReference; + } + public String getPOReference() + { + return POReference; + } + + public String getPostalAddress() { + return postalAddress; + } + public String getPostalAddress1() { + return postalAddress1; + } + public String getPostalCity() { + return postalCity; + } + public String getPostalCode() { + return postalCode; + } + public String getPostalPostalCode() { + return postalPostalCode; + } + public String getPrefOrderLineId() + { + return prefOrderLineId; + } + + public String getPriceEntered() + { + return priceEntered; + } + + public String getPriceListVersionId() { + return priceListVersionId; + } + public AttributeValuesPair getProductAttributes() + { + return productAttributes; + } + + public String getProductAttributeSetInstanceId() + { + return productAttributeSetInstanceId; + } + + public String getProductCategoryId() + { + return productCategoryId; + } + + public String getProductId() + { + return productId; + } + + public String getProductName() + { + return productName; + } + + public String getQty() { + return qty; + } + public String getQtyReserved() + { + return qtyReserved; + } + + public String[] getQtyTargeted() { + return qtyTargeted; + } + + public String getQuantity() + { + return quantity; + } + + public String getRead() { + return read; + } + + + public Integer getRefToQuote() + { + return refToQuote; + } + public String getRegion() { + return region; + } + + public String getRegionId() { + return regionId; + } + public String getRegisterNumber() + { + return registerNumber; + } + + public String getReserveStatus() + { + return reserveStatus; + } + public String getRoleId() { + return roleId; + } + public String getRoleName() { + return roleName; + } + public String getRoutingNumber() { + return routingNumber; + } + + public String getSernoAttributeSetInstance() + { + return sernoAttributeSetInstance; + } + + public String getSotrxFlag() + { + return sotrxFlag; + } + public String getStartDay() { + return startDay; + } + public String getStartHour() { + return startHour; + } + public String getStartMinute() { + return startMinute; + } + public String getStartMonth() { + return startMonth; + } + public String getStartYear() { + return startYear; + } + public String getStdPurchasePrice() { + return stdPurchasePrice; + } + public String getStdSalesPrice() { + return stdSalesPrice; + } + public String getSubject() { + return subject; + } + + public String getSubmit() + { + return submit; + } + public String getSurname() { + return surname; + } + + public Integer[] getTargetId() { + return targetId; + } + public String getTermsAgreement() + { + return termsAgreement; + } + + public String getToDate() { + return toDate; + } + + public String getToOrderLineId() + { + return toOrderLineId; + } + + public String getTotalLines() + { + return totalLines; + } + + public String getTransmission() { + return transmission; + } + public String getTransmissionAttributeValueId() { + return transmissionAttributeValueId; + } + public String getUserId() { + return userId; + } + + public String getUsername() { + return username; + } + public String getValue() { + return value; + } + + public String getVinNumber() + { + return vinNumber; + } + public String getWarehouseId() { + return warehouseId; + } + public String getWarehouseName() { + return warehouseName; + } + + public String getWarehouseType() + { + return warehouseType; + } + public String getYear() { + return year; + } + + public void setAisle(String aisle) { + this.aisle = aisle; + } + + + public void setAllocationId(String allocationId) + { + this.allocationId = allocationId; + } + + public void setAllocationStatus(String allocationStatus) + { + this.allocationStatus = allocationStatus; + } + public void setAttribute(String attribute) { + this.attribute = attribute; + } + public void setAttributeId(String attributeId) { + this.attributeId = attributeId; + } + public void setAttributeSetId(String attributeSetId) { + this.attributeSetId = attributeSetId; + } + public void setAttributeSetInstanceId(String attributeSetInstanceId) + { + this.attributeSetInstanceId = attributeSetInstanceId; + } + public void setAttributeValue(String attributeValue) { + this.attributeValue = attributeValue; + } + public void setBankId(String bankId) { + this.bankId = bankId; + } + public void setBankName(String bankName) { + this.bankName = bankName; + } + public void setBin(String bin) { + this.bin = bin; + } + public void setBpartnerId(String partnerId) { + bpartnerId = partnerId; + } + public void setCheckBox(Integer[] checkBox) + { + this.checkBox = checkBox; + } + + public String getYearAttributeValueId() { + return yearAttributeValueId; + } + public void setAaCardnumber(String aaCardnumber) { + this.aaCardnumber = aaCardnumber; + } + public void setAccountNo(String accountNo) { + this.accountNo = accountNo; + } + public void setAccountType(String accountType) { + this.accountType = accountType; + } + public void setAddress1(String address1) { + this.address1 = address1; + } + public void setAddress2(String address2) { + this.address2 = address2; + } + + public void setAgreement(String agreement) + { + this.agreement = agreement; + } + + public void setCheckNo(String checkNo) { + this.checkNo = checkNo; + } + public void setCity(String city) { + this.city = city; + } + public void setColour(String colour) { + this.colour = colour; + } + public void setColourAttributeValueId(String colourAttributeValueId) { + this.colourAttributeValueId = colourAttributeValueId; + } + + public void setCompiereDocStatus(String compiereDocStatus) + { + this.compiereDocStatus = compiereDocStatus; + } + public void setConfirmEmail(String confirmEmail) { + this.confirmEmail = confirmEmail; + } + public void setConfirmPassword(String confirmPassword) { + this.confirmPassword = confirmPassword; + } + public void setCounterOrderStatusInfo(String counterOrderStatusInfo) { + this.counterOrderStatusInfo = counterOrderStatusInfo; + } + public void setCounterOrgID(String counterOrgID) { + this.counterOrgID = counterOrgID; + } + public void setCounterOrgName(String counterOrgName) { + this.counterOrgName = counterOrgName; + } + public void setCurrentBalance(String currentBalance) { + this.currentBalance = currentBalance; + } + public void setCustIdNumber(String custIdNumber) { + this.custIdNumber = custIdNumber; + } + public void setDateCreated(String dateCreated) { + this.dateCreated = dateCreated; + } + public void setDateOrdered(String dateOrdered) { + this.dateOrdered = dateOrdered; + } + public void setDatePromised(String datePromised) { + this.datePromised = datePromised; + } + public void setDateTrx(String dateTrx) { + this.dateTrx = dateTrx; + } + public void setDescription(String description) { + this.description = description; + } + public void setDocStatus(String docStatus) { + this.docStatus = docStatus; + } + public void setDocStatusCode(String docStatusCode) { + this.docStatusCode = docStatusCode; + } + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + public void setDocumentNo(String documentNo) { + this.documentNo = documentNo; + } + public void setDocumentType(String documentType) { + this.documentType = documentType; + } + public void setEmail(String email) { + this.email = email; + } + public void setEndDay(String endDay) { + this.endDay = endDay; + } + public void setEndHour(String endHour) { + this.endHour = endHour; + } + public void setEndMinute(String endMinute) { + this.endMinute = endMinute; + } + public void setEndMonth(String endMonth) { + this.endMonth = endMonth; + } + public void setEndYear(String endYear) { + this.endYear = endYear; + } + public void setEngineNo(String engineNo) { + this.engineNo = engineNo; + } + public void setEngineNumber(String engineNumber) + { + this.engineNumber = engineNumber; + } + + public void setFile(FormFile file) + { + this.file = file; + } + + public void setFromDate(String fromDate) { + this.fromDate = fromDate; + } + + public void setFromOrderLineId(String fromOrderLineId) + { + this.fromOrderLineId = fromOrderLineId; + } + + public void setGrandTotal(String grandTotal) { + this.grandTotal = grandTotal; + } + public void setId(String id) { + this.id = id; + } + public void setInvoiceId(String invoiceId) { + this.invoiceId = invoiceId; + } + public void setIsAccessAllOrgs(String isAccessAllOrgs) { + this.isAccessAllOrgs = isAccessAllOrgs; + } + + public void setIsActive(String isActive) { + this.isActive = isActive; + } + public void setIsApproved(String isApproved) { + this.isApproved = isApproved; + } + public void setIsAutomobile(String isAutomobile) { + this.isAutomobile = isAutomobile; + } + public void setIsCustomer(String isCustomer) { + this.isCustomer = isCustomer; + } + public void setIsDefault(String isDefault) { + this.isDefault = isDefault; + } + public void setIsDelivered(String isDelivered) { + this.isDelivered = isDelivered; + } + public void setIsEmployee(String isEmployee) { + this.isEmployee = isEmployee; + } + public void setIsInvoiced(String isInvoiced) { + this.isInvoiced = isInvoiced; + } + public void setIsMotorcycle(String isMotorcycle) { + this.isMotorcycle = isMotorcycle; + } + public void setIsNatisReleased(String isNatisReleased) { + this.isNatisReleased = isNatisReleased; + } + public void setIsPublic(String isPublic) { + this.isPublic = isPublic; + } + public void setIsQtyReserved(String isQtyReserved) { + this.isQtyReserved = isQtyReserved; + } + + public void setIsReceipt(String isReceipt) { + this.isReceipt = isReceipt; + } + public void setIsRetailer(String isRetailer) { + this.isRetailer = isRetailer; + } + public void setIsSalesRep(String isSalesRep) { + this.isSalesRep = isSalesRep; + } + public void setIsSotrx(String isSotrx) { + this.isSotrx = isSotrx; + } + public void setIsVendor(String isVendor) { + this.isVendor = isVendor; + } + public void setIsWholesaler(String isWholesaler) { + this.isWholesaler = isWholesaler; + } + public void setLevel(String level) { + this.level = level; + } + public void setList(ArrayList list) + { + this.list = list; + } + + public void setLocationId(String locationId) { + this.locationId = locationId; + } + + public void setLocatorId(String locatorId) + { + this.locatorId = locatorId; + } + + public void setLogo(FormFile logo) + { + this.logo = logo; + } + public void setLogoName(String logoName) + { + this.logoName = logoName; + } + public void setMaintenanceContractNumber(String maintenanceContractNumber) { + this.maintenanceContractNumber = maintenanceContractNumber; + } + + public void setMake(String make) + { + this.make = make; + } + + public void setMakeAttributeValueId(String makeAttributeValueId) + { + this.makeAttributeValueId = makeAttributeValueId; + } + + public void setMenuId(String menuId) { + this.menuId = menuId; + } + public void setMenuItemName(String menuItemName) { + this.menuItemName = menuItemName; + } + public void setMenuLink(String menuLink) { + this.menuLink = menuLink; + } + public void setMessage(String message) { + this.message = message; + } + public void setMessageID(String messageID) { + this.messageID = messageID; + } + public void setMobile(String mobile) { + this.mobile = mobile; + } + public void setModel(String model) { + this.model = model; + } + public void setModelAttributeValueId(String modelAttributeValueId) { + this.modelAttributeValueId = modelAttributeValueId; + } + public void setModelGroup(String modelGroup) { + this.modelGroup = modelGroup; + } + public void setMonth(String month) { + this.month = month; + } + + public void setMovementDate(String movementDate) + { + this.movementDate = movementDate; + } + + public void setMovementDescription(String movementDescription) + { + this.movementDescription = movementDescription; + } + public void setName(String name) { + this.name = name; + } + public void setNatisApplicationDate(String natisApplicationDate) + { + this.natisApplicationDate = natisApplicationDate; + } + public void setNatisControlNumber(String natisControlNumber) + { + this.natisControlNumber = natisControlNumber; + } + public void setNatisReleaseId(String natisReleaseId) + { + this.natisReleaseId = natisReleaseId; + } + public void setNewEmail(String newEmail) { + this.newEmail = newEmail; + } + public void setNewPassword(String newPassword) { + this.newPassword = newPassword; + } + public void setOldPassword(String oldPassword) { + this.oldPassword = oldPassword; + } + public void setOrderId(String orderId) { + this.orderId = orderId; + } + public void setOrderLineBean(ArrayList orderLineBean) + { + this.orderLineBean = orderLineBean; + } + + public void setOrderLineId(String orderLineId) + { + this.orderLineId = orderLineId; + } + + public void setOrderLineIndexed(int index, OrderLineBean value) + { + orderLineList.add(index, value); + } + + public void setOrderLineIndexed(OrderLineBean orderLineIndexed) + { + this.orderLineIndexed = orderLineIndexed; + } + + public void setOrderLineList(ArrayList orderLineList) + { + this.orderLineList = orderLineList; + } + + public void setOrderStatusInfo(String orderStatusInfo) { + this.orderStatusInfo = orderStatusInfo; + } + + public void setOrderType(String orderType) + { + this.orderType = orderType; + } + public void setOrgId(String orgId) + { + this.orgId = orgId; + } + public void setOrgID(String orgID) { + OrgID = orgID; + } + public void setOrgName(String orgName) { + this.orgName = orgName; + } + public void setOrgType(String orgType) { + this.orgType = orgType; + } + public void setOrgUser(String orgUser) { + this.orgUser = orgUser; + } + public void setParentMenuId(String parentMenuId) { + this.parentMenuId = parentMenuId; + } + public void setPartnerId(String partnerId) { + this.partnerId = partnerId; + } + public void setPartnerName(String partnerName) { + this.partnerName = partnerName; + } + public void setPassword(String password) { + this.password = password; + } + public void setPayAmt(String payAmt) { + this.payAmt = payAmt; + } + public void setPaymentId(String paymentId) { + this.paymentId = paymentId; + } + public void setPhone1(String phone1) { + this.phone = phone1; + } + public void setPhoneNo(String phoneNo) { + this.phone2 = phoneNo; + } + public void setPoReference(String poReference) { + this.poReference = poReference; + } + public void setPOReference(String reference) + { + POReference = reference; + } + + public void setPostalAddress(String postalAddress) { + this.postalAddress = postalAddress; + } + public void setPostalAddress1(String postalAddress1) { + this.postalAddress1 = postalAddress1; + } + public void setPostalCity(String postalCity) { + this.postalCity = postalCity; + } + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + public void setPostalPostalCode(String postalPostalCode) { + this.postalPostalCode = postalPostalCode; + } + + public void setPrefOrderLineId(String prefOrderLineId) + { + this.prefOrderLineId = prefOrderLineId; + } + + public void setPriceEntered(String priceEntered) + { + this.priceEntered = priceEntered; + } + + public void setPriceListVersionId(String priceListVersionId) { + this.priceListVersionId = priceListVersionId; + } + public void setProductAttributes(AttributeValuesPair productAttributes) + { + this.productAttributes = productAttributes; + } + + public void setProductAttributeSetInstanceId(String productAttributeSetInstanceId) + { + this.productAttributeSetInstanceId = productAttributeSetInstanceId; + } + + public void setProductCategoryId(String productCategoryId) + { + this.productCategoryId = productCategoryId; + } + + public void setProductId(String productId) + { + this.productId = productId; + } + + public void setProductName(String productName) + { + this.productName = productName; + } + public void setQty(String qty) { + this.qty = qty; + } + public void setQtyReserved(String qtyReserved) + { + this.qtyReserved = qtyReserved; + } + public void setQtyTargeted(String[] qtyTargeted) { + this.qtyTargeted = qtyTargeted; + } + + + public void setQuantity(String quantity) + { + this.quantity = quantity; + } + + public void setRead(String read) { + this.read = read; + } + public void setRefToQuote(Integer refToQuote) + { + this.refToQuote = refToQuote; + } + public void setRegion(String region) { + this.region = region; + } + + + public void setRegionId(String regionId) { + this.regionId = regionId; + } + public void setRegisterNumber(String registerNumber) + { + this.registerNumber = registerNumber; + } + + public void setReserveStatus(String reserveStatus) + { + this.reserveStatus = reserveStatus; + } + public void setRoleId(String roleId) { + this.roleId = roleId; + } + public void setRoleName(String roleName) { + this.roleName = roleName; + } + public String getPrice() { + return price; + } + public void setPrice(String price) { + this.price = price; + } + public String getPriceList() { + return priceList; + } + public void setPriceList(String priceList) { + this.priceList = priceList; + } + + public void setRoutingNumber(String routingNumber) { + this.routingNumber = routingNumber; + } + + public void setSernoAttributeSetInstance(String sernoAttributeSetInstance) + { + this.sernoAttributeSetInstance = sernoAttributeSetInstance; + } + + public void setSotrxFlag(String sotrxFlag) + { + this.sotrxFlag = sotrxFlag; + } + public void setStartDay(String startDay) { + this.startDay = startDay; + } + public void setStartHour(String startHour) { + this.startHour = startHour; + } + public void setStartMinute(String startMinute) { + this.startMinute = startMinute; + } + public void setStartMonth(String startMonth) { + this.startMonth = startMonth; + } + public void setStartYear(String startYear) { + this.startYear = startYear; + } + public void setStdPurchasePrice(String stdPurchasePrice) { + this.stdPurchasePrice = stdPurchasePrice; + } + public void setStdSalesPrice(String stdSalesPrice) { + this.stdSalesPrice = stdSalesPrice; + } + public void setSubject(String subject) { + this.subject = subject; + } + + public void setSubmit(String submit) + { + this.submit = submit; + } + public void setSurname(String surname) { + this.surname = surname; + } + public void setTargetId(Integer[] targetId) { + this.targetId = targetId; + } + public void setTermsAgreement(String termsAgreement) + { + this.termsAgreement = termsAgreement; + } + public void setToDate(String toDate) { + this.toDate = toDate; + } + + public void setToOrderLineId(String toOrderLineId) + { + this.toOrderLineId = toOrderLineId; + } + + public void setTotalLines(String totalLines) + { + this.totalLines = totalLines; + } + public void setTransmission(String transmission) { + this.transmission = transmission; + } + public void setTransmissionAttributeValueId( + String transmissionAttributeValueId) { + this.transmissionAttributeValueId = transmissionAttributeValueId; + } + public void setUserId(String userId) { + this.userId = userId; + } + + public void setUsername(String username) { + this.username = username; + } + public void setValue(String value) { + this.value = value; + } + public void setVinNumber(String vinNumber) + { + this.vinNumber = vinNumber; + } + public void setWarehouseId(String warehouseId) { + this.warehouseId = warehouseId; + } + public void setWarehouseName(String warehouseName) { + this.warehouseName = warehouseName; + } + + public void setWarehouseType(String warehouseType) + { + this.warehouseType = warehouseType; + } + + public void setYear(String year) { + this.year = year; + } + public void setYearAttributeValueId(String yearAttributeValueId) { + this.yearAttributeValueId = yearAttributeValueId; + } + + public String getFirst() + { + return first; + } + + public void setFirst(String first) + { + this.first = first; + } + + public String getLicensingDistrict() + { + return licensingDistrict; + } + + public void setLicensingDistrict(String licensingDistrict) + { + this.licensingDistrict = licensingDistrict; + } + + public String getCompanyRegNo() + { + return companyRegNo; + } + + public void setCompanyRegNo(String companyRegNo) + { + this.companyRegNo = companyRegNo; + } + + public String getPassportNo() + { + return passportNo; + } + + public void setPassportNo(String passportNo) + { + this.passportNo = passportNo; + } + + public String getTradeInOrderlineId() + { + return tradeInOrderlineId; + } + + public void setTradeInOrderlineId(String tradeInOrderlineId) + { + this.tradeInOrderlineId = tradeInOrderlineId; + } + + public String getProspects() + { + return prospects; + } + + public void setProspects(String prospects) + { + this.prospects = prospects; + } + + public String getSales() + { + return sales; + } + + public void setSales(String sales) + { + this.sales = sales; + } + + public ArrayList getShowroomTrafficBean() + { + return showroomTrafficBean; + } + + public void setShowroomTrafficBean(ArrayList showroomTrafficBean) + { + this.showroomTrafficBean = showroomTrafficBean; + } + + + + public String getTraffic() + { + return traffic; + } + + public void setTraffic(String traffic) + { + this.traffic = traffic; + } + + + + public String getModelCode() { + return modelCode; + } + public void setModelCode(String modelCode) { + this.modelCode = modelCode; + } + public String getModelCodeId() { + return modelCodeId; + } + public void setModelCodeId(String modelCodeId) { + this.modelCodeId = modelCodeId; + } + public String getModelId() { + return modelId; + } + public void setModelId(String modelId) { + this.modelId = modelId; + } + public String getTrx() { + return trx; + } + public void setTrx(String trx) { + this.trx = trx; + } + public String getTrxId() { + return trxId; + } + public void setTrxId(String trxId) { + this.trxId = trxId; + } + public String getDealerCode() { + return dealerCode; + } + public void setDealerCode(String dealerCode) { + this.dealerCode = dealerCode; + } + public String getDealerCodeId() { + return dealerCodeId; + } + public void setDealerCodeId(String dealerCodeId) { + this.dealerCodeId = dealerCodeId; + } + public String getName2() + { + return name2; + } + public void setName2(String name2) + { + this.name2 = name2; + } + public String getIsAllocationWarehouse() { + return isAllocationWarehouse; + } + public void setIsAllocationWarehouse(String isAllocationWarehouse) { + this.isAllocationWarehouse = isAllocationWarehouse; + } + + + public String getCanAlterOrder() { + return canAlterOrder; + } + public void setCanAlterOrder(String canAlterOrder) { + this.canAlterOrder = canAlterOrder; + } + public String getCanCreateOrder() { + return canCreateOrder; + } + public void setCanCreateOrder(String canCreateOrder) { + this.canCreateOrder = canCreateOrder; + } + public String getCanViewOrder() { + return canViewOrder; + } + public void setCanViewOrder(String canViewOrder) { + this.canViewOrder = canViewOrder; + } + public String getSalesRepId() { + return salesRepId; + } + public void setSalesRepId(String salesRepId) { + this.salesRepId = salesRepId; + } + public String getAltText() { + return altText; + } + public void setAltText(String altText) { + this.altText = altText; + } + public String getDateFrom() { + return dateFrom; + } + public void setDateFrom(String dateFrom) { + this.dateFrom = dateFrom; + } + public String getDateTo() { + return dateTo; + } + public void setDateTo(String dateTo) { + this.dateTo = dateTo; + } + public String getImagePath() { + return imagePath; + } + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } + public String getImageTitle() { + return imageTitle; + } + public void setImageTitle(String imageTitle) { + this.imageTitle = imageTitle; + } + + public String getEndDate() + { + return endDate; + } + public void setEndDate(String endDate) + { + this.endDate = endDate; + } + public String getStartDate() + { + return startDate; + } + public void setStartDate(String startDate) + { + this.startDate = startDate; + } + public String getWeekNo() + { + return weekNo; + } + public void setWeekNo(String weekNo) + { + this.weekNo = weekNo; + } + public String getFax() + { + return fax; + } + public void setFax(String fax) + { + this.fax = fax; + } + + public String getFinanceOption() + { + return financeOption; + } + public void setFinanceOption(String financeOption) + { + this.financeOption = financeOption; + } + public String getStatus() + { + return status; + } + public void setStatus(String status) + { + this.status = status; + } + + + + public String getCountryOfImpCode() + { + return countryOfImpCode; + } + + + + public void setCountryOfImpCode(String countryOfImpCode) + { + this.countryOfImpCode = countryOfImpCode; + } + + + + public String getEnginePower() + { + return enginePower; + } + + + + public void setEnginePower(String enginePower) + { + this.enginePower = enginePower; + } + + + + public String getMainColourCode() + { + return mainColourCode; + } + + + + public void setMainColourCode(String mainColourCode) + { + this.mainColourCode = mainColourCode; + } + + + + public String getNatisModelNo() + { + return natisModelNo; + } + + + + public void setNatisModelNo(String natisModelNo) + { + this.natisModelNo = natisModelNo; + } + + + + public String getNewVinNumber() + { + return newVinNumber; + } + + + + public void setNewVinNumber(String newVinNumber) + { + this.newVinNumber = newVinNumber; + } + + + + public String getNoOfWheels() + { + return noOfWheels; + } + + + + public void setNoOfWheels(String noOfWheels) + { + this.noOfWheels = noOfWheels; + } + + + + public String getTare() + { + return tare; + } + + + + public void setTare(String tare) + { + this.tare = tare; + } + + + + public String getUnitNumber() + { + return unitNumber; + } + + + + public void setUnitNumber(String unitNumber) + { + this.unitNumber = unitNumber; + } + + public String getAttributesetinstanceIdFrom() { + return attributesetinstanceIdFrom; + } + public void setAttributesetinstanceIdFrom(String attributesetinstanceIdFrom) { + this.attributesetinstanceIdFrom = attributesetinstanceIdFrom; + } + public String getAttributesetinstanceIdTo() { + return attributesetinstanceIdTo; + } + public void setAttributesetinstanceIdTo(String attributesetinstanceIdTo) { + this.attributesetinstanceIdTo = attributesetinstanceIdTo; + } + + public String getReleasedBy() { + return releasedBy; + } + public void setReleasedBy(String releasedBy) { + this.releasedBy = releasedBy; + } + + public Integer[] getProductIds() { + return productIds; + } + public void setProductIds(Integer[] productIds) { + this.productIds = productIds; + } + public String getColourCodeHES() + { + return colourCodeHES; + } + + + + public void setColourCodeHES(String colourCodeHES) + { + this.colourCodeHES = colourCodeHES; + } + public String getNatisModelDescription() + { + return natisModelDescription; + } + + + + public void setNatisModelDescription(String natisModelDescription) + { + this.natisModelDescription = natisModelDescription; + } + + public String getETA() + { + return ETA; + } + public void setETA(String eta) + { + ETA = eta; + } + + public String getETAFilter() + { + return ETAFilter; + } + public void setETAFilter(String filter) + { + ETAFilter = filter; + } + + + public String getEngineCapacity() + { + return engineCapacity; + } + + public void setEngineCapacity(String engineCapacity) + { + this.engineCapacity = engineCapacity; + } + + public Integer[] getOrderIds() + { + return orderIds; + } + public void setOrderIds(Integer[] orderIds) { + this.orderIds = orderIds; + } + + public Integer[] getSernoAttributeSetInstanceIds() + { + return sernoAttributeSetInstanceIds; + } + public void setSernoAttributeSetInstanceIds( + Integer[] sernoAttributeSetInstanceIds) + { + this.sernoAttributeSetInstanceIds = sernoAttributeSetInstanceIds; + } + + + public String getModelDesc() + { + return modelDesc; + } + + public void setModelDesc(String modelDesc) + { + this.modelDesc = modelDesc; + } + + public String getModelMatchID() + { + return modelMatchID; + } + + public void setModelMatchID(String modelMatchID) + { + this.modelMatchID = modelMatchID; + } + + public String getNatisModelDesc() + { + return natisModelDesc; + } + + public void setNatisModelDesc(String natisModelDesc) + { + this.natisModelDesc = natisModelDesc; + } + + public String getTrans() + { + return trans; + } + + public void setTrans(String trans) + { + this.trans = trans; + } + public String getAttributeValueId() { + return attributeValueId; + } + public void setAttributeValueId(String attributeValueId) { + this.attributeValueId = attributeValueId; + } + public String getShowActiveOnly() { + return showActiveOnly; + } + public void setShowActiveOnly(String showActiveOnly) { + this.showActiveOnly = showActiveOnly; + } + public String getUpdateAttrValueId() { + return updateAttrValueId; + } + public void setUpdateAttrValueId(String updateAttrValueId) { + this.updateAttrValueId = updateAttrValueId; + } + + public String getIsVisible() + { + return isVisible; + } + + public void setIsVisible(String isVisible) + { + this.isVisible = isVisible; + } + + public String getActive() + { + return active; + } + + public void setActive(String active) + { + this.active = active; + } + + public String getVisible() + { + return visible; + } + + public void setVisible(String visible) + { + this.visible = visible; + } + + public String getColourName() + { + return colourName; + } + + public void setColourName(String colourName) + { + this.colourName = colourName; + } + + public String getColourCodeMatchId() + { + return colourCodeMatchId; + } + + public void setColourCodeMatchId(String colourCodeMatchId) + { + this.colourCodeMatchId = colourCodeMatchId; + } + + + + public String getBeginingBalance() + { + return beginingBalance; + } + + public void setBeginingBalance(String beginingBalance) + { + this.beginingBalance = beginingBalance; + } + + public String getEndingBalance() + { + return endingBalance; + } + + public void setEndingBalance(String endingBalance) + { + this.endingBalance = endingBalance; + } + + public String getStatementDifference() + { + return statementDifference; + } + + public void setStatementDifference(String statementDifference) + { + this.statementDifference = statementDifference; + } + + public String getAmount() + { + return amount; + } + + + public void setAmount(String amount) + { + this.amount = amount; + } + + + public String getTrxType() + { + return trxType; + } + + + public void setTrxType(String trxType) + { + this.trxType = trxType; + } + + + + public String getAmountGiven() { + return amountGiven; + } + + public void setAmountGiven(String amountGiven) { + this.amountGiven = amountGiven; + } + + public String getAmountRefunded() + { + return amountRefunded; + } + + public void setAmountRefunded(String amountRefunded) + { + this.amountRefunded = amountRefunded; + } + + + + public Integer getCashBookId() + { + return cashBookId; + } + + public void setCashBookId(Integer cashBookId) + { + this.cashBookId = cashBookId; + } + + public String getCashBookName() + { + return cashBookName; + } + + + public void setCashBookName(String cashBookName) + { + this.cashBookName = cashBookName; + } + + + + public String getChequeNo() + { + return chequeNo; + } + + public void setChequeNo(String chequeNo) + { + this.chequeNo = chequeNo; + } + + public String getCreditCardExpMonth() + { + return creditCardExpMonth; + } + + public void setCreditCardExpMonth(String creditCardExpMonth) + { + this.creditCardExpMonth = creditCardExpMonth; + } + + public String getCreditCardExpYear() + { + return creditCardExpYear; + } + + public void setCreditCardExpYear(String creditCardExpYear) + { + this.creditCardExpYear = creditCardExpYear; + } + + public String getCreditCardNumber() + { + return creditCardNumber; + } + + public void setCreditCardNumber(String creditCardNumber) + { + this.creditCardNumber = creditCardNumber; + } + + public String getCreditCardType() + { + return creditCardType; + } + + public void setCreditCardType(String creditCardType) + { + this.creditCardType = creditCardType; + } + + + + public Integer[] getOrderLineIds() + { + return orderLineIds; + } + + public void setOrderLineIds(Integer[] orderLineIds) + { + this.orderLineIds = orderLineIds; + } + + + public Integer[] getPosOrderLineIds() + { + return posOrderLineIds; + } + + public void setPosOrderLineIds(Integer[] posOrderLineIds) + { + this.posOrderLineIds = posOrderLineIds; + } + public String getQtyLarge() + { + return qtyLarge; + } + + public void setQtyLarge(String qtyLarge) + { + this.qtyLarge = qtyLarge; + } + + public String getQtyMedium() + { + return qtyMedium; + } + + public void setQtyMedium(String qtyMedium) + { + this.qtyMedium = qtyMedium; + } + + public String getQtySmall() + { + return qtySmall; + } + + public void setQtySmall(String qtySmall) + { + this.qtySmall = qtySmall; + } + + public String getQtyXLarge() + { + return qtyXLarge; + } + + public void setQtyXLarge(String qtyXLarge) + { + this.qtyXLarge = qtyXLarge; + } + + public String getClientName() + { + return clientName; + } + + public void setClientName(String clientName) + { + this.clientName = clientName; + } + + + + public String getCashBookIds() { + return cashBookIds; + } + public void setCashBookIds(String cashBookIds) { + this.cashBookIds = cashBookIds; + } + public String getTransferAmount() { + return transferAmount; + } + public void setTransferAmount(String transferAmount) { + this.transferAmount = transferAmount; + } + public String getApplicationName() { + return applicationName; + } + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + + public String getPosId() { + return this.posId; + } + + public String getBackOrder() + { + return backOrder; + } + + public void setBackOrder(String backOrder) + { + this.backOrder = backOrder; + } + + public String getDesignAttributeValueId() + { + return designAttributeValueId; + } + + public void setDesignAttributeValueId(String designAttributeValueId) + { + this.designAttributeValueId = designAttributeValueId; + } + + public String getFieldName() + { + return fieldName; + } + + public void setFieldName(String fieldName) + { + this.fieldName = fieldName; + } + + public String getKeyword() + { + return keyword; + } + + public void setKeyword(String keyword) + { + this.keyword = keyword; + } + + public String getSearchText() + { + return searchText; + } + + public void setSearchText(String searchText) + { + this.searchText = searchText; + } + + public String getShoppingCartItemId() + { + return shoppingCartItemId; + } + + public void setShoppingCartItemId(String shoppingCartItemId) + { + this.shoppingCartItemId = shoppingCartItemId; + } + + public String getSizeAttributeValueId() + { + return sizeAttributeValueId; + } + + public void setSizeAttributeValueId(String sizeAttributeValueId) + { + this.sizeAttributeValueId = sizeAttributeValueId; + } + + public String getIsNotWebstoreFeatured() + { + return isNotWebstoreFeatured; + } + + public void setIsNotWebstoreFeatured(String isNotWebstoreFeatured) + { + this.isNotWebstoreFeatured = isNotWebstoreFeatured; + } + + public String getIsWebstoreFeatured() + { + return isWebstoreFeatured; + } + + public void setIsWebstoreFeatured(String isWebstoreFeatured) + { + this.isWebstoreFeatured = isWebstoreFeatured; + } + + public String getImageName() + { + return imageName; + } + + public void setImageName(String imageName) + { + this.imageName = imageName; + } + + public ProductImageBean getProductsIndexed() + { + return productsIndexed; + } + + public ProductImageBean getProductsIndexed(int index) + { + while (index >= productsList.size()) + productsList.add(new ProductImageBean()); + return (ProductImageBean) productsList.get(index); + } + + public void setProductsIndexed(ProductImageBean productsIndexed) + { + this.productsIndexed = productsIndexed; + } + + public void setProductsIndexed(int index, ProductImageBean value) + { + productsList.add(index, value); + } + public void setPosId(String posId) { + this.posId = posId; + } + + public String getBarCode() { + return barCode; + } + public void setBarCode(String barCode) { + this.barCode = barCode; + } + public String getPurchasePriceStandard() { + return purchasePriceStandard; + } + public void setPurchasePriceStandard(String purchasePriceStandard) { + this.purchasePriceStandard = purchasePriceStandard; + } + + + public String getPurchasePriceLimit() { + return purchasePriceLimit; + } + public void setPurchasePriceLimit(String purchasePriceLimit) { + this.purchasePriceLimit = purchasePriceLimit; + } + public String getPurchasePriceList() { + return purchasePriceList; + } + public void setPurchasePriceList(String purchasePriceList) { + this.purchasePriceList = purchasePriceList; + } + public String getSalesPriceLimit() { + return salesPriceLimit; + } + public void setSalesPriceLimit(String salesPriceLimit) { + this.salesPriceLimit = salesPriceLimit; + } + public String getSalesPriceList() { + return salesPriceList; + } + public void setSalesPriceList(String salesPriceList) { + this.salesPriceList = salesPriceList; + } + public String getSalesPriceStandard() { + return salesPriceStandard; + } + public void setSalesPriceStandard(String salesPriceStandard) { + this.salesPriceStandard = salesPriceStandard; + } + public String getNoOfProductsRequired() { + return noOfProductsRequired; + } + public void setNoOfProductsRequired(String noOfProductsRequired) { + this.noOfProductsRequired = noOfProductsRequired; + } + public String getReportType() { + return reportType; + } + public void setReportType(String reportType) { + this.reportType = reportType; + } + + public String getUserSurname() { + return userSurname; + } + public void setUserSurname(String userSurname) { + this.userSurname = userSurname; + } + public String getCountryId() { + return countryId; + } + public void setCountryId(String countryId) { + this.countryId = countryId; + } + public String getCountryName() { + return countryName; + } + public void setCountryName(String countryName) { + this.countryName = countryName; + } + + public ArrayList getProductsList() + { + return productsList; + } + + public void setProductsList(ArrayList productsList) + { + this.productsList = productsList; + } + + public String getNewName() + { + return newName; + } + + public void setNewName(String newName) + { + this.newName = newName; + } + public String getPaymentByCard() { + return paymentByCard; + } + public void setPaymentByCard(String paymentByCard) { + this.paymentByCard = paymentByCard; + } + public String getPaymentByCash() { + return paymentByCash; + } + public void setPaymentByCash(String paymentByCash) { + this.paymentByCash = paymentByCash; + } + public String getPaymentByChq() { + return paymentByChq; + } + public void setPaymentByChq(String paymentByChq) { + this.paymentByChq = paymentByChq; + } + public String getIsSales() { + return isSales; + } + public void setIsSales(String isSales) { + this.isSales = isSales; + } + public String getProductClassification() { + return productClassification; + } + + public void setProductClassification(String productClassification) { + this.productClassification = productClassification; + } + + + public String getTrackingNo() { + return trackingNo; + } + + + public void setTrackingNo(String trackingNo) { + this.trackingNo = trackingNo; + } + + public String[] getSizes() + { + return sizes; + } + public void setSizes(String[] sizes) + { + this.sizes = sizes; + } + + public String getRevenueRecognition() + { + return revenueRecognition; + } + public void setRevenueRecognition(String revenueRecognition) + { + this.revenueRecognition = revenueRecognition; + } + public String getBrandName() + { + return brandName; + } + + public void setBrandName(String brandName) + { + this.brandName = brandName; + } + public String getDesignName() + { + return designName; + } + + public void setDesignName(String designName) { + this.designName = designName; + } + + public String getModelName() { + return modelName; + } + + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getProductCategory() { + return productCategory; + } + + public void setProductCategory(String productCategory) + { + this.productCategory = productCategory; + } + + public String getSizeName() + { + return sizeName; + } + + public String getRevenueRecoId() + { + return revenueRecoId; + } + + + public void setRevenueRecoId(String revenueRecoId) + { + this.revenueRecoId = revenueRecoId; + } + + + public void setSizeName(String sizeName) + { + this.sizeName = sizeName; + } + + + + public String getIsTextileProduct() + { + return isTextileProduct; + } + + + public void setIsTextileProduct(String isTextileProduct) + { + this.isTextileProduct = isTextileProduct; + } + + + public String getQtyFilter() + { + return qtyFilter; + } + + + public void setQtyFilter(String qtyFilter) + { + this.qtyFilter = qtyFilter; + } + public ArrayList getAttributeValueList() { + return attributeValueList; + } + public void setAttributeValueList(ArrayList attributeValueList) { + this.attributeValueList = attributeValueList; + } + public String[] getAttributeValueIds() { + return attributeValueIds; + } + public void setAttributeValueIds(String[] attributeValueIds) { + this.attributeValueIds = attributeValueIds; + } + + + + public String getCvv() + { + return cvv; + } + + public void setCvv(String cvv) + { + this.cvv = cvv; + } + + + + + public String getCreditCardPayment() + { + return creditCardPayment; + } + + + + + public void setCreditCardPayment(String creditCardPayment) + { + this.creditCardPayment = creditCardPayment; + } + + + + + + + + + public String getRequestId() + { + return requestId; + } + + public void setRequestId(String requestId) + { + this.requestId = requestId; + } + + + + + public String getBccAddresses() + { + return bccAddresses; + } + + + + + public void setBccAddresses(String bccAddresses) + { + this.bccAddresses = bccAddresses; + } + + + + + public String getCcAddresses() + { + return ccAddresses; + } + + + + + public void setCcAddresses(String ccAddresses) + { + this.ccAddresses = ccAddresses; + } + + + + + public String getFromAddress() + { + return fromAddress; + } + + + + + public void setFromAddress(String fromAddress) + { + this.fromAddress = fromAddress; + } + + + + + public String getTextMessage() + { + return textMessage; + } + + + + + public void setTextMessage(String textMessage) + { + this.textMessage = textMessage; + } + + + + + public String getToAddresses() + { + return toAddresses; + } + + + + + public void setToAddresses(String toAddresses) + { + this.toAddresses = toAddresses; + } + + + + + public String getShipperId() + { + return shipperId; + } + + + + + public void setShipperId(String shipperId) + { + this.shipperId = shipperId; + } + + + + + public String getAccountName() + { + return accountName; + } + + + + + public void setAccountName(String accountName) + { + this.accountName = accountName; + } + + + + + public String getCreditCardExpMonthName() + { + return creditCardExpMonthName; + } + + + + + public void setCreditCardExpMonthName(String creditCardExpMonthName) + { + this.creditCardExpMonthName = creditCardExpMonthName; + } + + + + + public String getCreditCardNumberEncrypted() + { + return creditCardNumberEncrypted; + } + + + + + public void setCreditCardNumberEncrypted(String creditCardNumberEncrypted) + { + this.creditCardNumberEncrypted = creditCardNumberEncrypted; + } + + + + + public String getPaymentMethod() + { + return paymentMethod; + } + + + + + public void setPaymentMethod(String paymentMethod) + { + this.paymentMethod = paymentMethod; + } + + + public String getToUserId() + { + return toUserId; + } + + + + + public void setToUserId(String toUserId) + { + this.toUserId = toUserId; + } + + + + + public String getPriority() + { + return priority; + } + + public void setPriority(String priority) + { + this.priority = priority; + } + public String getTitle() + { + return title; + } + public void setTitle(String title) + { + this.title = title; + } + public String getChargeId() + { + return chargeId; + } + public void setChargeId(String chargeId) + { + this.chargeId = chargeId; + } + public String getStatusId() + { + return statusId; + } + public void setStatusId(String statusId) + { + this.statusId = statusId; + } + public String getProductType() + { + return productType; + } + public void setProductType(String productType) + { + this.productType = productType; + } + public String getQtyNumberFilter() + { + return qtyNumberFilter; + } + public void setQtyNumberFilter(String qtyNumberFilter) + { + this.qtyNumberFilter = qtyNumberFilter; + } + public String getTaxCategoryId() + { + return taxCategoryId; + } + public void setTaxCategoryId(String taxCategoryId) + { + this.taxCategoryId = taxCategoryId; + } + public String getTaxCategoryName() + { + return taxCategoryName; + } + public void setTaxCategoryName(String taxCategoryName) + { + this.taxCategoryName = taxCategoryName; + } + public String getTotalActualPrice() + { + return totalActualPrice; + } + public void setTotalActualPrice(String totalActualPrice) + { + this.totalActualPrice = totalActualPrice; + } + public String getIfAdd() { + return ifAdd; + } + public void setIfAdd(String ifAdd) { + this.ifAdd = ifAdd; + } + public String getVendorName() { + return vendorName; + } + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + public String getTimePeriod() { + return timePeriod; + } + public void setTimePeriod(String timePeriod) { + this.timePeriod = timePeriod; + } + + public String getChartType() { + return chartType; + } + public void setChartType(String chartType) { + this.chartType = chartType; + } + + public String getTaxRate() { + return taxRate; + } + + + public void setTaxRate(String taxRate) { + this.taxRate = taxRate; + } + + + public String getState() + { + return state; + } + public void setState(String state) + { + this.state = state; + } + + public String getAccountId() { + return accountId; + } + public void setAccountId(String accountId) { + this.accountId = accountId; + } + public String getDateRange() { + return dateRange; + } + public void setDateRange(String dateRange) { + this.dateRange = dateRange; + } + public String getReportName() { + return reportName; + } + public void setReportName(String reportName) { + this.reportName = reportName; + } + + + public String getTransferAllAmount() { + return transferAllAmount; + } + + + public void setTransferAllAmount(String transferAllAmount) { + this.transferAllAmount = transferAllAmount; + } + + + public String getAdjustmentAmount() { + return adjustmentAmount; + } + + + public void setAdjustmentAmount(String adjustmentAmount) { + this.adjustmentAmount = adjustmentAmount; + } + + + public String getDifferenceAmt() { + return differenceAmt; + } + + + public void setDifferenceAmt(String differenceAmt) { + this.differenceAmt = differenceAmt; + } + + + public String getCardTotal() { + return cardTotal; + } + + + public void setCardTotal(String cardTotal) { + this.cardTotal = cardTotal; + } + + + public String getCashTotal() { + return cashTotal; + } + + + public void setCashTotal(String cashTotal) { + this.cashTotal = cashTotal; + } + + + public String getChequeTotal() { + return chequeTotal; + } + + + public void setChequeTotal(String chequeTotal) { + this.chequeTotal = chequeTotal; + } + + + public String getTillGrandTotal() { + return tillGrandTotal; + } + + + public void setTillGrandTotal(String tillGrandTotal) { + this.tillGrandTotal = tillGrandTotal; + } + + + public String getCreatingFromOrder() { + return creatingFromOrder; + } + + + public void setCreatingFromOrder(String creatingFromOrder) { + this.creatingFromOrder = creatingFromOrder; + } + + + public String getTransferType() { + return transferType; + } + + + public void setTransferType(String transferType) { + this.transferType = transferType; + } +public String getCustomSize() { + return customSize; + } + + + public void setCustomSize(String customSize) { + this.customSize = customSize; + } + + + public String getPriceQtyFilter() { + return priceQtyFilter; + } + + public String getDeliveryViaRule() + { + return deliveryViaRule; + } + + + public void setPriceQtyFilter(String priceQtyFilter) { + this.priceQtyFilter = priceQtyFilter; + } + + public void setDeliveryViaRule(String deliveryViaRule) + { + this.deliveryViaRule = deliveryViaRule; + } + + + public String getCashId() + { + return cashId; + } + + + public void setCashId(String cashId) + { + this.cashId = cashId; + } + + + public String getCashLineId() + { + return cashLineId; + } + + + public void setCashLineId(String cashLineId) + { + this.cashLineId = cashLineId; + } + public String getUserPIN() { + return userPIN; + } + + + public void setUserPIN(String userPIN) { + this.userPIN = userPIN; + } + + public String getPaymentRule() { + return paymentRule; + } + + + public void setPaymentRule(String paymentRule) { + this.paymentRule = paymentRule; + } + + public String getIsSelfService() + { + return isSelfService; + } + + + public void setIsSelfService(String isSelfService) + { + this.isSelfService = isSelfService; + } + + + public String getCardDifference() { + return cardDifference; + } + + + public void setCardDifference(String cardDifference) { + this.cardDifference = cardDifference; + } + + + public String getChequeDifference() { + return chequeDifference; + } + + + public void setChequeDifference(String chequeDifference) { + this.chequeDifference = chequeDifference; + } + + + + public String getDocumentNote() + { + return documentNote; + } + + + public void setDocumentNote(String documentNote) + { + this.documentNote = documentNote; + } + + + public String getCurrencySymbole() { + return currencySymbole; + } + + + public void setCurrencySymbole(String currencySymbole) { + this.currencySymbole = currencySymbole; + } + +public String getUserDiscount() { + return userDiscount; + } + + + public void setUserDiscount(String userDiscount) { + this.userDiscount = userDiscount; + } + + + public String getOpenAmt() { + return openAmt; + } + + + public void setOpenAmt(String openAmt) { + this.openAmt = openAmt; + } + + + public String getOverUnderPayment() { + return overUnderPayment; + } + + + public void setOverUnderPayment(String overUnderPayment) { + this.overUnderPayment = overUnderPayment; + } + + + public String getPaidAmt() { + return paidAmt; + } + + + public void setPaidAmt(String paidAmt) { + this.paidAmt = paidAmt; + } + + + public String getPaymentAmt() { + return paymentAmt; + } + + + public void setPaymentAmt(String paymentAmt) { + this.paymentAmt = paymentAmt; + } + + + public String getWriteOffAmt() { + return writeOffAmt; + } + + + public void setWriteOffAmt(String writeOffAmt) { + this.writeOffAmt = writeOffAmt; + } + + + + public String getCurrencyId() { + return currencyId; + } + + + public void setCurrencyId(String currencyId) { + this.currencyId = currencyId; + } + + + public String getDaysDue() { + return daysDue; + } + + + public void setDaysDue(String daysDue) { + this.daysDue = daysDue; + } + + + public String getDiscountAmt() { + return discountAmt; + } + + + public void setDiscountAmt(String discountAmt) { + this.discountAmt = discountAmt; + } + + + public String getDiscountDate() { + return discountDate; + } + + + public void setDiscountDate(String discountDate) { + this.discountDate = discountDate; + } + + + public String getDue0() { + return due0; + } + + + public void setDue0(String due0) { + this.due0 = due0; + } + + + public String getDue0_30() { + return due0_30; + } + + + public void setDue0_30(String due0_30) { + this.due0_30 = due0_30; + } + + + public String getDue1_7() { + return due1_7; + } + + + public void setDue1_7(String due1_7) { + this.due1_7 = due1_7; + } + + + public String getDue31_60() { + return due31_60; + } + + + public void setDue31_60(String due31_60) { + this.due31_60 = due31_60; + } + + + public String getDue61_90() { + return due61_90; + } + + + public void setDue61_90(String due61_90) { + this.due61_90 = due61_90; + } + + + public String getDue8_30() { + return due8_30; + } + + + public void setDue8_30(String due8_30) { + this.due8_30 = due8_30; + } + + + public String getDue91_PLUS() { + return due91_PLUS; + } + + + public void setDue91_PLUS(String due91_PLUS) { + this.due91_PLUS = due91_PLUS; + } + + + public String getDueAmt() { + return dueAmt; + } + + + public void setDueAmt(String dueAmt) { + this.dueAmt = dueAmt; + } + + + public String getDueDate() { + return dueDate; + } + + + public void setDueDate(String dueDate) { + this.dueDate = dueDate; + } + + + public String getInvoicedAmt() { + return invoicedAmt; + } + + + public void setInvoicedAmt(String invoicedAmt) { + this.invoicedAmt = invoicedAmt; + } + + + public String getInvoiceDate() { + return invoiceDate; + } + + + public void setInvoiceDate(String invoiceDate) { + this.invoiceDate = invoiceDate; + } + + + public String getInvoiceGrandTotal() { + return invoiceGrandTotal; + } + + + public void setInvoiceGrandTotal(String invoiceGrandTotal) { + this.invoiceGrandTotal = invoiceGrandTotal; + } + + + public String getInvoiceScheduleId() { + return invoiceScheduleId; + } + + + public void setInvoiceScheduleId(String invoiceScheduleId) { + this.invoiceScheduleId = invoiceScheduleId; + } + + + public String getNetDays() { + return netDays; + } + + + public void setNetDays(String netDays) { + this.netDays = netDays; + } + + + public String getPastDue1_30() { + return pastDue1_30; + } + + + public void setPastDue1_30(String pastDue1_30) { + this.pastDue1_30 = pastDue1_30; + } + + + public String getPastDue1_7() { + return pastDue1_7; + } + + + public void setPastDue1_7(String pastDue1_7) { + this.pastDue1_7 = pastDue1_7; + } + + + public String getPastDue31_60() { + return pastDue31_60; + } + + + public void setPastDue31_60(String pastDue31_60) { + this.pastDue31_60 = pastDue31_60; + } + + + public String getPastDue61_90() { + return pastDue61_90; + } + + + public void setPastDue61_90(String pastDue61_90) { + this.pastDue61_90 = pastDue61_90; + } + + + public String getPastDue8_30() { + return pastDue8_30; + } + + + public void setPastDue8_30(String pastDue8_30) { + this.pastDue8_30 = pastDue8_30; + } + + + public String getPastDue91_plus() { + return pastDue91_plus; + } + + + public void setPastDue91_plus(String pastDue91_plus) { + this.pastDue91_plus = pastDue91_plus; + } + + + public String getPastDueAmt() { + return pastDueAmt; + } + + + public void setPastDueAmt(String pastDueAmt) { + this.pastDueAmt = pastDueAmt; + } + + + public String getPaymentTermId() { + return paymentTermId; + } + + + public void setPaymentTermId(String paymentTermId) { + this.paymentTermId = paymentTermId; + } + + + public FormFile getImage() + { + return image; + } + + + public void setImage(FormFile image) + { + this.image = image; + } + + + public String getBlackListedId() + { + return blackListedId; + } + + + public void setBlackListedId(String blackListedId) + { + this.blackListedId = blackListedId; + } + + + public String getBlackListedBankName() + { + return blackListedBankName; + } + + + public void setBlackListedBankName(String blackListedBankName) + { + this.blackListedBankName = blackListedBankName; + } + + + public String getBlackListedChequeNo() + { + return blackListedChequeNo; + } + + + public void setBlackListedChequeNo(String blackListedChequeNo) + { + this.blackListedChequeNo = blackListedChequeNo; + } + + public String getInvoiceNo() + { + + return invoiceNo; + } + public void setInvoiceNo(String invoiceNo) + { + this.invoiceNo = invoiceNo; + } + + + + + + + public Integer[] getBpartnerIds() { + return bpartnerIds; + } + + + public void setBpartnerIds(Integer[] bpartnerIds) { + this.bpartnerIds = bpartnerIds; + } + + + public String getPaymentTermName() { + return paymentTermName; + } + + + public void setPaymentTermName(String paymentTermName) { + this.paymentTermName = paymentTermName; + } + + + public String getBP_Group_ID() { + return BP_Group_ID; + } + + + public void setBP_Group_ID(String group_ID) { + BP_Group_ID = group_ID; + } + + + public String getDunningLevelId() { + return dunningLevelId; + } + + + public void setDunningLevelId(String dunningLevelId) { + this.dunningLevelId = dunningLevelId; + } + + + public String getDunningLevelName() { + return dunningLevelName; + } + + + public void setDunningLevelName(String dunningLevelName) { + this.dunningLevelName = dunningLevelName; + } + + + public String getDunningPrintNote() { + return dunningPrintNote; + } + + + public void setDunningPrintNote(String dunningPrintNote) { + this.dunningPrintNote = dunningPrintNote; + } + + + public String getDunningPrintText() { + return dunningPrintText; + } + + + public void setDunningPrintText(String dunningPrintText) { + this.dunningPrintText = dunningPrintText; + } + + + + + public String getDunningId() { + return dunningId; + } + + + public void setDunningId(String dunningId) { + this.dunningId = dunningId; + } + + + public String getDunningName() { + return dunningName; + } + + + public void setDunningName(String dunningName) { + this.dunningName = dunningName; + } + + + public String getCreditLimit() { + return creditLimit; + } + + + public void setCreditLimit(String creditLimit) { + this.creditLimit = creditLimit; + } + + + public String getCreditStatus() { + return creditStatus; + } + + + public void setCreditStatus(String creditStatus) { + this.creditStatus = creditStatus; + } + + + public String getCreditUsed() { + return creditUsed; + } + + + public void setCreditUsed(String creditUsed) { + this.creditUsed = creditUsed; + } + + + public String getDocBasisType() { + return docBasisType; + } + + + public void setDocBasisType(String docBasisType) { + this.docBasisType = docBasisType; + } + + + public String getAmtMultiplier() { + return amtMultiplier; + } + + + public void setAmtMultiplier(String amtMultiplier) { + this.amtMultiplier = amtMultiplier; + } + + + public String getFrequencyType() { + return frequencyType; + } + + + public void setFrequencyType(String frequencyType) { + this.frequencyType = frequencyType; + } + + + public String getCommissionAmtId() { + return commissionAmtId; + } + + + public void setCommissionAmtId(String commissionAmtId) { + this.commissionAmtId = commissionAmtId; + } + + + public String getSubtractAmt() { + return subtractAmt; + } + + + public void setSubtractAmt(String subtractAmt) { + this.subtractAmt = subtractAmt; + } + + + public String getForward() { + return forward; + } + + + public void setForward(String forward) { + this.forward = forward; + } + + + public String getIsTaxExempted() { + return isTaxExempted; + } + + + public void setIsTaxExempted(String isTaxExempted) { + this.isTaxExempted = isTaxExempted; + } + + + public String getTaxId() { + return taxId; + } + + + public void setTaxId(String taxId) { + this.taxId = taxId; + } + + + public String getTaxName() { + return taxName; + } + + + public void setTaxName(String taxName) { + this.taxName = taxName; + } + + + public Integer[] getInvoiceIds() { + return invoiceIds; + } + + + public void setInvoiceIds(Integer[] invoiceIds) { + this.invoiceIds = invoiceIds; + } + + + public String getInventoryId() { + return inventoryId; + } + + + public void setInventoryId(String inventoryId) { + this.inventoryId = inventoryId; + } + + + public String getInventoryLineId() { + return inventoryLineId; + } + + + public void setInventoryLineId(String inventoryLineId) { + this.inventoryLineId = inventoryLineId; + } + + + public String getQtyBook() { + return qtyBook; + } + + + public void setQtyBook(String qtyBook) { + this.qtyBook = qtyBook; + } + + + public String getQtyCount() { + return qtyCount; + } + + + public void setQtyCount(String qtyCount) { + this.qtyCount = qtyCount; + } + + + public String getAfterDelivery() { + return afterDelivery; + } + + + public void setAfterDelivery(String afterDelivery) { + this.afterDelivery = afterDelivery; + } + + + public String getFiedMonthCutoff() { + return fiedMonthCutoff; + } + + + public void setFiedMonthCutoff(String fiedMonthCutoff) { + this.fiedMonthCutoff = fiedMonthCutoff; + } + + + public String getFixedDueDate() { + return fixedDueDate; + } + + + public void setFixedDueDate(String fixedDueDate) { + this.fixedDueDate = fixedDueDate; + } + + + public String getFixedMonthDay() { + return fixedMonthDay; + } + + + public void setFixedMonthDay(String fixedMonthDay) { + this.fixedMonthDay = fixedMonthDay; + } + + + public String getFixedMonthOffset() { + return fixedMonthOffset; + } + + + public void setFixedMonthOffset(String fixedMonthOffset) { + this.fixedMonthOffset = fixedMonthOffset; + } + + + public String getNextBusinessday() { + return nextBusinessday; + } + + + public void setNextBusinessday(String nextBusinessday) { + this.nextBusinessday = nextBusinessday; + } + + + public String getPhone() { + return phone; + } + + + public void setPhone(String phone) { + this.phone = phone; + } + + + public String getPhone2() { + return phone2; + } + + + public void setPhone2(String phone2) { + this.phone2 = phone2; + } + + public String getToBeShipped() { + return toBeShipped; + } + + + public void setToBeShipped(String toBeShipped) { + this.toBeShipped = toBeShipped; + } + + + public String getDiscountAmt1() { + return discountAmt1; + } + + + public void setDiscountAmt1(String discountAmt1) { + this.discountAmt1 = discountAmt1; + } + + + public String getDiscountAmt2() { + return discountAmt2; + } + + + public void setDiscountAmt2(String discountAmt2) { + this.discountAmt2 = discountAmt2; + } + + + public String getDiscountDay1() { + return discountDay1; + } + + + public void setDiscountDay1(String discountDay1) { + this.discountDay1 = discountDay1; + } + + + public String getDiscountDay2() { + return discountDay2; + } + + + public void setDiscountDay2(String discountDay2) { + this.discountDay2 = discountDay2; + } + + + + + + + + public PaymentBean getPaymentBeanIndex() { + return paymentBeanIndex; + } + + + public void setPaymentBeanIndex(PaymentBean paymentBeanIndex) { + this.paymentBeanIndex = paymentBeanIndex; + } + + + public String getAllocatedAmount() { + return allocatedAmount; + } + + + public void setAllocatedAmount(String allocatedAmount) { + this.allocatedAmount = allocatedAmount; + } + + + public String getGroup1() { + return group1; + } + + + public void setGroup1(String group1) { + this.group1 = group1; + } + + + public String getGroup2() { + return group2; + } + + + public void setGroup2(String group2) { + this.group2 = group2; + } + + + + public String getIsFullAccess() { + return isFullAccess; + } + + + public void setIsFullAccess(String isFullAccess) { + this.isFullAccess = isFullAccess; + } + + + public Integer[] getInventoryIds() + { + return inventoryIds; + } + + + public void setInventoryIds(Integer[] inventoryIds) + { + this.inventoryIds = inventoryIds; + } + + + public String[] getAllocateAmount() { + return allocateAmount; + } + + + public void setAllocateAmount(String[] allocateAmount) { + this.allocateAmount = allocateAmount; + } + + + public String getBirthdate() { + return birthdate; + } + + + public void setBirthdate(String birthdate) { + this.birthdate = birthdate; + } + + + public String getDay() { + return day; + } + + + public void setDay(String day) { + this.day = day; + } + + + public String getOpenDrawer() { + return openDrawer; + } + + + public void setOpenDrawer(String openDrawer) { + this.openDrawer = openDrawer; + } + +} + + + + diff --git a/posterita/src/main/org/posterita/struts/customer/CustomerAction.java b/posterita/src/main/org/posterita/struts/customer/CustomerAction.java new file mode 100644 index 0000000000..0ccd2c5e2f --- /dev/null +++ b/posterita/src/main/org/posterita/struts/customer/CustomerAction.java @@ -0,0 +1,760 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 02-Sep-2005 + */ + + +package org.posterita.struts.customer; + +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MBPartner; +import org.compiere.util.Trx; +import org.posterita.Constants; +import org.posterita.beans.CustomerBean; +import org.posterita.businesslogic.CustomerCart; +import org.posterita.businesslogic.CustomerManager; +import org.posterita.businesslogic.PaymentTermManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.core.EmailValidator; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BPartnerNotFoundException; +import org.posterita.exceptions.NoCustomerFoundException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.SurnameNotPresentException; +import org.posterita.exceptions.SystemException; +import org.posterita.form.CustomerForm; +import org.posterita.form.InitCustomerForm; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + + +public class CustomerAction extends BaseDispatchAction +{ + public static final String CREATE_CUSTOMER = "createCustomer"; + public static final String RETURN_TO_ORDER = "returnToOrder"; + + public ActionForward createCustomer(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + CustomerBean bean = (CustomerBean)request.getSession().getAttribute(Constants.CUSTOMER_DETAILS); + + String email = bean.getEmail(); + + if( email != null ) + { + boolean isValid = EmailValidator.isValidEmail(email); + if( !isValid ) + { + postGlobalError("errors.invalid","email", request); + return mapping.getInputForward(); + } + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + trx.start(); + try + { + MBPartner partner = CustomerManager.saveCustomer(ctx,bean.getBpartnerId() ,bean, trx.getTrxName()); + Integer customerId = Integer.valueOf(partner.get_ID()); + request.getSession().setAttribute(Constants.CUSTOMER_ID, customerId); + trx.commit(); + } + catch (SurnameNotPresentException e) + { + trx.rollback(); + postGlobalError("error.required.Surname", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + if(bean.getCreatingFromOrder()) + return new ActionForward("RETURN_TO_ORDER"); + else + return mapping.findForward(CREATE_CUSTOMER); + } + + public static final String CREATE_POS_ORDER = "createPOSOrder"; + public static final String CREATE_CREDIT_ORDER = "initCreateCreditOrder"; + public static final String CREATE_POS_ORDER2 = "createPOSOrder2"; + public static final String CREATE_POS_ORDER3 = "createPOSOrder3"; + public static final String CREATE_POS_ORDER_WA = "createPOSOrderWA"; + public static final String SAVE_POS_CUSTOMER = "savePOSCustomer"; + public static final String CREATE_PAYMENT = "createPayment"; + public ActionForward savePOSCustomer(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm)form; + String creatingForOrder=(String)request.getSession().getAttribute(Constants.CREATING_FROM_ORDER); + CustomerBean bean = (CustomerBean)df.getBean(); + bean.setRegionId(Integer.valueOf(1000001));//FIXME why do we need regionId? Is it compulsory? + + String email = bean.getEmail(); + + if( email != null ) + { + boolean isValid = EmailValidator.isValidEmail(email); + if( !isValid ) + { + postGlobalError("errors.invalid","email", request); + return mapping.getInputForward(); + } + } + if(bean.getBpartnerId()==null) + { + bean.setBpartnerId(0); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + trx.start(); + try + { + MBPartner partner = CustomerManager.saveCustomer(ctx, bean.getBpartnerId(), bean, trx.getTrxName()); + + request.getSession().setAttribute(Constants.CUSTOMER_ID, partner.get_ID()); + trx.commit(); + } + catch (SurnameNotPresentException e) + { + trx.rollback(); + postGlobalError("error.required.Surname", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + if (creatingForOrder == null) + return mapping.findForward(SAVE_POS_CUSTOMER); + + if (creatingForOrder.equals(Constants.POS_ORDER)) + return mapping.findForward(CREATE_POS_ORDER); + else + if (creatingForOrder.equals(Constants.CREDIT_ORDER)) + return mapping.findForward(CREATE_CREDIT_ORDER); + else + if (creatingForOrder.equals(Constants.CREATE_PAYMENT)) + return mapping.findForward(CREATE_PAYMENT); + else + if (creatingForOrder.equals(Constants.POS_ORDER_CUSTOMER_COMPULSORY)) + return mapping.findForward(CREATE_POS_ORDER2); + else + if (creatingForOrder.equals(Constants.QUICK_POS_ORDER)) + return mapping.findForward(CREATE_POS_ORDER3); + else + if (creatingForOrder.equals(Constants.POS_ORDER_WITHOUT_ADVANCED)) + return mapping.findForward(CREATE_POS_ORDER_WA); + + return mapping.findForward(SAVE_POS_CUSTOMER); + } + + public static final String GET_EXISTING_CUSTOMERS = "getExistingCustomers"; + public ActionForward getExistingCustomers(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, SQLException + { + ActionForward fwd = init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList customers = CustomerManager.getAllCustomers(ctx,false); + + request.getSession().setAttribute(Constants.ALL_CUSTOMERS, customers); + + return mapping.findForward(GET_EXISTING_CUSTOMERS); + } + + + public static final String GET_EXISTING_POS_CUSTOMERS = "getExistingPOSCustomers"; + public ActionForward getExistingPOSCustomers(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, SQLException + { + ActionForward fwd = init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + + Properties ctx=TmkJSPEnv.getCtx(request); + + ArrayList customers = CustomerManager.getAllCustomers(ctx,true); + + request.getSession().setAttribute(Constants.ALL_CUSTOMERS, customers); + + return mapping.findForward(GET_EXISTING_POS_CUSTOMERS); + } + + + public static final String GET_CUSTOMER_DETAILS = "getCustomerDetails"; + public ActionForward getCustomerDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + Integer partnerId = Integer.valueOf(df.getBpartnerId()); + + CustomerBean customerBean = CustomerManager.getCustomerDetails(ctx, partnerId.intValue()); + + request.getSession().setAttribute(Constants.CUSTOMER_DETAILS, customerBean); + + return mapping.findForward(GET_CUSTOMER_DETAILS); + } + + + public static final String INIT_CREATE_POS_CUSTOMER_ACTION = "initCreatePOSCustomer"; + public ActionForward initCreatePOSCustomer(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, SystemException + { + ActionForward fwd = init(mapping,form,request,response); + + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + InitCustomerForm cf = (InitCustomerForm) form; + + CustomerBean bean = (CustomerBean) cf.getBean(); + bean.setBpartnerId(0); + String creatingFromOrder= cf.getCreatingFromOrder(); + cf.populate(bean); + + + ArrayList list = PaymentTermManager.getAllActivePaymentTerm(ctx); + request.getSession().setAttribute (Constants.PAYMENT_TERM,list); + + request.getSession().setAttribute(Constants.CREATING_FROM_ORDER, creatingFromOrder); + + return mapping.findForward(INIT_CREATE_POS_CUSTOMER_ACTION); + } + + public static final String GET_ALL_CUSTOMER = "getAllPOSCustomer"; + public ActionForward getAllPOSCustomer(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList customerList = CustomerManager.getAllPosCustomer(ctx); + + request.getSession().setAttribute(Constants.ALL_CUSTOMERS,customerList); + + return mapping.findForward(GET_ALL_CUSTOMER); + } + + + public static final String INIT_EDIT_POS_CUSTOMER = "initEditPOSCustomer"; + public ActionForward initEditPOSCustomer(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + + CustomerForm f = (CustomerForm) form; + f.validate(mapping,request); + + CustomerBean bean = (CustomerBean) f.getBean(); + Integer bpartnerId = bean.getBpartnerId(); + if(bpartnerId==null) + { + throw new OperationException("Cannot edit customer. Cause customer id cannot be null!"); + } + + + bean = CustomerManager.getCustomerDetails(ctx,bpartnerId); + f.populate(bean); + ArrayList list = PaymentTermManager.getAllActivePaymentTerm(ctx); + request.getSession().setAttribute (Constants.PAYMENT_TERM,list); + + return mapping.findForward(INIT_EDIT_POS_CUSTOMER); + } + + + public static final String VIEW_POS_CUSTOMER = "viewPOSCustomer"; + public ActionForward viewPOSCustomer(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException,Exception + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + CustomerForm f = (CustomerForm) form; + f.validate(mapping,request); + + CustomerBean bean = (CustomerBean) f.getBean(); + Integer bpartnerId = bean.getBpartnerId(); + if(bpartnerId==null) + { + throw new OperationException("Cannot load customer details. Cause customer id cannot be null!"); + } + + bean = CustomerManager.getCustomerDetails(ctx,bpartnerId); + request.getSession().setAttribute(Constants.CUSTOMER_DETAILS,bean); + + return mapping.findForward(VIEW_POS_CUSTOMER); + } + + public static final String ACTIVATE_POS_CUSTOMER = "activatePOSCustomer"; + @SuppressWarnings("unchecked") + public ActionForward activatePOSCustomer(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + CustomerForm f = (CustomerForm) form; + f.validate(mapping,request); + + CustomerBean bean = (CustomerBean) f.getBean(); + Integer bpartnerId = bean.getBpartnerId(); + if(bpartnerId==null) + { + throw new OperationException("Cannot activate customer. Cause customer id cannot be null!"); + } + + //since customer is a business partner we call the BPartnerManager's activate method + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + + try + { + trx.start(); + CustomerManager.activateCustomer(ctx,bpartnerId.intValue(), trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.activate.customer", request); + mapping.getInputForward(); + } + finally + { + trx.rollback(); + } + + ArrayList list = (ArrayList) request.getSession().getAttribute(Constants.ALL_CUSTOMERS); + //ArrayList customerBeanList = list; + + ArrayList newList = CustomerManager.updateCustomerListStatus(list, bpartnerId, true); + + request.getSession().setAttribute(Constants.ALL_CUSTOMERS, newList); + + + return mapping.findForward(ACTIVATE_POS_CUSTOMER); + } + + public static final String DEACTIVATE_POS_CUSTOMER = "deactivatePOSCustomer"; + @SuppressWarnings("unchecked") + public ActionForward deactivatePOSCustomer(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + CustomerForm f = (CustomerForm) form; + f.validate(mapping,request); + + CustomerBean bean = (CustomerBean) f.getBean(); + Integer bpartnerId = bean.getBpartnerId(); + if(bpartnerId==null) + { + throw new OperationException("Cannot deactivate customer. Cause customer id cannot be null!"); + } + + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + //since customer is a business partner we call the BPartnerManager's deactivate method + try + { + trx.start(); + CustomerManager.deactivateCustomer(ctx,bpartnerId.intValue(), trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.deactivate.customer", request); + mapping.getInputForward(); + } + finally + { + trx.close(); + } + + ArrayList list = (ArrayList) request.getSession().getAttribute(Constants.ALL_CUSTOMERS); + //ArrayList customerBeanList = list; + + ArrayList newList = CustomerManager.updateCustomerListStatus(list, bpartnerId, false); + + request.getSession().setAttribute(Constants.ALL_CUSTOMERS, newList); + + return mapping.findForward(DEACTIVATE_POS_CUSTOMER); + } + + public static final String GENERATE_CARD ="generateFidelityCard"; + public ActionForward generateFidelityCard(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, IOException, Exception + { + ActionForward fwd = init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList customerList =null; + CustomerCart cart = (CustomerCart) request.getSession().getAttribute(Constants.CUSTOMER_CART); + + if(cart != null) + { + customerList = cart.getCustomers(); + + } + else + { + customerList = new ArrayList(); + } + + String reportName = null; + try + { + reportName = CustomerManager.fidelityCard(ctx,customerList); + } + catch (NoCustomerFoundException e) + { + postGlobalError("error.print.fidelity.card",request); + return new ActionForward("/ViewAllCartCustomers.do"); + } + + String uri = ReportManager.getReportURI(reportName,request); + + response.sendRedirect(uri); + //ReportManager.writeReport(reportName, response); + + + return null; + } + + public static final String INIT_SEARCH_POS_CUSTOMER = "initSearchPOSCustomer"; + public ActionForward initSearchPOSCustomer(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + + return mapping.findForward(INIT_SEARCH_POS_CUSTOMER); + } + + + public static final String SEARCH_POS_CUSTOMER = "searchPOSCustomer"; + public ActionForward searchPOSCustomer(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm)form; + + String customerName = df.getPartnerName(); + + ArrayList customerList = CustomerManager.searchPOSCustomer(ctx, customerName, df.getDay(), df.getMonth(),df.getYear(), df.getIsActive()); + + request.getSession().setAttribute(Constants.ALL_CUSTOMERS,customerList); + + return mapping.findForward(SEARCH_POS_CUSTOMER); + } + + public static final String ADD_ALL_CUSTOMERS = "addAllCustomers"; + public ActionForward addAllCustomers(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + CustomerCart cart = (CustomerCart)request.getSession().getAttribute(Constants.CUSTOMER_CART); + + ArrayList customerList = (ArrayList) request.getSession().getAttribute(Constants.ALL_CUSTOMERS); + + if(customerList==null) + { + return mapping.findForward(SEARCH_POS_CUSTOMER); + } + + if(cart == null) + { + cart = new CustomerCart(ctx); + } + + for(CustomerBean bean : customerList) + { + Integer customerId = bean.getBpartnerId(); + if(customerId == null) continue; + + if(! cart.hasCustomer(customerId.intValue())) + { + cart.addCustomer(customerId.intValue()); + } + + } + + request.getSession().setAttribute(Constants.CUSTOMER_CART, cart); + return mapping.findForward(SEARCH_POS_CUSTOMER); + } + +// used for create pos order to get customer name from id + public ActionForward getNameByID(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, Exception + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + CustomerForm f = (CustomerForm) form; + + String errormsg = ""; + String bpartner = f.getBpartnerId(); + + + + if(bpartner == null||bpartner.length()==0) + { + errormsg = "alert('Invalid Customer ID. ID cannot be empty');"; + return sendData(errormsg,response); + } + + Integer bpartnerId = null; + try + { + bpartnerId = Integer.valueOf(bpartner); + } + catch (NumberFormatException e2) + { + errormsg = "alert('Please enter numeric value for Customer ID!');defaultCustomer();"; + return sendData(errormsg,response); + } + + String customerName = ""; + + try + { + CustomerBean bean = CustomerManager.getCustomerDetails(ctx,bpartnerId); + + String firstname = (bean.getPartnerName() == null) ? "" : bean.getPartnerName(); + String lastname = (bean.getSurname() == null) ? "" : bean.getSurname(); + + customerName = firstname + " " + lastname; + customerName = customerName.trim(); + + String data = "setCustomerName('"+ customerName +"');"; + + return sendData(data,response); + } + catch (BPartnerNotFoundException e1) + { + errormsg = "alert('Could not find customer! Please try again with proper Customer ID');defaultCustomer();"; + return sendData(errormsg,response); + } + + } + + private ActionForward sendData(String data,HttpServletResponse response) throws OperationException + { + try + { + response.setContentType("text/plain"); + PrintWriter out = response.getWriter(); + out.print(data); + + out.flush(); + out.close(); + } + catch (IOException e) + { + throw new OperationException(e); + } + return null; + } + + public static final String ADD_TO_CART = "addToCart"; + public ActionForward addToCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + //CustomerBean bean = (CustomerBean) df.getBean(); + + int customerId = Integer.parseInt(df.getBpartnerId()); + + CustomerCart cart = (CustomerCart) request.getSession().getAttribute(Constants.CUSTOMER_CART); + + if( cart == null ) + { + cart = new CustomerCart( ctx ); + } + + if ( ! cart.hasCustomer (customerId ) ) + { + cart.addCustomer( customerId ); + } + + request.getSession().setAttribute(Constants.CUSTOMER_CART, cart); + + String script = "setCartCounter("+ cart.getNoOfCustomers() +");customerAdded("+ customerId +")"; + + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + + public ActionForward clearCart (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + HttpSession session = request.getSession(); + session.removeAttribute(Constants.CUSTOMER_CART); + + request.getSession().getAttribute(Constants.CUSTOMER_CART); + + String script = "clearAll();"; + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + + public static final String VIEW_CART = "viewCart"; + public ActionForward viewCart (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException, Exception + { + HttpSession session = request.getSession(); + CustomerCart cart = (CustomerCart) session.getAttribute(Constants.CUSTOMER_CART); + + ArrayList customerList =null; + + if(cart != null) + { + customerList = cart.getCustomers(); + + } + else + { + customerList = new ArrayList(); + } + + session.setAttribute(Constants.ALL_CART_CUSTOMERS, customerList); + + return mapping.findForward(VIEW_CART); + } + + public static final String REMOVE = "remove"; + public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException, Exception + { + DefaultForm df = (DefaultForm) form; + + int customerId = Integer.parseInt(df.getBpartnerId()); + CustomerCart cart = (CustomerCart) request.getSession().getAttribute(Constants.CUSTOMER_CART); + + if( cart != null ) + { + cart.removeCustomer(customerId); + ArrayList customerList = cart.getCustomers(); + request.getSession().setAttribute(Constants.CUSTOMER_CART, cart); + request.getSession().setAttribute(Constants.ALL_CART_CUSTOMERS, customerList); + } + + return mapping.findForward(VIEW_CART); + } + + public static final String REMOVE_FROM_CART = "removeFromCart"; + public ActionForward removeFromCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + //CustomerBean bean = (CustomerBean) df.getBean(); + + int customerId = Integer.parseInt(df.getBpartnerId()); + + CustomerCart cart = (CustomerCart) request.getSession().getAttribute(Constants.CUSTOMER_CART); + + if( cart == null ) + { + cart = new CustomerCart( ctx ); + } + + if ( cart.hasCustomer (customerId ) ) + { + cart.removeCustomer( customerId ); + } + + request.getSession().setAttribute(Constants.CUSTOMER_CART, cart); + + String script = "setCartCounter("+ cart.getNoOfCustomers() +");customerRemoved("+ customerId +")"; + + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + +} diff --git a/posterita/src/main/org/posterita/struts/customer/SalesAction.java b/posterita/src/main/org/posterita/struts/customer/SalesAction.java new file mode 100644 index 0000000000..c942249930 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/customer/SalesAction.java @@ -0,0 +1,94 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Nov 16, 2005 by praveen + * + */ +package org.posterita.struts.customer; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.posterita.core.TmkJSPEnv; + +import org.posterita.Constants; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.SystemException; +import org.posterita.keyname.SalesRepKeyNamePair; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + +public class SalesAction extends BaseDispatchAction +{ + public static final String INIT_SALES = "initSales"; + public ActionForward initSales(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, SystemException + { + ActionForward fwd = init(mapping,form,request,response); + + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + //CustomerBean bean = new CustomerBean(); + //get sales reps + ArrayList salesRep = SalesRepKeyNamePair.getKeyNamePairs(ctx); + request.getSession().setAttribute(Constants.SALES_REP,salesRep); + + return mapping.findForward(INIT_SALES); + } + + public static String INIT_SALES_FOR_EXISTING_CUSTOMER = "initSalesForExistingCustomer"; + public ActionForward initSalesForExistingCustomer(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, SystemException + { + ActionForward fwd = init(mapping,form,request,response); + + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + Integer customerId = Integer.valueOf(df.getBpartnerId()); + + request.getSession().setAttribute(Constants.CUSTOMER_ID, customerId); + + ArrayList salesRep = SalesRepKeyNamePair.getKeyNamePairs(ctx); + + Boolean canTradeIn = Boolean.valueOf(true); + request.getSession().setAttribute(Constants.SALES_REP,salesRep); + request.getSession().setAttribute(Constants.CAN_TRADE_IN, canTradeIn); + + return mapping.findForward(INIT_SALES); + } + + public static final String CREATE_TRADE_IN_ORDER = "createTradeInOrder"; + public static final String CREATE_NATIS_ORDER = "createNatisOrder"; + + + public static final String PURCHASE_TRADE_IN_VEHICLE_AND_CREATE_CUSTOMER_ORDER = "purchaseTradeInVehicleAndCreateCustomerOrder"; + +} diff --git a/posterita/src/main/org/posterita/struts/inOut/ViewMinOutAction.java b/posterita/src/main/org/posterita/struts/inOut/ViewMinOutAction.java new file mode 100644 index 0000000000..de64bc0fea --- /dev/null +++ b/posterita/src/main/org/posterita/struts/inOut/ViewMinOutAction.java @@ -0,0 +1,107 @@ +/* +* +* Copyright (c) 2005 UDI Ltd. All Rights Reserved. +* +* This software is the confidential and proprietary information of +* UDI Ltd. ("Confidential Information"). You shall not +* disclose such Confidential Information and shall use it only in +* accordance with the terms of the license agreement you entered into +* with UDI. +* +* UDI MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE +* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT +* NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR +* A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. UDI SHALL NOT +* BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, +* MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* +*/ +package org.posterita.struts.inOut; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.Globals; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.config.ActionConfig; +import org.apache.struts.config.ForwardConfig; +import org.apache.struts.util.MessageResources; +import org.compiere.model.MInOut; +import org.posterita.core.TmkJSPEnv; + +import org.posterita.Constants; +import org.posterita.beans.DocumentBean; +import org.posterita.beans.WebDocumentBean; +import org.posterita.businesslogic.MinOutManager; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.BaseAction; +import org.posterita.struts.core.DefaultForm; + + +public class ViewMinOutAction extends BaseAction +{ + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + + MessageResources resources = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); + + String operationException = resources.getMessage("error.operationException"); + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + DocumentBean bean = (DocumentBean) df.getBean(); + Integer minoutId = bean.getDocumentId(); + + // retrieve from cache + WebDocumentBean webBean = null; + + MInOut inout = null; + if (minoutId!= null) + { + inout = new MInOut(ctx, minoutId.intValue(), null); + webBean = MinOutManager.getWebMinOutBean(ctx, inout); + request.getSession().setAttribute(Constants.WEB_MINOUT_BEAN, webBean); + + } + + //int orgID = Env.getAD_Org_ID(ctx); + + if (webBean == null) + webBean = (WebDocumentBean) request.getSession().getAttribute(Constants.WEB_MINOUT_BEAN); + + if (webBean == null) + throw new OperationException(operationException); + + request.getSession().setAttribute(Constants.ME_LOCATION, webBean.getMeLocation()); + request.getSession().setAttribute(Constants.YOU_LOCATION, webBean.getYouLocation()); + request.getSession().setAttribute(Constants.YOU_BP_LOCATION, webBean.getYoubpLocation()); + request.getSession().setAttribute(Constants.ME, webBean.getMe()); + request.getSession().setAttribute(Constants.YOU,webBean.getYou()); + request.getSession().setAttribute(Constants.MINOUT_LINES_COLLECTION, webBean.getLines()); + request.getSession().setAttribute(Constants.MINOUT, webBean.getMinOut()); + request.getSession().setAttribute(Constants.MINVOICE, webBean.getInvoice()); + request.getSession().setAttribute(Constants.SIMPLE_COMMAND,webBean.getSimpleCommand()); + request.getSession().setAttribute(Constants.COMPLEX_COMMAND,webBean.getComplexCommand()); + request.getSession().setAttribute(Constants.WEB_DOCUMENT_HEADER_BEAN, webBean.getHeaderBean()); + + ForwardConfig forwardConfig = getForward(ctx,webBean,mapping,form); + + ActionForward forward = new ActionForward(forwardConfig.getPath()); + + return forward; + } + + private ForwardConfig getForward(Properties ctx, WebDocumentBean webBean, ActionMapping mapping, ActionForm form) + { + + ActionConfig config = mapping.getModuleConfig().findActionConfig("/ViewMinOutAction"); + + return config.findForwardConfig(Constants.VIEW_MINOUT); + } +} diff --git a/posterita/src/main/org/posterita/struts/invoice/ViewInvoiceAction.java b/posterita/src/main/org/posterita/struts/invoice/ViewInvoiceAction.java new file mode 100644 index 0000000000..0f417a6590 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/invoice/ViewInvoiceAction.java @@ -0,0 +1,190 @@ +/* +* +* Copyright (c) 2005 UDI Ltd. All Rights Reserved. +* +* This software is the confidential and proprietary information of +* UDI Ltd. ("Confidential Information"). You shall not +* disclose such Confidential Information and shall use it only in +* accordance with the terms of the license agreement you entered into +* with UDI. +* +* UDI MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE +* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT +* NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR +* A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. UDI SHALL NOT +* BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, +* MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* +*/ +package org.posterita.struts.invoice; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.Globals; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.config.ActionConfig; +import org.apache.struts.config.ForwardConfig; +import org.apache.struts.util.MessageResources; +import org.compiere.model.MDocType; +import org.compiere.model.MInvoice; +import org.compiere.model.MOrder; +import org.compiere.process.DocumentEngine; +import org.compiere.util.Env; +import org.posterita.Constants; +import org.posterita.beans.DocumentBean; +import org.posterita.beans.WebDocumentBean; +import org.posterita.businesslogic.InvoiceManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.order.UDIOrderTypes; +import org.posterita.struts.core.BaseAction; +import org.posterita.struts.core.DefaultForm; + + +public class ViewInvoiceAction extends BaseAction +{ + + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + MessageResources resources = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); + + //String securityException = resources.getMessage("error.securityException"); + String operationException = resources.getMessage("error.operationException"); + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + DocumentBean bean = (DocumentBean) df.getBean(); + Integer invoiceId = bean.getDocumentId(); + + // retrieve from cache + WebDocumentBean webBean = null; + + MInvoice invoice = null; + if (invoiceId!= null && (invoiceId.intValue()!=0)) + { + invoice = new MInvoice(ctx, invoiceId.intValue(), null); + webBean = InvoiceManager.getWebInvoiceBean(invoice); + request.getSession().setAttribute(Constants.WEB_INVOICE_BEAN, webBean); + } + + //int orgID = Env.getAD_Org_ID(ctx); + + if (webBean == null) + webBean = (WebDocumentBean) request.getSession().getAttribute(Constants.WEB_INVOICE_BEAN); + + if (webBean == null) + throw new OperationException(operationException); + + request.getSession().setAttribute(Constants.ME_LOCATION, webBean.getMeLocation()); + request.getSession().setAttribute(Constants.YOU_LOCATION, webBean.getYouLocation()); + request.getSession().setAttribute(Constants.YOU_BP_LOCATION, webBean.getYoubpLocation()); + request.getSession().setAttribute(Constants.ME, webBean.getMe()); + request.getSession().setAttribute(Constants.YOU,webBean.getYou()); + request.getSession().setAttribute(Constants.MINVOICE, webBean.getInvoice()); + request.getSession().setAttribute(Constants.MORDER, webBean.getOrder()); + request.getSession().setAttribute(Constants.MINVOICE_LINES_COLLECTION,webBean.getLines()); + request.getSession().setAttribute(Constants.SIMPLE_COMMAND,webBean.getSimpleCommand()); + request.getSession().setAttribute(Constants.COMPLEX_COMMAND,webBean.getComplexCommand()); + request.getSession().setAttribute(Constants.WEB_DOCUMENT_HEADER_BEAN, webBean.getHeaderBean()); + request.getSession().setAttribute(Constants.INVOICE_TAX,webBean.getTotalTax()); + request.getSession().setAttribute(Constants.TOTAL_LINES,webBean.getTotalLines()); + request.getSession().setAttribute(Constants.GRAND_TOTAL,webBean.getGrandTotal()); + request.setAttribute(Constants.CURRENCY_SYMBOLE,webBean.getCurrencySymbole()); + + + ForwardConfig forwardConfig = getForward(ctx,webBean,mapping,form); + + ActionForward forward = new ActionForward(forwardConfig.getPath()); + + return forward; + } + + private ForwardConfig getForward(Properties ctx, WebDocumentBean webBean, ActionMapping mapping, ActionForm form) throws OperationException + { + ActionConfig config = mapping.getModuleConfig().findActionConfig("/ViewInvoiceAction"); + + MInvoice invoice = webBean.getInvoice(); + + //vendor invoice -- isSoTrx is false + //customer invoice -- isSoTrx true + + if (webBean.getOrder().getOrderType().equals(UDIOrderTypes.WEBSTORE_ORDER.getOrderType())) + { + //Webstore CI--customer invoice + if (invoice.isSOTrx()) + return getWebstoreCI_Forward(webBean,config); + } + else + { + //VI--vendor invoice + if (!invoice.isSOTrx()) + return getVI_Forward(webBean,config); + + //CI--customer invoice + if (invoice.isSOTrx()) + return getCI_Forward(webBean,config); + } + + // DEFAULT + return config.findForwardConfig(Constants.FINISHED_DO); + + } + + public ForwardConfig getVI_Forward(WebDocumentBean invoiceBean, ActionConfig config) throws OperationException + { + return config.findForwardConfig(Constants.WEBSTORE_INVOICE); + } + + public ForwardConfig getWebstoreCI_Forward(WebDocumentBean invoiceBean, ActionConfig config) throws OperationException + { + MInvoice invoice = invoiceBean.getInvoice(); + + String status = invoice.getDocStatus(); + + if(status.equals(DocumentEngine.STATUS_Completed)) + { + return config.findForwardConfig(Constants.WEBSTORE_INVOICE); + } + + return config.findForwardConfig(Constants.WEBSTORE_INVOICE); + } + + public ForwardConfig getCI_Forward(WebDocumentBean invoiceBean, ActionConfig config) throws OperationException + { + MInvoice invoice = invoiceBean.getInvoice(); + + MOrder order = new MOrder(invoice.getCtx(), invoice.getC_Order_ID(), null); + + + int[] docTypes = MDocType.getAllIDs(MDocType.Table_Name, " ad_client_id="+ Env.getAD_Client_ID(invoice.getCtx()) + " and DOCSUBTYPESO='" + MDocType.DOCSUBTYPESO_POSOrder+ "'", null ); + + + //POS order + if (order.getC_DocType_ID() == docTypes[0]) + return config.findForwardConfig(Constants.PAID_INVOICE); + + String status = invoice.getDocStatus(); + + if (!invoice.isActive()) + return config.findForwardConfig(Constants.CANCEL_INVOICE); + + if(status.equals(DocumentEngine.STATUS_Completed)) + { + return config.findForwardConfig(Constants.WEBSTORE_INVOICE); + } + return config.findForwardConfig(Constants.UNPAID_INVOICE); + } + +} diff --git a/posterita/src/main/org/posterita/struts/login/ChangePasswordAction.java b/posterita/src/main/org/posterita/struts/login/ChangePasswordAction.java new file mode 100644 index 0000000000..6f2f5bb636 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/login/ChangePasswordAction.java @@ -0,0 +1,78 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 29, 2005 by din + */ + +package org.posterita.struts.login; + + + +import java.util.Properties; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.posterita.core.TmkJSPEnv; + +import org.posterita.Constants; +import org.posterita.beans.ChangePasswordBean; +import org.posterita.businesslogic.LoginManager; +import org.posterita.exceptions.WrongPasswordException; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; +import org.posterita.user.WebUserInfo; + + + + public class ChangePasswordAction extends BaseDispatchAction + { + + public ActionForward change(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + ChangePasswordBean bean = (ChangePasswordBean) df.getBean(); + Properties ctx = TmkJSPEnv.getCtx(request); + + WebUserInfo userInfo = (WebUserInfo) request.getSession().getAttribute(WebUserInfo.NAME); + + try + { + LoginManager.changePassword(ctx, bean, userInfo); + } + + catch(WrongPasswordException e) + { + postGlobalError("admin.wrongPasswordError",request); + return (new ActionForward(mapping.getInput())); + + } + + + return mapping.findForward(Constants.CHANGE); + + } + + } + + diff --git a/posterita/src/main/org/posterita/struts/login/GoToHomePageAction.java b/posterita/src/main/org/posterita/struts/login/GoToHomePageAction.java new file mode 100644 index 0000000000..fd291638d3 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/login/GoToHomePageAction.java @@ -0,0 +1,111 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 26, 2005 by praveen + * + */ +package org.posterita.struts.login; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Env; +import org.posterita.Constants; +import org.posterita.beans.ApplicationParametersBean; +import org.posterita.businesslogic.ApplicationManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.DefaultStoreException; +import org.posterita.lib.UdiConstants; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + +public class GoToHomePageAction extends BaseDispatchAction +{ + public static String GO_TO_HOMEPAGE = "goToHomePage"; + public ActionForward goToHomePage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + try + { + ApplicationManager.changeApplication(request, response); + + Properties ctx = TmkJSPEnv.getCtx(request); + String forward = Env.getContext(ctx, UdiConstants.WEBPARAM6); + + return mapping.findForward(forward); + } + catch(Exception ex) + { + postGlobalError("error.store.default", ex.getMessage(), request); + return mapping.findForward(CHOOSE_APPLICATION); + } + } + + public static final String LICENSE_INVALID = "clientLicensing"; + public static final String CHOOSE_APPLICATION = "chooseApplication"; + public ActionForward setApplicationParameters(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + DefaultForm df = (DefaultForm) form; + ApplicationParametersBean bean = (ApplicationParametersBean) df.getBean(); + + String appName = bean.getApplicationName(); + + try + { + ApplicationManager.changeApplication(request, response, appName); + + Properties ctx = TmkJSPEnv.getCtx(request); + String defaultAppName = ApplicationManager.getApplicationType(ctx).toUpperCase(); + + String displayAppName = ApplicationManager.getApplicationName(bean.getApplicationName()); + + request.getSession().getServletContext().setAttribute(Constants.APP_NAME,displayAppName); + + ApplicationManager.setApplicationNameInCookie(response, appName); + + String forward = Env.getContext(ctx, UdiConstants.WEBPARAM6); + + + + return mapping.findForward(forward); + } + catch(DefaultStoreException ex) + { + postGlobalError("error.store.default", ex.getMessage(), request); + return mapping.findForward(CHOOSE_APPLICATION); + } + } + + public static final String INIT_CHOOSE_APPLICATION = "initChooseApplication"; + public ActionForward initChooseApplication(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + ArrayList appList = ApplicationManager.getAvailableApplications(); + servlet.getServletContext().setAttribute(Constants.WEB_APPLICATIONS, appList); + + return mapping.findForward(INIT_CHOOSE_APPLICATION); + } +} diff --git a/posterita/src/main/org/posterita/struts/login/LoginAction.java b/posterita/src/main/org/posterita/struts/login/LoginAction.java new file mode 100644 index 0000000000..5f4a4d7b41 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/login/LoginAction.java @@ -0,0 +1,480 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ +package org.posterita.struts.login; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts.Globals; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.util.MessageResources; +import org.compiere.model.MSession; +import org.compiere.model.MUser; +import org.compiere.model.X_U_Menu; +import org.compiere.util.Env; +import org.compiere.util.KeyNamePair; +import org.compiere.util.WebUser; +import org.posterita.Constants; +import org.posterita.beans.ChangePasswordBean; +import org.posterita.beans.LoginBean; +import org.posterita.beans.UserBean; +import org.posterita.businesslogic.ApplicationManager; +import org.posterita.businesslogic.LoginManager; +import org.posterita.businesslogic.MenuManager; +import org.posterita.businesslogic.POSManager; +import org.posterita.businesslogic.POSTerminalManager; +import org.posterita.businesslogic.RoleManager; +import org.posterita.core.MenuItem; +import org.posterita.core.SessionStorage; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.EmailNotFoundException; +import org.posterita.exceptions.InvalidPasswordLengthException; +import org.posterita.exceptions.InvalidRoleException; +import org.posterita.exceptions.NotLoggedInException; +import org.posterita.exceptions.UserInactiveException; +import org.posterita.exceptions.UserNotFoundException; +import org.posterita.exceptions.WrongPasswordException; +import org.posterita.lib.UdiConstants; +import org.posterita.model.UDIU_Menu; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; +import org.posterita.user.WebUserInfo; + +public class LoginAction extends BaseDispatchAction +{ + + LoginManager bd = new LoginManager(); + Properties ctx = null; + + public static final String LOGIN_USER = "loginUser"; + public ActionForward loginUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd !=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + LoginBean bean = (LoginBean) df.getBean(); + ctx = TmkJSPEnv.getCtx(request); + + WebUserInfo wuInfo = null; + MenuItem menus = null; + ArrayList topMenusList; + ArrayList leftMenusList; + + try + { + //Checking username and password + + //TODO + wuInfo = bd.loginUser(ctx, bean); + + ArrayList menuList = MenuManager.getMenus(ctx); + menus = MenuManager.buildMenuTree(ctx, menuList); + topMenusList = menus.getTopMenus(); + leftMenusList = menus.getLeftMenus(); + + //Adding the switch user menu + Object userId = request.getSession().getAttribute(Constants.ADMIN_USER_ID); + + if(userId != null) + { + X_U_Menu xmenu = new X_U_Menu(ctx,0,null); + xmenu.setName("Switch User"); + xmenu.setMenuLink("LoginUserAction.do?action=loginUser&userId=" + userId); + + UDIU_Menu menu = new UDIU_Menu(xmenu); + //MenuItem menuItem = new MenuItem(menu); + leftMenusList.add(new MenuItem(menu)); + } + + + } + catch(UserNotFoundException unfe) + { + postGlobalError("login.passwordError",request); + return (mapping.getInputForward()); + } + catch(NotLoggedInException e) + { + postGlobalError("login.passwordError",request); + return (mapping.getInputForward()); + } + catch(InvalidRoleException ire) + { + postGlobalError("error.role.invalid", request); + return (mapping.getInputForward()); + } + catch(UserInactiveException unae) + { + postGlobalError("login.userInactive",request); + return (mapping.getInputForward()); + } + + HttpSession session = request.getSession(); + MSession cSession = MSession.get (ctx, request.getRemoteAddr(), request.getRemoteHost(), session.getId()); + + if (cSession != null) + cSession.setWebStoreSession(true); + + //Set breadcrumb to empty + + request.getSession().setAttribute(Constants.BREADCRUMB, null); + + request.getSession().setAttribute(WebUserInfo.NAME, wuInfo); + request.getSession().setAttribute(Constants.MENUS, menus); + request.getSession().setAttribute(Constants.TOP_MENUS, topMenusList); + request.getSession().setAttribute(Constants.LEFT_MENUS, leftMenusList); + SessionStorage.putOrg(ctx, request); + + + return mapping.findForward(LOGIN_USER); + + } + + public static final String LOGOUT = "logout"; + public ActionForward logout(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + HttpSession session = request.getSession(); + Properties ctx = TmkJSPEnv.getCtx(request); + + WebUserInfo wuInfo = (WebUserInfo)session.getAttribute(WebUserInfo.NAME); + + String appName = ApplicationManager.getApplicationType(ctx); + if (wuInfo != null) + { + WebUser wu = wuInfo.getUser(); + if (wu != null) + wu.logout(); + + session.removeAttribute(WebUserInfo.NAME); + } + + + + if(appName.endsWith(Constants.APP_POS)) + session.setMaxInactiveInterval(0); + + try + { + ApplicationManager.changeApplication(request, response); + ctx = TmkJSPEnv.getCtx(request); + + String forward = Env.getContext(ctx, UdiConstants.WEBPARAM6); + + return mapping.findForward(forward); + } + catch(Exception ex) + { + postGlobalError("error.store.default", ex.getMessage(), request); + return mapping.findForward(CHOOSE_APPLICATION); + } + } + + public static final String SUCCESS = "success"; + public static final String CHOOSEPOS = "choosePOS"; + public static final String CREATEPOSORDER = "createPOSOrder"; + public ActionForward success(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + DefaultForm df = (DefaultForm) form; + LoginBean bean = (LoginBean) df.getBean(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + HttpSession session = request.getSession(); + WebUserInfo info = null; + WebUser wu; + + try + { + wu = bd.checkLoginPassword(ctx, bean); + + info = bd.login(ctx, wu); + + + + MSession cSession = MSession.get (ctx, request.getRemoteAddr(), request.getRemoteHost(), session.getId()); + + if (cSession != null) + cSession.setWebStoreSession(true); + + session.setAttribute (WebUserInfo.NAME, info); + + SessionStorage.putMenus(ctx, request); + + + } + catch(UserNotFoundException unfe) + { + postGlobalError("login.passwordError",request); + return (mapping.getInputForward()); + } + catch(NotLoggedInException e) + { + postGlobalError("login.passwordError",request); + return (mapping.getInputForward()); + } + catch(InvalidRoleException ire) + { + postGlobalError("error.role.invalid", request); + return (mapping.getInputForward()); + } + catch(UserInactiveException unae) + { + postGlobalError("login.userInactive",request); + return (mapping.getInputForward()); + } + + + String applicationName = ApplicationManager.getApplicationType(ctx); + + if(applicationName.endsWith(Constants.APP_POS)) + { + String strPosId = POSManager.getPOSIDFromCookie(request); + + + boolean isValidPOSId = false; + + if(strPosId != null) + { + try + { + int posId = Integer.parseInt(strPosId); + isValidPOSId = POSManager.isPOSTerminalPresent(ctx, posId); + } + catch(Exception ex) + {} + } + + + if(!isValidPOSId) + { + ArrayList list=POSManager.getAllPOSIDs(ctx); + request.getSession().setAttribute(Constants.POSIDS,list); + return mapping.findForward(CHOOSEPOS); + + } + else + { + SessionStorage.putPOSID(ctx,strPosId,request); + String currSymboleSales = POSTerminalManager.getPOSDefaultSellCurrency(ctx).getCurSymbol(); + String currSymbolePurchase=POSTerminalManager.getPOSDefaultPurchaseCurrency(ctx).getCurSymbol(); + request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE,currSymboleSales); + request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE_PURCHASE,currSymbolePurchase); + return mapping.findForward(CREATEPOSORDER); + } + + } + + return mapping.findForward(SUCCESS); + } + + public ActionForward password(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + DefaultForm df = (DefaultForm) form; + UserBean bean = (UserBean) df.getBean(); + Properties ctx = TmkJSPEnv.getCtx(request); + + + MessageResources resources = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); + + String subject = resources.getMessage("login.password.emailTitle"); + String content = resources.getMessage("login.password.emailSubject"); + + try + { + bd.sendPassword(ctx, bean, subject, content); + } + catch(EmailNotFoundException e) + { + postGlobalError("login.emailNotFound",request); + return (new ActionForward(mapping.getInput())); + } + catch(UserNotFoundException une) + { + postGlobalError("login.userNotFound",request); + return (new ActionForward(mapping.getInput())); + + } + + + return mapping.findForward(Constants.PASSWORD); + } + + + + public ActionForward udiAdmin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd !=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + int userID = Env.getAD_User_ID(ctx); + MUser muser = new MUser(ctx,userID, null); + + if(muser.getName().equals("HSAF Auto")) + return mapping.findForward(Constants.UDIADMINAUTO); + else if(muser.getName().equals("HSAF Wing")) + return mapping.findForward(Constants.UDIADMINBIKE); + else + return mapping.findForward(Constants.UDIADMIN); + } + + public static final String CHANGE_USER_PASSWORD="changeUserPassword"; + public ActionForward changeUserPassword(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd !=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + ChangePasswordBean bean = (ChangePasswordBean) df.getBean(); + Properties ctx = TmkJSPEnv.getCtx(request); + + WebUserInfo userInfo = (WebUserInfo) request.getSession().getAttribute(WebUserInfo.NAME); + + try + { + LoginManager.changePassword(ctx,bean,userInfo); + } + catch(InvalidPasswordLengthException e2) + { + postGlobalError("error.wrong.password.length", request); + return mapping.getInputForward(); + } + catch(WrongPasswordException e) + { + postGlobalError("admin.wrongPasswordError",request); + return (new ActionForward(mapping.getInput())); + } + + return mapping.findForward(CHANGE_USER_PASSWORD); + } + + + + //----------------------------------Refactoring LoginAction----------------------------------- + + public static final String VALIDATE_USER = "validateUser"; + /** + * We check whether the name & password supplied is valid + * Result: + * If valid we forward to choose role + * else we forward to login page witn appropriate login error + */ + public ActionForward validateUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + LoginBean bean = (LoginBean) df.getBean(); + + HttpSession session = request.getSession(); + WebUserInfo info = null; + WebUser wu = null; + + // validate user + try + { + wu = bd.checkLoginPassword(ctx, bean); + + info = bd.login(ctx, wu); + + MSession cSession = MSession.get (ctx, request.getRemoteAddr(), request.getRemoteHost(), session.getId()); + + if (cSession != null) + cSession.setWebStoreSession(true); + + session.setAttribute (WebUserInfo.NAME, info); + + ArrayList myRoles = RoleManager.getMyRoles(ctx); + + if(myRoles.size() == 1) + { + KeyNamePair pair = (KeyNamePair) myRoles.get(0); + + Env.setContext(ctx,"#AD_Role_ID", pair.getKey()); + + SessionStorage.putMenus(ctx,request); + SessionStorage.putOrg(ctx, request); + + return mapping.findForward(LOGIN_SUCCESS); + } + + + } + catch(UserNotFoundException unfe) + { + postGlobalError("login.passwordError",request); + return (mapping.getInputForward()); + } + catch(NotLoggedInException e) + { + postGlobalError("login.passwordError",request); + return (mapping.getInputForward()); + } + catch(InvalidRoleException ire) + { + postGlobalError("error.role.invalid", request); + return (mapping.getInputForward()); + } + catch(UserInactiveException unae) + { + postGlobalError("login.userInactive",request); + return (mapping.getInputForward()); + } + + return mapping.findForward(INIT_CHOOSE_ROLE); + } + + + public static final String INIT_CHOOSE_ROLE = "initChooseRole"; + /** + * We get all the roles assign to the user and all orgs + * accessible by the user + */ + + + + + public static final String LOGIN_SUCCESS = "loginSuccess"; + /** + * We load all the menus + */ + public ActionForward loginSuccess(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd !=null) + return fwd; + + return mapping.findForward(LOGIN_SUCCESS); + } + +} diff --git a/posterita/src/main/org/posterita/struts/login/POSLoginAction.java b/posterita/src/main/org/posterita/struts/login/POSLoginAction.java new file mode 100644 index 0000000000..317c4aeb8b --- /dev/null +++ b/posterita/src/main/org/posterita/struts/login/POSLoginAction.java @@ -0,0 +1,177 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Sep 25, 2006 + */ + + +package org.posterita.struts.login; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MSession; +import org.compiere.util.WebUser; +import org.posterita.Constants; +import org.posterita.beans.LoginBean; +import org.posterita.businesslogic.ApplicationManager; +import org.posterita.businesslogic.LoginManager; +import org.posterita.businesslogic.POSManager; +import org.posterita.businesslogic.POSTerminalManager; +import org.posterita.core.SessionStorage; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.DuplicatePINException; +import org.posterita.exceptions.InvalidPINException; +import org.posterita.exceptions.InvalidRoleException; +import org.posterita.exceptions.NotLoggedInException; +import org.posterita.exceptions.UserInactiveException; +import org.posterita.exceptions.UserNotFoundException; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; +import org.posterita.user.WebUserInfo; + + +public class POSLoginAction extends BaseDispatchAction +{ + LoginManager bd = new LoginManager(); + public static final String SUCCESS = "success"; + public static final String CHOOSEPOS = "choosePOS"; + public static final String CREATEPOSORDER = "createPOSOrder"; + // public static final String SUCCESS_WSTORE_USER = "successWStoreUser"; + public ActionForward success(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + DefaultForm df = (DefaultForm) form; + LoginBean bean = (LoginBean) df.getBean(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + HttpSession session = request.getSession(); + WebUserInfo info = null; + WebUser wu; + + + try + { + if(bean.getUserPIN()!=null) + { + bean=bd.getUserNameFromPIN(ctx,bean.getUserPIN()); + } + + wu = bd.checkLoginPassword(ctx, bean);/////////////// + + info = bd.login(ctx, wu); + + + + MSession cSession = MSession.get (ctx, request.getRemoteAddr(), request.getRemoteHost(), session.getId()); + + if (cSession != null) + cSession.setWebStoreSession(false); + + session.setAttribute (WebUserInfo.NAME, info); + + SessionStorage.putMenus(ctx, request); + + + } + catch(InvalidPINException e) + { + postGlobalError("error.invalid.pin",request); + return (mapping.getInputForward()); + } + catch(DuplicatePINException e) + { + postGlobalError("error.duplicate.pin",request); + return (mapping.getInputForward()); + } + catch(UserNotFoundException unfe) + { + postGlobalError("login.passwordError",request); + return (mapping.getInputForward()); + } + catch(NotLoggedInException e) + { + postGlobalError("login.passwordError",request); + return (mapping.getInputForward()); + } + catch(InvalidRoleException ire) + { + postGlobalError("error.role.invalid", request); + return (mapping.getInputForward()); + } + catch(UserInactiveException unae) + { + postGlobalError("login.userInactive",request); + return (mapping.getInputForward()); + } + + + String applicationName = ApplicationManager.getApplicationType(ctx); + + if(applicationName.endsWith(Constants.APP_POS)) + { + String strPosId = POSManager.getPOSIDFromCookie(request); + + + boolean isValidPOSId = false; + + if(strPosId != null) + { + try + { + int posId = Integer.parseInt(strPosId); + isValidPOSId = POSManager.isPOSTerminalPresent(ctx, posId); + } + catch(Exception ex) + {} + } + + + if(!isValidPOSId) + { + ArrayList list=POSManager.getAllPOSIDs(ctx); + request.getSession().setAttribute(Constants.POSIDS,list); + return mapping.findForward(CHOOSEPOS); + + } + else + { + SessionStorage.putPOSID(ctx,strPosId,request); + String currSymboleSales = POSTerminalManager.getPOSDefaultSellCurrency(ctx).getCurSymbol(); + String currSymbolePurchase=POSTerminalManager.getPOSDefaultPurchaseCurrency(ctx).getCurSymbol(); + request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE,currSymboleSales); + request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE_PURCHASE,currSymbolePurchase); + return mapping.findForward(CREATEPOSORDER); + } + + } + + SessionStorage.putOrg(ctx, request); + SessionStorage.putWebstoreUser(ctx, request, info.getUser().getAD_User_ID()); + + return mapping.findForward(SUCCESS); + } +} + diff --git a/posterita/src/main/org/posterita/struts/menu/CloseMenuAction.java b/posterita/src/main/org/posterita/struts/menu/CloseMenuAction.java new file mode 100644 index 0000000000..b571a5092f --- /dev/null +++ b/posterita/src/main/org/posterita/struts/menu/CloseMenuAction.java @@ -0,0 +1,89 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 28, 2005 by din + */ + +package org.posterita.struts.menu; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.Constants; +import org.posterita.beans.MenuItemBean; +import org.posterita.businesslogic.MenuManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.SystemException; +import org.posterita.keyname.MenuKeyNamePair; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + +public class CloseMenuAction extends BaseDispatchAction +{ + + public static final String CLOSE_MENU= "closeMenuItems"; + public ActionForward closeMenuItems(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, SystemException, OperationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + MenuItemBean bean = (MenuItemBean) df.getBean(); + + MenuManager.saveMenu(ctx,bean); + + request.getSession().setAttribute(Constants.MENUS,bean); + + return mapping.findForward(CLOSE_MENU); + } + + public static final String INIT_MENU= "initMenuItems"; + public ActionForward initMenuItems(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, SystemException, OperationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList menus = MenuKeyNamePair.getKeyNamePairs(ctx); + + + + request.getSession().setAttribute(Constants.MENUS, menus); + + return mapping.findForward(INIT_MENU); + } + } + + diff --git a/posterita/src/main/org/posterita/struts/menu/MenuAction.java b/posterita/src/main/org/posterita/struts/menu/MenuAction.java new file mode 100644 index 0000000000..e1312eb6ff --- /dev/null +++ b/posterita/src/main/org/posterita/struts/menu/MenuAction.java @@ -0,0 +1,318 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.struts.menu; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Env; + +import org.posterita.Constants; +import org.posterita.beans.MenuItemBean; +import org.posterita.businesslogic.ApplicationManager; +import org.posterita.businesslogic.MenuManager; +import org.posterita.core.MenuItem; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.DefaultStoreException; +import org.posterita.exceptions.OperationException; +import org.posterita.factory.POSMenuFactory; +import org.posterita.lib.UdiConstants; +import org.posterita.model.UDIPO; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; +import org.posterita.core.bean.ElementBean; +import org.posterita.core.businesslogic.ElementManager; + + + +public class MenuAction extends BaseDispatchAction +{ + public static final String GET_MENU_ITEMS = "getMenuItems"; + public static final String GET_POS_MENU_ITEMS = "getPOSMenuItems"; + + public ActionForward getMenuItems(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + MenuItemBean bean = (MenuItemBean) df.getBean(); + + MenuItem rootMenuItem = (MenuItem)request.getSession().getAttribute(Constants.MENUS); + + if(rootMenuItem == null) + { + try + { + ApplicationManager.changeApplication(request, response); + + ctx = TmkJSPEnv.getCtx(request); + String forward = Env.getContext(ctx, UdiConstants.WEBPARAM6); + + return mapping.findForward(forward); + } + catch(DefaultStoreException ex) + { + postGlobalError("error.store.default", ex.getMessage(), request); + return mapping.findForward(CHOOSE_APPLICATION); + } + catch(Exception ex) + { + return mapping.findForward(APPLICATION_ERROR); + } + } + + ArrayList subMenus = new ArrayList(); + String applicationName = ApplicationManager.getApplicationType(ctx).toUpperCase(); + + if(bean.getMenuId()==null) + { + UDIPO udiPO = POSMenuFactory.getFactoryInstance(ctx).get(ctx, POSMenuFactory.PMENU_SALES_ID); + bean.setMenuId(udiPO.getID()); + } + + if(bean.getMenuId()!= null) + { + subMenus = rootMenuItem.getSubMenus(bean.getMenuId().intValue()); + } + + + + if (applicationName.equalsIgnoreCase("POS")) + { + //subgrouping menus + ArrayList menuItems = subMenus; + HashMap> categoryMap = new HashMap>(); + + StringWriter sw = new StringWriter(); + PrintWriter out = new PrintWriter(sw); + ElementBean elementBean = null; + + String category = ""; + ArrayList list = null; + ArrayList categories = new ArrayList(); + + //group menus + for(MenuItem menuItem : menuItems) + { + category = menuItem.getCategory(); + category = (category==null)? "" : category; + + if(!categories.contains(category)) + { + categories.add(category); + } + + list = categoryMap.get(category); + + if(list==null) + { + list = new ArrayList(); + } + + list.add(menuItem); + categoryMap.put(category,list); + + } + + //display groups + + Iterator iter = categories.iterator(); + + out.print(""); + while(iter.hasNext()) + { + out.print(""); + } + + out.print("
"); + //---------------------------------------------------------------------------------------------------------------------- + + category = iter.next(); + list = categoryMap.get(category); + + if((category != null)&&(category.length() != 0)) + { + out.print("
"); + out.print(""); + + elementBean = ElementManager.getMsg(ctx,category); + out.print(elementBean.getName()); + + out.print(""); + }//if + + out.print(""); + + if((category != null)&&(category.length() != 0)) + { + out.print("
"); + }//if + + //---------------------------------------------------------------------------------------------------------------------- + out.print("
"); + + if(!iter.hasNext()) + { + out.print(" "); + } + else + { + //---------------------------------------------------------------------------------------------------------------------- + + category = iter.next(); + list = categoryMap.get(category); + + if((category != null)&&(category.length() != 0)) + { + out.print("
"); + out.print(""); + + elementBean = ElementManager.getMsg(ctx,category); + out.print(elementBean.getName()); + + out.print(""); + }//if + + out.print(""); + + if((category != null)&&(category.length() != 0)) + { + out.print("
"); + }//if + + //---------------------------------------------------------------------------------------------------------------------- + + } + out.print("
"); + out.flush(); + + String menu = sw.toString(); + + request.getSession().setAttribute(Constants.MENU_ITEMS, menu); + return mapping.findForward(GET_POS_MENU_ITEMS); + } + + return mapping.findForward(GET_MENU_ITEMS); + } + + public static final String INIT_EDIT_LINKSTATUS = "initEditLinkStatus"; + public ActionForward initEditLinkStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList menuKeyNamePairs = MenuManager.getClosableMenus(ctx); + + request.getSession().setAttribute(Constants.MENU_LIST, menuKeyNamePairs); + + return mapping.findForward(INIT_EDIT_LINKSTATUS); + } + + public static final String SELECT_LINK_TO_EDIT = "selectLinkToEdit"; + public ActionForward selectLinkToEdit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + MenuItemBean bean = (MenuItemBean) df.getBean(); + + MenuItemBean bean2 = MenuManager.getMenu(ctx, bean.getMenuId().intValue()); + + df.populate(bean2); + + return mapping.findForward(SELECT_LINK_TO_EDIT); + } + + public static final String EDIT_MENU = "editMenu"; + public ActionForward editMenu(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + MenuItemBean bean = (MenuItemBean) df.getBean(); + + MenuItemBean editedMenu = MenuManager.editMenu(ctx, bean); + + request.getSession().setAttribute(Constants.MENU, editedMenu); + + return mapping.findForward(EDIT_MENU); + } +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/struts/order/CompletePOSOrderAction.java b/posterita/src/main/org/posterita/struts/order/CompletePOSOrderAction.java new file mode 100644 index 0000000000..53195712f4 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/order/CompletePOSOrderAction.java @@ -0,0 +1,72 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 27-Mar-2006 + */ + + +package org.posterita.struts.order; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MOrder; + +import org.posterita.Constants; +import org.posterita.beans.WebDocumentBean; +import org.posterita.businesslogic.OrderReferenceManager; +import org.posterita.businesslogic.POSManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; + + +public class CompletePOSOrderAction extends ViewOrderAction +{ + + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + + WebDocumentBean webBean = null; + + Integer posOrderId=(Integer) request.getSession().getAttribute(Constants.CURRENT_POS_ORDER_ID); + + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER_ID,posOrderId); + + MOrder completedPOSOrder=POSManager.completePOSOrder(ctx,posOrderId, null); + webBean = OrderReferenceManager.getWebOrderBean(ctx,completedPOSOrder); + + + request.getSession().setAttribute(Constants.WEB_ORDER_BEAN, webBean); + + return super.execute(mapping,form,request,response); + } + + +} diff --git a/posterita/src/main/org/posterita/struts/order/ViewOrderAction.java b/posterita/src/main/org/posterita/struts/order/ViewOrderAction.java new file mode 100644 index 0000000000..0b31d0e623 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/order/ViewOrderAction.java @@ -0,0 +1,307 @@ +/* + * Created on Mar 4, 2005 + * + * To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.posterita.struts.order; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.Globals; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.config.ActionConfig; +import org.apache.struts.config.ForwardConfig; +import org.apache.struts.util.MessageResources; +import org.compiere.model.MOrder; +import org.compiere.model.MUser; +import org.compiere.process.DocumentEngine; +import org.compiere.util.Env; + +import org.posterita.Constants; +import org.posterita.beans.DocumentBean; +import org.posterita.beans.WebDocumentBean; +import org.posterita.businesslogic.OrderReferenceManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.order.UDIOrderTypes; +import org.posterita.struts.core.BaseAction; +import org.posterita.struts.core.DefaultForm; + + +public class ViewOrderAction extends BaseAction +{ + + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + + MessageResources resources = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); + + //String securityException = resources.getMessage("error.securityException"); + String operationException = resources.getMessage("error.operationException"); + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + DocumentBean bean = (DocumentBean) df.getBean(); + Integer orderID = bean.getDocumentId(); + + // retrieve from cache + WebDocumentBean webBean = null; + + MOrder order = null; + if (orderID!= null) + { + order = new MOrder(ctx, orderID.intValue(), null); + webBean = OrderReferenceManager.getWebOrderBean(ctx,order); + request.getSession().setAttribute(Constants.WEB_ORDER_BEAN, webBean); + } + + + if (webBean == null) + webBean = (WebDocumentBean) request.getSession().getAttribute(Constants.WEB_ORDER_BEAN); + + if (webBean == null) + throw new OperationException(operationException); + + request.getSession().setAttribute(Constants.ME_LOCATION, webBean.getMeLocation()); + request.getSession().setAttribute(Constants.YOU_LOCATION, webBean.getYouLocation()); + request.getSession().setAttribute(Constants.YOU_BP_LOCATION, webBean.getYoubpLocation()); + request.getSession().setAttribute(Constants.ME, webBean.getMe()); + request.getSession().setAttribute(Constants.YOU,webBean.getYou()); + request.getSession().setAttribute(Constants.MORDER, webBean.getOrder()); + request.getSession().setAttribute(Constants.MORDER_LINES_COLLECTION,webBean.getLines()); + request.getSession().setAttribute(Constants.SIMPLE_COMMAND,webBean.getSimpleCommand()); + request.getSession().setAttribute(Constants.COMPLEX_COMMAND,webBean.getComplexCommand()); + request.getSession().setAttribute(Constants.WEB_DOCUMENT_HEADER_BEAN, webBean.getHeaderBean()); + request.getSession().setAttribute(Constants.ORDER_TAX,webBean.getTotalTax()); + request.getSession().setAttribute(Constants.TOTAL_LINES,webBean.getTotalLines()); + request.getSession().setAttribute(Constants.GRAND_TOTAL,webBean.getGrandTotal()); + request.getSession().setAttribute(Constants.ALLOCATION,webBean.getAllocations()); + request.getSession().setAttribute(Constants.SALES_REP, webBean.getSalesRep()); + request.getSession().setAttribute(Constants.IS_PAID, webBean.getIsPaid()); + + ForwardConfig forwardConfig = getForward(ctx,webBean,mapping,form); + + ActionForward forward = new ActionForward(forwardConfig.getPath()); + + return forward; + } + + + private ForwardConfig getForward(Properties ctx, WebDocumentBean webBean, ActionMapping mapping, ActionForm form) throws OperationException + { + ActionConfig config = mapping.getModuleConfig().findActionConfig("/ViewOrderAction"); + + MOrder order = webBean.getOrder(); + + String orderType = order.getOrderType(); + + webBean.setCtx(ctx); + + if (orderType == null) + throw new OperationException("Cannot determine type of order. Type is null"); + + + //Tamak POS Order + if(orderType.equals(UDIOrderTypes.POS_ORDER.getOrderType())) + return getCustomerOrderForward(webBean,config); + + + + //Material Return Order + if(orderType.equals(UDIOrderTypes.CUSTOMER_RETURN_ORDER.getOrderType())) + return getMROForward(webBean, config); + + // WEBSTORE ORDER + if (orderType.equals(UDIOrderTypes.WEBSTORE_ORDER.getOrderType())) + return getWebstoreOrderForward(ctx, webBean,config); + + // DEFAULT + return config.findForwardConfig(Constants.FINISHED_DO); + } + + + + + + + public ForwardConfig getAllocationOrderForward(WebDocumentBean bean, ActionConfig config) + { + MOrder order = bean.getOrder(); + + String docStatus = order.getDocStatus(); + + if (!order.isActive()) + return config.findForwardConfig(Constants.CANCEL_DO); + + if (docStatus.equals(DocumentEngine.STATUS_Drafted)) + return config.findForwardConfig(Constants.UNFINISHED_AL); + + if (docStatus.equals(DocumentEngine.STATUS_InProgress)) + return config.findForwardConfig(Constants.SWAP_VIN); + + if (docStatus.equals(DocumentEngine.STATUS_Voided)) + return config.findForwardConfig(Constants.UNFINISHED_AL); + + return config.findForwardConfig(Constants.GENERATE_INVOICE); + } + + // same as for customer order + private ForwardConfig getUsedCarPurchaseOrderForward(WebDocumentBean webBean, ActionConfig config) throws OperationException + { + MOrder order = webBean.getOrder(); + + String status = order.getDocStatus(); + + if (status.equals(DocumentEngine.STATUS_Completed)) + return config.findForwardConfig(Constants.PROGRESS_TI); + + if (!order.isActive()) + return config.findForwardConfig(Constants.CANCEL_DO); + + + return config.findForwardConfig(Constants.PROGRESS_TI); + } + + + private ForwardConfig getCustomerOrderForward(WebDocumentBean webBean, ActionConfig config) throws OperationException + { + MOrder order = webBean.getOrder(); + + String status = order.getDocStatus(); + + + if (status.equals(DocumentEngine.STATUS_Drafted)) + { + return config.findForwardConfig(Constants.UNFINISHED_NR); + } + + if(status.equals(DocumentEngine.STATUS_InProgress)) + return config.findForwardConfig(Constants.PROGRESS_NR); + + if (status.equals(DocumentEngine.STATUS_Completed)) + return config.findForwardConfig(Constants.FINISHED_NR); + + + if (!order.isActive()) + return config.findForwardConfig(Constants.CANCEL_DO); + + return config.findForwardConfig(Constants.UNFINISHED_NR); + } + + private ForwardConfig getMROForward(WebDocumentBean webBean, ActionConfig config) + { + MOrder order = webBean.getOrder(); + + if (order.isSOTrx()) + return getSO_MROForward(webBean, config); + + return getPO_MROForward(webBean, config); + } + + + + + private ForwardConfig getSO_MROForward(WebDocumentBean webBean, ActionConfig config) + { + MOrder order = webBean.getOrder(); + + if (!order.isActive()) + { + return config.findForwardConfig(Constants.CANCEL_DO); + } + + return config.findForwardConfig(Constants.PROGRESS_DT); + } + + private ForwardConfig getPO_MROForward(WebDocumentBean orderBean, ActionConfig config) + { + MOrder order = orderBean.getOrder(); + + + if (order == null) + { + + return config.findForwardConfig(Constants.CANCEL_DO); + } + + String status = order.getDocStatus(); + + if (status.equals(DocumentEngine.STATUS_Drafted)) + { + //orderStatusMessage = "status drafted"; + } + + if (!order.isActive()) + return config.findForwardConfig(Constants.CANCEL_DO); + + + return config.findForwardConfig(Constants.PROGRESS_DT); + + } + + private ForwardConfig getWebstoreOrderForward(Properties ctx, WebDocumentBean webBean, ActionConfig config) throws OperationException + { + + int userId = Env.getAD_User_ID(ctx); + new MUser(ctx, userId, null); + + + return getWebstoreSOForward(webBean, config); + } + + public ForwardConfig getWebstoreSOForward(WebDocumentBean orderBean, ActionConfig config) throws OperationException + { + + MOrder order = orderBean.getOrder(); + + + if (order == null) + throw new OperationException("Order cannot be NULL!"); + + + return config.findForwardConfig(Constants.WEBSTORE_PROGRESS_DO); + } + + + public ForwardConfig getPO_SCO_Forward(WebDocumentBean webBean, ActionConfig config) + { + MOrder order = webBean.getOrder(); + + if (order == null) + { + return config.findForwardConfig(Constants.CANCEL_SCO); + } + + if (!order.isActive()) + { + return config.findForwardConfig(Constants.CANCEL_SCO); + } + + + String status = order.getDocStatus(); + + if (status.equals(DocumentEngine.STATUS_Drafted)) + { + return config.findForwardConfig(Constants.UNFINISHED_SCO); + } + + + if (status.equals(DocumentEngine.STATUS_Voided)) + { + return config.findForwardConfig(Constants.PROGRESS_SCO); + } + + + return config.findForwardConfig(Constants.PROGRESS_SCO); + + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/BarcodeAction.java b/posterita/src/main/org/posterita/struts/pos/BarcodeAction.java new file mode 100644 index 0000000000..743f5f6055 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/BarcodeAction.java @@ -0,0 +1,54 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 17-Aug-2006 13:49:29 by praveen + * + */ + +package org.posterita.struts.pos; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.businesslogic.BarcodeManager; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + +public class BarcodeAction extends POSDispatchAction +{ + public ActionForward getBarcodeImage(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd !=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + String barcode = df.getBarCode(); + + //send image + BarcodeManager.writeBarcode(barcode,response); + + return null; + + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/BlackListedAction.java b/posterita/src/main/org/posterita/struts/pos/BlackListedAction.java new file mode 100644 index 0000000000..16f7c09b7b --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/BlackListedAction.java @@ -0,0 +1,232 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.BlackListedBean; +import org.posterita.businesslogic.BlackListedManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.form.BlackListForm; +import org.posterita.struts.core.DefaultForm; + +public class BlackListedAction extends POSDispatchAction +{ + public static final String CREATE_BLACKLISTED="createBlackListed"; + public ActionForward createBlackListed(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd != null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + BlackListedBean bean =(BlackListedBean)df.getBean(); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + try + { + trx.start(); + BlackListedManager.createBlackListed(ctx, bean, trx.getTrxName()); + trx.commit(); + } + catch (OperationException ex) + { + trx.rollback(); + throw ex; + + } + finally + { + trx.close(); + } + request.setAttribute(Constants.BLACKLISTED_DETAILS, bean); + return mapping.findForward(CREATE_BLACKLISTED); + + + } + + public static final String GET_ALL_BLACKLISTED ="getAllBlackListed"; + public ActionForward getAllBlackListed(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + if (fwd!=null) + return fwd; + Properties ctx= TmkJSPEnv.getCtx(request); + ArrayList blackListedList = BlackListedManager.getAllBlackListed(ctx); + request.getSession().setAttribute(Constants.BLACKLISTED_LISTS , blackListedList); + return mapping.findForward(GET_ALL_BLACKLISTED); + } + + public static final String INIT_SEARCH_CHEQUE="initSearchCheque"; + public ActionForward initSearchCheque(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ArrayList Blacklist = new ArrayList(); + request.getSession().setAttribute(Constants.BLACKLISTED_LISTS, Blacklist); + + return mapping.findForward(INIT_SEARCH_CHEQUE); + } + + public static final String SEARCH_CHEQUE="searchCheque"; + public ActionForward searchCheque(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm)form; + + //BlackListedBean bean = (BlackListedBean)df.getBean(); + + ArrayList Blacklist = BlackListedManager.searchChequeNo(ctx, df.getChequeNo()); + + request.getSession().setAttribute(Constants.BLACKLISTED_LISTS, Blacklist); + + return mapping.findForward(SEARCH_CHEQUE); + + } + + public static final String INIT_EDIT_CHEQUE="initEditCheque"; + public ActionForward initEditCheque(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + + BlackListForm f = (BlackListForm) form; + f.validate(mapping,request); + + BlackListedBean bean = (BlackListedBean) f.getBean(); + Integer blacklistedID = bean.getBlackListedId(); + + if(blacklistedID==null) + { + throw new OperationException("Cannot edit Cheques. Cause BlacklistedID id cannot be null!"); + } + + bean= BlackListedManager.getBlackListedDetails(ctx, blacklistedID); + f.populate(bean); + + return mapping.findForward(INIT_EDIT_CHEQUE); + } + + + public static final String EDIT_CHEQUE = "editCheque"; + public ActionForward editCheque(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + BlackListForm f = (BlackListForm) form; + BlackListedBean bean=(BlackListedBean)f.getBean(); + + Integer blacklistedID = bean.getBlackListedId(); + if(blacklistedID==null) + { + throw new OperationException("Cannot load Cheque details. Cause BlacklistedId cannot be null!"); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + trx.start(); + + try + { + BlackListedManager.editBlackListed(ctx, bean, trx.getTrxName()); + trx.commit(); + } + catch(OperationException ex) + { + trx.rollback(); + throw ex; + } + finally + { + trx.close(); + } + request.getSession().setAttribute(Constants.BLACKLISTED_DETAILS,bean); + return mapping.findForward(EDIT_CHEQUE); + } + + + public static final String DEACTIVATE_CHEQUE = "deactivateCheque"; + public ActionForward deactivateCheque(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + BlackListForm f=(BlackListForm)form; + f.validate(mapping,request); + + BlackListedBean bean=(BlackListedBean)f.getBean(); + Integer blackListedId = bean.getBlackListedId(); + + if(blackListedId==null) + { + throw new OperationException("Cannot deactivate Blacklisted Cheques. Cause BlackListed id cannot be null!"); + } + + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + try + { + trx.start(); + BlackListedManager.deactivateBListedCheque(ctx, blackListedId.intValue(), trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.deactivate.customer", request); + mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return mapping.findForward(DEACTIVATE_CHEQUE); + } + + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/struts/pos/BpartnerInfoAction.java b/posterita/src/main/org/posterita/struts/pos/BpartnerInfoAction.java new file mode 100644 index 0000000000..753a9ea75a --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/BpartnerInfoAction.java @@ -0,0 +1,98 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 26, 2006 + */ + + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.Constants; +import org.posterita.beans.BPartnerInfoBean; +import org.posterita.businesslogic.MenuManager; +import org.posterita.businesslogic.POSBpartnerInfoManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.factory.POSMenuFactory; +import org.posterita.struts.core.DefaultForm; + + +public class BpartnerInfoAction extends POSDispatchAction +{ + public static final String GET_BPARTNER_INFO = "getBpartnerInfo"; + public ActionForward getBpartnerInfo(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + BPartnerInfoBean bean=(BPartnerInfoBean) df.getBean(); + + ArrayList list = POSBpartnerInfoManager.getPartnerInfo(ctx,bean.getPartnerName(),bean.getIsCustomer()); + + request.getSession().setAttribute(Constants.BUSINESSPARTNER,list); + request.getSession().removeAttribute(Constants.DEBTORS); + + return mapping.findForward(GET_BPARTNER_INFO); + } + + + public static final String GET_BPARTNER_TRX_DETAILS = "getBpartnerTrxDetails"; + public ActionForward getBpartnerTrxDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + BPartnerInfoBean bean=(BPartnerInfoBean) df.getBean(); + + boolean access=MenuManager.getRoleMenuAccess(ctx,POSMenuFactory.SMENU_VIEW_BPINFO); + if(access==false) + { + postGlobalError("error.access.not.allowed",request); + return new ActionForward(bean.getForward()); + } + + ArrayList list = POSBpartnerInfoManager.getbPartnerTrxDetails(ctx,bean.getBpartnerId(),bean.getIsCustomer()); + ArrayList orderList=POSBpartnerInfoManager.getBpartnerOrderHistory(ctx,bean.getBpartnerId()); + ArrayList infoList = POSBpartnerInfoManager.getPartnerInfo(ctx,bean.getBpartnerId(),bean.getIsCustomer()); + + request.getSession().setAttribute(Constants.BUSINESSPARTNERINFO,infoList); + request.getSession().setAttribute(Constants.BUSINESSPARTNER_TRX_DETAILS,list); + request.getSession().setAttribute(Constants.BUSINESSPARTNER_ORDER_DETAILS,orderList); + + return mapping.findForward(GET_BPARTNER_TRX_DETAILS); + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/CashAction.java b/posterita/src/main/org/posterita/struts/pos/CashAction.java new file mode 100644 index 0000000000..e6339c474f --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/CashAction.java @@ -0,0 +1,133 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Created on Sep 11, 2006 by ashley +* +*/ + +/** + @author ashley + */ + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.Constants; +import org.posterita.beans.CashBean; +import org.posterita.beans.CashLineBean; +import org.posterita.beans.CashSummaryBean; +import org.posterita.beans.DateFilterBean; +import org.posterita.beans.POSHistoryBean; +import org.posterita.businesslogic.CashManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.form.POSHistoryForm; +import org.posterita.struts.core.DefaultForm; + +public class CashAction extends POSDispatchAction +{ + + public static final String INIT_GET_CASH_DETAILS_HISTORY = "initGetCashDetailsHistory"; + public ActionForward initGetCashDetailsHistory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + getCashDetailsHistory(mapping, new POSHistoryForm(), request, response); + + return mapping.findForward(INIT_GET_CASH_DETAILS_HISTORY); + } + + public static final String GET_CASH_DETAILS_HISTORY = "getCashDetailsHistory"; + public ActionForward getCashDetailsHistory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm)form; + + Properties ctx = TmkJSPEnv.getCtx(request); + + POSHistoryBean historyBean = (POSHistoryBean)df.getBean(); + + ArrayList cashList = CashManager.getCashDetails(ctx, historyBean.getMonth(), historyBean.getYear(), null); + + request.getSession().setAttribute(Constants.CASH_DETAILS, cashList); + + return mapping.findForward(GET_CASH_DETAILS_HISTORY); + } + + public static final String GET_CASHLINE_DETAILS = "getCashLineDetails"; + public ActionForward getCashLineDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm)form; + + Properties ctx = TmkJSPEnv.getCtx(request); + + CashBean cashBean = (CashBean)df.getBean(); + + CashSummaryBean cashSummaryBean = CashManager.getCashSummary(ctx, cashBean.getCashId(), null); + + ArrayList cashLineList = CashManager.getCashLineHistory(ctx, cashBean.getCashId(), null); + + request.setAttribute(Constants.CASH_LINE_DETAILS, cashLineList); + request.setAttribute(Constants.CASH_SUMMARY, cashSummaryBean); + + return mapping.findForward(GET_CASHLINE_DETAILS); + } + + public static final String GET_CASH_SUMMARY_BY_DATE = "getCashSummaryByDate"; + public ActionForward getCashSummaryByDate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm)form; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DateFilterBean dateBean = (DateFilterBean)df.getBean(); + + CashSummaryBean cashSummaryBean = CashManager.getCashSummary(ctx, dateBean.getFromDate(), dateBean.getToDate(), null); + + ArrayList cashLineList = CashManager.getCashLineHistory(ctx, dateBean.getFromDate(), dateBean.getToDate(), null); + + request.setAttribute(Constants.CASH_LINE_DETAILS, cashLineList); + request.setAttribute(Constants.CASH_SUMMARY, cashSummaryBean); + + return mapping.findForward(GET_CASH_SUMMARY_BY_DATE); + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/CashBookAction.java b/posterita/src/main/org/posterita/struts/pos/CashBookAction.java new file mode 100644 index 0000000000..1cbdecb382 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/CashBookAction.java @@ -0,0 +1,383 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 22-Mar-2006 + */ + + +package org.posterita.struts.pos; + +import java.io.IOException; +import java.io.OutputStream; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MCurrency; +import org.compiere.util.Env; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.CashBookDetailBean; +import org.posterita.beans.CurrentTillAmountBean; +import org.posterita.businesslogic.CashManager; +import org.posterita.businesslogic.POSManager; +import org.posterita.businesslogic.POSReportManager; +import org.posterita.businesslogic.POSTerminalManager; +import org.posterita.businesslogic.PrintManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.CanNotAjdustTillException; +import org.posterita.exceptions.CanNotCloseTillException; +import org.posterita.exceptions.NullTransferAmountException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.TransferAmountExceedsTotalAmountException; +import org.posterita.lib.UdiConstants; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + + +public class CashBookAction extends BaseDispatchAction +{ + + public static final String GET_CASH_BOOK_DETAILS="getCashBookDetails"; + + public ActionForward getCashBookDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList list = CashManager.getCashBookDetails(ctx); + + request.getSession().setAttribute(Constants.CASH_BOOK,list); + + return mapping.findForward(GET_CASH_BOOK_DETAILS); + } + + + + public static final String ADJUST_CASH_BOOK_ACTION="adjustCashBookAction"; + public ActionForward adjustCashBookAction(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + + DefaultForm df = (DefaultForm)form; + CashBookDetailBean bean =(CashBookDetailBean)df.getBean(); + Properties ctx = TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + CashManager.adjustCashBook(ctx,bean,trx.getTrxName()); + trx.commit(); + + } + catch(NullTransferAmountException e) + { + + trx.rollback(); + postGlobalError("error.no.transfer.amount",request); + return mapping.getInputForward(); + + } + + catch(TransferAmountExceedsTotalAmountException e) + { + + trx.rollback(); + postGlobalError("error.transferAmt.exceeds.endingBalance",request); + return mapping.getInputForward(); + + } + catch(CanNotAjdustTillException e) + { + + trx.rollback(); + postGlobalError("error.cannot.adjust.till",request); + return mapping.getInputForward(); + + } + catch(NumberFormatException e) + { + + trx.rollback(); + postGlobalError("error.invalid.number",request); + return mapping.getInputForward(); + + } + + finally + { + trx.close(); + } + + ArrayList list = CashManager.getCashBookDetails(ctx); + request.getSession().setAttribute(Constants.CASH_BOOK,list); + + return mapping.findForward(ADJUST_CASH_BOOK_ACTION); + } + + + + public static final String CLOSE_CASH_BOOK="closeCashBook"; + public ActionForward closeCashBook(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + + DefaultForm df = (DefaultForm)form; + CashBookDetailBean bean =(CashBookDetailBean)df.getBean(); + Properties ctx = TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + CashManager.CloseCashBook(ctx,bean,trx.getTrxName()); + trx.commit(); + + } + catch(NullTransferAmountException e) + { + + trx.rollback(); + postGlobalError("error.no.transfer.amount",request); + return mapping.getInputForward(); + + } + + catch(TransferAmountExceedsTotalAmountException e) + { + + trx.rollback(); + postGlobalError("error.transferAmt.exceeds.endingBalance",request); + return mapping.getInputForward(); + + } + + catch(CanNotCloseTillException e) + { + + trx.rollback(); + postGlobalError("error.cannot.close.till",request); + return mapping.getInputForward(); + + } + + catch(NumberFormatException e) + { + + trx.rollback(); + postGlobalError("error.invalid.number",request); + return mapping.getInputForward(); + + } + catch(OperationException e) + { + trx.rollback(); + throw e; + + /**not thorwing the exception because, it caters for + * tranferring the card /cheque amt when there is no cash order*/ + } + + finally + { + trx.close(); + } + + ArrayList list = CashManager.getCashBookDetails(ctx); + request.getSession().setAttribute(Constants.CASH_BOOK,list); + + return mapping.findForward(CLOSE_CASH_BOOK); + } + + + public static final String INIT_CLOSE_TILL="initCloseTill"; + public ActionForward initCloseTill(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + + CurrentTillAmountBean tillBean = POSManager.getCurrentTillAmount(ctx); + request.setAttribute(Constants.CURRENT_TILL_AMOUNT_POS,tillBean); + MCurrency currency = POSTerminalManager.getCurrencyOfDefaultCashBook(ctx); + request.setAttribute(Constants.CURRENCY_SYMBOLE,currency.getCurSymbol()); + return mapping.findForward(INIT_CLOSE_TILL); + + } + + public static final String CLOSE_TILL="closeTill"; + public ActionForward closeTill(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, SQLException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + + DefaultForm df = (DefaultForm)form; + CashBookDetailBean bean =(CashBookDetailBean)df.getBean(); + if(bean.getTransferAmount()!=null) + bean.setTransferAmount(bean.getTransferAmount().replaceAll(",","")); + Properties ctx = TmkJSPEnv.getCtx(request); + CurrentTillAmountBean tillBean=null; + + tillBean = POSManager.getCurrentTillAmount(ctx); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + bean=CashManager.CloseTill(ctx,bean,trx.getTrxName()); + trx.commit(); + + } + catch(NullTransferAmountException e) + { + + trx.rollback(); + postGlobalError("error.no.transfer.amount",request); + return mapping.getInputForward(); + + } + + + + catch(CanNotCloseTillException e) + { + + trx.rollback(); + postGlobalError("error.till.already.close",request); + return mapping.getInputForward(); + + } + + catch(NumberFormatException e) + { + + trx.rollback(); + postGlobalError("error.invalid.number",request); + return mapping.getInputForward(); + + } + catch(OperationException e) + { + trx.rollback(); + throw e; + } + + finally + { + request.setAttribute(Constants.CURRENT_TILL_AMOUNT_POS,tillBean); + trx.close(); + } + + String reportName = POSReportManager.endOfTheDayPDF(ctx,tillBean,bean); //generates report + String reportURI = ReportManager.getReportURI(reportName,request); //resolves report path + + + String data = POSReportManager.endOfTheDayReport(ctx,tillBean,bean); + + Timestamp ts = new Timestamp(System.currentTimeMillis()); + int posId = Env.getContextAsInt(ctx,UdiConstants.POS_ID); + String salesData = POSReportManager.getDailySalesReport(ctx,ts,posId, null); + + request.getSession().setAttribute(Constants.CLOSE_TILL_PRINT_DATA, data + salesData); + + request.setAttribute(Constants.CURRENT_TILL_AMOUNT_POS,tillBean); + request.setAttribute(Constants.END_OF_THE_DAY_DETAILS,bean); + request.setAttribute(Constants.REPORT_URL,reportURI); + + + return mapping.findForward(CLOSE_TILL); + } + + public static final String OPEN_CASH_DRAWER="openCashDrawer"; + + public ActionForward openCashDrawer(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + PrintManager.openCashDrawer(ctx); + + return null; + + } + + //--------------------------------------------------------------- + public ActionForward getClosedTillData(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + byte [] openCashDrawer= {10,27,112,48,55,1}; + String printData = (String)request.getSession().getAttribute(Constants.CLOSE_TILL_PRINT_DATA); + + try + { + response.setContentType("application/octet-stream"); + OutputStream os = response.getOutputStream(); + os.write(openCashDrawer); + os.write(printData.getBytes()); + os.flush(); + os.close(); + } + catch (IOException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + return null; + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/CommissionAction.java b/posterita/src/main/org/posterita/struts/pos/CommissionAction.java new file mode 100644 index 0000000000..432e29b3dc --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/CommissionAction.java @@ -0,0 +1,114 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Nov 7, 2006 + */ + + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MCurrency; +import org.posterita.Constants; +import org.posterita.beans.CommissionBean; +import org.posterita.beans.ReportBean; +import org.posterita.businesslogic.CommissionManager; +import org.posterita.businesslogic.POSTerminalManager; +import org.posterita.businesslogic.ReportDateManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + + +public class CommissionAction extends POSDispatchAction +{ + + public static final String GENERATE_COMMISSION="generateCommission"; + public ActionForward generateCommission(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + ReportBean bean = (ReportBean) df.getBean(); + MCurrency currency = POSTerminalManager.getCurrencyOfDefaultCashBook(ctx); + request.setAttribute(Constants.CURRENCY_SYMBOLE,currency.getCurSymbol()); + + String fromdate = ReportDateManager.getFromDate(bean); + CommissionManager.generateCommission(ctx,fromdate); + ArrayList list=CommissionManager.getCommissionAmt(ctx); + String reportName = CommissionManager.getCommissionAmtAsCSV(ctx, list); + String reportURI = ReportManager.getReportURI(reportName, request); + + request.getSession().setAttribute(Constants.COMMISSION_AMT,list); + request.getSession().setAttribute(Constants.REPORT_URL, reportURI); + + return mapping.findForward(GENERATE_COMMISSION); + } + + public static final String VIEW_COMMISSION="viewCommission"; + public ActionForward viewCommission(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + ArrayList list=CommissionManager.getCommissionAmt(ctx); + String reportName = CommissionManager.getCommissionAmtAsCSV(ctx, list); + String reportURI = ReportManager.getReportURI(reportName, request); + + request.getSession().setAttribute(Constants.COMMISSION_AMT,list); + request.getSession().setAttribute(Constants.REPORT_URL, reportURI); + + return mapping.findForward(VIEW_COMMISSION); + } + + + public static final String VIEW_COMMISSION_DETAILS="viewCommissionDetails"; + public ActionForward viewCommissionDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + CommissionBean bean = (CommissionBean) df.getBean(); + + ArrayList list=CommissionManager.getCommissionDetails(ctx,bean.getCommissionAmtId()); + request.getSession().setAttribute(Constants.COMMISSION_AMT_DETAILS,list); + + return mapping.findForward(VIEW_COMMISSION_DETAILS); + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/CreditOrderAction.java b/posterita/src/main/org/posterita/struts/pos/CreditOrderAction.java new file mode 100644 index 0000000000..7daba11164 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/CreditOrderAction.java @@ -0,0 +1,721 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 13, 2006 + */ + + +package org.posterita.struts.pos; + +import java.io.IOException; +import java.io.PrintWriter; +import java.math.BigDecimal; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MCurrency; +import org.compiere.model.MInOut; +import org.compiere.model.MInvoice; +import org.compiere.model.MOrder; +import org.compiere.model.MPayment; +import org.compiere.util.Env; +import org.compiere.util.Trx; +import org.compiere.util.WebUser; +import org.posterita.Constants; +import org.posterita.beans.DocumentHistoryBean; +import org.posterita.beans.LoginBean; +import org.posterita.beans.OpenItemBean; +import org.posterita.beans.OrderLineBean; +import org.posterita.beans.PaymentAllocationBean; +import org.posterita.beans.PaymentTypeBean; +import org.posterita.beans.ShoppingCartBean; +import org.posterita.beans.WebDocumentBean; +import org.posterita.businesslogic.BPartnerManager; +import org.posterita.businesslogic.CreditOrderManager; +import org.posterita.businesslogic.LoginManager; +import org.posterita.businesslogic.MenuManager; +import org.posterita.businesslogic.OrderManager; +import org.posterita.businesslogic.OrderReferenceManager; +import org.posterita.businesslogic.POSBpartnerInfoManager; +import org.posterita.businesslogic.POSManager; +import org.posterita.businesslogic.POSTerminalManager; +import org.posterita.businesslogic.PaymentAllocationManager; +import org.posterita.businesslogic.PaymentManager; +import org.posterita.businesslogic.PaymentTermManager; +import org.posterita.businesslogic.RoleManager; +import org.posterita.core.SessionStorage; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BPartnerNotFoundException; +import org.posterita.exceptions.BPartnerOverCreditLimitException; +import org.posterita.exceptions.CanNotCreatePaymentAllocationException; +import org.posterita.exceptions.DiscountLimitException; +import org.posterita.exceptions.DuplicatePINException; +import org.posterita.exceptions.InsufficientQtyException; +import org.posterita.exceptions.InvalidAddressException; +import org.posterita.exceptions.InvalidPINException; +import org.posterita.exceptions.LimitPriceVioletException; +import org.posterita.exceptions.MandatoryException; +import org.posterita.exceptions.NoAllocateeInvoiceException; +import org.posterita.exceptions.NoPaymentAmountException; +import org.posterita.exceptions.NotLoggedInException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.TooManyAllocateInvoiceException; +import org.posterita.exceptions.UserInactiveException; +import org.posterita.exceptions.UserNotFoundException; +import org.posterita.factory.POSMenuFactory; +import org.posterita.form.DocumentHistoryForm; +import org.posterita.form.OpenItemForm; +import org.posterita.struts.core.DefaultForm; + + +public class CreditOrderAction extends POSDispatchAction +{ + + + public static final String GET_BPARTNER_PAYMENT_STATUS="getBpartnerPaymentStatus"; + public ActionForward getBpartnerPaymentStatus(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OpenItemBean bean=(OpenItemBean) df.getBean(); + boolean access=MenuManager.getRoleMenuAccess(ctx,POSMenuFactory.SMENU_SETTLE_PAYMENT_ID); + if(access==false) + { + postGlobalError("error.access.not.allowed",request); + return new ActionForward(bean.getForward()); + } + + ArrayList openItemList = null; + ArrayList agingList = null; + ArrayList paymentList = null; + try + { + openItemList=CreditOrderManager.getOpenItems(ctx,bean.getBpartnerId()); + agingList = CreditOrderManager.getAging(ctx,bean.getBpartnerId()); + paymentList = CreditOrderManager.getUnallocatedPayments(ctx,bean.getBpartnerId()); + + } + catch(BPartnerNotFoundException e) + { + postGlobalError("error.customer.not.exists",request); + return mapping.getInputForward(); + } + + + request.getSession().setAttribute(Constants.OPEN_ITEMS,openItemList); + request.getSession().setAttribute(Constants.AGING_ITEMS,agingList); + request.getSession().setAttribute(Constants.UNALLOCATED_PAYMENTS,paymentList); + return mapping.findForward(GET_BPARTNER_PAYMENT_STATUS); + } + + + public static final String MATCH_INVOICE = "matchInvoice"; + public ActionForward matchInvoice(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OpenItemBean bean=(OpenItemBean) df.getBean(); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + try + { + trx.start(); + PaymentAllocationManager.allocate(ctx,bean.getInvoiceIds(),bean.getPaymentIds(),trx.getTrxName()); + trx.commit(); + } + + catch(TooManyAllocateInvoiceException e) + { + trx.rollback(); + postGlobalError("error.too.many.invoice",request); + return mapping.getInputForward(); + } + catch(CanNotCreatePaymentAllocationException e1) + { + trx.rollback(); + postGlobalError("error.allocation.amt.exceeds.openamt",request); + return mapping.getInputForward(); + } + catch(NoAllocateeInvoiceException e2) + { + trx.rollback(); + postGlobalError("error.no.invoice.to.allocate",request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + ArrayList openItemList=CreditOrderManager.getOpenItems(ctx,bean.getBpartnerId()); + ArrayList agingList = CreditOrderManager.getAging(ctx,bean.getBpartnerId()); + ArrayList paymentList = CreditOrderManager.getUnallocatedPayments(ctx,bean.getBpartnerId()); + + request.getSession().setAttribute(Constants.UNALLOCATED_PAYMENTS,paymentList); + request.getSession().setAttribute(Constants.OPEN_ITEMS,openItemList); + request.getSession().setAttribute(Constants.AGING_ITEMS,agingList); + + df.setInvoiceIds(null); + df.setPaymentIds(null); + + return mapping.findForward(MATCH_INVOICE); + } + + + public static final String INIT_GET_BPARTNER_PAYMENT_STATUS = "initGetBpartnerPaymentStatus"; + public ActionForward initGetBpartnerPaymentStatus(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + //DefaultForm df= (DefaultForm) form; + ArrayList list = POSBpartnerInfoManager.getPartnerInfo(ctx,true); + request.getSession().removeAttribute(Constants.UNALLOCATED_PAYMENTS); + request.getSession().removeAttribute(Constants.OPEN_ITEMS); + request.getSession().removeAttribute(Constants.AGING_ITEMS); + request.getSession().setAttribute(Constants.BUSINESSPARTNER,list); + return mapping.findForward(INIT_GET_BPARTNER_PAYMENT_STATUS); + } + + + public static final String INIT_CREATE_PAYMENT = "initCreatePayment"; + public ActionForward initCreatePayment(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + // Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OpenItemBean bean=(OpenItemBean) df.getBean(); + request.getSession().setAttribute(Constants.CREDIT_INVOICE_INFO,bean); + return mapping.findForward(INIT_CREATE_PAYMENT); + } + + public static final String CREATE_PAYMENT = "createPayment"; + public ActionForward createPayment(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OpenItemBean bean=(OpenItemBean) df.getBean(); + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + PaymentTypeBean pBean =null; + + HashMap map = new HashMap(); + map.put("Cash",MInvoice.PAYMENTRULE_Cash); + map.put("Card",MPayment.TENDERTYPE_CreditCard); + map.put("Cheque",MPayment.TENDERTYPE_Check); + + bean.setTrxType(map.get(bean.getTrxType())); + + try + { + trx.start(); + pBean = CreditOrderManager.createPayment(ctx,bean,trx.getTrxName()); + MCurrency currency = POSTerminalManager.getCurrencyOfDefaultCashBook(ctx); + request.setAttribute(Constants.CURRENCY_SYMBOLE,currency.getCurSymbol()); + + trx.commit(); + if(!pBean.getPaymentType().equalsIgnoreCase("cash")) + { + MPayment payment = new MPayment(ctx,pBean.getId(),null); + PaymentManager.completePayment(ctx,payment); + request.getSession().removeAttribute(Constants.OPEN_ITEMS); + request.getSession().removeAttribute(Constants.AGING_ITEMS); + trx.close(); + return new ActionForward("/ViewWebstorePaymentAction.do?action=viewOrder&documentId="+payment.get_ID()); + } + } + catch(NoPaymentAmountException ex) + { + trx.rollback(); + postGlobalError("error.paymentamount.mandatory",request); + return mapping.getInputForward(); + } + catch(OperationException e) + { + trx.rollback(); + } + finally + { + trx.close(); + } + + request.getSession().removeAttribute(Constants.OPEN_ITEMS); + request.getSession().removeAttribute(Constants.AGING_ITEMS); + + + return new ActionForward("/ViewWebstoreCashPaymentAction.do?action=viewOrder&documentId="+pBean.getId()); + //return mapping.findForward(CREATE_PAYMENT); + } + + + public static final String GET_PAYMENT_DETAILS_FOR_INVOICE = "getPaymentDetailsForInvoice"; + public ActionForward getPaymentDetailsForInvoice(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OpenItemBean bean=(OpenItemBean) df.getBean(); + ArrayList cashPaymentList = CreditOrderManager.getAllCashPaymentForInvoice(ctx,bean.getInvoiceId()); + ArrayList cardChqPaymentList=CreditOrderManager.getAllPaymentForInvoice(ctx,bean.getInvoiceId()); + request.getSession().setAttribute(Constants.CASH_PAYMENT_LIST,cashPaymentList); + request.getSession().setAttribute(Constants.CARD_CHQ_PAYMENT_LIST,cardChqPaymentList); + request.getSession().setAttribute(Constants.INVOICE_GRAND_TOTAL,bean.getPaidAmt()); + return mapping.findForward(GET_PAYMENT_DETAILS_FOR_INVOICE); + } + + + + + public static final String GET_CRDITORDER_DISC_DETAILS="getCreditOrderDiscDetails"; + public ActionForward getCreditOrderDiscDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + Properties ctx=TmkJSPEnv.getCtx(request); + Integer bPartnerId = bean.getBpartnerId(); + MOrder order=null; + String toBeShipped=bean.getToBeShipped(); + if(toBeShipped==null) + { + toBeShipped=(String)request.getSession().getAttribute(Constants.TO_BE_SHIPPED); + bean.setToBeShipped(toBeShipped); + } + if(toBeShipped==null) + { + toBeShipped="true"; + } + + if(bPartnerId==null) + { + postGlobalError("error.required.bpartnerId",request); + return mapping.getInputForward(); + } + if(BPartnerManager.isBPartnerPresent(ctx,bPartnerId,null) == false) + { + postGlobalError("error.customer.not.exists",request); + return mapping.getInputForward(); + } + + if(bean.getOrderId()!=null) + { + order = new MOrder(ctx, bean.getOrderId(), null); + } + + df.populate(new OrderLineBean()); + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.CREDIT_ORDER_SHOPPING_CART); + if(cartBean==null) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + request.getSession().setAttribute(Constants.CREDIT_ORDER_SHOPPING_CART, cartBean); + request.getSession().setAttribute(Constants.PRESENT_CREDIT_ORDER,order); + request.getSession().setAttribute(Constants.CREDITORDER_BPARTNER,bPartnerId); + request.getSession().setAttribute(Constants.TO_BE_SHIPPED,bean.getToBeShipped()); + request.getSession().setAttribute(Constants.CREDIT_ORDER_SHOPPING_CART_ITEMS, cartBean.getItems()); + return mapping.findForward(GET_CRDITORDER_DISC_DETAILS); + } + + public static final String CREATE_CREDIT_ORDER="createCreditOrder"; + public ActionForward createCreditOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.CREDIT_ORDER_SHOPPING_CART); + + if(cartBean==null ||cartBean.getItems() == null||cartBean.getItems().size()==0) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + + String toBeShipped=bean.getToBeShipped(); + if(toBeShipped==null) + { + toBeShipped=(String)request.getSession().getAttribute(Constants.TO_BE_SHIPPED); + bean.setToBeShipped(toBeShipped); + } + if(toBeShipped==null) + { + toBeShipped="true"; + } + + Integer bPartnerId = bean.getBpartnerId(); + if(bPartnerId==null) + { + bPartnerId = (Integer) request.getSession().getAttribute(Constants.CREDITORDER_BPARTNER); + bean.setBpartnerId(bPartnerId); + } + + if(bPartnerId==null) + { + postGlobalError("error.required.bpartnerId",request); + return mapping.getInputForward(); + } + + if(BPartnerManager.isBPartnerPresent(ctx,bean.getBpartnerId(),null) == false) + { + postGlobalError("error.customer.not.exists",request); + return mapping.getInputForward(); + } + + BigDecimal discountAllowed = (BigDecimal) request.getSession().getAttribute( Constants.DISCOUNT_ALLOWED ); + bean.setUserDiscount( discountAllowed ); + MOrder previousOrder= null; + previousOrder=(MOrder)request.getSession().getAttribute(Constants.PRESENT_CREDIT_ORDER); + + if(previousOrder!=null) + { + bean.setOrderId(Integer.valueOf(previousOrder.get_ID())); + } + else + { + bean.setOrderId(null); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + MOrder creditOrder=null; + try + { + trx.start(); + creditOrder= CreditOrderManager.createCreditOrder(ctx,bean,cartBean.getItems(),trx.getTrxName()); + trx.commit(); + } + catch (DiscountLimitException e) + { + trx.rollback(); + postGlobalError("error.discountLimit.exceeded",request); + return mapping.getInputForward(); + } + catch(BPartnerOverCreditLimitException e1) + { + trx.rollback(); + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + + catch(MandatoryException e2) + { + trx.rollback(); + postGlobalError("error.bpartner.no.payment.term",request); + return mapping.getInputForward(); + } + catch(InsufficientQtyException e3) + { + trx.rollback(); + postGlobalError("error.insufficient.qty",e3.getMessage(),request); + return mapping.getInputForward(); + } + catch(LimitPriceVioletException e3) + { + trx.rollback(); + postGlobalError("error.limit.price.violet",e3.getMessage(),request); + return mapping.getInputForward(); + } + + catch(OperationException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + request.getSession().removeAttribute( Constants.DISCOUNT_ALLOWED ); + } + bean.setOrderId(Integer.valueOf(creditOrder.get_ID())); + df.populate(new OrderLineBean()); + WebDocumentBean webBean =null; + try + { + webBean = OrderReferenceManager.getWebOrderBean(ctx, creditOrder); + } + catch(InvalidAddressException e) + { + postGlobalError("error.invalid.address",request); + return mapping.getInputForward(); + } + + ArrayList list = POSManager.populateOrderLines(ctx,creditOrder); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER_ID,Integer.valueOf(creditOrder.get_ID())); + request.getSession().setAttribute(Constants.PRESENT_CREDIT_ORDER,creditOrder); + request.getSession().setAttribute(Constants.ORDER_LINE_BEAN,bean); + request.getSession().setAttribute(Constants.CREDITORDER_BPARTNER,bPartnerId); + request.setAttribute(Constants.POS_ORDER_LINES,list); + request.getSession().removeAttribute(Constants.PRESENT_CREDIT_ORDER); + request.getSession().removeAttribute(Constants.PRESENT_CREDIT_ORDER_ID); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + return mapping.findForward(CREATE_CREDIT_ORDER); + } + + + public static final String COMPLETE_CREDIT_ORDER="completeCreditOrder"; + public ActionForward completeCreditOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean b = (OrderLineBean) df.getBean(); + + OrderLineBean bean=(OrderLineBean) request.getSession().getAttribute(Constants.ORDER_LINE_BEAN); + bean.setAmountGiven(b.getAmountGiven()); + bean.setAmountRefunded(b.getAmountRefunded()); + + Integer orderId = (Integer) request.getSession().getAttribute(Constants.CURRENT_POS_ORDER_ID); + MOrder completedCreditOrder=null; + + if(OrderManager.isOrderEmpty(ctx,orderId.intValue(),null)) + { + postGlobalError("error.pos.no.orderline",request); + request.getSession().removeAttribute(Constants.CREDIT_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.CREDIT_ORDER_SHOPPING_CART_ITEMS); + + return mapping.getInputForward(); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + try + { + trx.start(); + completedCreditOrder=CreditOrderManager.completeCreditOrder(ctx,orderId.intValue()); + trx.commit(); + } + catch(BPartnerOverCreditLimitException e1) + { + trx.rollback(); + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(OperationException e2) + { + trx.rollback(); + throw e2; + } + finally + { + trx.close(); + } + + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx, completedCreditOrder); + ArrayList list = POSManager.populateOrderLines(ctx,completedCreditOrder); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER_ID,completedCreditOrder.get_ID()); + request.setAttribute(Constants.POS_ORDER_LINES,list); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.CREDIT_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.CREDIT_ORDER_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.CURRENT_POS_ORDER_ID); + request.getSession().removeAttribute(Constants.CREDITORDER_BPARTNER); + request.getSession().removeAttribute(Constants.SHIPMENT_REQUIRED); + request.getSession().removeAttribute(Constants.TO_BE_SHIPPED); + // String reportName = POSReportManager.getInvoicePDFReport(ctx,completedCreditOrder.getC_Invoice_ID(),null); + // String reportURI = ReportManager.getReportURI(reportName,request); + //request.getSession().setAttribute(Constants.REPORT_URL,reportURI); + return mapping.findForward(COMPLETE_CREDIT_ORDER); + } + + public ActionForward validateAdvanceOrderPIN(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws IOException, OperationException + { + Properties ctx=TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + String userPIN = df.getUserPIN(); + + LoginBean bean = null; + LoginManager loginManager = new LoginManager(); + String script = null; + + try + { + bean = loginManager.getUserNameFromPIN(ctx, userPIN); + WebUser wu = loginManager.checkLoginPassword(ctx, bean); + + int roleId = Env.getAD_Role_ID(ctx); + + BigDecimal discountAllowed = RoleManager.getDiscountAllowed(ctx, roleId, null); + + if(discountAllowed != Env.ZERO) + { + script = "setAction(document.forms[0],'GetCreditOrderDiscDetailsAction.do','getCreditOrderDiscDetails');" + + "disableButtons();"; + + request.getSession().setAttribute(Constants.DISCOUNT_ALLOWED, discountAllowed); + } + else + { + script = "PINError('It seems that you are not authorised to give discounts.');"; + } + } + catch (DuplicatePINException e) + { + script = "PINError('It seems that you are not authorised to give discounts.');"; + } + catch (InvalidPINException e) + { + script = "PINError('It seems that you are not authorised to give discounts.');"; + } + catch (UserNotFoundException e) + { + + } + catch (UserInactiveException e) + { + + } + catch (NotLoggedInException e) + { + + } + catch (SQLException e) + { + throw new OperationException(e); + } + catch (OperationException e) + { + throw new OperationException(e); + } + + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + + + public static final String GET_ALLOCATION_DETAILS_FOR_PARTNER = "getAllocationDetailsForPartner"; + public ActionForward getAllocationDetailsForPartner(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + PaymentAllocationBean bean=(PaymentAllocationBean) df.getBean(); + ArrayList allocationList = CreditOrderManager.viewAllocation(ctx,bean.getPartnerName(),bean.getInvoiceNo()); + request.getSession().setAttribute(Constants.PAYMENT_ALLOCATIONS,allocationList); + return mapping.findForward(GET_ALLOCATION_DETAILS_FOR_PARTNER); + } + + public static final String INIT_CREATE_CREDIT_ORDER = "initCreateCreditOrder"; + public ActionForward initCreateCreditOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + ArrayList list = PaymentTermManager.getAllActivePaymentTerm(ctx); + request.getSession().setAttribute (Constants.PAYMENT_TERM,list); + return mapping.findForward(INIT_CREATE_CREDIT_ORDER); + } + + + public static final String CREATE_SHIPMENT_CREDIT_ORDER = "createShipmentForCreditOrder"; + public ActionForward createShipmentForCreditOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DocumentHistoryForm dhf = (DocumentHistoryForm) form; + DocumentHistoryBean bean = (DocumentHistoryBean) dhf.getBean(); + MInOut shipment=CreditOrderManager.createAndCompleteShipment(ctx,bean.getInvoiceId()); + return new ActionForward("/ViewMinOutAction.do?action=viewOrder&documentId="+shipment.get_ID()); + } + + + + public static final String GET_MULTIPLE_INVOICE_FOR_PAYMENT = "getMultipleInvoicesForPayment"; + public ActionForward getMultipleInvoicesForPayment(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + OpenItemForm oif= (OpenItemForm) form; + OpenItemBean bean=(OpenItemBean) oif.getBean(); + ArrayList list=null; + try + { + list= PaymentAllocationManager.getInvoiceToAllocate(ctx,bean.getInvoiceIds(),null); + } + catch(NoAllocateeInvoiceException e2) + { + postGlobalError("error.no.invoice.to.allocate",request); + return mapping.getInputForward(); + } + request.getSession().setAttribute (Constants.INVOICE_FOR_ALLOCATION,list); + return mapping.findForward(GET_MULTIPLE_INVOICE_FOR_PAYMENT); + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/CustomPOSReportAction.java b/posterita/src/main/org/posterita/struts/pos/CustomPOSReportAction.java new file mode 100644 index 0000000000..6456c12779 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/CustomPOSReportAction.java @@ -0,0 +1,371 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 24-Jul-2006 15:53:04 by praveen + * + */ + +package org.posterita.struts.pos; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.compiere.model.MAttribute; +import org.compiere.model.MAttributeSet; +import org.compiere.model.MElementValue; +import org.compiere.util.Env; +import org.posterita.Constants; +import org.posterita.beans.ReportBean; +import org.posterita.businesslogic.CSVReportManager; +import org.posterita.businesslogic.CustomPOSReportManager; +import org.posterita.businesslogic.ReportDateManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.core.BarChart; +import org.posterita.core.PieChart; +import org.posterita.core.RandomStringGenerator; +import org.posterita.core.SessionStorage; +import org.posterita.core.TabularReport; +import org.posterita.core.TimeSeriesChart; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.form.SalesReportForm; + +public class CustomPOSReportAction extends POSDispatchAction +{ + public static final String INIT_CUSTOM_REPORT = "initCustomReport"; + public ActionForward initCustomReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + SalesReportForm reportForm = (SalesReportForm) form; + + //setting defaults + String chartType = PieChart.CHART_TYPE; + String accountId = "41000"; + String timePeriod = ReportDateManager.TODAY; + String salesGroup = Constants.REVENUE_RECOGNITION; + String dateRange = Constants.FIXED_DATE_RANGE; + + reportForm.setChartType(chartType); + reportForm.setAccountId(accountId); + reportForm.setTimePeriod(timePeriod); + reportForm.setSalesGroup(salesGroup); + reportForm.setDateRange(dateRange); + reportForm.setFromDate(""); + reportForm.setToDate(""); + + reportForm.validate(mapping,request); + + ReportBean reportBean = (ReportBean) reportForm.getBean(); + + SessionStorage.putSalesGroupFilter(ctx,request,reportBean); + + return mapping.findForward(INIT_CUSTOM_REPORT); + } + + + public static final String GET_CUSTOM_REPORT = "getCustomReport"; + public ActionForward getCustomReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + SalesReportForm reportForm = (SalesReportForm) form; + ReportBean bean = (ReportBean) reportForm.getBean(); + + //validate form + ActionMessages messages = validate(form); + if(!messages.isEmpty()) + { + saveErrors(request, messages); + return mapping.getInputForward(); + } + + final Integer TAX_DUE = Constants.TAX_DUE; + final Integer TAX_CREDIT = Constants.TAX_CREDIT; + final Integer PROFIT_MARGIN = Constants.PROFIT_MARGIN; + + String fromDate = null; + String toDate = null; + String dateRange = bean.getDateRange(); + String timePeriod = bean.getTimePeriod(); + String chartType = bean.getChartType(); + String salesGroup = bean.getSalesGroup(); + String priceQtyFilter = bean.getPriceQtyFilter(); + Integer account_id = bean.getAccountId(); + + String filename = RandomStringGenerator.randomstring(); + String reportPath = ReportManager.getReportPath(filename); + + String title = ""; + String subtitle = ""; + int height = 600; + int width = 700; + + //setting from and to dates + if(dateRange.endsWith(Constants.FIXED_DATE_RANGE)) + { + if(timePeriod == null) + { + throw new OperationException("Invalid Parameter for timePeriod. TimePeriod is null"); + } + + Date startDate = ReportDateManager.getStartDateForPeriod(timePeriod); + Date endDate = ReportDateManager.getEndDateForPeriod(timePeriod); + + SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + fromDate = sdf.format(startDate); + toDate = sdf.format(endDate); + + subtitle = "For " + timePeriod; + } + else if(dateRange.endsWith(Constants.CUSTOM_DATE_RANGE)) + { + fromDate = ReportDateManager.getFromDate(bean); + toDate = ReportDateManager.getToDate(bean); + + subtitle = "For period:"+fromDate+" to "+toDate; + } + else + { + throw new OperationException("Invalid Parameter for dateRange :" + dateRange); + } + + //setting title + String str = null; + boolean isProfitMargin = (account_id.equals( PROFIT_MARGIN )); + + if(isProfitMargin) + { + str = "Profit Margin"; + } + else + { + int[] ids = MElementValue.getAllIDs(MElementValue.Table_Name,"AD_CLIENT_ID ="+ Env.getAD_Client_ID(ctx) + " AND VALUE ='"+ account_id + "'",null); + + if(ids==null || ids.length==0) + { + throw new OperationException("Unable to resolve account type!"); + } + else + { + MElementValue elementValue = new MElementValue(ctx,ids[0],null); + str = elementValue.getName(); + }//else + }//else + + + + boolean isTaxDue = (account_id.equals( TAX_DUE )); + boolean isTaxCredit = (account_id.equals( TAX_CREDIT )); + + if(isTaxCredit || isTaxDue) + { + title = str; + } + else + { + title = str + " by "; + + if( + salesGroup.equalsIgnoreCase(Constants.REVENUE_RECOGNITION)|| + salesGroup.equalsIgnoreCase(Constants.ATTRIBUTESET) || + salesGroup.equalsIgnoreCase(Constants.PRODUCT) || + salesGroup.equalsIgnoreCase(Constants.GROUP1) || + salesGroup.equalsIgnoreCase(Constants.GROUP2) || + salesGroup.equalsIgnoreCase(Constants.CUSTOMER) + ) + { + title = title + salesGroup; + } + else + { + String[] s = salesGroup.split("_"); + + if(s.length!=2) + { + throw new OperationException("Cannot generate sql. Unknown salesGroup parameter:"+salesGroup); + } + + int attributeSetId = Integer.parseInt(s[0]); + int attributeId = Integer.parseInt(s[1]); + + String attributeSetName = null; + String attributeName = null; + + attributeSetName = MAttributeSet.get(ctx,attributeSetId).getName(); + attributeName = new MAttribute(ctx,attributeId,null).getName(); + + title = title + attributeName + " For " + attributeSetName; + + }//else + + }//else + + + //drawing chart + if(chartType.equals(PieChart.CHART_TYPE)) + { + PieChart pieChart = CustomPOSReportManager.generatePieChart(ctx,title,subtitle,account_id.intValue(),fromDate,toDate,salesGroup,priceQtyFilter); + pieChart.saveChartAsJPEG(reportPath+".jpg",width,height); + } + else if(chartType.equals(BarChart.CHART_TYPE)) + { + BarChart barChart = CustomPOSReportManager.generateBarChart(ctx,title,subtitle,account_id.intValue(),fromDate,toDate,salesGroup,priceQtyFilter); + barChart.saveChartAsJPEG(reportPath+".jpg",width,height); + } + else if(chartType.equals(TimeSeriesChart.CHART_TYPE)) + { + //draw timeseries + TimeSeriesChart timeSeriesChart = CustomPOSReportManager.generateTimeSeriesChart(ctx,title,subtitle,account_id.intValue(),fromDate,toDate,salesGroup,priceQtyFilter); + timeSeriesChart.saveChartAsJPEG(reportPath+".jpg",width,height); + } + else if(chartType.equals("Tabular")) + { + //constructing the table + TabularReport tReport = CustomPOSReportManager.generateTabularReport( ctx, title, subtitle, account_id.intValue(), fromDate, toDate, salesGroup, priceQtyFilter ); + + String csvReport = CSVReportManager.generateCSVReport(ctx,tReport.getReportData()); + String csvURI = ReportManager.getReportURI(csvReport,request); + + request.getSession().removeAttribute(Constants.REPORT_URL); + request.getSession().setAttribute(Constants.TABULAR_REPORT_DATA,tReport.toString()); + request.getSession().setAttribute(Constants.CSV_FILE,csvURI); + request.getSession().setAttribute(Constants.DISPLAY_REPORT,""); + + //------------------------------------------------------------------------------------------------------------------- + tReport = CustomPOSReportManager.generateTabularReportGroupByDate(ctx,title,subtitle,account_id.intValue(),fromDate,toDate,salesGroup,priceQtyFilter); + csvReport = CSVReportManager.generateCSVReport(ctx,tReport.getReportData()); + csvURI = ReportManager.getReportURI(csvReport,request); + + request.getSession().removeAttribute(Constants.REPORT_URL); + request.getSession().setAttribute(Constants.TABULAR_REPORT_DATA2,tReport.toString()); + request.getSession().setAttribute(Constants.CSV_FILE2,csvURI); + request.getSession().setAttribute(Constants.DISPLAY_REPORT,""); + + return mapping.findForward(GET_CUSTOM_REPORT); + + + } + else + { + throw new OperationException("Invalid Chart type:" + chartType); + } + + String imgURL = ReportManager.getReportURI(filename+".jpg",request); + + request.getSession().setAttribute(Constants.REPORT_URL,imgURL); + request.getSession().removeAttribute(Constants.TABULAR_REPORT_DATA); + request.getSession().setAttribute(Constants.DISPLAY_REPORT,""); + + + + return mapping.findForward(GET_CUSTOM_REPORT); + } + + + //---------------------------------------------------------------------------------------------------- + public static ActionMessages validate(ActionForm form) throws OperationException, ApplicationException + { + ActionMessages messages = new ActionMessages(); + ActionMessage message = null; + boolean error = false; + + SalesReportForm reportForm = (SalesReportForm) form; + ReportBean bean = (ReportBean) reportForm.getBean(); + + String fromDate = bean.getFromDate(); + String toDate = bean.getToDate(); + String dateRange = bean.getDateRange(); + String timePeriod = bean.getTimePeriod(); + + + if(dateRange.endsWith(Constants.FIXED_DATE_RANGE)) + { + if(timePeriod == null) + { + throw new OperationException("Invalid Parameter for timePeriod. Time Period is null."); + } + } + else if(dateRange.endsWith(Constants.CUSTOM_DATE_RANGE)) + { + + if((fromDate == null)||(fromDate == "")) + { + message = new ActionMessage("error.required.fromDate"); + messages.add(ActionMessages.GLOBAL_MESSAGE, message); + error = true; + } + + if((toDate == null)||(toDate == "")) + { + message = new ActionMessage("error.required.toDate"); + messages.add(ActionMessages.GLOBAL_MESSAGE, message); + error = true; + } + + if(!error) + { + SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + + fromDate = ReportDateManager.getFromDate(bean); + toDate = ReportDateManager.getToDate(bean); + + try + { + //validating date selected + if(sdf.parse(toDate).getTime()<=sdf.parse(fromDate).getTime()) + { + message = new ActionMessage("error.invalid.period"); + messages.add(ActionMessages.GLOBAL_MESSAGE, message); + error = true; + } + } + catch (ParseException e) + { + throw new OperationException(e); + } + } + } + else + { + throw new OperationException("Invalid Parameter for dateRange :" + dateRange); + } + + return messages; + + } + + +} diff --git a/posterita/src/main/org/posterita/struts/pos/CustomerReturnOrderAction.java b/posterita/src/main/org/posterita/struts/pos/CustomerReturnOrderAction.java new file mode 100644 index 0000000000..518e4480cf --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/CustomerReturnOrderAction.java @@ -0,0 +1,78 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 22-Sep-2006 11:43:05 by praveen + * + */ + +package org.posterita.struts.pos; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.exceptions.ApplicationException; + +public class CustomerReturnOrderAction extends POSDispatchAction +{ + public static final String CREATE_CUSTOMER_RETURN_ORDER = "createCustomerReturnOrder"; + public static final String ADD_TO_SHOPPING_CART = "addToShoppingCart"; + public static final String INCREMENT_QTY = "incrementQty"; + public static final String DECREMENT_QTY = "decrementQty"; + public static final String DELETE_ORDERLINE = "deleteOrderline"; + + public ActionForward addToShoppingCart(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(ADD_TO_SHOPPING_CART); + } + + public ActionForward incrementQty(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(INCREMENT_QTY); + } + + public ActionForward decrementQty(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(DECREMENT_QTY); + } + + public ActionForward deleteOrderline(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(DELETE_ORDERLINE); + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/DocumentAction.java b/posterita/src/main/org/posterita/struts/pos/DocumentAction.java new file mode 100644 index 0000000000..808fb5b881 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/DocumentAction.java @@ -0,0 +1,188 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Created on Oct 17, 2006 by ashley +* +*/ + +/** + @author ashley + */ + +package org.posterita.struts.pos; + +import java.io.File; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.print.ReportEngine; + +import org.posterita.Constants; +import org.posterita.beans.DocumentBean; +import org.posterita.businesslogic.POSReportManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.core.RandomStringGenerator; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + +public class DocumentAction extends POSDispatchAction +{ + public static final String VIEW_ORDER_DOCUMENT_PDF = "viewOrderDocumentPDF"; + public ActionForward viewOrderDocumentPDF(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + DocumentBean bean = (DocumentBean) df.getBean(); + String reportName = RandomStringGenerator.randomstring() + ".pdf"; + String reportPath = ReportManager.getReportPath(reportName); + + ReportEngine reportEngine = ReportEngine.get(ctx, ReportEngine.ORDER, bean.getDocumentId().intValue()); + reportEngine.createPDF(new File(reportPath)); + + String reportURI = ReportManager.getReportURI(reportPath,request); + request.setAttribute(Constants.DOCUMENT_PDF, reportURI); + + return mapping.findForward(VIEW_ORDER_DOCUMENT_PDF); + } + + public static final String VIEW_INVOICE_DOCUMENT_PDF = "viewInvoiceDocumentPDF"; + public ActionForward viewInvoiceDocumentPDF(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + DocumentBean bean = (DocumentBean) df.getBean(); + String reportName = RandomStringGenerator.randomstring() + ".pdf"; + String reportPath = ReportManager.getReportPath(reportName); + + ReportEngine reportEngine = ReportEngine.get(ctx, ReportEngine.INVOICE, bean.getDocumentId().intValue()); + reportEngine.createPDF(new File(reportPath)); + + String reportURI = ReportManager.getReportURI(reportPath,request); + request.setAttribute(Constants.DOCUMENT_PDF, reportURI); + + return mapping.findForward(VIEW_INVOICE_DOCUMENT_PDF); + } + + public static final String VIEW_SHIPMENT_DOCUMENT_PDF = "viewShipmentDocumentPDF"; + public ActionForward viewShipmentDocumentPDF(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + DocumentBean bean = (DocumentBean) df.getBean(); + String reportName = RandomStringGenerator.randomstring() + ".pdf"; + String reportPath = ReportManager.getReportPath(reportName); + + ReportEngine reportEngine = ReportEngine.get(ctx, ReportEngine.SHIPMENT, bean.getDocumentId().intValue()); + reportEngine.createPDF(new File(reportPath)); + + String reportURI = ReportManager.getReportURI(reportPath,request); + request.setAttribute(Constants.DOCUMENT_PDF, reportURI); + + return mapping.findForward(VIEW_SHIPMENT_DOCUMENT_PDF); + } + + public static String VIEW_PAYMENT_DOCUMENT_PDF = "viewPaymentDocumentPDF"; + public ActionForward viewPaymentDocumentPDF(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + DocumentBean bean = (DocumentBean) df.getBean(); + String reportName = RandomStringGenerator.randomstring() + ".pdf"; + String reportPath = ReportManager.getReportPath(reportName); + + ReportEngine reportEngine = ReportEngine.get(ctx, ReportEngine.REMITTANCE, bean.getDocumentId().intValue()); + reportEngine.createPDF(new File(reportPath)); + + String reportURI = ReportManager.getReportURI(reportPath,request); + request.setAttribute(Constants.DOCUMENT_PDF, reportURI); + + return mapping.findForward(VIEW_SHIPMENT_DOCUMENT_PDF); + } + + + + +/* public static String VIEW_PAYMENT_DOCUMENT_PDF = "viewPaymentDocumentPDF"; + public ActionForward viewPaymentDocumentPDF(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + DocumentBean bean = (DocumentBean) df.getBean(); + + String pdfPath = POSReportManager.getPaymentPDFReport(ctx, bean.getDocumentId(), null); + pdfPath = ReportManager.getReportURI(pdfPath,request); + + request.setAttribute(Constants.DOCUMENT_PDF, pdfPath); + + return mapping.findForward(VIEW_PAYMENT_DOCUMENT_PDF); + } +*/ + + /*public static String VIEW_INVOICEFROMORDER_DOCUMENT_PDF = "viewInvoiceFromOrderDocumentPDF"; + public ActionForward viewInvoiceFromOrderDocumentPDF(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + DocumentBean bean = (DocumentBean) df.getBean(); + + String pdfPath = POSReportManager.getInvoiceFromOrderPDFReport(ctx, bean.getDocumentId(), null); + pdfPath = ReportManager.getReportURI(pdfPath,request); + + request.setAttribute(Constants.DOCUMENT_PDF, pdfPath); + + return mapping.findForward(VIEW_INVOICEFROMORDER_DOCUMENT_PDF); + }*/ +} diff --git a/posterita/src/main/org/posterita/struts/pos/DunningAction.java b/posterita/src/main/org/posterita/struts/pos/DunningAction.java new file mode 100644 index 0000000000..4bfafee3ff --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/DunningAction.java @@ -0,0 +1,80 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 27, 2006 + */ + + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.Constants; +import org.posterita.beans.DunningBean; +import org.posterita.businesslogic.DunningManager; +import org.posterita.businesslogic.POSBpartnerInfoManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + + +public class DunningAction extends POSDispatchAction +{ + + public static final String INIT_PRINT_DUNNING = "initPrintDunning"; + public ActionForward initPrintDunning(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DunningManager.associateAllBpartnerWithDunning(ctx); + ArrayList list = POSBpartnerInfoManager.getPartnerInfo(ctx,true); + + request.getSession().setAttribute(Constants.DEBTORS,list); + request.getSession().removeAttribute(Constants.BUSINESSPARTNER); + + return mapping.findForward(INIT_PRINT_DUNNING); + } + + public static final String PRINT_DUNNING_LETTERS="printDunningLetters"; + public ActionForward printDunningLetters(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + DunningBean bean=(DunningBean) df.getBean(); + + DunningManager.printDunningLetters(ctx,bean); + return mapping.findForward(PRINT_DUNNING_LETTERS); + } + +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/struts/pos/EditBulkProductFromFileAction.java b/posterita/src/main/org/posterita/struts/pos/EditBulkProductFromFileAction.java new file mode 100644 index 0000000000..278e210ab8 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/EditBulkProductFromFileAction.java @@ -0,0 +1,265 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Sep 28, 2006 + */ + + +package org.posterita.struts.pos; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.ProductBean; +import org.posterita.businesslogic.EditBulkProductFromFileManager; +import org.posterita.businesslogic.POSProductManager; +import org.posterita.businesslogic.ProductCart; +import org.posterita.businesslogic.ReportManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BarcodeAlreadyExistsException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ProductAlreadyExistException; +import org.posterita.exceptions.ProductNotFoundException; +import org.posterita.exceptions.TaxRateNotDefineException; +import org.posterita.struts.core.DefaultForm; + + +public class EditBulkProductFromFileAction extends POSDispatchAction +{ + + public static final String VIEW_ALL_POS_PRODUCTS_FOR_UPDATE="viewAllPOSProductsForUpdate"; + public ActionForward viewAllPOSProductsForUpdate(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + ProductBean bean = (ProductBean) df.getBean(); + ArrayList list=null; + + try + { + list = new ArrayList(); + list = POSProductManager.viewAllProducts(ctx,bean.getProductName(),null); + + } + catch(ProductNotFoundException e1) + { + postGlobalError("error.product.not.defined.client",request); + + } + + request.setAttribute(Constants.POS_PRODUCTS_FOR_UPDATE,list); + return mapping.findForward(VIEW_ALL_POS_PRODUCTS_FOR_UPDATE); + } + + public static final String CREATE_CSV_FILE="createCSVFile"; + public ActionForward createCSVFile(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + ProductCart cart = (ProductCart) request.getSession().getAttribute(Constants.PRODUCT_CART); + + if(cart==null) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return new ActionForward("/jsp/pos/viewAllPOSProductsForUpdate.jsp"); + } + String fileName= EditBulkProductFromFileManager.createCSVFile(ctx, cart.getProductIDs()); + String fileURI = ReportManager.getReportURI(fileName,request); + + request.getSession().setAttribute(Constants.FILE_FOR_UPDATE,fileURI); + return mapping.findForward(CREATE_CSV_FILE); + } + + public static final String UPDATE_ALL_PRODUCTS="updateAllProducts"; + public ActionForward updateAllProducts(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + request.getSession().removeAttribute(Constants.PRODUCT_CREATED); + DefaultForm df = (DefaultForm) form; + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + EditBulkProductFromFileManager.updateAllProducts(ctx,df.getFile(),trx.getTrxName()); + trx.commit(); + } + catch(ProductAlreadyExistException e) + { + trx.rollback(); + postGlobalError("error.duplicate.product",e.getMessage(),request); + return mapping.getInputForward(); + + } + catch(BarcodeAlreadyExistsException e) + { + trx.rollback(); + postGlobalError("error.duplicate.barcode",e.getMessage(),request); + return mapping.getInputForward(); + } + catch(NumberFormatException e) + { + trx.rollback(); + postGlobalError("error.invalid.number",request); + return mapping.getInputForward(); + } + catch(TaxRateNotDefineException e) + { + trx.rollback(); + postGlobalError("tax.rate.not.defined",e.getMessage(),request); + return mapping.getInputForward(); + } + catch(Exception e) + { + trx.rollback(); + postGlobalError("error.in.file",request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return mapping.findForward(UPDATE_ALL_PRODUCTS); + + } + + public static final String VIEW_CART = "viewCart"; + public ActionForward viewCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ProductCart cart = (ProductCart) request.getSession().getAttribute(Constants.PRODUCT_CART); + + if( cart == null ) + { + throw new OperationException( "Cart is empty" ); + } + + ArrayList productList = EditBulkProductFromFileManager.getProductList( ctx, cart.getProductIDs() ); + request.getSession().setAttribute( Constants.PRODUCT_CART_ITEMS, productList ); + + return mapping.findForward(VIEW_CART); + } + + public static final String REMOVE = "remove"; + public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + ProductBean bean = (ProductBean) df.getBean(); + + Integer productId = bean.getProductId(); + + ProductCart cart = (ProductCart) request.getSession().getAttribute(Constants.PRODUCT_CART); + + if( cart == null ) + { + throw new OperationException( "Cart is empty" ); + } + + cart.removeProduct( productId.intValue() ); + + ArrayList productList = EditBulkProductFromFileManager.getProductList( ctx, cart.getProductIDs() ); + request.getSession().setAttribute( Constants.PRODUCT_CART_ITEMS, productList ); + request.getSession().setAttribute( Constants.PRODUCT_CART, cart); + + return mapping.findForward(REMOVE); + } + + + //------------------------------------------------------------------------------------------------------------------------------------------------ + public static final String ADD_TO_CART = "addToCart"; + public ActionForward addToCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + ProductBean bean = (ProductBean) df.getBean(); + + Integer productId = bean.getProductId(); + + ProductCart cart = (ProductCart) request.getSession().getAttribute(Constants.PRODUCT_CART); + + if( cart == null ) + { + cart = new ProductCart( ctx ); + } + + cart = EditBulkProductFromFileManager.addToCart( ctx, cart, productId.intValue() ); + request.getSession().setAttribute(Constants.PRODUCT_CART, cart); + + String script = "setCartCounter("+ cart.getNoOfProducts() +");productAdded("+ productId +")"; + + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + + public ActionForward clearCart (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + HttpSession session = request.getSession(); + session.removeAttribute(Constants.PRODUCT_CART); + + String script = "clearAll();"; + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + +} + diff --git a/posterita/src/main/org/posterita/struts/pos/FastMovingItemReportAction.java b/posterita/src/main/org/posterita/struts/pos/FastMovingItemReportAction.java new file mode 100644 index 0000000000..0888763f9b --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/FastMovingItemReportAction.java @@ -0,0 +1,126 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.pos; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.Constants; +import org.posterita.beans.ReportBean; +import org.posterita.businesslogic.POSReportManager; +import org.posterita.businesslogic.ReportDateManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + +public class FastMovingItemReportAction extends POSDispatchAction +{ + public static final String GET_CURRENT_DAY_REPORT = "getCurrentDayReport"; + public ActionForward getCurrentDayReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String toDate = sdf.format(new Date(cal.getTimeInMillis())); + + cal.set(Calendar.HOUR_OF_DAY,0); + cal.set(Calendar.MINUTE,0); + cal.set(Calendar.SECOND,0); + cal.set(Calendar.MILLISECOND,0); + + String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + + ArrayList list=POSReportManager.getMaxMinSoldProducts(ctx,"desc",fromDate,toDate); + request.getSession().setAttribute(Constants.MAX_SOLD_ITEMS,list); + + return mapping.findForward(GET_CURRENT_DAY_REPORT); + } + + public static final String GET_CURRENT_MONTH_REPORT = "getCurrentMonthReport"; + public ActionForward getCurrentMonthReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String toDate = sdf.format(new Date(cal.getTimeInMillis())); + + cal.set(Calendar.DATE,1); + cal.set(Calendar.HOUR_OF_DAY,0); + cal.set(Calendar.MINUTE,0); + cal.set(Calendar.SECOND,0); + cal.set(Calendar.MILLISECOND,0); + + String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + + ArrayList list=POSReportManager.getMaxMinSoldProducts(ctx,"desc",fromDate,toDate); + request.getSession().setAttribute(Constants.MAX_SOLD_ITEMS,list); + + return mapping.findForward(GET_CURRENT_MONTH_REPORT); + } + + public static final String GET_CUSTOM_REPORT = "getCustomReport"; + public ActionForward getCustomReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + ReportBean bean = (ReportBean) df.getBean(); + String fromDate = ReportDateManager.getFromDate(bean); + String toDate = ReportDateManager.getToDate(bean); + + ArrayList list=POSReportManager.getMaxMinSoldProducts(ctx,"desc",fromDate,toDate); + request.getSession().setAttribute(Constants.MAX_SOLD_ITEMS,list); + + return mapping.findForward(GET_CUSTOM_REPORT); + } + + +} diff --git a/posterita/src/main/org/posterita/struts/pos/GetReportAction.java b/posterita/src/main/org/posterita/struts/pos/GetReportAction.java new file mode 100644 index 0000000000..c896e86472 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/GetReportAction.java @@ -0,0 +1,103 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 31-Jul-2006 10:08:46 by praveen + * + */ + +package org.posterita.struts.pos; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.MimeType; + +import org.posterita.businesslogic.ReportManager; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + +public class GetReportAction extends POSAction +{ + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException + { + + DefaultForm df = (DefaultForm) form; + String reportName = df.getReportName(); + + if(reportName==null) + { + throw new OperationException("Invalid parameter! ReportName cannot be null."); + } + + String mimeType = null; + + if(reportName.endsWith(".csv")) + { + mimeType = "text/comma-separated-values"; + } + else + { + mimeType = MimeType.getMimeType(reportName); + } + + String reportPath = ReportManager.getReportPath(reportName); + + File f = new File(reportPath); + + if(!f.exists()) + { + throw new OperationException("Unable to load " + reportName + ". Cause file not found."); + } + + try + { + response.setContentType(mimeType); + + FileInputStream fis = new FileInputStream(f); + BufferedInputStream bis = new BufferedInputStream(fis); + BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream()); + + //Transfer bytes from bis to bos + byte[] buf = new byte[1024]; + int len; + while ((len = bis.read(buf)) > 0) + { + bos.write(buf, 0, len); + } + bis.close(); + + bos.flush(); + bos.close(); + + } + catch (Exception e) + { + throw new OperationException(e); + } + + return null; + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/GoodsReceiveNoteAction.java b/posterita/src/main/org/posterita/struts/pos/GoodsReceiveNoteAction.java new file mode 100644 index 0000000000..f344f0c1fb --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/GoodsReceiveNoteAction.java @@ -0,0 +1,90 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 22-Sep-2006 11:41:54 by praveen + * + */ + +package org.posterita.struts.pos; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.exceptions.ApplicationException; + +public class GoodsReceiveNoteAction extends POSDispatchAction +{ + public static final String CREATE_GOODS_RECEIVE_NOTE = "createGoodsReceiveNote"; + public static final String ADD_TO_SHOPPING_CART = "addToShoppingCart"; + public static final String DELETE_ORDERLINES = "deleteOrderlines"; + + public static final String INCREMENT_QTY = "incrementQty"; + public static final String DECREMENT_QTY = "decrementQty"; + public static final String DELETE_ORDERLINE = "deleteOrderline"; + + public ActionForward addToShoppingCart(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(ADD_TO_SHOPPING_CART); + } + + public ActionForward deleteOrderlines(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(DELETE_ORDERLINES); + } + + //----------------------------------------------------------------------------------------------------------- + + public ActionForward incrementQty(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(INCREMENT_QTY); + } + + public ActionForward decrementQty(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(DECREMENT_QTY); + } + + public ActionForward deleteOrderline(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(DELETE_ORDERLINE); + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/GoodsReturnNoteAction.java b/posterita/src/main/org/posterita/struts/pos/GoodsReturnNoteAction.java new file mode 100644 index 0000000000..cbeb8303f8 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/GoodsReturnNoteAction.java @@ -0,0 +1,77 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 22-Sep-2006 11:42:25 by praveen + * + */ + +package org.posterita.struts.pos; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.exceptions.ApplicationException; + +public class GoodsReturnNoteAction extends POSDispatchAction +{ + public static final String CREATE_GOODS_RETURN_NOTE = "createGoodsReturnNote"; + public static final String ADD_TO_SHOPPING_CART = "addToShoppingCart"; + public static final String INCREMENT_QTY = "incrementQty"; + public static final String DECREMENT_QTY = "decrementQty"; + public static final String DELETE_ORDERLINE = "deleteOrderline"; + + public ActionForward addToShoppingCart(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(ADD_TO_SHOPPING_CART); + } + + public ActionForward incrementQty(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(INCREMENT_QTY); + } + + public ActionForward decrementQty(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(DECREMENT_QTY); + } + + public ActionForward deleteOrderline(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(DELETE_ORDERLINE); + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/ImportCustomerAction.java b/posterita/src/main/org/posterita/struts/pos/ImportCustomerAction.java new file mode 100644 index 0000000000..4ae445b387 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/ImportCustomerAction.java @@ -0,0 +1,98 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.businesslogic.ImportCustomerManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BarcodeAlreadyExistsException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ProductAlreadyExistException; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + + +public class ImportCustomerAction extends BaseDispatchAction +{ + public static final String IMPORT_POS_CUSTOMER ="importPOSCustomer"; + public ActionForward importPOSCustomer(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + ArrayList list = new ArrayList(); + try + { + list=ImportCustomerManager.importCustomer(ctx, df.getFile(), trx.getTrxName()); + trx.commit(); + trx.close(); + + } + catch(ProductAlreadyExistException e) + { + trx.rollback(); + trx.close(); + postGlobalError("error.duplicate.product",request); + return mapping.getInputForward(); + + } + + catch(BarcodeAlreadyExistsException e) + { + trx.rollback(); + trx.close(); + postGlobalError("error.duplicate.barcode",request); + return mapping.getInputForward(); + } + catch(NumberFormatException e) + { + trx.rollback(); + trx.close(); + postGlobalError("error.invalid.number",request); + return mapping.getInputForward(); + } + + + + request.getSession().setAttribute(Constants.CUSTOMER_CREATED,list); + return mapping.findForward(IMPORT_POS_CUSTOMER); + + } +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/struts/pos/ImportPOSProductAction.java b/posterita/src/main/org/posterita/struts/pos/ImportPOSProductAction.java new file mode 100644 index 0000000000..702ad7b594 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/ImportPOSProductAction.java @@ -0,0 +1,111 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on May 16, 2006 + */ + + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.businesslogic.ImportPosProductManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BarcodeAlreadyExistsException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ProductAlreadyExistException; +import org.posterita.exceptions.TaxRateNotDefineException; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + + +public class ImportPOSProductAction extends BaseDispatchAction +{ + public static final String IMPORT_POS_PRODUCT ="importPOSProducts"; + public ActionForward importPOSProducts(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + request.getSession().removeAttribute(Constants.PRODUCT_CREATED); + DefaultForm df = (DefaultForm) form; + ArrayList list=new ArrayList(); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + list=ImportPosProductManager.importProducts(ctx,df.getFile(),trx.getTrxName()); + trx.commit(); + } + catch(ProductAlreadyExistException e) + { + trx.rollback(); + postGlobalError("error.duplicate.product",e.getMessage(),request); + return mapping.getInputForward(); + + } + catch(BarcodeAlreadyExistsException e) + { + trx.rollback(); + postGlobalError("error.duplicate.barcode",e.getMessage(),request); + return mapping.getInputForward(); + } + catch(NumberFormatException e) + { + trx.rollback(); + postGlobalError("error.invalid.number",request); + return mapping.getInputForward(); + } + catch(TaxRateNotDefineException e) + { + trx.rollback(); + postGlobalError("tax.rate.not.defined",e.getMessage(),request); + return mapping.getInputForward(); + } + catch(Exception e) + { + trx.rollback(); + postGlobalError("error.in.file",request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + request.getSession().setAttribute(Constants.PRODUCT_CREATED,list); + return mapping.findForward(IMPORT_POS_PRODUCT); + + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/InventoryAction.java b/posterita/src/main/org/posterita/struts/pos/InventoryAction.java new file mode 100644 index 0000000000..5e912d1aef --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/InventoryAction.java @@ -0,0 +1,380 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Dec 4, 2006 + */ + + +package org.posterita.struts.pos; + +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MInventory; +import org.compiere.process.DocumentEngine; +import org.compiere.util.Trx; +import org.posterita.Constants; +import org.posterita.beans.InventoryBean; +import org.posterita.businesslogic.InventoryManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.businesslogic.StockManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.CannotCreateInventoryLineException; +import org.posterita.exceptions.NoCheckBoxSelectedException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ProductNotFoundException; +import org.posterita.form.InventoryForm; +import org.posterita.struts.core.BaseDispatchAction; + + +public class InventoryAction extends BaseDispatchAction +{ + + public static final String CREATE_INVENTORY="createInventory"; + public ActionForward createInventory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + InventoryForm If = (InventoryForm)form; + InventoryBean bean = (InventoryBean) If.getBean(); + MInventory inventory=null; + + if(bean.getBarCode()!=null && bean.getProductId()==null) + { + int productId=StockManager.getProductIdFromBarCode(ctx,bean.getBarCode()); + bean.setProductId(productId); + } + + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + try + { + if(bean.getInventoryId()==null || bean.getInventoryId()==0) + { + inventory=InventoryManager.createInventory(ctx,bean.getDescription(),null); + bean.setInventoryId(inventory.get_ID()); + } + if(bean.getDescription()!=null) + { + MInventory inventory2=new MInventory(ctx,bean.getInventoryId(),null); + inventory2.setDescription(bean.getDescription()); + inventory2.save(); + } + + + InventoryManager.addInventoryLine(ctx,bean.getInventoryId(),bean.getProductId(), new BigDecimal(1), true,null); + trx.commit(); + } + catch(CannotCreateInventoryLineException e) + { + trx.rollback(); + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.INVENTORY_ID,bean.getInventoryId()); + postGlobalError("error.cannot.create.inventory.line",request); + return mapping.getInputForward(); + } + catch(ProductNotFoundException e) + { + postGlobalError("error.product.name.required",request); + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.INVENTORY_ID,bean.getInventoryId()); + return mapping.getInputForward(); + } + + catch(OperationException e) + { + trx.rollback(); + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.INVENTORY_ID,bean.getInventoryId()); + throw new OperationException(e); + } + finally + { + trx.close(); + } + + If.populate(bean); + + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.INVENTORY_ID,bean.getInventoryId()); + + return mapping.findForward(CREATE_INVENTORY); + } + + public static final String SAVE_COUNT_QTY="saveCountQty"; + public ActionForward saveCountQty(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + InventoryForm If = (InventoryForm)form; + InventoryBean bean = (InventoryBean) If.getBean(); + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + try + { + InventoryManager.saveCountQtyInInventoryLine(ctx,bean.getInventoryLineId(),bean.getQtyCount(),trx.getTrxName()); + trx.commit(); + } + catch(OperationException e) + { + trx.rollback(); + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.INVENTORY_ID,bean.getInventoryId()); + throw new OperationException(e); + } + finally + { + trx.close(); + } + + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.WHOLE_INVENTORY_LINE_LIST,list); + return mapping.findForward(SAVE_COUNT_QTY); + } + + + public static final String COMPLETE_INVENTORY="completeInventory"; + public ActionForward completeInventory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + InventoryForm If = (InventoryForm)form; + InventoryBean bean = (InventoryBean) If.getBean(); + InventoryManager.completeStockAdjustment(ctx,bean.getInventoryId()); + + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + request.setAttribute(Constants.COMPLETED_INVENTORY_LINE_LIST,list); + request.removeAttribute(Constants.INVENTORY_LINE_LIST); + request.removeAttribute(Constants.WHOLE_INVENTORY_LINE_LIST); + return mapping.findForward(COMPLETE_INVENTORY); + } + + + public static final String VIEW_INVENTORY_HISTORY="viewInventoryHistory"; + public ActionForward viewInventoryHistory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + ArrayList list = InventoryManager.viewInventoryHistory(ctx); + request.setAttribute(Constants.INVENTORY_HISTORY_LIST,list); + return mapping.findForward(VIEW_INVENTORY_HISTORY); + } + + public static final String DELETE_INVENTORY="deleteInventory"; + public ActionForward deleteInventory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + InventoryForm If = (InventoryForm)form; + InventoryBean bean = (InventoryBean) If.getBean(); + InventoryManager.deleteInventory(ctx,bean.getInventoryId().intValue()); + ArrayList list = InventoryManager.viewInventoryHistory(ctx); + request.setAttribute(Constants.INVENTORY_HISTORY_LIST,list); + return mapping.findForward(DELETE_INVENTORY); + } + + public static final String DELETE_INVENTORY_LINE="deleteInventoryLine"; + public ActionForward deleteInventoryLine(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + InventoryForm If = (InventoryForm)form; + InventoryBean bean = (InventoryBean) If.getBean(); + InventoryManager.deleteInventoryLine(ctx,bean.getInventoryId().intValue(),bean.getInventoryLineId().intValue()); + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.INVENTORY_ID,bean.getInventoryId()); + + return mapping.findForward(DELETE_INVENTORY_LINE); + } + + public static final String VIEW_INVENTORY="viewInventory"; + public ActionForward viewInventory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + InventoryForm If = (InventoryForm)form; + InventoryBean bean = (InventoryBean) If.getBean(); + + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + If.populate(bean); + if(InventoryManager.getInventoryDocStatus(ctx,bean.getInventoryId()).equals(DocumentEngine.STATUS_Drafted)) + { + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.INVENTORY_ID,bean.getInventoryId()); + return new ActionForward("/ViewInventory.do"); + } + else + { + request.setAttribute(Constants.COMPLETED_INVENTORY_LINE_LIST,list); + return new ActionForward("/CompletedAdjustmentStock.do"); + } + + } + + public static final String CREATE_WHOLE_INVENTORY="createWholeInventory"; + public ActionForward createWholeInventory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + InventoryForm If = (InventoryForm)form; + InventoryBean bean = (InventoryBean) If.getBean(); + MInventory inventory=null; + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + try + { trx.start(); + if(bean.getInventoryId()==null || bean.getInventoryId()==0) + { + inventory=InventoryManager.createInventory(ctx,bean.getDescription(),trx.getTrxName()); + bean.setInventoryId(inventory.get_ID()); + } + + InventoryManager.addAllProductsInventoryLine(ctx,bean.getInventoryId(),trx.getTrxName()); + + trx.commit(); + } + catch(OperationException e) + { + trx.rollback(); + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.INVENTORY_ID,bean.getInventoryId()); + throw new OperationException(e); + } + finally + { + trx.close(); + } + + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.INVENTORY_ID,bean.getInventoryId()); + return mapping.findForward(CREATE_WHOLE_INVENTORY); + } + + public static final String CREATE_CSV_FILE_FOR_INVENTORY="createCSVFileForInventory"; + public ActionForward createCSVFileForInventory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + InventoryForm If = (InventoryForm)form; + InventoryBean bean = (InventoryBean) If.getBean(); + ArrayList list = InventoryManager.getInventoryLines(ctx,bean.getInventoryId()); + String reportName = InventoryManager.createCSVForInventory(ctx,list); + String reportURI=ReportManager.getReportURI(reportName,request); + response.sendRedirect(reportURI); + return null; + + } + + + public static final String MERGE_INVENTORY_TO_CREATE_ONE="mergeInventoryToCreateOne"; + public ActionForward mergeInventoryToCreateOne(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + InventoryForm If = (InventoryForm)form; + InventoryBean bean = (InventoryBean) If.getBean(); + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + MInventory inventory =null; + try + { + inventory = InventoryManager.mergeInventory(ctx,bean,null); + trx.commit(); + } + catch(NoCheckBoxSelectedException e) + { + trx.rollback(); + ArrayList list = InventoryManager.viewInventoryHistory(ctx); + request.setAttribute(Constants.INVENTORY_HISTORY_LIST,list); + postGlobalError("error.no.checkbox.selected",request); + return mapping.getInputForward(); + } + catch(CannotCreateInventoryLineException e1) + { + trx.rollback(); + ArrayList list = InventoryManager.viewInventoryHistory(ctx); + request.setAttribute(Constants.INVENTORY_HISTORY_LIST,list); + postGlobalError("error.cannot.create.inventory.line",request); + return mapping.getInputForward(); + } + + catch(OperationException e2) + { + trx.rollback(); + throw new OperationException(e2); + } + finally + { + trx.close(); + } + + ArrayList list = InventoryManager.getInventoryLines(ctx,inventory.get_ID()); + request.setAttribute(Constants.INVENTORY_LINE_LIST,list); + request.setAttribute(Constants.INVENTORY_ID,inventory.get_ID()); + return mapping.findForward(MERGE_INVENTORY_TO_CREATE_ONE); + + } +} + \ No newline at end of file diff --git a/posterita/src/main/org/posterita/struts/pos/POSAction.java b/posterita/src/main/org/posterita/struts/pos/POSAction.java new file mode 100644 index 0000000000..4e704ac2bb --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSAction.java @@ -0,0 +1,50 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.pos; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.exceptions.ApplicationException; +import org.posterita.struts.core.BaseAction; + +public class POSAction extends BaseAction +{ + public static final String POS_LOGIN = "posLogin"; + + public final ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException + { + ActionForward fwd = super.init(mapping,form,request,response); + + if(fwd!=null) + { + return mapping.findForward(POS_LOGIN); + } + + return fwd; + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSAttributesAction.java b/posterita/src/main/org/posterita/struts/pos/POSAttributesAction.java new file mode 100644 index 0000000000..5ee6bbace5 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSAttributesAction.java @@ -0,0 +1,140 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on May 23, 2006 by ashley +* +*/ + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.KeyNamePair; +import org.compiere.util.Trx; +import org.posterita.Constants; +import org.posterita.beans.AttributeValueDetailBean; +import org.posterita.beans.ProductKeywordsBean; +import org.posterita.businesslogic.AttributeValuesManager; +import org.posterita.businesslogic.ProductManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.form.EditAttributeForm; +import org.posterita.struts.core.DefaultForm; + +public class POSAttributesAction extends POSDispatchAction +{ + public static final String INIT_VIEW_ATTRIBUTEVALUES = "initViewAttributeValues"; + public ActionForward initViewAttributeValues(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList attributeList = AttributeValuesManager.getAttributes(ctx); + + request.getSession().setAttribute(Constants.ATTRIBUTE_LIST, attributeList); + + return mapping.findForward(INIT_VIEW_ATTRIBUTEVALUES); + } + + public static final String LIST_ATTRIBUTEVALUES = "listAttributeValues"; + public ActionForward listAttributeValues(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm)form; + + AttributeValueDetailBean attrValBean = (AttributeValueDetailBean)df.getBean(); + + ArrayList attributeValuesList = AttributeValuesManager.getAttributeValues(ctx, attrValBean.getAttributeId().intValue()); + + request.setAttribute(Constants.ATTRIBUTE_VALUES_LIST, attributeValuesList); + + return mapping.findForward(LIST_ATTRIBUTEVALUES); + } + + public static final String INIT_EDIT_ATTRIBUTEVALUE = "initEditAttributeValue"; + public ActionForward initEditAttributeValue(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + return mapping.findForward(INIT_EDIT_ATTRIBUTEVALUE); + } + + public static final String EDIT_ATTRIBUTEVALUE = "editAttributeValue"; + public ActionForward editAttributeValue(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + EditAttributeForm df = (EditAttributeForm)form; + ActionErrors errors = df.validate(mapping,request); + + if(!errors.isEmpty()) + { + postGlobalError("error.required","New Name",request); + return mapping.getInputForward(); + } + + AttributeValueDetailBean attrBean = (AttributeValueDetailBean)df.getBean(); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + + try + { + trx.start(); + int newAttrValueId = AttributeValuesManager.changeAttributeValue(ctx, attrBean.getAttributeValueId().intValue(), attrBean.getNewName(), trx.getTrxName()); + ProductManager.updateProductsAttribute(ctx, attrBean.getAttributeValueId().intValue(), newAttrValueId, attrBean.getAttributeId().intValue(), trx.getTrxName()); + trx.commit(); + } + catch(Exception ex) + { + trx.rollback(); + postGlobalError("error.updating.attribute", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + + return mapping.findForward(EDIT_ATTRIBUTEVALUE); + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSDispatchAction.java b/posterita/src/main/org/posterita/struts/pos/POSDispatchAction.java new file mode 100644 index 0000000000..9b740400e7 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSDispatchAction.java @@ -0,0 +1,46 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.pos; + + + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.struts.core.BaseDispatchAction; + +public class POSDispatchAction extends BaseDispatchAction +{ + + public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException + { + TmkJSPEnv.getCtx(request); + return super.init(mapping, form, request, response); + + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSGoodsAction.java b/posterita/src/main/org/posterita/struts/pos/POSGoodsAction.java new file mode 100644 index 0000000000..957af92779 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSGoodsAction.java @@ -0,0 +1,1390 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 27-Apr-2006 + */ + + +package org.posterita.struts.pos; + +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MBPartner; +import org.compiere.model.MOrder; +import org.compiere.model.MPayment; +import org.compiere.model.MProduct; +import org.compiere.process.DocAction; +import org.compiere.process.DocumentEngine; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.OrderBean; +import org.posterita.beans.OrderLineBean; +import org.posterita.beans.POSSupplierBean; +import org.posterita.beans.ProductBean; +import org.posterita.beans.ShoppingCartBean; +import org.posterita.beans.WebDocumentBean; +import org.posterita.businesslogic.BPartnerManager; +import org.posterita.businesslogic.OrderReferenceManager; +import org.posterita.businesslogic.OrderManager; +import org.posterita.businesslogic.POSGoodsManager; +import org.posterita.businesslogic.POSManager; +import org.posterita.businesslogic.POSTerminalManager; +import org.posterita.businesslogic.StockManager; +import org.posterita.core.SessionStorage; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BPartnerNoLocationException; +import org.posterita.exceptions.BPartnerOverCreditLimitException; +import org.posterita.exceptions.InputQuantityLessThanZeroException; +import org.posterita.exceptions.InvalidOrderIDException; +import org.posterita.exceptions.NoOrderLineFoundException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ProductNotFoundException; +import org.posterita.exceptions.ProductNotOnPriceListException; +import org.posterita.exceptions.QuantityNotAvailableException; +import org.posterita.form.OrderLineForm; +import org.posterita.lib.UdiConstants; +import org.posterita.order.UDIOrderTypes; +import org.posterita.struts.core.DefaultForm; +import org.posterita.core.bean.ElementBean; +import org.posterita.core.businesslogic.ElementManager; + + +public class POSGoodsAction extends POSDispatchAction +{ + public static final String CREATE_POS_GOODS_RECEIVE_NOTE="createPOSGoodsReceiveNote"; + public ActionForward createPOSGoodsReceiveNote(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + ActionForward fwd= init(mapping,form,request,response); + + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + Integer bPartnerId = bean.getBpartnerId(); + String supplierRef = bean.getDescription(); + + MOrder previousOrder= null; + previousOrder=(MOrder)request.getSession().getAttribute(Constants.PRESENT_GRN_ORDER); + + if(previousOrder!=null) + { + bean.setOrderId(Integer.valueOf(previousOrder.get_ID())); + } + else + { + bean.setOrderId(null); + } + + if( bPartnerId == null ) + { + //see if we have previously saved bpartnerId + bPartnerId= (Integer) request.getSession().getAttribute(Constants.B_PARTNER_ID); + } + else + { + //set the new bpartnerId in session + request.getSession().setAttribute(Constants.B_PARTNER_ID, bPartnerId); + } + + if( supplierRef == null ) + { + //see if we have previously saved supplierRef + supplierRef=(String) request.getSession().getAttribute(Constants.DESCRIPTION); + } + else + { + //set new supplierRef in session + request.getSession().setAttribute(Constants.DESCRIPTION, supplierRef); + } + + if( bPartnerId == null ) + { + postGlobalError("error.required.supplierName", request); + return mapping.getInputForward(); + } + + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART); + + if(cartBean == null||cartBean.getItems() == null||cartBean.getItems().size() == 0) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + + MOrder goodsReceiveNote = null; + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + goodsReceiveNote = POSGoodsManager.createGoodsReceiveNote(ctx,bean,cartBean.getItems(),bPartnerId,supplierRef,trx.getTrxName()); + trx.commit(); + } + catch(BPartnerNoLocationException ex) + { + trx.rollback(); + postGlobalError("error.bpartner.nolocation", request); + return mapping.getInputForward(); + } + catch(OperationException e) + { + trx.rollback(); + throw (e); + } + finally + { + trx.close(); + } + + bean.setOrderId(Integer.valueOf(goodsReceiveNote.get_ID())); + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx,goodsReceiveNote); + ArrayList list = POSManager.populateOrderLines(ctx,goodsReceiveNote); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + + request.getSession().setAttribute(Constants.GOODS_RECEIVE_NOTE_ID,goodsReceiveNote.get_ID()); + request.setAttribute(Constants.GOODS_RECEIVE_NOTE_LINES,list); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + request.getSession().removeAttribute(Constants.PRESENT_GRN_ORDER); + request.getSession().removeAttribute(Constants.PRESENT_GRN_ORDER_ID); + + return mapping.findForward(CREATE_POS_GOODS_RECEIVE_NOTE); + } + + public static final String COMPLETE_GOODS_RECEIVE_NOTE="completeGoodsReceiveNote"; + public ActionForward completeGoodsReceiveNote(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + //OrderLineBean bean=(OrderLineBean) df.getBean(); + Integer goodsReceiveNoteId=(Integer) request.getSession().getAttribute(Constants.GOODS_RECEIVE_NOTE_ID); + + MOrder completedGRN=null; + + Trx trx =Trx.get(TrxPrefix.getPrefix(),true); + + if(goodsReceiveNoteId==null) + { + postGlobalError("error.no.order.exists",request); + return mapping.getInputForward(); + } + + try + { + trx.start(); + completedGRN=POSGoodsManager.createAndCompletePODocuments(ctx,goodsReceiveNoteId,null); + trx.commit(); + } + catch(NoOrderLineFoundException e) + { + trx.rollback(); + postGlobalError("error.pos.no.orderline",request); + request.getSession().removeAttribute(Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART); + request.getSession().removeAttribute(Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART_ITEMS); + return mapping.getInputForward(); + } + catch(OperationException e) + { + trx.rollback(); + throw new OperationException("Could not complete documents. Reason: " + e); + + } + finally + { + trx.close(); + } + + + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx,completedGRN); + ArrayList list = POSManager.populateOrderLines(ctx,completedGRN); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + + //request.getSession().setAttribute(Constants.GOODS_RECEIVE_NOTE_ID,completedGRN.get_ID()); + request.setAttribute(Constants.GOODS_RECEIVE_NOTE_LINES,list); + /*request.removeAttribute(Constants.POS_ORDER_LINES);*/ + + + + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART); + request.getSession().removeAttribute(Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.DESCRIPTION); + request.getSession().removeAttribute(Constants.B_PARTNER_ID); + request.getSession().removeAttribute(Constants.GOODS_RECEIVE_NOTE_ID); + request.getSession().removeAttribute(Constants.DESCRIPTION); + request.getSession().removeAttribute(Constants.PRESENT_GRN_ORDER); + request.getSession().removeAttribute(Constants.PRESENT_GRN_ORDER_ID); + + request.removeAttribute(Constants.DESCRIPTION); + + return mapping.findForward(COMPLETE_GOODS_RECEIVE_NOTE); + } + + + public static final String CREATE_POS_GOODS_RETURN_NOTE="createPOSGoodsReturnNote"; + public ActionForward createPOSGoodsReturnNote(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + + Integer bPartnerId = bean.getBpartnerId(); + String supplierRef = bean.getDescription(); + Integer quantity = bean.getQuantity(); + + if( bPartnerId == null ) + { + //see if we have previously saved bpartnerId + bPartnerId= (Integer) request.getSession().getAttribute(Constants.B_PARTNER_ID); + } + else + { + //set the new bpartnerId in session + request.getSession().setAttribute(Constants.B_PARTNER_ID, bPartnerId); + } + + if ( quantity == null) + { + throw new OperationException("Quantity cannot be null"); + } + if( quantity.equals(0) == true) + { + throw new OperationException("Quantity cannot be zero"); + } + + if( supplierRef == null ) + { + //see if we have previously saved supplierRef + supplierRef=(String) request.getSession().getAttribute(Constants.DESCRIPTION); + } + else + { + //set new supplierRef in session + request.getSession().setAttribute(Constants.DESCRIPTION, supplierRef); + } + + if( bPartnerId == null ) + { + postGlobalError("error.required.supplierName", request); + return mapping.getInputForward(); + } + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.GOODS_RETURN_NOTE_SHOPPING_CART); + + if(cartBean == null||cartBean.getItems() == null||cartBean.getItems().size() == 0) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + + MOrder previousOrder= null; + previousOrder=(MOrder)request.getSession().getAttribute(Constants.PRESENT_GOODS_RET_ORDER); + + if(previousOrder!=null) + { + bean.setOrderId(Integer.valueOf(previousOrder.get_ID())); + } + else + { + bean.setOrderId(null); + } + MOrder goodsReturnNote=null; + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + bean.getDescription(); + try + { + trx.start(); + goodsReturnNote= POSGoodsManager.createGoodsReturnNote(ctx,bean,cartBean.getItems(),bPartnerId,supplierRef,trx.getTrxName()); + trx.commit(); + + } + catch(BPartnerOverCreditLimitException e1) + { + trx.rollback(); + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + + catch(BPartnerNoLocationException ex) + { + trx.rollback(); + postGlobalError("error.bpartner.nolocation", request); + return mapping.getInputForward(); + } + catch (OperationException e) + { + trx.rollback(); + throw new OperationException("Could not create goods return note: Reason :" + e); + } + finally + { + trx.close(); + } + bean.setOrderId(Integer.valueOf(goodsReturnNote.get_ID())); + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx,goodsReturnNote); + ArrayList list = POSManager.populateOrderLines(ctx,goodsReturnNote); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + request.setAttribute(Constants.GOODS_RETURN_NOTE_LINES,list); + request.getSession().setAttribute(Constants.GOODS_RETURN_NOTE_ID,goodsReturnNote.get_ID()); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + + request.getSession().removeAttribute(Constants.PRESENT_GOODS_RET_ORDER); + request.getSession().removeAttribute(Constants.PRESENT_GOODS_RET_ORDER_ID); + + return mapping.findForward(CREATE_POS_GOODS_RETURN_NOTE); + } + + + public static final String COMPLETE_GOODS_RETURN_NOTE="completeGoodsReturnNote"; + public ActionForward completeGoodsReturnNote(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + //OrderLineBean bean=(OrderLineBean) df.getBean(); + Integer goodsReturnNoteId=(Integer) request.getSession().getAttribute(Constants.GOODS_RETURN_NOTE_ID); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + MOrder completedGRetN=null; + + + if(goodsReturnNoteId==null) + { + postGlobalError("error.no.order.exists",request); + return mapping.getInputForward(); + } + + try + { + trx.start(); + completedGRetN=POSGoodsManager.createAndCompletePODocuments(ctx,goodsReturnNoteId,null);//same sort of order i.e. sales Order + trx.commit(); + } + catch(BPartnerOverCreditLimitException e1) + { + trx.rollback(); + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(NoOrderLineFoundException e) + { + trx.rollback(); + postGlobalError("error.pos.no.orderline",request); + request.getSession().removeAttribute(Constants.GOODS_RETURN_NOTE_SHOPPING_CART); + request.getSession().removeAttribute(Constants.GOODS_RETURN_NOTE_SHOPPING_CART_ITEMS); + return mapping.getInputForward(); + } + + catch(OperationException e) + { + trx.rollback(); + throw new OperationException("Could not complete documents. Reason : " + e); + } + finally + { + trx.close(); + } + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx,completedGRetN); + ArrayList list = POSManager.populateOrderLines(ctx,completedGRetN); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + request.setAttribute(Constants.GOODS_RETURN_NOTE_LINES,list); + //request.getSession().setAttribute(Constants.GOODS_RETURN_NOTE_ID,completedGRetN.get_ID()); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.GOODS_RETURN_NOTE_SHOPPING_CART); + request.getSession().removeAttribute(Constants.GOODS_RETURN_NOTE_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.GOODS_RETURN_NOTE_ID); + request.getSession().removeAttribute(Constants.B_PARTNER_ID); + request.getSession().removeAttribute(Constants.DESCRIPTION); + request.getSession().removeAttribute(Constants.PRESENT_GOODS_RET_ORDER); + request.getSession().removeAttribute(Constants.PRESENT_GOODS_RET_ORDER_ID); + + + request.removeAttribute(Constants.DESCRIPTION); + + return mapping.findForward(COMPLETE_GOODS_RETURN_NOTE); + } + + //public static final String GET_ALL_VENDORS="getAllVendors"; + public ActionForward getAllVendors(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + HttpSession session = request.getSession(); + + DefaultForm df = (DefaultForm) form; + OrderLineBean b = (OrderLineBean) df.getBean(); + + OrderLineForm f = (OrderLineForm) form; + OrderLineBean bean = new OrderLineBean(); + + Integer bPartnerId = (Integer) session.getAttribute(Constants.B_PARTNER_ID); + String description = (String) session.getAttribute(Constants.DESCRIPTION); + + bean.setBpartnerId(bPartnerId); + bean.setDescription(description); + + f.populate(bean); + + ArrayList list=POSGoodsManager.getAllSuppliers(ctx); + + session.setAttribute(Constants.BP_LIST,list); + return mapping.findForward(POSGoodsManager.getForward(ctx,b.getIsSales())); + } + + public static final String ADD_TO_SHOPPING_CART = "addToShoppingCart"; + public ActionForward addToShoppingCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + OrderLineBean bean = (OrderLineBean) df.getBean(); + + String orderType = bean.getOrderType(); + String shoppingCart = null; + String shoppingCartItem = null; + + if(orderType.equals(Constants.GOODS_RECEIVE_NOTE)) + { + shoppingCart = Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART; + shoppingCartItem = Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART_ITEMS; + + String currSymbolePurchase=POSTerminalManager.getPOSDefaultPurchaseCurrency(ctx).getCurSymbol(); + request.setAttribute(Constants.CURRENCY_SYMBOLE,currSymbolePurchase); + + } + else if(orderType.equals(Constants.GOODS_RETURN_NOTE)) + { + shoppingCart = Constants.GOODS_RETURN_NOTE_SHOPPING_CART; + shoppingCartItem = Constants.GOODS_RETURN_NOTE_SHOPPING_CART_ITEMS; + + String currSymbolePurchase=POSTerminalManager.getPOSDefaultPurchaseCurrency(ctx).getCurSymbol(); + request.setAttribute(Constants.CURRENCY_SYMBOLE,currSymbolePurchase); + + } + else if(orderType.equals(Constants.CUSTOMER_RETURN_ORDER)) + { + shoppingCart = Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART; + shoppingCartItem = Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART_ITEMS; + String currSymboleSales = POSTerminalManager.getPOSDefaultSellCurrency(ctx).getCurSymbol(); + request.setAttribute(Constants.CURRENCY_SYMBOLE,currSymboleSales); + + } + + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(shoppingCart); + + try + { + //POSManager.getQtyAndItem(bean); + if(bean.getProductId()==null && bean.getBarCode()==null) + { + postGlobalError("error.barcode.required", request); + return mapping.getInputForward(); + } + + cartBean = StockManager.addToPOSCart(ctx, bean, cartBean,Boolean.parseBoolean(bean.getIsSales()),Boolean.parseBoolean(bean.getIfAdd())); + } + catch (InputQuantityLessThanZeroException e1) + { + postGlobalError("error.invalid.inputQty", request); + return mapping.getInputForward(); + } + catch (ProductNotFoundException e2) + { + postGlobalError("error.product.not.found", e2.getMessage(), request); + return mapping.getInputForward(); + } + catch(QuantityNotAvailableException e3) + { + postGlobalError("error.quantity.notAvailable", e3.getMessage(), request); + return mapping.getInputForward(); + } + + catch(ProductNotOnPriceListException e4) + { + postGlobalError("error.product.price.not.found", e4.getMessage(), request); + return mapping.getInputForward(); + } + + request.getSession().setAttribute(Constants.DESCRIPTION, bean.getDescription()); + bean.setDescription(bean.getDescription()); + request.getSession().setAttribute(shoppingCart, cartBean); + request.getSession().setAttribute(shoppingCartItem, cartBean.getItems()); + request.getSession().setAttribute(Constants.B_PARTNER_ID,bean.getBpartnerId()); + + df.setQtyAndItem(""); + + return mapping.findForward(ADD_TO_SHOPPING_CART); + } + + public static final String SET_SUPPLIER="setSupplier"; + public ActionForward setSupplier(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + //Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + POSSupplierBean bean = (POSSupplierBean)df.getBean(); + request.getSession().setAttribute(Constants.B_PARTNER_ID,bean.getBpartnerId()); + return mapping.findForward(SET_SUPPLIER); + } + + //NOTE:this does not select the actualy product category of compiere,its gets all the revenue recognitions + //revenue reco is used to categorise the proucts + public static final String GET_PRODUCT_CATEGORY="getProductCategory"; + public ActionForward getProductCategory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + + ArrayList list = POSGoodsManager.getAllRevenueRecos(ctx); + ArrayList supList=POSGoodsManager.getAllSuppliers(ctx); + ArrayList taxList=POSGoodsManager.getAllTaxCategory(ctx); + request.getSession().setAttribute(Constants.BP_LIST,supList); + request.getSession().setAttribute(Constants.PRODUCT_CATEGORY_ID,list); + request.getSession().setAttribute(Constants.TAX_CATEGORY_ID,taxList); + + ProductBean bean = new ProductBean(); + bean.setProductType(MProduct.PRODUCTTYPE_Item); + df.populate(bean); + + + return mapping.findForward(GET_PRODUCT_CATEGORY); + } + + + public static final String CREATE_CUSTOMER_RETURN_ORDER="createCustomerReturnOrder"; + public ActionForward createCustomerReturnOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + HttpSession session = request.getSession(); + Integer bPartnerId = bean.getBpartnerId(); + + if( bPartnerId == null) + { + bPartnerId = (Integer) request.getSession().getAttribute(Constants.B_PARTNER_ID); + } + else + { + request.getSession().setAttribute(Constants.B_PARTNER_ID, bPartnerId); + } + + Integer qty = bean.getQuantity(); + + if ( (qty.equals(0) == true) || (qty == null) ) + { + postGlobalError("error.qty.required", request); + return mapping.getInputForward(); + } + + + String reason = bean.getDescription(); + + if( reason == null ) + { + reason = (String) session.getAttribute(Constants.DESCRIPTION); + + if( reason == null ) + { + postGlobalError("error.reason.required", request); + return mapping.getInputForward(); + } + } + else + { + session.setAttribute(Constants.DESCRIPTION, reason); + } + MOrder previousOrder= null; + previousOrder=(MOrder)request.getSession().getAttribute(Constants.PRESENT_CUSTOMER_RET_ORDER); + + if(previousOrder!=null) + { + bean.setOrderId(Integer.valueOf(previousOrder.get_ID())); + } + else + { + bean.setOrderId(null); + } + + String posOrderDocNumber = (String) request.getSession().getAttribute(Constants.POS_ORDER_DOC_NUMBER); + Integer paymentTermId =(Integer) request.getSession().getAttribute(Constants.CREDIT_PAYMENT_TERM_ID); + String orderType = (String) request.getSession().getAttribute(Constants.ORDER_TYPE); + + if(posOrderDocNumber!=null) + bean.setDocumentNo(posOrderDocNumber); + if(orderType!=null) + bean.setOrderType(orderType); + if(paymentTermId!=null) + bean.setPaymentTermId(paymentTermId); + if(bPartnerId==null) + bPartnerId=Integer.valueOf(POSTerminalManager.getPOSDefaultBpartner(ctx).get_ID()); + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART); + + if(cartBean == null||cartBean.getItems() == null||cartBean.getItems().size() == 0) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + + MOrder customerReturnOrder=null; + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + customerReturnOrder= POSGoodsManager.createCustomerReturn(ctx,bean,cartBean.getItems(),bPartnerId,reason,trx.getTrxName()); + trx.commit(); + } + catch(BPartnerNoLocationException ex) + { + trx.rollback(); + postGlobalError("error.bpartner.nolocation", request); + return mapping.getInputForward(); + } + catch(BPartnerOverCreditLimitException e1) + { + trx.rollback(); + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(OperationException e) + { + trx.rollback(); + throw new OperationException("Could not create customer return order!! Reason : " + e); + } + finally + { + trx.close(); + } + + bean.setOrderId(Integer.valueOf(customerReturnOrder.get_ID())); + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx,customerReturnOrder); + ArrayList list = POSManager.populateOrderLines(ctx,customerReturnOrder); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + + if(customerReturnOrder.getPaymentRule().equalsIgnoreCase(MOrder.PAYMENTRULE_OnCredit)) + { + ElementBean title=ElementManager.getMsg(ctx,"credit.memo"); + request.getSession().setAttribute(Constants.ORDER_TITLE,title.getName()); + } + + else + { + ElementBean title=ElementManager.getMsg(ctx,"customer.returned.order"); + request.getSession().setAttribute(Constants.ORDER_TITLE,title.getName()); + } + + + request.getSession().setAttribute(Constants.CUSTOMER_RETURN_ORDER_ID,customerReturnOrder.get_ID()); + request.setAttribute(Constants.CUSTOMER_RETURN_ORDER_LINES,list); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + + return mapping.findForward(CREATE_CUSTOMER_RETURN_ORDER); + } + + public static final String COMPLETE_CUSTOMER_RETURN_ORDER="completeCustomerReturnOrder"; + public ActionForward completeCustomerReturnOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + + Integer customerReturnOrderId=(Integer)request.getSession().getAttribute(Constants.CUSTOMER_RETURN_ORDER_ID); + MOrder completedCustomerReturn=null; + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + if(customerReturnOrderId==null) + { + postGlobalError("error.no.order.exists",request); + return mapping.getInputForward(); + } + + try + { + trx.start(); + completedCustomerReturn=POSGoodsManager.completeCustomerReturnOrder(ctx,customerReturnOrderId.intValue(),trx.getTrxName()); + trx.commit(); + } + catch(NoOrderLineFoundException e) + { + trx.rollback(); + postGlobalError("error.pos.no.orderline",request); + request.getSession().removeAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART_ITEMS); + return mapping.getInputForward(); + } + catch(BPartnerOverCreditLimitException e1) + { + trx.rollback(); + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + + catch(OperationException e) + { + trx.rollback(); + throw new OperationException("Could not complete customer return order!! Reason : " + e); + } + finally + { + trx.close(); + } + + + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx,completedCustomerReturn); + ArrayList list = POSManager.populateOrderLines(ctx,completedCustomerReturn); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + + //request.getSession().setAttribute(Constants.CUSTOMER_RETURN_ORDER_ID,completedCustomerReturn.get_ID()); + request.setAttribute(Constants.CUSTOMER_RETURN_ORDER_LINES,list); + /*request.removeAttribute(Constants.POS_ORDER_LINES);*/ + + + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + + if(completedCustomerReturn.getPaymentRule().equalsIgnoreCase(MOrder.PAYMENTRULE_OnCredit)) + { + ElementBean title=ElementManager.getMsg(ctx,"credit.memo"); + request.getSession().setAttribute(Constants.ORDER_TITLE,title.getName()); + } + + else + { + ElementBean title=ElementManager.getMsg(ctx,"customer.returned.order"); + request.getSession().setAttribute(Constants.ORDER_TITLE,title.getName()); + } + + + request.getSession().removeAttribute(Constants.DESCRIPTION); + request.removeAttribute(Constants.DESCRIPTION); + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.DESCRIPTION); + request.getSession().removeAttribute(Constants.CUSTOMER_RETURN_ORDER_ID); + request.getSession().removeAttribute(Constants.B_PARTNER_ID); + + request.getSession().removeAttribute(Constants.ORDER_TYPE); + request.getSession().removeAttribute(Constants.POS_ORDER_DOC_NUMBER); + request.getSession().removeAttribute(Constants.CREDIT_PAYMENT_TERM_ID); + + return mapping.findForward(COMPLETE_CUSTOMER_RETURN_ORDER); + } + + public static final String COMPLETE_POS_ORDER="completePOSOrder"; + public static final String VIEW_POS_ORDERS="viewPOSOrders"; + public static final String COMPLETED_CREDIT_ORDER="completedCreditOrder"; + + + public ActionForward viewPOSOrders(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + MOrder order= new MOrder(ctx,bean.getOrderId(),null); + String status = order.getDocStatus(); + + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx,order); + + ArrayList list = POSManager.populateOrderLines(ctx,order); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + ActionForward forward=null; + + if(order.getOrderType().equals(UDIOrderTypes.POS_GOODS_RECEIVE_NOTE.getOrderType())) + { + if( status.equals(DocAction.STATUS_Drafted) ) + { + int c_BPartner_Id = order.getC_BPartner_ID(); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.GOODS_RECEIVE_NOTE_LINES, list ); + request.getSession().setAttribute( Constants.GOODS_RECEIVE_NOTE_ID , Integer.valueOf(order.get_ID()) ); + forward = new ActionForward("/DraftedGoodsReceiveNote.do"); + } + else + { + request.getSession().setAttribute(Constants.GOODS_RECEIVE_NOTE,order); + request.setAttribute(Constants.GOODS_RECEIVE_NOTE_LINES,list); + forward= mapping.findForward(COMPLETE_GOODS_RECEIVE_NOTE); + } + } + else if(order.getOrderType().equals(UDIOrderTypes.POS_GOODS_RETURN_NOTE.getOrderType())) + { + if( status.equals(DocAction.STATUS_Drafted) ) + { + + int c_BPartner_Id = order.getC_BPartner_ID(); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.GOODS_RETURN_NOTE_LINES, list ); + request.getSession().setAttribute( Constants.GOODS_RETURN_NOTE_ID, Integer.valueOf(order.get_ID()) ); + + forward = new ActionForward("/DraftedGoodsReturnNote.do"); + } + else + { + request.getSession().setAttribute(Constants.GOODS_RETURN_NOTE,order); + request.setAttribute(Constants.GOODS_RETURN_NOTE_LINES,list); + forward= mapping.findForward(COMPLETE_GOODS_RETURN_NOTE); + } + + } + else if(order.getOrderType().equals(UDIOrderTypes.CUSTOMER_RETURN_ORDER.getOrderType())|| order.getOrderType().equals(UDIOrderTypes.CREDIT_MEMO.getOrderType())) + { + if(order.getPaymentRule().equalsIgnoreCase(MOrder.PAYMENTRULE_OnCredit)) + { + ElementBean title=ElementManager.getMsg(ctx,"credit.memo"); + request.getSession().setAttribute(Constants.ORDER_TITLE,title.getName()); + } + + else + { + ElementBean title=ElementManager.getMsg(ctx,"customer.returned.order"); + request.getSession().setAttribute(Constants.ORDER_TITLE,title.getName()); + } + if( status.equals(DocAction.STATUS_Drafted) ) + { + + int c_BPartner_Id = order.getC_BPartner_ID(); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.CUSTOMER_RETURN_ORDER_LINES, list ); + request.getSession().setAttribute( Constants.CUSTOMER_RETURN_ORDER_ID, Integer.valueOf(order.get_ID()) ); + + + forward = new ActionForward("/DraftedCustomerReturnOrder.do"); + } + else + { + + request.getSession().setAttribute(Constants.CUSTOMER_RETURN_ORDER,order); + request.setAttribute(Constants.CUSTOMER_RETURN_ORDER_LINES,list); + forward= mapping.findForward(COMPLETE_CUSTOMER_RETURN_ORDER); + } + } + else if(order.getOrderType().equals(UDIOrderTypes.WEBSTORE_ORDER.getOrderType())) + { + + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER,order); + request.setAttribute(Constants.POS_ORDER_LINES,list); + request.setAttribute(Constants.ORDER_NAME,"Webstore Order"); + + forward= mapping.findForward(COMPLETE_POS_ORDER); + } + + else if(order.getOrderType().equals(UDIOrderTypes.POS_ORDER.getOrderType())) + { + if( status.equals(DocAction.STATUS_Drafted) ) + { + int c_BPartner_Id = order.getC_BPartner_ID(); + + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.POS_ORDER_LINES, list ); + request.getSession().setAttribute( Constants.CURRENT_POS_ORDER_ID , Integer.valueOf(order.get_ID()) ); + forward = new ActionForward("/DraftedPOSOrder.do"); + } + else if( status.equals(DocAction.STATUS_InProgress) ) + { + int c_BPartner_Id = order.getC_BPartner_ID(); + + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.POS_ORDER_LINES, list ); + request.setAttribute(Constants.ORDER_NAME,"POS Order"); + request.getSession().setAttribute( Constants.CURRENT_POS_ORDER_ID , Integer.valueOf(order.get_ID()) ); + forward= mapping.findForward(COMPLETE_POS_ORDER); + } + else + { + if( status.equals(DocAction.STATUS_Completed) ) + { //setting card & check tendered amount + BigDecimal cardTendered = POSManager.getPayment(ctx,order.get_ID(),MPayment.TENDERTYPE_CreditCard,null); + BigDecimal chequeTendered = POSManager.getPayment(ctx,order.get_ID(),MPayment.TENDERTYPE_Check,null); + + request.setAttribute(Constants.CARD_AMT_TENDERED, cardTendered); + request.setAttribute(Constants.CHEQUE_AMT_TENDERED, chequeTendered); + } + + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER,order); + request.setAttribute(Constants.POS_ORDER_LINES,list); + request.setAttribute(Constants.ORDER_NAME,"POS Order"); + forward= mapping.findForward(COMPLETE_POS_ORDER); + } + } + else if(order.getOrderType().equals(UDIOrderTypes.CREDIT_ORDER.getOrderType())) + { + if( status.equals(DocAction.STATUS_Drafted) ) + { + int c_BPartner_Id = order.getC_BPartner_ID(); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.POS_ORDER_LINES, list ); + request.getSession().setAttribute( Constants.CURRENT_POS_ORDER_ID , Integer.valueOf(order.get_ID()) ); + + forward = new ActionForward("/DraftedCreditOrder.do"); + } + else + { + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER,order); + request.setAttribute(Constants.POS_ORDER_LINES,list); + forward= mapping.findForward(COMPLETED_CREDIT_ORDER); + } + } + else + { + String msg = "Unknown orderType : " + order.getOrderType(); + throw new OperationException(msg); + } + if(order.getPaymentRule().equals(UdiConstants.PAYMENTRULE_MIXED)) + { + POSManager.getAmountForMixedPayment(ctx,order,webBean); + } + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + df.populate(new OrderLineBean()); + return forward; + + } + + public static final String VIEW_COMPLETED_POS_ORDER = "viewCompletedPOSOrder"; + public ActionForward viewCompletedPOSOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + MOrder order= new MOrder(ctx,bean.getOrderId(),null); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx,order); + + + + ArrayList list = POSManager.populateOrderLines(ctx,order); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER,order); + request.setAttribute(Constants.POS_ORDER_LINES,list); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + + return mapping.findForward(VIEW_COMPLETED_POS_ORDER); + } + + public static final String GET_TAX_CATEGORY="getTaxCategory"; + public ActionForward getTaxCategory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + //DefaultForm df = (DefaultForm)form; + ArrayList taxList=POSGoodsManager.getAllTaxCategory(ctx); + + request.getSession().setAttribute(Constants.TAX_CATEGORY_ID,taxList); + return mapping.findForward(GET_TAX_CATEGORY); + } + + public static final String INCREMENT_QTY = "incrementQty"; + public ActionForward incrementQty(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + addToShoppingCart(mapping,form,request,response); + return getShoppingCart(mapping,form,request,response); + } + + public static final String DECREMENT_QTY = "decrementQty"; + public ActionForward decrementQty(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + addToShoppingCart(mapping,form,request,response); + return getShoppingCart(mapping,form,request,response); + } + + public ActionForward getShoppingCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException + { + DefaultForm df = (DefaultForm) form; + String orderType = df.getOrderType(); + + if(orderType == null) + { + throw new OperationException("Cannot lookup for shopping cart! Cause orderType is null."); + } + + HashMap map = new HashMap(); + + map.put(Constants.GOODS_RECEIVE_NOTE, "/jsp/pos/goodsReceiveShoppingCart.jsp"); + map.put(Constants.GOODS_RETURN_NOTE, "/jsp/pos/goodsReturnShoppingCart.jsp"); + map.put(Constants.CUSTOMER_RETURN_ORDER,"/jsp/pos/customerReturnShoppingCart.jsp"); + + String url = map.get(orderType); + if(url == null) + { + throw new OperationException("Cannot lookup for shopping cart! Cause no shopping cart is define for orderType:" + orderType); + } + + return new ActionForward(url); + } + + + public static final String CREATE_CUSTOMER_RETURN_FROM_POSORDER="createCustomerReturnFromPOSOrder"; + public ActionForward createCustomerReturnFromPOSOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + ShoppingCartBean cart =null; + OrderBean orderBean; + try + { + orderBean = POSManager.getPOSOrderDetail(ctx,bean.getDocumentNo()); + + if(orderBean==null) + { + postGlobalError("error.orderid.notpresent",request); + return mapping.getInputForward(); + } + + if(!orderBean.getOrderType().equalsIgnoreCase(UDIOrderTypes.POS_ORDER.getOrderType())) + { + postGlobalError("error.only.pos.order.supported",request); + return mapping.getInputForward(); + } + + if(orderBean.getDocStatus().equalsIgnoreCase(DocumentEngine.STATUS_Drafted)) + { + postGlobalError("error.pos.order.not.completed",request); + return mapping.getInputForward(); + } + + cart = POSManager.getShoppingCartForOrder(ctx,orderBean.getOrderId(),null); + } + catch(InvalidOrderIDException e) + { + postGlobalError("error.orderid.notpresent",request); + return mapping.getInputForward(); + } + + if(orderBean.getOrderType().equalsIgnoreCase(UDIOrderTypes.CREDIT_ORDER.getOrderType())) + { + ElementBean title=ElementManager.getMsg(ctx,"credit.memo"); + request.getSession().setAttribute(Constants.ORDER_TITLE,title.getName()); + } + + else + { + ElementBean title=ElementManager.getMsg(ctx,"customer.returned.order"); + request.getSession().setAttribute(Constants.ORDER_TITLE,title.getName()); + } + + int bpartnerId = orderBean.getBpartnerId().intValue(); + MBPartner partner = BPartnerManager.loadBPartner(ctx, bpartnerId,null); + String partnerName = partner.getName() + " " + partner.getName2(); + partnerName = partnerName.trim(); + + df.setPartnerName(partnerName); + df.setBpartnerId(orderBean.getBpartnerId().toString()); + + request.getSession().setAttribute(Constants.B_PARTNER_ID,orderBean.getBpartnerId()); + request.getSession().setAttribute(Constants.ORDER_TYPE,orderBean.getOrderType()); + request.getSession().setAttribute(Constants.POS_ORDER_DOC_NUMBER,bean.getDocumentNo()); + request.getSession().setAttribute(Constants.CREDIT_PAYMENT_TERM_ID,orderBean.getPaymentTermId()); + request.getSession().setAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART,cart); + request.getSession().setAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART_ITEMS,cart.getItems()); + return mapping.findForward(CREATE_CUSTOMER_RETURN_FROM_POSORDER); + } + + + //--------------------------------------------------credit order------------------------------------------------------------ + public static final String LOAD_CREDIT_ORDER="loadCreditOrder"; + public ActionForward loadCreditOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + ShoppingCartBean cart =null; + OrderBean orderBean; + + try + { + orderBean = POSManager.getPOSOrderDetail(ctx,bean.getDocumentNo()); + + if(orderBean==null) + { + postGlobalError("error.orderid.notpresent",request); + return mapping.getInputForward(); + } + + if(!orderBean.getOrderType().equalsIgnoreCase(UDIOrderTypes.CREDIT_ORDER.getOrderType()) && !orderBean.getOrderType().equalsIgnoreCase(UDIOrderTypes.CREDIT_ORDER.getOrderType())) + { + postGlobalError("error.only.credit.order.supported",request); + return mapping.getInputForward(); + } + + if(orderBean.getDocStatus().equalsIgnoreCase(DocumentEngine.STATUS_Drafted)) + { + postGlobalError("error.credit.order.not.completed",request); + return mapping.getInputForward(); + } + + cart = POSManager.getShoppingCartForOrder(ctx,orderBean.getOrderId(),null); + } + catch(InvalidOrderIDException e) + { + postGlobalError("error.orderid.notpresent",request); + return mapping.getInputForward(); + } + + int bpartnerId = orderBean.getBpartnerId().intValue(); + MBPartner partner = BPartnerManager.loadBPartner(ctx, bpartnerId,null); + String partnerName = partner.getName() + " " + partner.getName2(); + partnerName = partnerName.trim(); + + df.setPartnerName(partnerName); + df.setBpartnerId(orderBean.getBpartnerId().toString()); + + request.getSession().setAttribute(Constants.B_PARTNER_ID,orderBean.getBpartnerId()); + request.getSession().setAttribute(Constants.ORDER_TYPE,orderBean.getOrderType()); + request.getSession().setAttribute(Constants.POS_ORDER_DOC_NUMBER,bean.getDocumentNo()); + request.getSession().setAttribute(Constants.CREDIT_PAYMENT_TERM_ID,orderBean.getPaymentTermId()); + request.getSession().setAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART,cart); + request.getSession().setAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART_ITEMS,cart.getItems()); + return mapping.findForward(LOAD_CREDIT_ORDER); + } + + //####################### Deletion of orders #######################// + //deleteGoodsReturnOrder + //deleteGoodsReceiveOrder + //deleteCustomerReturnOrder + + public static final String DELETE_GOODS_RETURN_ORDER = "deleteGoodsReturnOrder"; + public static final String DELETE_GOODS_RECEIVE_ORDER = "deleteGoodsReceiveOrder"; + public static final String DELETE_CUSTOMER_RETURN_ORDER = "deleteCustomerReturnOrder"; + + public ActionForward deleteGoodsReturnOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + Integer orderId = (Integer) request.getSession().getAttribute( Constants.GOODS_RETURN_NOTE_ID ); + + if( orderId == null ) + { + throw new OperationException("Cannot delete order. Reason: order ID not found!"); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + OrderManager.deleteDraftedOrder(ctx, orderId.intValue(), null); + trx.commit(); + } + catch(OperationException ex) + { + trx.rollback(); + postGlobalError("error.order.delete", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + //remove previously set values + request.getSession().removeAttribute(Constants.GOODS_RETURN_NOTE_SHOPPING_CART); + request.getSession().removeAttribute(Constants.GOODS_RETURN_NOTE_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.GOODS_RETURN_NOTE_ID); + request.getSession().removeAttribute(Constants.B_PARTNER_ID); + request.getSession().removeAttribute(Constants.DESCRIPTION); + + //return mapping.findForward(DELETE_GOODS_RETURN_ORDER); + return new ActionForward( "/GetAllPOSVendor.do?action=getAllVendors&isSales=false" ); + } + + public ActionForward deleteGoodsReceiveOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + Integer orderId = (Integer) request.getSession().getAttribute( Constants.GOODS_RECEIVE_NOTE_ID ); + + if( orderId == null ) + { + throw new OperationException("Cannot delete order. Reason: order ID not found!"); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + OrderManager.deleteDraftedOrder(ctx, orderId.intValue(), null); + trx.commit(); + } + catch(OperationException ex) + { + trx.rollback(); + postGlobalError("error.order.delete", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + //remove previously set values + request.getSession().removeAttribute(Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART); + request.getSession().removeAttribute(Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.GOODS_RECEIVE_NOTE_ID); + request.getSession().removeAttribute(Constants.B_PARTNER_ID); + request.getSession().removeAttribute(Constants.DESCRIPTION); + + //GetAllPOSVendor.do?action=getAllVendors&isSales=false + //return mapping.findForward(DELETE_GOODS_RECEIVE_ORDER); + return new ActionForward( "/GetAllPOSVendor.do?action=getAllVendors&isSales=true" ); + } + + public ActionForward deleteCustomerReturnOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + Integer orderId = (Integer) request.getSession().getAttribute( Constants.CUSTOMER_RETURN_ORDER_ID ); + + if( orderId == null ) + { + throw new OperationException("Cannot delete order. Reason: order ID not found!"); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + OrderManager.deleteDraftedOrder(ctx, orderId.intValue(), null); + trx.commit(); + } + catch(OperationException ex) + { + trx.rollback(); + postGlobalError("error.order.delete", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + //remove previously set values + request.getSession().removeAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.CUSTOMER_RETURN_ORDER_ID); + request.getSession().removeAttribute(Constants.B_PARTNER_ID); + request.getSession().removeAttribute(Constants.DESCRIPTION); + + request.getSession().removeAttribute(Constants.ORDER_TYPE); + request.getSession().removeAttribute(Constants.POS_ORDER_DOC_NUMBER); + request.getSession().removeAttribute(Constants.CREDIT_PAYMENT_TERM_ID); + + return mapping.findForward(DELETE_CUSTOMER_RETURN_ORDER); + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSInfoAction.java b/posterita/src/main/org/posterita/struts/pos/POSInfoAction.java new file mode 100644 index 0000000000..56db3b6391 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSInfoAction.java @@ -0,0 +1,206 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.pos; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.posterita.Constants; +import org.posterita.beans.ReportBean; +import org.posterita.businesslogic.CSVReportManager; +import org.posterita.businesslogic.POSManager; +import org.posterita.businesslogic.ReportDateManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.core.TabularReport; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + +public class POSInfoAction extends POSDispatchAction +{ + public static final String GET_CURRENT_DAY_REPORT = "getCurrentDayReport"; + public ActionForward getCurrentDayReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String toDate = sdf.format(new Date(cal.getTimeInMillis())); + + cal.set(Calendar.HOUR_OF_DAY,0); + cal.set(Calendar.MINUTE,0); + cal.set(Calendar.SECOND,0); + cal.set(Calendar.MILLISECOND,0); + + String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + + ArrayList list=POSManager.getPOSInfo(ctx,fromDate,toDate); + request.getSession().setAttribute(Constants.POS_INFO,list); + + return mapping.findForward(GET_CURRENT_DAY_REPORT); + } + + public static final String GET_CURRENT_MONTH_REPORT = "getCurrentMonthReport"; + public ActionForward getCurrentMonthReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String toDate = sdf.format(new Date(cal.getTimeInMillis())); + + cal.set(Calendar.DATE,1); + cal.set(Calendar.HOUR_OF_DAY,0); + cal.set(Calendar.MINUTE,0); + cal.set(Calendar.SECOND,0); + cal.set(Calendar.MILLISECOND,0); + + String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + + ArrayList list=POSManager.getPOSInfo(ctx,fromDate,toDate); + request.getSession().setAttribute(Constants.POS_INFO,list); + + return mapping.findForward(GET_CURRENT_MONTH_REPORT); + } + + public static final String GET_CUSTOM_REPORT = "getCustomReport"; + public ActionForward getCustomReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + ReportBean bean = (ReportBean) df.getBean(); + + String title = "POS Info"; + String subtitle = ""; + + String dateRange = bean.getDateRange(); + String timePeriod = bean.getTimePeriod(); + + String fromDate = null; + String toDate = null; + + //setting from and to dates + if(dateRange.endsWith(Constants.FIXED_DATE_RANGE)) + { + if(timePeriod==null) + { + throw new OperationException("Invalid Parameter for timePeriod. timePeriod is NULL"); + } + + Date startDate = ReportDateManager.getStartDateForPeriod(timePeriod); + Date endDate = ReportDateManager.getEndDateForPeriod(timePeriod); + + SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + fromDate = sdf.format(startDate); + toDate = sdf.format(endDate); + + subtitle = "For " + timePeriod; + } + else if(dateRange.endsWith(Constants.CUSTOM_DATE_RANGE)) + { + boolean error = false; + ActionMessages messages = new ActionMessages(); + ActionMessage message = null; + + + if((bean.getFromDate()==null)||(bean.getFromDate()=="")) + { + message = new ActionMessage("error.required.fromDate"); + messages.add(ActionMessages.GLOBAL_MESSAGE, message); + error = true; + } + + if((bean.getToDate()==null)||(bean.getToDate()=="")) + { + message = new ActionMessage("error.required.toDate"); + messages.add(ActionMessages.GLOBAL_MESSAGE, message); + error = true; + } + + if(error) + { + saveErrors(request, messages); + return mapping.getInputForward(); + } + else + { + fromDate = ReportDateManager.getFromDate(bean); + toDate = ReportDateManager.getToDate(bean); + + } + + + subtitle = "For period:"+fromDate+" to "+toDate; + } + else + { + throw new OperationException("Invalid Parameter for dateRange :" + dateRange); + } + + ArrayList reportData = POSManager.getPOSInfoReportData(ctx,fromDate,toDate); + + //constructing the table + TabularReport tReport = new TabularReport(reportData); + tReport.setSortable(false); + tReport.setStyle("display"); + tReport.setTitle(title); + tReport.setSubtitle(subtitle); + tReport.createReport(); + + String csvReport = CSVReportManager.generateCSVReport(ctx,reportData); + String csvURI = ReportManager.getReportURI(csvReport,request); + + request.getSession().setAttribute(Constants.TABULAR_REPORT_DATA,tReport.toString()); + request.getSession().setAttribute(Constants.CSV_FILE,csvURI); + + return mapping.findForward(GET_CUSTOM_REPORT); + + + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSOrderAction.java b/posterita/src/main/org/posterita/struts/pos/POSOrderAction.java new file mode 100644 index 0000000000..24e8939bf9 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSOrderAction.java @@ -0,0 +1,1533 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on 14-Mar-2006 + */ + + +package org.posterita.struts.pos; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.math.BigDecimal; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MBPartner; +import org.compiere.model.MCurrency; +import org.compiere.model.MOrder; +import org.compiere.model.MPayment; +import org.compiere.util.Env; +import org.compiere.util.Trx; +import org.compiere.util.WebUser; +import org.posterita.Constants; +import org.posterita.beans.CurrentTillAmountBean; +import org.posterita.beans.LoginBean; +import org.posterita.beans.OrderBean; +import org.posterita.beans.OrderLineBean; +import org.posterita.beans.RemoveSessionBean; +import org.posterita.beans.ReportBean; +import org.posterita.beans.ShoppingCartBean; +import org.posterita.beans.WebDocumentBean; +import org.posterita.businesslogic.BPartnerManager; +import org.posterita.businesslogic.LoginManager; +import org.posterita.businesslogic.OrderManager; +import org.posterita.businesslogic.OrderReferenceManager; +import org.posterita.businesslogic.POSManager; +import org.posterita.businesslogic.POSTerminalManager; +import org.posterita.businesslogic.PrintManager; +import org.posterita.businesslogic.ReportDateManager; +import org.posterita.businesslogic.RoleManager; +import org.posterita.businesslogic.StockManager; +import org.posterita.businesslogic.UserManager; +import org.posterita.core.ContextId; +import org.posterita.core.SessionStorage; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.core.businesslogic.ElementManager; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BPartnerNoLocationException; +import org.posterita.exceptions.BPartnerOverCreditLimitException; +import org.posterita.exceptions.DiscountLimitException; +import org.posterita.exceptions.DuplicatePINException; +import org.posterita.exceptions.InputQuantityLessThanZeroException; +import org.posterita.exceptions.InsufficientQtyException; +import org.posterita.exceptions.InvalidAddressException; +import org.posterita.exceptions.InvalidPINException; +import org.posterita.exceptions.InvalidTenderedAmountException; +import org.posterita.exceptions.LimitPriceVioletException; +import org.posterita.exceptions.NoOrderLineSelectedException; +import org.posterita.exceptions.NotLoggedInException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ProductNotFoundException; +import org.posterita.exceptions.ProductNotOnPriceListException; +import org.posterita.exceptions.QuantityNotAvailableException; +import org.posterita.exceptions.UserInactiveException; +import org.posterita.exceptions.UserNotFoundException; +import org.posterita.form.RemoveSessionForm; +import org.posterita.lib.UdiConstants; +import org.posterita.order.UDIOrderTypes; +import org.posterita.struts.core.DefaultForm; +import org.posterita.util.OrderFormatter; + + +public class POSOrderAction extends POSDispatchAction +{ + public static final String CREATE_POS_ORDER="createPOSOrder"; + public ActionForward createPOSOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + bean.getPaymentByCash(); + bean.getPaymentByCard(); + bean.getPaymentByChq(); + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.SHOPPING_ORDER_CART); + + if(cartBean==null ||cartBean.getItems() == null||cartBean.getItems().size()==0) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + + String[] discountPercentage = df.getDiscountPercent(); + String[] actualPrice = df.getActualPrice(); + double d = 0.0d; + + if(( discountPercentage != null ) && ( discountPercentage.length != 0 )) + { + for(String s : discountPercentage) + { + if(s == null || s == "") + { + continue; + } + + try + { + d = Double.parseDouble(s); + + if(d < 0) + { + postGlobalError("error.discount.nagative",request); + return mapping.getInputForward(); + } + } + catch (NumberFormatException e) + { + postGlobalError("errors.double","Discount(s)",request); + return mapping.getInputForward(); + } + } + + for(String s : actualPrice) + { + if(s == null || s == "") + { + continue; + } + + try + { + Double.parseDouble(s); + } + catch (NumberFormatException e) + { + postGlobalError("errors.double","Price(s)",request); + return mapping.getInputForward(); + } + } + } + + + + Integer bPartnerId = bean.getBpartnerId(); + + if(bPartnerId==null) + bPartnerId = (Integer) request.getSession().getAttribute(Constants.BPARTNER); + + if(bPartnerId==null) + { + String orderType = df.getOrderType(); + if(orderType!=null && orderType.equalsIgnoreCase( Constants.POS_ORDER_CUSTOMER_COMPULSORY )) + { + postGlobalError("error.required" ,"customer" ,request); + return mapping.getInputForward(); + } + + bPartnerId=Integer.valueOf(POSTerminalManager.getPOSDefaultBpartner(ctx).get_ID()); + } + else + { + boolean isBPartnerPresent = BPartnerManager.isBPartnerPresent(ctx,bPartnerId.intValue(),null); + + if( !isBPartnerPresent ) + { + postGlobalError("error.pos.invalid.customerID",request); + return mapping.getInputForward(); + } + } + + // VALIDATING DISCOUNT AUTHORISATION <========= + BigDecimal discountAllowed = (BigDecimal) request.getSession().getAttribute(Constants.DISCOUNT_ALLOWED); + + + bean.setUserDiscount(discountAllowed); + bean.setBpartnerId(bPartnerId); + + //check if the order is alredy created + MOrder previousOrder= null; + previousOrder=(MOrder)request.getSession().getAttribute(Constants.PRESENT_POS_ORDER); + + if(previousOrder!=null) + { + bean.setOrderId(Integer.valueOf(previousOrder.get_ID())); + } + else + { + bean.setOrderId(null); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + MOrder posOrder=null; + try + { + trx.start(); + posOrder= POSManager.createPOSOrder(ctx,bean,cartBean.getItems(),trx.getTrxName()); + trx.commit(); + } + catch(BPartnerOverCreditLimitException e1) + { + trx.rollback(); + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(BPartnerNoLocationException ex) + { + trx.rollback(); + postGlobalError("error.bpartner.nolocation", request); + return mapping.getInputForward(); + } + catch(InvalidTenderedAmountException e) + { + trx.rollback(); + postGlobalError("error.pos.incorrect.tendered.amount",request); + return mapping.getInputForward(); + } + catch (DiscountLimitException e) + { + trx.rollback(); + postGlobalError("error.discountLimit.exceeded",request); + return mapping.getInputForward(); + } + catch(InsufficientQtyException e3) + { + trx.rollback(); + postGlobalError("error.insufficient.qty",e3.getMessage(),request); + return mapping.getInputForward(); + } + catch(LimitPriceVioletException e3) + { + trx.rollback(); + postGlobalError("error.limit.price.violet",e3.getMessage(),request); + return mapping.getInputForward(); + } + + + finally + { + trx.close(); + } + + bean.setOrderId(Integer.valueOf(posOrder.get_ID())); + + df.populate(new OrderLineBean()); + WebDocumentBean webBean =null; + try + { + webBean = OrderReferenceManager.getWebOrderBean(ctx, posOrder); + } + catch(InvalidAddressException e) + { + postGlobalError("error.invalid.address",request); + return mapping.getInputForward(); + } + + if(posOrder.getPaymentRule().equals(UdiConstants.PAYMENTRULE_MIXED)) + { + if(bean.getPaymentByCash()!=null) + webBean.setPaymentByCash(bean.getPaymentByCash()); + if(bean.getPaymentByCard()!=null) + webBean.setPaymentByCard(bean.getPaymentByCard()); + if(bean.getPaymentByChq()!=null) + webBean.setPaymentbyCheque(bean.getPaymentByChq()); + } + + + ArrayList list = POSManager.populateOrderLines(ctx,posOrder); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER_ID,Integer.valueOf(posOrder.get_ID())); + request.getSession().setAttribute(Constants.PRESENT_POS_ORDER,posOrder); + request.getSession().setAttribute(Constants.ORDER_LINE_BEAN,bean); + request.getSession().setAttribute(Constants.BPARTNER,bPartnerId); + request.setAttribute(Constants.POS_ORDER_LINES,list); + request.getSession().removeAttribute(Constants.PRESENT_POS_ORDER); + request.getSession().removeAttribute(Constants.PRESENT_POS_ORDER_ID); + + + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + + //remove any previously set discount + request.getSession().removeAttribute(Constants.DISCOUNT_ALLOWED); + + return mapping.findForward(CREATE_POS_ORDER); + } + + public static final String COMPLETE_POS_ORDER="completePOSOrder"; + public ActionForward completePOSOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean b = (OrderLineBean) df.getBean(); + + OrderLineBean bean=(OrderLineBean) request.getSession().getAttribute(Constants.ORDER_LINE_BEAN); + + + if(bean==null) + { + bean = new OrderLineBean(); + } + bean.setAmountGiven(b.getAmountGiven()); + bean.setAmountRefunded(b.getAmountRefunded()); + + Integer orderId = (Integer) request.getSession().getAttribute(Constants.CURRENT_POS_ORDER_ID); + MOrder completedPOSOrder=null; + + + if(orderId==null) + { + postGlobalError("error.no.order.exists",request); + return mapping.getInputForward(); + } + + + if(OrderManager.isOrderEmpty(ctx,orderId.intValue(),null)) + { + postGlobalError("error.pos.no.orderline",request); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART_ITEMS); + + return mapping.getInputForward(); + } + + + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + completedPOSOrder=POSManager.completePOSOrder(ctx,orderId.intValue(),bean,null); + trx.commit(); + } + catch(BPartnerOverCreditLimitException e1) + { + trx.rollback(); + MOrder posOrder = new MOrder(ctx,orderId.intValue(),null); + ArrayList list = POSManager.populateOrderLines(ctx,posOrder); + request.setAttribute(Constants.POS_ORDER_LINES,list); + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(InvalidTenderedAmountException e) + { + trx.rollback(); + MOrder posOrder = new MOrder(ctx,orderId.intValue(),null); + ArrayList list = POSManager.populateOrderLines(ctx,posOrder); + request.setAttribute(Constants.POS_ORDER_LINES,list); + postGlobalError("error.required.amount.given",request); + return mapping.getInputForward(); + } + catch(OperationException e) + { + trx.rollback(); + MOrder posOrder = new MOrder(ctx,orderId.intValue(),null); + ArrayList list = POSManager.populateOrderLines(ctx,posOrder); + request.setAttribute(Constants.POS_ORDER_LINES,list); + throw e; + } + finally + { + trx.close(); + } + + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx, completedPOSOrder); + + if(completedPOSOrder.getPaymentRule().equals(UdiConstants.PAYMENTRULE_MIXED)) + { + POSManager.getAmountForMixedPayment(ctx,completedPOSOrder,webBean); + } + + ArrayList list = POSManager.populateOrderLines(ctx,completedPOSOrder); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER_ID,completedPOSOrder.get_ID()); + request.setAttribute(Constants.POS_ORDER_LINES,list); + + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + /*request.removeAttribute(Constants.POS_ORDER_LINES);*/ + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.BPARTNER); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART_ITEMS); + request.getSession().removeAttribute(Constants.CURRENT_POS_ORDER_ID); + + + //fix for invoke partial pos order + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID); + request.getSession().removeAttribute(Constants.PRESENT_POS_ORDER); + request.getSession().removeAttribute( Constants.PRESENT_POS_ORDER_ID ); + + //setting card & check tendered amount + BigDecimal cardTendered = POSManager.getPayment(ctx,completedPOSOrder.get_ID(),MPayment.TENDERTYPE_CreditCard,trx.getTrxName()); + BigDecimal chequeTendered = POSManager.getPayment(ctx,completedPOSOrder.get_ID(),MPayment.TENDERTYPE_Check,trx.getTrxName()); + + request.setAttribute(Constants.CARD_AMT_TENDERED, cardTendered); + request.setAttribute(Constants.CHEQUE_AMT_TENDERED, chequeTendered); + + return mapping.findForward(COMPLETE_POS_ORDER); + } + + + public static final String COMPLETE_POS_ORDER_PRINT_INVOICE="completePOSOrderPrintInvoice"; + public ActionForward completePOSOrderPrintInvoice(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean b = (OrderLineBean) df.getBean(); + + OrderLineBean bean=(OrderLineBean) request.getSession().getAttribute(Constants.ORDER_LINE_BEAN); + bean.setAmountGiven(b.getAmountGiven()); + bean.setAmountRefunded(b.getAmountRefunded()); + + Integer orderId = (Integer) request.getSession().getAttribute(Constants.CURRENT_POS_ORDER_ID); + MOrder completedPOSOrder=null; + + + if(OrderManager.isOrderEmpty(ctx,orderId.intValue(),null)) + { + postGlobalError("error.pos.no.orderline",request); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART_ITEMS); + + return mapping.getInputForward(); + } + + + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + completedPOSOrder=POSManager.completePOSOrder2(ctx,orderId.intValue(),bean,null); + trx.commit(); + } + catch(BPartnerOverCreditLimitException e1) + { + trx.rollback(); + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(OperationException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + } + + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx, completedPOSOrder); + + if(completedPOSOrder.getPaymentRule().equals(UdiConstants.PAYMENTRULE_MIXED)) + { + POSManager.getAmountForMixedPayment(ctx,completedPOSOrder,webBean); + } + + ArrayList list = POSManager.populateOrderLines(ctx,completedPOSOrder); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER_ID,completedPOSOrder.get_ID()); + request.setAttribute(Constants.POS_ORDER_LINES,list); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + + /*request.removeAttribute(Constants.POS_ORDER_LINES);*/ + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART_ITEMS); + request.getSession().removeAttribute(Constants.CURRENT_POS_ORDER_ID); + + return mapping.findForward(COMPLETE_POS_ORDER_PRINT_INVOICE); + } + + + public static final String CREATE_AND_COMPLETE_POS_ORDER="createAndCompletePOSOrder"; + public ActionForward createAndCompletePOSOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + bean.getPaymentByCash(); + bean.getPaymentByCard(); + bean.getPaymentByChq(); + + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.SHOPPING_ORDER_CART); + + if(cartBean==null ||cartBean.getItems() == null||cartBean.getItems().size()==0) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + + //MOrder posOrder=(MOrder) request.getSession().getAttribute(Constants.CURRENT_POS_ORDER); + + Integer bPartnerId = bean.getBpartnerId(); + + if(bPartnerId==null) + bPartnerId = (Integer) request.getSession().getAttribute(Constants.BPARTNER); + + if(bPartnerId==null) + { + bPartnerId=Integer.valueOf(POSTerminalManager.getPOSDefaultBpartner(ctx).get_ID()); + } + else + { + boolean isBPartnerPresent = BPartnerManager.isBPartnerPresent(ctx,bPartnerId.intValue(),null); + + if( !isBPartnerPresent ) + { + postGlobalError("error.pos.invalid.customerID",request); + return mapping.getInputForward(); + } + } + + bean.setBpartnerId(bPartnerId); + + MOrder completedPOSOrder = null; + + try + { + completedPOSOrder = POSManager.createAndCompletePOSOrder(ctx,bean,cartBean.getItems()); + } + catch(BPartnerOverCreditLimitException e1) + { + + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(BPartnerNoLocationException ex) + { + postGlobalError("error.bpartner.nolocation", request); + return mapping.getInputForward(); + } + catch (DiscountLimitException e) + { + postGlobalError("error.discountLimit.exceeded",request); + return mapping.getInputForward(); + } + + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx, completedPOSOrder); + + ArrayList list = POSManager.populateOrderLines(ctx,completedPOSOrder); + WebDocumentBean documentBean=POSManager.calculateOrderTotals(list); + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER_ID,completedPOSOrder.get_ID()); + request.setAttribute(Constants.POS_ORDER_LINES,list); + + /*request.removeAttribute(Constants.POS_ORDER_LINES);*/ + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART_ITEMS); + request.getSession().removeAttribute(Constants.CURRENT_POS_ORDER_ID); + + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + + return mapping.findForward(CREATE_AND_COMPLETE_POS_ORDER); + } + + public static final String GET_POS_PAYMENT_DETAILS="getPOSPaymentDetails"; + public ActionForward getPOSPaymentDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + MOrder order=null; + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + df.populate(new OrderLineBean()); + if(bean.getBpartnerId()!=null) + request.getSession().setAttribute(Constants.BPARTNER, bean.getBpartnerId()); + + else if(bean.getOrderId()!=null) + { + order = new MOrder(ctx, bean.getOrderId(), null); + bean.setBpartnerId(order.getC_BPartner_ID()); + request.getSession().setAttribute(Constants.BPARTNER, bean.getBpartnerId()); + + } + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.SHOPPING_ORDER_CART); + if(cartBean==null) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + request.getSession().setAttribute(Constants.PRESENT_POS_ORDER,order); + request.getSession().setAttribute(Constants.SHOPPING_ORDER_CART, cartBean); + request.getSession().setAttribute(Constants.SHOPPING_ORDER_CART_ITEMS, cartBean.getItems()); + return mapping.findForward(GET_POS_PAYMENT_DETAILS); + } + + public static final String GET_POS_CUSTOMERS="getPOSCustomers"; + public ActionForward getPOSCustomers(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + //Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + //OrderLineBean bean=(OrderLineBean) df.getBean(); + df.populate(new OrderLineBean()); + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.SHOPPING_ORDER_CART); + + if(cartBean == null||cartBean.getItems() == null||cartBean.getItems().size() == 0) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + request.getSession().setAttribute(Constants.SHOPPING_ORDER_CART, cartBean); + request.getSession().setAttribute(Constants.SHOPPING_ORDER_CART_ITEMS, cartBean.getItems()); + + + return mapping.findForward(GET_POS_CUSTOMERS); + } + + public ActionForward deletePOSOrderLine(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + String forward = null; + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + forward = POSManager.deleteOrderLines(ctx,bean.getPosOrderLineIds(),trx.getTrxName()); + trx.commit(); + } + catch (NoOrderLineSelectedException e) + { + trx.rollback(); + SessionStorage.putPOSOrderInfo(ctx,bean,request,forward); + + postGlobalError("error.order.noOrderline.selected",request); + return mapping.getInputForward(); + } + catch(OperationException ex) + { + trx.rollback(); + throw new OperationException("Could not delete orderline. Reason : " + ex); + } + finally + { + trx.close(); + } + + Integer orderId = getCurrentOrderId(mapping, form, request, response); + //validating order + //if lines == 0 goto createpartialOrder + + //reload shopping cart + ShoppingCartBean cart = POSManager.getShoppingCartForOrder(ctx,orderId.intValue(),null); + String shoppingCart = null; + String shoppingCartItem = null; + String input = null; + + String orderType = bean.getOrderType(); + + if(orderType.equals(Constants.POS_ORDER)) + { + input = "/CreatePOSOrder.do"; + + shoppingCart = Constants.SHOPPING_ORDER_CART; + shoppingCartItem = Constants.SHOPPING_ORDER_CART_ITEMS; + } + else if(orderType.equals(Constants.GOODS_RECEIVE_NOTE)) + { + input = "/GetAllPOSVendor.do?action=getAllVendors&isSales=true"; + + shoppingCart = Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART; + shoppingCartItem = Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART_ITEMS; + } + else if(orderType.equals(Constants.GOODS_RETURN_NOTE)) + { + input = "/GetAllPOSVendor.do?action=getAllVendors&isSales=false"; + + shoppingCart = Constants.GOODS_RETURN_NOTE_SHOPPING_CART; + shoppingCartItem = Constants.GOODS_RETURN_NOTE_SHOPPING_CART_ITEMS; + } + else if(orderType.equals(Constants.CUSTOMER_RETURN_ORDER)) + { + input = "/CustomerReturnOrder.do"; + + shoppingCart = Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART; + shoppingCartItem = Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART_ITEMS; + } + else + { + + } + + request.getSession().setAttribute(shoppingCart,cart); + request.getSession().setAttribute(shoppingCartItem,cart.getItems()); + + + if(OrderManager.isOrderEmpty(ctx,orderId.intValue(),null)) + { + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(shoppingCart); + request.getSession().removeAttribute(shoppingCartItem); + return new ActionForward(input); + } + + SessionStorage.putPOSOrderInfo(ctx,bean,request,forward); + df.populate(new OrderLineBean()); + return mapping.findForward(forward); + } + + public static final String VIEW_POS_INFO="viewPOSInfo"; + public ActionForward viewPOSInfo(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + ReportBean bean = (ReportBean) df.getBean(); + + String fromdate = ReportDateManager.getFromDate(bean); + String todate = ReportDateManager.getToDate(bean); + + ArrayList list=POSManager.getPOSInfo(ctx,fromdate,todate); + request.getSession().setAttribute(Constants.POS_INFO,list); + //df.populate(new OrderLineBean()); + + + return mapping.findForward(VIEW_POS_INFO); + } + + + + public static final String INCREMENT_QTY = "incrementQty"; + public ActionForward incrementQty(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + addToShoppingCart(mapping,form,request,response); + return getShoppingCart(mapping,form,request,response); + } + + public static final String DECREMENT_QTY = "decrementQty"; + public ActionForward decrementQty(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + addToShoppingCart(mapping,form,request,response); + return getShoppingCart(mapping,form,request,response); + } + + + public static final String ADD_TO_SHOPPING_CART = "addToShoppingCart"; + public ActionForward addToShoppingCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + OrderLineBean bean = (OrderLineBean) df.getBean(); + // ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.SHOPPING_ORDER_CART); + String orderType = bean.getOrderType(); + if(orderType==null) + { + orderType=(String)request.getSession().getAttribute(Constants.ORDER_TYPE); + bean.setOrderType(orderType); + df.populate(bean); + } + String shoppingCart = null; + String shoppingCartItem = null; + String path=null; + + + + if(orderType.equalsIgnoreCase(Constants.POS_ORDER)) + { + shoppingCart = Constants.SHOPPING_ORDER_CART; + shoppingCartItem = Constants.SHOPPING_ORDER_CART_ITEMS; + path="/jsp/pos/createPOSOrder.jsp"; + + + } + + if(orderType.equalsIgnoreCase(Constants.POS_ORDER_WITHOUT_ADVANCED)) + { + shoppingCart = Constants.SHOPPING_ORDER_CART; + shoppingCartItem = Constants.SHOPPING_ORDER_CART_ITEMS; + path="/jsp/pos/createPOSOrderWithoutAdvance.jsp"; + + + } + + if(orderType.equalsIgnoreCase(Constants.QUICK_POS_ORDER)) + { + shoppingCart = Constants.SHOPPING_ORDER_CART; + shoppingCartItem = Constants.SHOPPING_ORDER_CART_ITEMS; + path="/jsp/pos/createPOSOrder3.jsp"; + + + } + + if(orderType.equalsIgnoreCase(Constants.POS_ORDER_CUSTOMER_COMPULSORY)) + { + shoppingCart = Constants.SHOPPING_ORDER_CART; + shoppingCartItem = Constants.SHOPPING_ORDER_CART_ITEMS; + path="/jsp/pos/createPOSOrder2.jsp"; + + + } + else if(orderType.equalsIgnoreCase(Constants.CREDIT_ORDER)) + { + shoppingCart = Constants.CREDIT_ORDER_SHOPPING_CART; + shoppingCartItem = Constants.CREDIT_ORDER_SHOPPING_CART_ITEMS; + path="/jsp/pos/createCreditOrder.jsp"; + } + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(shoppingCart); + + try + { + // POSManager.getQtyAndItem(bean); + if(bean.getProductId()==null && bean.getBarCode()==null) + { + postGlobalError("error.barcode.required", request); + return new ActionForward(path); + } + + cartBean = StockManager.addToPOSCart(ctx, bean, cartBean,true,Boolean.parseBoolean(bean.getIfAdd())); + } + catch (InputQuantityLessThanZeroException e1) + { + postGlobalError("error.invalid.inputQty", request); + return new ActionForward(path); + } + catch (ProductNotFoundException e2) + { + postGlobalError("error.product.not.found", e2.getMessage(), request); + return new ActionForward(path); + } + catch(QuantityNotAvailableException e3) + { + postGlobalError("error.quantity.notAvailable", e3.getMessage(), request); + return new ActionForward(path); + } + + catch(ProductNotOnPriceListException e4) + { + postGlobalError("error.product.price.not.found", e4.getMessage(), request); + return new ActionForward(path); + } + + + + String currSymboleSales = POSTerminalManager.getPOSDefaultSellCurrency(ctx).getCurSymbol(); + request.setAttribute(Constants.CURRENCY_SYMBOLE,currSymboleSales); + request.getSession().setAttribute(Constants.ORDER_TYPE,orderType); + + + request.getSession().setAttribute(shoppingCart, cartBean); + request.getSession().setAttribute(shoppingCartItem, cartBean.getItems()); + request.getSession().setAttribute(Constants.B_PARTNER_ID,bean.getBpartnerId()); + + df.setQtyAndItem(""); + + return new ActionForward(path); + //return mapping.findForward(ADD_TO_SHOPPING_CART); + } + + + + public static final String CHOOSE_POS="choosePOS"; + + public ActionForward choosePOS(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + SessionStorage.putPOSID(ctx,df.getPosId(),request); + POSManager.setPOSIDInCookie(response,df.getPosId()); + String currSymboleSales = POSTerminalManager.getPOSDefaultSellCurrency(ctx).getCurSymbol(); + String currSymbolePurchase=POSTerminalManager.getPOSDefaultPurchaseCurrency(ctx).getCurSymbol(); + request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE,currSymboleSales); + request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE_PURCHASE,currSymbolePurchase); + + return mapping.findForward(CHOOSE_POS); + } + + public static final String GET_CURRENT_TILL_AMOUNT="getCurrentTillAmount"; + + public ActionForward getCurrentTillAmount(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + //DefaultForm df= (DefaultForm) form; + + CurrentTillAmountBean bean = POSManager.getCurrentTillAmount(ctx); + MCurrency currency = POSTerminalManager.getCurrencyOfDefaultCashBook(ctx); + request.setAttribute(Constants.CURRENCY_SYMBOLE,currency.getCurSymbol()); + request.getSession().setAttribute(Constants.CURRENT_TILL_AMOUNT,bean); + return mapping.findForward(GET_CURRENT_TILL_AMOUNT); + } + + public static final String OPEN_CASH_DRAWER="openCashDrawer"; + + public ActionForward openCashDrawer(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + String cmd = PrintManager.getOpenDrawerCmd(); + + response.setContentType("application/octet-stream"); + OutputStream os = response.getOutputStream(); + os.write(cmd.getBytes()); + os.flush(); + os.close(); + + return null; + //return mapping.findForward(OPEN_CASH_DRAWER); + } + + public static final String REPRINT_ORDER="reprintOrder"; + + public ActionForward reprintOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + DefaultForm df= (DefaultForm) form; + + OrderLineBean bean=(OrderLineBean)df.getBean(); + + OrderManager.rePrintOrder(ctx,bean.getOrderId()); + + return mapping.findForward(REPRINT_ORDER); + } + + public static final String DELETE_ORDER="deleteOrder"; + public ActionForward deleteOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + DefaultForm df= (DefaultForm) form; + + OrderBean orderBean = (OrderBean)df.getBean(); + + try + { + OrderManager.deleteDraftedOrder(ctx, orderBean.getOrderId(), null); + } + catch(OperationException ex) + { + MOrder posOrder = new MOrder(ctx,orderBean.getOrderId(),null); + ArrayList list = POSManager.populateOrderLines(ctx,posOrder); + request.setAttribute(Constants.POS_ORDER_LINES,list); + postGlobalError("error.order.delete", request); + return mapping.getInputForward(); + } + return mapping.findForward(DELETE_ORDER); + } + + public static Integer getCurrentOrderId(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) + { + DefaultForm f = (DefaultForm)form; + + String orderType = f.getOrderType(); + Integer orderId = null; + + if(orderType.equals(Constants.POS_ORDER)) + { + orderId = (Integer) request.getSession().getAttribute(Constants.CURRENT_POS_ORDER_ID); + } + + if(orderType.equals(Constants.GOODS_RECEIVE_NOTE)) + { + orderId = (Integer) request.getSession().getAttribute(Constants.GOODS_RECEIVE_NOTE_ID); + } + + if(orderType.equals(Constants.GOODS_RETURN_NOTE)) + { + orderId = (Integer) request.getSession().getAttribute(Constants.GOODS_RETURN_NOTE_ID); + } + + if(orderType.equals(Constants.CUSTOMER_RETURN_ORDER)) + { + orderId = (Integer) request.getSession().getAttribute(Constants.CUSTOMER_RETURN_ORDER_ID); + } + + return orderId; + } + + public static final String DELETE_POS_ORDER = "deletePOSOrder"; + public ActionForward deletePOSOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + Integer orderId = (Integer) request.getSession().getAttribute( Constants.CURRENT_POS_ORDER_ID ); + + if( orderId == null ) + { + throw new OperationException("Cannot delete order. Reason: order ID not found!"); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + OrderManager.deleteDraftedOrder(ctx, orderId.intValue(), trx.getTrxName()); + trx.commit(); + } + catch(OperationException ex) + { + trx.rollback(); + MOrder posOrder = new MOrder(ctx,orderId.intValue(),null); + ArrayList list = POSManager.populateOrderLines(ctx,posOrder); + request.setAttribute(Constants.POS_ORDER_LINES,list); + postGlobalError("error.order.delete", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + //remove previously set values + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART); + request.getSession().removeAttribute(Constants.SHOPPING_ORDER_CART_ITEMS); + request.getSession().removeAttribute(Constants.CURRENT_POS_ORDER_ID); + request.getSession().removeAttribute(Constants.CREDIT_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.CREDIT_ORDER_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.CREDITORDER_BPARTNER); + + return mapping.findForward(DELETE_POS_ORDER); + } + + public ActionForward getShoppingCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException + { + DefaultForm df = (DefaultForm) form; + String orderType = df.getOrderType(); + + if(orderType == null) + { + throw new OperationException("Cannot lookup for shopping cart! Cause orderType is null."); + } + + HashMap map = new HashMap(); + + map.put(Constants.POS_ORDER, "/jsp/pos/posShoppingCartFirstPage.jsp"); + map.put(Constants.QUICK_POS_ORDER, "/jsp/pos/posShoppingCartFirstPage.jsp"); + map.put(Constants.POS_ORDER_CUSTOMER_COMPULSORY, "/jsp/pos/posShoppingCartFirstPage.jsp"); + map.put(Constants.CREDIT_ORDER, "/jsp/pos/creditOrderShoppingCart.jsp"); + map.put(Constants.POS_ORDER_WITHOUT_ADVANCED, "/jsp/pos/posShoppingCartFirstPage.jsp"); + + + + String url = map.get(orderType); + if(url == null) + { + throw new OperationException("Cannot lookup for shopping cart! Cause no shopping cart is define for orderType:" + orderType); + } + + return new ActionForward(url); + } + + + public ActionForward validateAdvanceOrderPIN(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws IOException, OperationException + { + Properties ctx=TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + String userPIN = df.getUserPIN(); + + LoginBean bean = null; + LoginManager loginManager = new LoginManager(); + String script = null; + String errorMsg = ElementManager.getMsg(ctx,"not.authorised.to.give.discount").getName(); + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.SHOPPING_ORDER_CART); + + if (cartBean == null || cartBean.getItems().size() == 0) + { + script = "PINError('No items in cart')"; + } + else + { + try + { + bean = loginManager.getUserNameFromPIN(ctx, userPIN); + WebUser wu = loginManager.checkLoginPassword(ctx, bean); + + int roleId = Env.getAD_Role_ID(ctx); + + BigDecimal discountAllowed = RoleManager.getDiscountAllowed(ctx, roleId, null); + + if(discountAllowed != Env.ZERO) + { + script = "setAction(document.forms[0],'GetPOSPaymentDetailsAction.do','getPOSPaymentDetails');" + + "disableButtons();"; + + request.getSession().setAttribute(Constants.DISCOUNT_ALLOWED, discountAllowed); + } + else + { + script = "PINError('" + errorMsg + "');" ; + } + } + catch (DuplicatePINException e) + { + script = "PINError('" + errorMsg + "');" ; + } + catch (InvalidPINException e) + { + script = "PINError('" + errorMsg + "');" ; + } + catch (UserNotFoundException e) + { + script = "PINError('" + errorMsg + "');" ; + } + catch (UserInactiveException e) + { + script = "PINError('" + errorMsg + "');" ; + } + catch (NotLoggedInException e) + { + script = "PINError('" + errorMsg + "');" ; + } + catch (SQLException e) + { + throw new OperationException(e); + } + catch (OperationException e) + { + throw new OperationException(e); + } + } + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + + public ActionForward validateAdvanceOrderPIN2(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws IOException, OperationException + { + Properties ctx=TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + String userPIN = df.getUserPIN(); + + LoginBean bean = null; + LoginManager loginManager = new LoginManager(); + String script = null; + + try + { + bean = loginManager.getUserNameFromPIN(ctx, userPIN); + WebUser wu = loginManager.checkLoginPassword(ctx, bean); + + int roleId = Env.getAD_Role_ID(ctx); + + BigDecimal discountAllowed = RoleManager.getDiscountAllowed(ctx, roleId, null); + + if(discountAllowed != Env.ZERO) + { + script = "setAction(document.forms[0],'GetPOSPaymentDetailsAction2.do','getPOSPaymentDetails');" + + "disableButtons();"; + + request.getSession().setAttribute(Constants.DISCOUNT_ALLOWED, discountAllowed); + } + else + { + script = "PINError('It seems that you are not authorised to give discounts.');" ; + } + } + catch (DuplicatePINException e) + { + script = "PINError('It seems that you are not authorised to give discounts.');" ; + } + catch (InvalidPINException e) + { + script = "PINError('It seems that you are not authorised to give discounts.');" ; + } + catch (UserNotFoundException e) + { + script = "PINError('It seems that you are not authorised to give discounts.');" ; + } + catch (UserInactiveException e) + { + script = "PINError('It seems that you are not authorised to give discounts.');" ; + } + catch (NotLoggedInException e) + { + script = "PINError('It seems that you are not authorised to give discounts.');" ; + } + catch (SQLException e) + { + throw new OperationException(e); + } + catch (OperationException e) + { + throw new OperationException(e); + } + + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + + public ActionForward getPrintOrderData(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws IOException, OperationException, ApplicationException + { + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + OrderLineBean bean = (OrderLineBean) df.getBean(); + + Integer C_Order_ID = bean.getOrderId(); + + if(C_Order_ID == null) + return null; + + String printData = PrintManager.getPrintData(ctx, C_Order_ID, null); + + byte [] openCashDrawer = {10,27,112,48,55,1}; + + response.setContentType("application/octet-stream"); + OutputStream os = response.getOutputStream(); + + if(bean.getOpenDrawer()) + { + os.write(openCashDrawer); + } + + os.write(printData.getBytes()); + os.flush(); + os.close(); + + + return null; + } + + public static final String GET_ORDER_SHOPPING_CART="getOrderShoppingCart"; + public ActionForward getOrderShoppingCart(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws IOException, OperationException, ApplicationException + { + + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + OrderLineBean bean = (OrderLineBean) df.getBean(); + ActionForward forward=null; + + Integer orderId = bean.getOrderId(); + MOrder order = new MOrder(ctx,orderId,null); + + ShoppingCartBean cart = (ShoppingCartBean)request.getSession().getAttribute(Constants.SHOPPING_ORDER_CART); + if(cart == null) + { + cart = POSManager.getShoppingCartForOrder(ctx, order.get_ID(), null); + } + + + int c_BPartner_Id = order.getC_BPartner_ID(); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + + if((Constants.POS_ORDER_WITHOUT_ADVANCED).equalsIgnoreCase(df.getOrderType())) + { + cart = POSManager.getShoppingCartForOrder(ctx, order.get_ID(), null); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.SHOPPING_ORDER_CART , cart ); + request.getSession().setAttribute( Constants.SHOPPING_ORDER_CART_ITEMS , cart.getItems() ); + request.getSession().setAttribute( Constants.PRESENT_POS_ORDER , order ); + request.getSession().setAttribute( Constants.PRESENT_POS_ORDER_ID , Integer.valueOf(order.get_ID()) ); + + forward = new ActionForward("/CreatePOSOrderWithoutAdvanced.do"); + + df.populate(new OrderLineBean()); + return forward; + } + + if((Constants.POS_ORDER_CUSTOMER_COMPULSORY).equalsIgnoreCase(df.getOrderType())) + { + cart = POSManager.getShoppingCartForOrder(ctx, order.get_ID(), null); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.SHOPPING_ORDER_CART , cart ); + request.getSession().setAttribute( Constants.SHOPPING_ORDER_CART_ITEMS , POSManager.getItemBean(cart.getItems()) ); + request.getSession().setAttribute( Constants.PRESENT_POS_ORDER , order ); + request.getSession().setAttribute( Constants.PRESENT_POS_ORDER_ID , Integer.valueOf(order.get_ID()) ); + + forward = new ActionForward("/CreatePOSOrder2.do"); + + df.populate(new OrderLineBean()); + return forward; + } + + if(order.getOrderType().equals(UDIOrderTypes.POS_ORDER.getOrderType())) + { + cart = POSManager.getShoppingCartForOrder(ctx, order.get_ID(), null); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.SHOPPING_ORDER_CART , cart ); + request.getSession().setAttribute( Constants.SHOPPING_ORDER_CART_ITEMS , POSManager.getItemBean(cart.getItems())); + request.getSession().setAttribute( Constants.PRESENT_POS_ORDER , order ); + request.getSession().setAttribute( Constants.PRESENT_POS_ORDER_ID , Integer.valueOf(order.get_ID()) ); + df.populate(new OrderLineBean()); + forward = new ActionForward("/CreatePOSOrder.do"); + } + else if(order.getOrderType().equals(UDIOrderTypes.POS_GOODS_RECEIVE_NOTE.getOrderType())) + { + cart = (ShoppingCartBean)request.getSession().getAttribute(Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART , cart ); + + if (cart != null) + { + request.getSession().setAttribute( Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART_ITEMS , cart.getItems() ); + request.getSession().setAttribute( Constants.PRESENT_GRN_ORDER , order ); + request.getSession().setAttribute( Constants.PRESENT_GRN_ORDER_ID , Integer.valueOf(order.get_ID()) ); + } + + forward = new ActionForward("/GetAllPOSVendor.do?action=getAllVendors&isSales=true"); + } + else if(order.getOrderType().equals(UDIOrderTypes.POS_GOODS_RETURN_NOTE.getOrderType())) + { + cart = (ShoppingCartBean)request.getSession().getAttribute(Constants.GOODS_RETURN_NOTE_SHOPPING_CART); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.GOODS_RETURN_NOTE_SHOPPING_CART, cart ); + request.getSession().setAttribute( Constants.GOODS_RETURN_NOTE_SHOPPING_CART_ITEMS,cart.getItems() ); + request.getSession().setAttribute( Constants.PRESENT_GOODS_RET_ORDER , order ); + request.getSession().setAttribute( Constants.PRESENT_GOODS_RET_ORDER_ID , Integer.valueOf(order.get_ID()) ); + + forward = new ActionForward("/GetAllPOSVendor.do?action=getAllVendors&isSales=false"); + } + else if(order.getOrderType().equals(UDIOrderTypes.CUSTOMER_RETURN_ORDER.getOrderType())) + { + cart = (ShoppingCartBean)request.getSession().getAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART); + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART, cart ); + request.getSession().setAttribute( Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART_ITEMS, POSManager.getItemBean(cart.getItems()) ); + request.getSession().setAttribute( Constants.PRESENT_CUSTOMER_RET_ORDER , order ); + request.getSession().setAttribute( Constants.PRESENT_CUSTOMER_RET_ORDER_ID , Integer.valueOf(order.get_ID()) ); + + forward = new ActionForward("/CustomerReturnOrder.do"); + + } + else if(order.getOrderType().equals(UDIOrderTypes.CREDIT_ORDER.getOrderType())) + { + cart = (ShoppingCartBean)request.getSession().getAttribute(Constants.CREDIT_ORDER_SHOPPING_CART); + request.getSession().setAttribute(Constants.CREDITORDER_BPARTNER, Integer.valueOf(c_BPartner_Id)); + request.getSession().setAttribute( Constants.CREDIT_ORDER_SHOPPING_CART , cart ); + request.getSession().setAttribute( Constants.CREDIT_ORDER_SHOPPING_CART_ITEMS , POSManager.getItemBean(cart.getItems()) ); + request.getSession().setAttribute( Constants.PRESENT_CREDIT_ORDER , order ); + request.getSession().setAttribute( Constants.PRESENT_CREDIT_ORDER_ID , Integer.valueOf(order.get_ID()) ); + forward = new ActionForward("/InitCreateCreditOrderAction.do?action=initCreateCreditOrder"); + + } + + else if(order.getOrderType().equals(UDIOrderTypes.CREDIT_MEMO.getOrderType())) + { + cart = (ShoppingCartBean)request.getSession().getAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART); + OrderBean orderBean = POSManager.getPOSOrderDetail(ctx,order.getDocumentNo()); + int bpartnerId = orderBean.getBpartnerId().intValue(); + MBPartner partner = BPartnerManager.loadBPartner(ctx, bpartnerId,null); + String partnerName = partner.getName() + " " + partner.getName2(); + partnerName = partnerName.trim(); + + df.setPartnerName(partnerName); + df.setBpartnerId(orderBean.getBpartnerId().toString()); + + request.getSession().setAttribute(Constants.B_PARTNER_ID,orderBean.getBpartnerId()); + request.getSession().setAttribute(Constants.ORDER_TYPE,orderBean.getOrderType()); + request.getSession().setAttribute(Constants.POS_ORDER_DOC_NUMBER,bean.getDocumentNo()); + request.getSession().setAttribute(Constants.CREDIT_PAYMENT_TERM_ID,orderBean.getPaymentTermId()); + if (cart != null) + { + request.getSession().setAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART,cart); + request.getSession().setAttribute(Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART_ITEMS,cart.getItems()); + } + forward = new ActionForward("/CreditMemoAction.do"); + + } + else + { + String msg = "Unknown orderType : " + order.getOrderType(); + throw new OperationException(msg); + } + df.populate(new OrderLineBean()); + return forward; + } + + public static final String GET_CUSTOMER_RETURN_ORDER_SHOPPING_CART = "getCustomerReturnOrderShoppingCart"; + public ActionForward getCustomerReturnOrderShoppingCart(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws IOException, OperationException, ApplicationException + { + getOrderShoppingCart(mapping,form,request,response); + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + Integer bpartnerId = (Integer) request.getSession().getAttribute(Constants.B_PARTNER_ID); + + MBPartner partner = BPartnerManager.loadBPartner(ctx, bpartnerId.intValue(),null); + String partnerName = partner.getName() + " " + partner.getName2(); + partnerName = partnerName.trim(); + + df.setPartnerName(partnerName); + df.setBpartnerId(bpartnerId.toString()); + + return mapping.findForward(GET_CUSTOMER_RETURN_ORDER_SHOPPING_CART); + } + + public static final String GET_CUSTOMER_RETURN_ORDER_SHOPPING_CART2 = "getCustomerReturnOrderShoppingCart2"; + public ActionForward getCustomerReturnOrderShoppingCart2(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws IOException, OperationException, ApplicationException + { + getOrderShoppingCart(mapping,form,request,response); + + /* + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + Integer bpartnerId = (Integer) request.getSession().getAttribute(Constants.B_PARTNER_ID); + + MBPartner partner = BPartnerManager.loadBPartner(ctx, bpartnerId.intValue(),null); + String partnerName = partner.getName() + " " + partner.getName2(); + partnerName = partnerName.trim(); + + df.setPartnerName(partnerName); + df.setBpartnerId(bpartnerId.toString()); + */ + + return mapping.findForward(GET_CUSTOMER_RETURN_ORDER_SHOPPING_CART2); + } + + public static final String GET_CREDIT_MEMO_SHOPPING_CART = "getCreditMemoShoppingCart"; + public ActionForward getCreditMemoShoppingCart(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws IOException, OperationException, ApplicationException + { + getCustomerReturnOrderShoppingCart(mapping,form,request,response); + return mapping.findForward(GET_CREDIT_MEMO_SHOPPING_CART); + } + + public static final String REMOVE_SESSION_FOR_NEW_OREDR="removeSessionForNewOrder"; + public ActionForward removeSessionForNewOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws IOException, OperationException, ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + Properties ctx=TmkJSPEnv.getCtx(request); + RemoveSessionForm df = (RemoveSessionForm) form; + RemoveSessionBean bean = (RemoveSessionBean) df.getBean(); + + SessionStorage.removeSession(ctx,request); + String forwd =POSManager.getForward(ctx,bean.getOrderType()); + + + return new ActionForward(forwd); + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSPriceListAction.java b/posterita/src/main/org/posterita/struts/pos/POSPriceListAction.java new file mode 100644 index 0000000000..e858a0e0df --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSPriceListAction.java @@ -0,0 +1,152 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 19, 2005 by praveen + * + */ +package org.posterita.struts.pos; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Env; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.EditPriceBean; +import org.posterita.beans.PriceListBean; +import org.posterita.beans.ProductPriceBean; +import org.posterita.businesslogic.PriceListManager; +import org.posterita.businesslogic.ProductCart; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.SystemException; +import org.posterita.form.PriceListForm; +import org.posterita.lib.UdiConstants; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + +public class POSPriceListAction extends BaseDispatchAction +{ + public static final String INIT_PRICE_LIST = "initPriceList"; + public ActionForward initPriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + String searchText = df.getSearchText(); + + int priceListId = Env.getContextAsInt(ctx, UdiConstants.PRICELIST_CTX_PARAM); + int priceListVersionId = PriceListManager.getPriceListVersionID(ctx, priceListId, null); + + ArrayList productPriceList = PriceListManager.getProductPriceList(ctx, priceListVersionId, searchText, null, null); + + request.getSession().setAttribute(Constants.POS_SALES_PRICE_LIST, productPriceList); + request.getSession().setAttribute(Constants.PRICE_LIST, productPriceList); + return mapping.findForward(INIT_PRICE_LIST); + } + + public static final String INIT_EDIT_PRICE_LIST = "initEditPriceList"; + public ActionForward initEditPriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + PriceListForm df = (PriceListForm) form; + + df.validate(mapping,request); + + PriceListBean bean = (PriceListBean) df.getBean(); + + if(bean.getProductIds() == null || bean.getProductIds().length == 0) + { + postGlobalError("error.product.not.selected", request); + return mapping.getInputForward(); + } + + request.getSession().setAttribute(Constants.PRODUCT_IDS, bean.getProductIds()); + + + return mapping.findForward(INIT_EDIT_PRICE_LIST); + } + + public static final String EDIT_PRICELIST = "editPriceList"; + public ActionForward editPriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException, SystemException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + EditPriceBean bean = (EditPriceBean) df.getBean(); + + BigDecimal priceEntered = bean.getPrice(); + + ProductCart cart = (ProductCart) request.getSession().getAttribute(Constants.PRODUCT_CART); + Integer productIds[] = cart.getProductIDs(); + + + int priceListId = Env.getContextAsInt(ctx, UdiConstants.PRICELIST_CTX_PARAM); + int priceListVersionId = PriceListManager.getPriceListVersionID(ctx, priceListId, null); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + + try + { + trx.start(); + PriceListManager.editProductPrices(ctx,productIds, priceListVersionId, priceEntered, trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + throw e; + } + catch (SystemException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + } + + return mapping.findForward(EDIT_PRICELIST); + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSProductAction.java b/posterita/src/main/org/posterita/struts/pos/POSProductAction.java new file mode 100644 index 0000000000..5517f3b5c6 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSProductAction.java @@ -0,0 +1,870 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on May 22, 2006 + */ + + +package org.posterita.struts.pos; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.ProductBean; +import org.posterita.beans.ProductDetailsBean; +import org.posterita.beans.ProductSalesInfoBean; +import org.posterita.beans.ProductSalesSummaryBean; +import org.posterita.businesslogic.POSGoodsManager; +import org.posterita.businesslogic.POSProductManager; +import org.posterita.businesslogic.ProductCart; +import org.posterita.businesslogic.ProductManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.core.RandomStringGenerator; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BarcodeAlreadyExistsException; +import org.posterita.exceptions.CannotInactivateProductException; +import org.posterita.exceptions.InvalidBarcodeException; +import org.posterita.exceptions.InvalidContentTypeException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ProductAlreadyExistException; +import org.posterita.exceptions.ProductNotFoundException; +import org.posterita.form.ProductForm; +import org.posterita.struts.core.DefaultForm; + + +public class POSProductAction extends POSDispatchAction +{ + + public static final String CREATE_POS_PRODUCT="createPOSProduct"; + public ActionForward createPOSProduct(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + ProductBean bean = (ProductBean)df.getBean(); + + //setting the image + bean.setFile(df.getFile()); + + ArrayList list=null; + request.getSession().removeAttribute(Constants.PRODUCT_CREATED); + boolean error=false; + + + + if(bean.getRevenueRecognition()==null) + { + postGlobalError("error.required.revenue.recognition",request); + error = true; + + } + + if(error) + { + return mapping.getInputForward(); + } + + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + list=new ArrayList(); + list=POSProductManager.createSinglePOSProduct(ctx,bean,trx.getTrxName()); + trx.commit(); + } + catch(ProductAlreadyExistException e1) + { + postGlobalError("error.product.already.exists",request); + trx.rollback(); + return mapping.getInputForward(); + } + catch(BarcodeAlreadyExistsException e2) + { + postGlobalError("error.barcode.already.exists",request); + trx.rollback(); + return mapping.getInputForward(); + } + catch(NumberFormatException e3) + { + postGlobalError("error.numberformatexception.price",request); + trx.rollback(); + trx.close(); + return mapping.getInputForward(); + + } + finally + { + trx.close(); + } + + + request.getSession().setAttribute(Constants.PRODUCT_CREATED,list); + return mapping.findForward(CREATE_POS_PRODUCT); + } + + + public static final String VIEW_PRODUCT_FOR_UPDATE="viewProductForUpdate"; + public ActionForward viewProductForUpdate(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + ProductForm pf = (ProductForm)form; + + pf.validate(mapping,request); + + ProductBean bean = (ProductBean)pf.getBean(); + bean = POSProductManager.viewPOSProduct(ctx,bean.getProductId().intValue()); + pf.populate(bean); + + //ArrayList list = POSGoodsManager.getAllProductCategory(ctx); + //ArrayList supList=POSGoodsManager.getAllSuppliers(ctx); + ArrayList taxList = POSGoodsManager.getAllTaxCategory(ctx); + + + // request.getSession().setAttribute(Constants.BP_LIST,supList); + request.getSession().setAttribute(Constants.EXISTING_BAR_CODE,bean.getBarCode()); + request.getSession().setAttribute(Constants.TAX_CATEGORY_ID,taxList); + //request.getSession().setAttribute(Constants.PRODUCT_CATEGORY_ID,list); + //request.getSession().setAttribute(Constants.PRODUCT_DETAILS,bean); + return mapping.findForward(VIEW_PRODUCT_FOR_UPDATE); + } + + + public static final String UPDATE_PRODUCT_DETAILS="updateProductDetails"; + public ActionForward updateProductDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + ProductBean bean = (ProductBean)df.getBean(); + bean.setFile(df.getFile()); + String existingBarCode = (String)request.getSession().getAttribute(Constants.EXISTING_BAR_CODE); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + POSProductManager.editProduct(ctx,bean,existingBarCode,trx.getTrxName()); + trx.commit(); + } + catch(BarcodeAlreadyExistsException e1) + { + + trx.rollback(); + postGlobalError("error.barcode.already.exists",request); + return mapping.getInputForward(); + } + catch(CannotInactivateProductException e2) + { + trx.rollback(); + postGlobalError("error.product.cannot.inactivate", e2.getMessage(), request); + return mapping.getInputForward(); + + } + catch(InvalidContentTypeException e3) + { + trx.rollback(); + postGlobalError("error.invalid.content", e3.getMessage(), request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + ProductBean productBean= POSProductManager.viewPOSProduct(ctx,bean.getProductId().intValue()); + request.getSession().setAttribute(Constants.PRODUCT_DETAILS,productBean); + return mapping.findForward(UPDATE_PRODUCT_DETAILS); + } + + + + public static final String CREATE_POS_GARMENT_PRODUCT="createPOSGarmentProduct"; + public ActionForward createPOSGarmentProduct(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + ProductBean bean = (ProductBean)df.getBean(); + + ArrayList list=new ArrayList(); + request.getSession().removeAttribute(Constants.PRODUCT_CREATED); + + String customSize = bean.getCustomSize(); + ArrayList sizeList = new ArrayList(); + if(bean.getSizes() != null && bean.getSizes().length > 0) + { + String[] sizes = bean.getSizes(); + for(int i = 0; i < sizes.length; i++) + sizeList.add(sizes[i]); + } + if(customSize != null && customSize.trim().length() > 0) + { + customSize = customSize.trim(); + sizeList.add(customSize); + } + + if(sizeList.size() == 0) + { + postGlobalError("error.required.sizes",request); + return mapping.getInputForward(); + } + else + { + String nSizes[] = new String[sizeList.size()]; + sizeList.toArray(nSizes); + bean.setSizes(nSizes); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + list=POSProductManager.createGarmentProduct(ctx,bean,0,false,null); + trx.commit(); + } + catch(ProductAlreadyExistException e1) + { + trx.rollback(); + postGlobalError("error.product.already.exists",request); + return mapping.getInputForward(); + } + catch(BarcodeAlreadyExistsException e2) + { + trx.rollback(); + postGlobalError("error.barcode.already.exists",request); + return mapping.getInputForward(); + } + catch(NumberFormatException e3) + { + trx.rollback(); + postGlobalError("error.numberformatexception.price",request); + return mapping.getInputForward(); + + } + finally + { + trx.close(); + } + + request.getSession().setAttribute(Constants.PRODUCT_CREATED,list); + + return mapping.findForward(CREATE_POS_GARMENT_PRODUCT); + } + + + public static final String VIEW_ALL_POS_PRODUCTS="viewAllPOSProducts"; + public ActionForward viewAllPOSProducts(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + ProductBean bean = (ProductBean) df.getBean(); + ArrayList list=null; + + try + { + list=new ArrayList(); + list=POSProductManager.viewAllProducts(ctx,bean.getProductName(),bean.getBarCode()); + + } + catch(ProductNotFoundException e1) + { + postGlobalError("error.product.not.defined.client",request); + return mapping.getInputForward(); + + } + + request.getSession().setAttribute(Constants.VIEW_POS_PRODUCTS,list); + return mapping.findForward(VIEW_ALL_POS_PRODUCTS); + } + + + public static final String VIEW_POS_PRODUCT_DETAIL="viewPOSProductDetails"; + public static final String ERROR_VIEW_PRODUCT_DETAIL = "errorViewProductDetails"; + + public ActionForward viewPOSProductDetailInfo(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + ProductDetailsBean bean = (ProductDetailsBean) df.getBean(); + + try + { + int productId = bean.getProductId().intValue(); + ProductDetailsBean prodDetailsBean = ProductManager.getProductDetailInfo(ctx, productId, null); + + request.setAttribute(Constants.PRODUCT_DETAIL_INFO, prodDetailsBean); + + return mapping.findForward(VIEW_POS_PRODUCT_DETAIL); + } + catch(Exception ex) + { + return mapping.findForward(ERROR_VIEW_PRODUCT_DETAIL); + } + } + + public ActionForward validateProductName(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + DefaultForm df = (DefaultForm) form; + String productName = df.getProductName(); + Properties ctx=TmkJSPEnv.getCtx(request); + + boolean isNameValid = ProductManager.isProductPresent(ctx, productName, null); + + response.setContentType("text/plain"); + PrintWriter out = response.getWriter(); + out.print(isNameValid); + out.flush(); + out.close(); + + return null; + } + + public ActionForward validateProductBarcode(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + DefaultForm df = (DefaultForm) form; + String barcode = df.getBarCode(); + Properties ctx=TmkJSPEnv.getCtx(request); + + boolean isBarcodeValid = ProductManager.isBarCodePresent(ctx, barcode, null); + + response.setContentType("text/plain"); + PrintWriter out = response.getWriter(); + out.print(isBarcodeValid); + out.flush(); + out.close(); + + return null; + } + + public static final String SEARCH_POS_PRODUCTS = "searchPOSProducts" ; + + public ActionForward searchPOSProducts (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + viewAllPOSProducts(mapping, form, request, response); + + return mapping.findForward(SEARCH_POS_PRODUCTS); + } + + + public ActionForward addAllProducts (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + Properties ctx=TmkJSPEnv.getCtx(request); + HttpSession session = request.getSession(); + + ProductCart cart = (ProductCart) session.getAttribute(Constants.PRODUCT_CART); + ArrayList productList = (ArrayList) session.getAttribute(Constants.VIEW_POS_PRODUCTS); + + if(productList == null) + { + return mapping.findForward(VIEW_ALL_POS_PRODUCTS); + } + + if(cart == null) + { + cart = new ProductCart(ctx); + } + + for(ProductBean bean:productList) + { + Integer productId = bean.getProductId(); + + if(productId == null) continue; + if(cart.hasProduct(productId.intValue())) continue; + + cart.addProduct(productId.intValue()); + } + + session.setAttribute(Constants.PRODUCT_CART,cart); + + return mapping.findForward(VIEW_ALL_POS_PRODUCTS); + + } + + public ActionForward addToCart (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + ProductBean bean = (ProductBean) df.getBean(); + + Integer productId = bean.getProductId(); + HttpSession session = request.getSession(); + + ProductCart cart = (ProductCart) session.getAttribute(Constants.PRODUCT_CART); + + if( cart == null ) + { + cart = new ProductCart( ctx ); + } + + cart.addProduct( productId.intValue() ); + session.setAttribute(Constants.PRODUCT_CART, cart); + + String script = "productAdded("+ productId +");setCartCounter("+ cart.getNoOfProducts() +")"; + + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + + public ActionForward removeFromCart (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + ProductBean bean = (ProductBean) df.getBean(); + + Integer productId = bean.getProductId(); + HttpSession session = request.getSession(); + + ProductCart cart = (ProductCart) session.getAttribute(Constants.PRODUCT_CART); + + if( cart == null ) + { + cart = new ProductCart( ctx ); + } + + cart.removeProduct( productId.intValue() ); + session.setAttribute(Constants.PRODUCT_CART, cart); + + String script = "productRemoved("+ productId +");setCartCounter("+ cart.getNoOfProducts() +")"; + + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + + public ActionForward clearCart (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + HttpSession session = request.getSession(); + session.removeAttribute(Constants.PRODUCT_CART); + + String script = "clearAll();"; + PrintWriter writer = response.getWriter(); + writer.print( script ); + writer.flush(); + writer.close(); + + return null; + } + + public static final String VIEW_CART = "viewCart"; + public ActionForward viewCart(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + HttpSession session = request.getSession(); + ProductCart cart = (ProductCart) session.getAttribute(Constants.PRODUCT_CART); + + ArrayList productList = null; + + if(cart != null) + { + productList = cart.getProducts(); + session.setAttribute(Constants.PRODUCT_DETAILS, productList); + } + + return mapping.findForward(VIEW_CART); + } + + public static final String REMOVE = "remove"; + public ActionForward remove(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + HttpSession session = request.getSession(); + ProductCart cart = (ProductCart) session.getAttribute(Constants.PRODUCT_CART); + + DefaultForm df = (DefaultForm) form; + ProductBean bean = (ProductBean) df.getBean(); + Integer productId = bean.getProductId(); + + if(cart != null) + { + cart.removeProduct( productId.intValue() ); + session.setAttribute(Constants.PRODUCT_CART, cart); + } + + return mapping.findForward(REMOVE); + } + + //---------------------------------------------------------------------------------------------------------------------------------------------------- + + public static final String EXPORT_CSV = "exportCSV"; + public ActionForward exportCSV(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + HttpSession session = request.getSession(); + ProductCart cart = (ProductCart) session.getAttribute(Constants.PRODUCT_CART); + + if(cart == null) + { + String msg = "Cannot print barcode. Reason: cart is empty!"; + throw new OperationException( msg ); + } + + String reportName = POSProductManager.getProductCartAsCSV( ctx, cart ); + String reportURI = ReportManager.getReportURI( reportName, request ); + response.sendRedirect(reportURI); + + //return mapping.findForward(EXPORT_CSV); + return null; + } + + public static final String PRINT_PDF = "printPDF"; + public ActionForward printPDF(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + HttpSession session = request.getSession(); + ProductCart cart = (ProductCart) session.getAttribute(Constants.PRODUCT_CART); + //ArrayList productList = null; + + //ArrayList productList = null; + + if(cart != null) + { + // productList = cart.getProducts(); + String reportName=POSProductManager.productcatalogue(ctx, cart); + String reportURI = ReportManager.getReportURI(reportName,request); + response.sendRedirect(reportURI); + } + + // Properties ctx = TmkJSPEnv.getCtx(request); + // String reportName=POSProductManager.productcatalogue(ctx); + // ReportManager.writeReport(reportName, response); + + //TODO by Martine + + return mapping.findForward(PRINT_PDF); + } + + public static final String PRINT_BARCODE = "printBarcode"; + public ActionForward printBarcode(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + HttpSession session = request.getSession(); + ProductCart cart = (ProductCart) session.getAttribute(Constants.PRODUCT_CART); + + if(cart == null) + { + String msg = "Cannot print barcode. Reason: cart is empty!"; + throw new OperationException( msg ); + } + + String printData = POSProductManager.getPrintBarcodeData( ctx, cart, null ); + //send it to client + + String filename = RandomStringGenerator.randomstring() + ".txt"; + String filepath = ReportManager.getReportPath( filename ); + + FileOutputStream fos = new FileOutputStream( new File( filepath ) ); + fos.write( printData.getBytes() ); + fos.flush(); + fos.close(); + + String fileURL = ReportManager.getReportURI( filename, request ); + response.sendRedirect( fileURL ); + + return null; + } + +// public static final String GENERATE_PROD_PDF ="generateproductpdf"; +// public ActionForward generateproductpdf(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException +// { +// ActionForward fwd = init(mapping,form,request,response); +// if (fwd!=null) +// return fwd; +// +// Properties ctx = TmkJSPEnv.getCtx(request); +// +// String reportName=POSProductManager.productcatalogue(ctx); +// +// ReportManager.writeReport(reportName, response); +// +// +// return null; +// } +// + + public static final String VIEW_PRODUCT_SALES_DETAILS = "viewProductSalesDetails"; + public ActionForward viewProductSalesDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, IOException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + HttpSession session = request.getSession(); + + DefaultForm df = (DefaultForm) form; + ProductBean bean = (ProductBean) df.getBean(); + Integer productId = bean.getProductId(); + + ProductSalesSummaryBean summaryBean = POSProductManager.getProductSalesInfoSummary( ctx, productId.intValue(), null ); + ArrayList salesDetails = POSProductManager.getProductSalesInfoDetails( ctx, productId.intValue(), null ); + + ProductSalesSummaryBean[] bucket = POSProductManager.getSalesBucket(ctx, productId.intValue(), null); + + + session.setAttribute( Constants.PRODUCT_SALES_SUMMARY, summaryBean ); + session.setAttribute( Constants.PRODUCT_SALES_DETAILS, salesDetails ); + session.setAttribute( Constants.PRODUCT_SALES_BUCKET, bucket ); + + return mapping.findForward( VIEW_PRODUCT_SALES_DETAILS ); + } + + + public static final String UPDATE_BULK_PRODUCT_DETAILS="updateBulkProductDetails"; + public ActionForward updateBulkProductDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + df.validate(mapping,request); + + ProductBean bean = (ProductBean)df.getBean(); + bean.setFile(df.getFile()); + + ProductCart cart = (ProductCart) request.getSession().getAttribute(Constants.PRODUCT_CART); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + Integer[] productIds = cart.getProductIDs(); + + try + { + trx.start(); + POSProductManager.editBulkProduct(ctx,productIds,bean,trx.getTrxName()); + trx.commit(); + } + catch(BarcodeAlreadyExistsException e1) + { + + trx.rollback(); + postGlobalError("error.barcode.already.exists",request); + return mapping.getInputForward(); + } + catch(CannotInactivateProductException e2) + { + trx.rollback(); + postGlobalError("error.product.cannot.inactivate", e2.getMessage(), request); + return mapping.getInputForward(); + + } + finally + { + trx.close(); + } + //ProductBean productBean= POSProductManager.viewPOSProduct(ctx,bean.getProductId().intValue()); + //request.getSession().setAttribute(Constants.PRODUCT_DETAILS,productBean); + return mapping.findForward(UPDATE_BULK_PRODUCT_DETAILS); + } + + + public static final String INIT_UPDATE_BULK_PRODUCT_DETAILS = "initUpdateBulkProductDetails"; + public ActionForward initUpdateBulkProductDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException + { + Properties ctx=TmkJSPEnv.getCtx(request); + ArrayList taxList = POSGoodsManager.getAllTaxCategory(ctx); + + request.setAttribute(Constants.TAX_CATEGORY_ID,taxList); + return mapping.findForward(INIT_UPDATE_BULK_PRODUCT_DETAILS); + } + + public static final String VIEW_PRODUCT = "viewProduct"; + public ActionForward viewProduct(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + viewProductForUpdate(mapping,form,request,response); + + return mapping.findForward(VIEW_PRODUCT); + } + + public static final String ACTIVATE_PRODUCT = "activateProduct"; + public ActionForward activateProduct(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd=init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + df.validate(mapping,request); + + ProductBean bean = (ProductBean)df.getBean(); + Integer productId = bean.getProductId(); + + ProductManager.activateProducts(ctx, new Integer[]{productId},null); + + ArrayList productList = (ArrayList) request.getSession().getAttribute(Constants.VIEW_POS_PRODUCTS); + ProductBean b = null; + ArrayList updatedProductList = new ArrayList(); + + for (int i=0; i productList = (ArrayList) request.getSession().getAttribute(Constants.VIEW_POS_PRODUCTS); + ProductBean b = null; + ArrayList updatedProductList = new ArrayList(); + + for (int i=0; i reportData = POSReportManager.getMaxMinSoldProductReportData(ctx,reportType,fromDate,toDate); + + //constructing the table + TabularReport tReport = new TabularReport(reportData); + tReport.setSortable(false); + tReport.setStyle("display"); + tReport.setTitle(title); + tReport.setSubtitle(subtitle); + tReport.createReport(); + + String csvReport = CSVReportManager.generateCSVReport(ctx,reportData); + String csvURI = ReportManager.getReportURI(csvReport,request); + + request.getSession().setAttribute(Constants.TABULAR_REPORT_DATA,tReport.toString()); + request.getSession().setAttribute(Constants.CSV_FILE,csvURI); + + return mapping.findForward(GET_CUSTOM_REPORT); + } + + //Partial POS History action + public static final String INIT_PARTIAL_POS_HISTORY="initPartialPOSHistory"; + public ActionForward initPartialPOSHistory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + ArrayList list=POSReportManager.getAllOrderTypes(ctx); + request.getSession().setAttribute(Constants.ORDER_TYPES,list); + + getPartialPOSHistory(mapping,new POSHistoryForm(),request,response); + + return mapping.findForward(INIT_PARTIAL_POS_HISTORY); + } + + + public static final String GET_PARTIAL_POS_HISTORY="getPartialPOSHistory"; + public ActionForward getPartialPOSHistory(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + POSHistoryBean bean = (POSHistoryBean) df.getBean(); + + String orderType = UDIOrderTypes.POS_ORDER.getOrderType(); + + ArrayList list=POSReportManager.getPartialOrderHistory(ctx,orderType,bean.getMonth(),bean.getYear()); + request.getSession().setAttribute(Constants.POS_HISTORY,list); + + return mapping.findForward(GET_PARTIAL_POS_HISTORY); + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSRoleAction.java b/posterita/src/main/org/posterita/struts/pos/POSRoleAction.java new file mode 100644 index 0000000000..d4aced2667 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSRoleAction.java @@ -0,0 +1,281 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MRole; +import org.compiere.util.Trx; +import org.posterita.Constants; +import org.posterita.beans.RoleBean; +import org.posterita.businesslogic.MenuManager; +import org.posterita.businesslogic.RoleManager; +import org.posterita.core.MenuItem; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.NoCheckBoxSelectedException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.RoleAlreadyExistsException; +import org.posterita.exceptions.SystemException; +import org.posterita.struts.core.DefaultForm; + +public class POSRoleAction extends POSDispatchAction +{ + public static final String CREATE_ROLE = "createRole"; + public static final String INIT_ROLE = "initRole"; + public static final String LIST_ROLES = "listRoles"; + public static final String VIEW_ROLE = "viewRole"; + public static final String DELETE_ROLE = "deleteRole"; + + public ActionForward createRole(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + RoleBean bean = (RoleBean) df.getBean(); + + + //Create Role and assign menus + MRole role; + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + try + { + trx.start(); + role = RoleManager.createRole(ctx,bean.getName(),bean.getIsAccessAllOrgs(), bean.getCheckBox(), bean.getCanCreateOrder(), bean.getCanAlterOrder(), bean.getCanViewOrder(), trx.getTrxName()); + trx.commit(); + ArrayList menus = MenuManager.getMenus(ctx, role.get_ID()); + MenuItem rootItem = MenuManager.buildMenuTree(ctx, menus); + + request.getSession().setAttribute(Constants.ROLE,bean); + request.getSession().setAttribute(Constants.ROLE_MENUS, rootItem.getSubMenus()); + } + catch (RoleAlreadyExistsException e) + { + trx.rollback(); + postGlobalError("error.role.already.exists",request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return mapping.findForward(CREATE_ROLE); + + } + + public ActionForward initRole(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + //ArrayList menuList = MenuKeyNamePair.getKeyNamePairs(ctx); + + //String menu = MenuItem.getMenu(ctx, null); + + //request.getSession().setAttribute(Constants.MENUS,menu); + + ArrayList menus = MenuManager.getMenusForOrganisationType(ctx); + MenuItem rootItem = MenuManager.buildMenuTree(ctx, menus); + + //request.getSession().setAttribute(Constants.ROLE,bean); + request.getSession().setAttribute(Constants.ROLE_MENUS, rootItem.getSubMenus()); + + return mapping.findForward(CREATE_ROLE); + + } + + public ActionForward listRoles(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, SystemException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + ArrayList roles = new ArrayList(); + + if (df.getFirst() != null && df.getFirst().equals("1")) + { + request.getSession().setAttribute(Constants.ALL_ROLES,roles); + return mapping.findForward(LIST_ROLES); + } + else + roles = RoleManager.getRoles(ctx, df.getName()); + + request.getSession().setAttribute(Constants.ALL_ROLES,roles); + + return mapping.findForward(LIST_ROLES); + + } + + public ActionForward deleteRole(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, SystemException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + Integer roleId = Integer.valueOf(df.getRoleId()); + + RoleManager.deleteRole(ctx,roleId.intValue()); + + return mapping.findForward(DELETE_ROLE); + } + + + public ActionForward viewRole(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, SystemException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + Integer roleId = Integer.valueOf(df.getRoleId()); + + RoleBean bean = RoleManager.getRole(ctx,roleId.intValue()); + + //ArrayList menus = MenuItem.getMenu(ctx,roleId.intValue()); + + //request.getSession().setAttribute(Constants.MENUS,menus); + + ArrayList menus = MenuManager.getMenus(ctx, roleId.intValue()); + MenuItem rootItem = MenuManager.buildMenuTree(ctx, menus); + + request.getSession().setAttribute(Constants.ROLE_MENUS, rootItem.getSubMenus()); + request.getSession().setAttribute(Constants.ROLE,bean); + + return mapping.findForward(VIEW_ROLE); + + } + + private static final String INIT_EDIT_ROLE = "initEditRole"; + public ActionForward initEditRole(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, SystemException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm)form; + + Integer roleId = Integer.valueOf(df.getRoleId()); + + RoleBean bean = RoleManager.getRole(ctx,roleId.intValue()); + MenuItem menuItem = RoleManager.getAvailableMenus(ctx, roleId); + + request.getSession().setAttribute(Constants.ROLE_MENUS, menuItem.getSubMenus()); + request.getSession().setAttribute(Constants.ROLE,bean); + + return mapping.findForward(INIT_EDIT_ROLE); + } + + + private static final String EDIT_ROLE = "editRole"; + public ActionForward editRole(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, SystemException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm)form; + + RoleBean roleBean = (RoleBean)df.getBean(); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + trx.start(); + try + { + RoleManager.editRole(ctx, roleBean.getRoleId(), roleBean.getName(), roleBean.getIsAccessAllOrgs(), roleBean.getCheckBox(), trx.getTrxName()); + trx.commit(); + } + catch(RoleAlreadyExistsException ex) + { + trx.rollback(); + postGlobalError("error.role.already.exists",request); + return mapping.getInputForward(); + } + catch(NoCheckBoxSelectedException e) + { + trx.rollback(); + postGlobalError("error.no.checkbox.selected",request); + return mapping.getInputForward(); + } + catch(OperationException ex) + { + trx.rollback(); + postGlobalError("error.role.edit", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + RoleBean bean = RoleManager.getRole(ctx, roleBean.getRoleId()); + ArrayList menus = MenuManager.getMenus(ctx, roleBean.getRoleId()); + MenuItem rootItem = MenuManager.buildMenuTree(ctx, menus); + + request.getSession().setAttribute(Constants.ROLE_MENUS, rootItem.getSubMenus()); + request.getSession().setAttribute(Constants.ROLE, bean); + + return mapping.findForward(EDIT_ROLE); + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSSalesReportAction.java b/posterita/src/main/org/posterita/struts/pos/POSSalesReportAction.java new file mode 100644 index 0000000000..3ee318cbcd --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSSalesReportAction.java @@ -0,0 +1,303 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 17-Jul-2006 14:12:03 by praveen + * + */ + +package org.posterita.struts.pos; + +import java.awt.Color; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MAttribute; +import org.compiere.model.MAttributeSet; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.plot.XYPlot; + +import org.posterita.Constants; +import org.posterita.beans.ReportBean; +import org.posterita.businesslogic.ReportDateManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.businesslogic.SalesAnalysisReportManager; +import org.posterita.core.PieChart; +import org.posterita.core.RandomStringGenerator; +import org.posterita.core.SessionStorage; +import org.posterita.core.TimeSeriesChart; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.form.SalesReportForm; +import org.posterita.struts.core.DefaultForm; + +public class POSSalesReportAction extends POSDispatchAction +{ + public static final String GET_CUSTOM_REPORT = "getCustomReport"; + public ActionForward getCustomReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + ReportBean bean = (ReportBean) df.getBean(); + String fromDate = ReportDateManager.getFromDate(bean); + String toDate = ReportDateManager.getToDate(bean); + String timeperiod = bean.getTimePeriod(); + String chartType = bean.getChartType(); + String salesGroup = bean.getSalesGroup(); + + String reportDir = ReportManager.getReportDirectoryFromServletContext(this.servlet); + String filename = RandomStringGenerator.randomstring(); + + String subtitle = null; + String title = null; + + if(timeperiod!=null) + { + subtitle = "For " + timeperiod; + } + else + { + subtitle = "For period:"+fromDate+" to "+toDate; + } + + + if(salesGroup.equalsIgnoreCase(Constants.REVENUE_RECOGNITION)||salesGroup.equalsIgnoreCase(Constants.ATTRIBUTESET)) + { + title = "Sales By " + salesGroup; + } + else + { + String[] s = salesGroup.split("_"); + + if(s.length!=2) + { + throw new OperationException("Cannot generate sql. Unknown salesGroup parameter:"+salesGroup); + } + + int attributeSetId = Integer.parseInt(s[0]); + int attributeId = Integer.parseInt(s[1]); + + String attributeSetName = null; + String attributeName = null; + + attributeSetName = MAttributeSet.get(ctx,attributeSetId).getName(); + attributeName = new MAttribute(ctx,attributeId,null).getName(); + + title = "Sales By " + attributeName + " For " + attributeSetName; + } + + + if(chartType.equals(PieChart.CHART_TYPE)) + { + //draw pie chart + String pieChartSQL = SalesAnalysisReportManager.getPieChartDataSetSQL(ctx,Integer.valueOf(1),fromDate,toDate,salesGroup); + PieChart pieChart = new PieChart(); + + pieChart.setTitle(title); + pieChart.setSubtitle(subtitle); + pieChart.getDataSetFromSQL(pieChartSQL); + pieChart.getChart().setBackgroundPaint(Color.white); + pieChart.saveChartAsJPEG(reportDir+filename+".jpg",700,600); + } + else if(chartType.equals(TimeSeriesChart.CHART_TYPE)) + { + //draw timeseries + String timeSeriesChartSQL = SalesAnalysisReportManager.getTimeSeriesDataSetSQL(ctx,Integer.valueOf(1),fromDate,toDate,salesGroup); + TimeSeriesChart timeSeriesChart = new TimeSeriesChart(); + + timeSeriesChart.setTitle(title); + timeSeriesChart.setSubtitle(subtitle); + timeSeriesChart.setShowShapes(true); + timeSeriesChart.getDataSetFromSQL(timeSeriesChartSQL); + + + XYPlot plot = (XYPlot) timeSeriesChart.getChart().getPlot(); + DateAxis axis = (DateAxis) plot.getDomainAxis(); + + SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + Date d1 = null; + Date d2 = null;; + try + { + d1 = sdf.parse(fromDate); + d2 = sdf.parse(toDate); + } + catch (ParseException e) + { + throw new OperationException("Unable to parse dates supplied."); + } + + + axis.setRange(d1,d2); + //axis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH,1,new SimpleDateFormat("MMM-yyyy"))); + + timeSeriesChart.getChart().setBackgroundPaint(Color.white); + timeSeriesChart.saveChartAsJPEG(reportDir+filename+".jpg",700,600); + } + else + { + throw new OperationException("Invalid Chart type:" + chartType); + } + + String imgURL = request.getContextPath() + "/config/reports/"+filename+".jpg"; + request.getSession().setAttribute(Constants.REPORT_URL,imgURL); + + return mapping.findForward(GET_CUSTOM_REPORT); + //return getGroupedSalesReport(mapping,form,request,response); + } + + public static final String INIT_CUSTOM_REPORT = "initCustomReport"; + public ActionForward initCustomReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + SalesReportForm salesReportForm = (SalesReportForm) form; + ReportBean reportBean = (ReportBean) salesReportForm.getBean(); + + salesReportForm.setChartType(PieChart.CHART_TYPE); + reportBean.setChartType(PieChart.CHART_TYPE); + + boolean error = false; + + if((salesReportForm.getFromDate()==null)||(salesReportForm.getFromDate()=="")) + { + postGlobalError("error.required.startDate",request); + error = true; + } + + if((salesReportForm.getToDate()==null)||(salesReportForm.getToDate()=="")) + { + postGlobalError("error.required.endDate",request); + error = true; + } + + if(error) + { + return mapping.getInputForward(); + } + + SessionStorage.putSalesGroupFilter(ctx,request,reportBean); + + return mapping.findForward(INIT_CUSTOM_REPORT); + } + + public static final String INIT_CUSTOM_SALES_REPORT = "initCustomSalesReport"; + public ActionForward initCustomSalesReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + SalesReportForm reportForm = (SalesReportForm) form; + ReportBean reportBean = (ReportBean) reportForm.getBean(); + + if(reportBean.getFromDate()==null) + { + String timeperiod = reportBean.getTimePeriod(); + if(timeperiod==null) + { + throw new OperationException("No period parameter found!"); + } + + Date startDate = ReportDateManager.getStartDateForPeriod(timeperiod); + Date endDate = ReportDateManager.getEndDateForPeriod(timeperiod); + + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + String fromDate = sdf.format(startDate); + String toDate = sdf.format(endDate); + + reportForm.setFromDate(fromDate); + reportForm.setToDate(toDate); + reportForm.setStartHour("0"); + reportForm.setStartMinute("0"); + reportForm.setChartType(PieChart.CHART_TYPE); + + reportBean.setFromDate(fromDate); + reportBean.setToDate(toDate); + reportBean.setStartHour("0"); + reportBean.setStartMinute("0"); + reportBean.setChartType(PieChart.CHART_TYPE); + + Calendar cal = Calendar.getInstance(); + + reportForm.setToDate(toDate); + reportForm.setEndHour(cal.get(Calendar.HOUR_OF_DAY)+""); + reportForm.setEndMinute(cal.get(Calendar.MINUTE)+""); + + reportBean.setToDate(toDate); + reportBean.setEndHour(cal.get(Calendar.HOUR_OF_DAY)+""); + reportBean.setEndMinute(cal.get(Calendar.MINUTE)+""); + + SessionStorage.putSalesGroupFilter(ctx,request,reportBean); + + } + + return mapping.findForward(INIT_CUSTOM_SALES_REPORT); + } + + public static final String SALES_BY_ATTRIBUTESET = "salesByAttributeSet"; + public static final String SALES_BY_REVENUE_RECOGNITION = "salesByRevenueRecognition"; + + public static final String GET_GROUPED_SALES_REPORT = "getGroupedSalesReport"; + public ActionForward getGroupedSalesReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + SalesReportForm reportForm = (SalesReportForm) form; + ReportBean reportBean = (ReportBean) reportForm.getBean(); + + String salesGroup = reportBean.getSalesGroup(); + + if(salesGroup.equalsIgnoreCase(Constants.REVENUE_RECOGNITION)) + { + return mapping.findForward(SALES_BY_REVENUE_RECOGNITION); + } + else if(salesGroup.equalsIgnoreCase(Constants.ATTRIBUTESET)) + { + return mapping.findForward(SALES_BY_ATTRIBUTESET); + } + else + { + throw new OperationException("Invalid Sales Grouping: "+ salesGroup); + } + + } + + +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSStockAction.java b/posterita/src/main/org/posterita/struts/pos/POSStockAction.java new file mode 100644 index 0000000000..aa13df6c52 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSStockAction.java @@ -0,0 +1,135 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Created on May 8, 2006 + */ + + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.Constants; +import org.posterita.beans.AttributeBean; +import org.posterita.businesslogic.POSStockManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + + +public class POSStockAction extends BaseDispatchAction +{ + + public static final String GET_POS_STOCK="getPOSStock"; + public ActionForward getPOSStock(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + + request.removeAttribute(Constants.PRODUCTS); + ArrayList list=POSStockManager.getAllAttributeSet(ctx); + request.getSession().setAttribute(Constants.PRODUCT_ATTRIBUTE_SET,list); + + + return mapping.findForward(GET_POS_STOCK); + + + } + + public static final String GET_STOCK="getStock"; + public ActionForward getStock(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx =TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + AttributeBean bean = (AttributeBean) df.getBean(); + ArrayList list=POSStockManager.getAllAttributeFromAttributeSet(ctx,bean); + request.getSession().setAttribute(Constants.ATTRIBUTE_SET_ID,bean.getAttributeSetId()); + request.getSession().setAttribute(Constants.PRODUCT_ATTRIBUTE_LIST,list); + request.removeAttribute(Constants.PRODUCTS); + ArrayList productList=POSStockManager.getAllProducts(ctx, bean.getAttributeSetId()); + request.getSession().setAttribute(Constants.PRODUCTS,productList); + + return mapping.findForward(GET_STOCK); + } + + + public static final String GET_PRODUCTS="getProducts"; + public ActionForward getProducts(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Integer attributeSetId=(Integer)request.getSession().getAttribute(Constants.ATTRIBUTE_SET_ID); + Properties ctx =TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + AttributeBean bean = (AttributeBean) df.getBean(); + ArrayList list=POSStockManager.getProducts(ctx,bean); + request.setAttribute(Constants.PRODUCTS,list); + + bean.setAttributeSetId(attributeSetId); + + ArrayList attriList=POSStockManager.getAllAttributeFromAttributeSet(ctx,bean); + request.getSession().setAttribute(Constants.PRODUCT_ATTRIBUTE_LIST,attriList); + + return mapping.findForward(GET_PRODUCTS); + } + + + public static final String GET_STOCK_FROM_SEARCH="getStockFromSearch"; + public ActionForward getStockFromSearch(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + Properties ctx =TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm)form; + + String filter=null; + if(df.getQtyFilter()!=null && df.getQtyFilter().length()!=0) + filter=df.getQtyFilter(); + + ArrayList list=POSStockManager.getStockFromSearch(ctx,df.getProductName(),df.getBarCode(),filter); + request.getSession().setAttribute(Constants.PRODUCTS,list); + + + + return mapping.findForward(GET_STOCK_FROM_SEARCH); + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/POSUserAction.java b/posterita/src/main/org/posterita/struts/pos/POSUserAction.java new file mode 100644 index 0000000000..87ec8264af --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/POSUserAction.java @@ -0,0 +1,286 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 29, 2005 by praveen + * + */ +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MCountry; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.UserBean; +import org.posterita.businesslogic.RoleManager; +import org.posterita.businesslogic.UserManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.DuplicateUserPinException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.UserAlreadyExistsException; +import org.posterita.form.UserForm; +import org.posterita.keyname.RegionKeyNamePair; +import org.posterita.struts.core.DefaultForm; + +public class POSUserAction extends POSDispatchAction +{ + + public static final String CREATE_USER = "createUser"; + public ActionForward createUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + + UserBean bean = (UserBean) df.getBean(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + try + { + trx.start(); + MCountry country = MCountry.getDefault(ctx); + UserManager.createUser(ctx,bean.getUsername(),bean.getUsername(), bean.getIsSalesRep().booleanValue(),bean.getAddress1(),bean.getPostalAddress(),bean.getCity(),bean.getPassword(),bean.getEmail(),bean.getIsActive().booleanValue(),bean.getPhone(),0, bean.getRoleId().intValue(), country.get_ID(),bean.getUserPIN(),bean.getUserDiscount(),bean.getDocBasisType(),bean.getAmtMultiplier(),bean.getFrequencyType(),bean.getSubtractAmt(),bean.getIsFullAccess(),trx.getTrxName()); + trx.commit(); + } + catch(DuplicateUserPinException e) + { + trx.rollback(); + postGlobalError("error.duplicate.userpin", request); + return mapping.getInputForward(); + } + catch(UserAlreadyExistsException e) + { + trx.rollback(); + postGlobalError("error.usernameAlreadyUsed", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return mapping.findForward(CREATE_USER); + } + + public static final String EDIT_USER = "editUser"; + public ActionForward editUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + + UserBean bean = (UserBean) df.getBean(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + try + { + trx.start(); + UserManager.editUser(ctx,bean.getUserId().intValue(),bean.getRoleId().intValue(),bean.getPassword(),bean.getEmail(),bean.getPhone(),bean.getAddress1(),bean.getPostalAddress(),bean.getCity(),bean.getIsSalesRep().booleanValue(),bean.getIsActive().booleanValue(),bean.getUserPIN(),bean.getUserDiscount(),bean.getDocBasisType(),bean.getAmtMultiplier(),bean.getFrequencyType(),bean.getSubtractAmt(),bean.getIsFullAccess(),trx.getTrxName()); + trx.commit(); + } + catch(DuplicateUserPinException e) + { + trx.rollback(); + postGlobalError("error.duplicate.userpin", request); + return mapping.getInputForward(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.editing.user", request); + mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return mapping.findForward(EDIT_USER); + } + + public static final String DELETE_USER = "deleteUser"; + @SuppressWarnings("unchecked") + public ActionForward deleteUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + UserForm uf = (UserForm) form; + + Properties ctx = TmkJSPEnv.getCtx(request); + + int userId = Integer.valueOf(uf.getUserId()).intValue(); + + UserManager.deleteUser(ctx,userId); + + ArrayList list = (ArrayList) request.getSession().getAttribute(Constants.ALL_USERS); + + ArrayList newList = UserManager.updateUserListStatus(list, userId, false); + + request.getSession().setAttribute(Constants.ALL_USERS,newList); + + return mapping.findForward(DELETE_USER); + } + + public static final String ACTIVATE_USER = "activateUser"; + @SuppressWarnings("unchecked") + public ActionForward activateUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + UserForm uf = (UserForm) form; + + Properties ctx = TmkJSPEnv.getCtx(request); + + int userId = Integer.valueOf(uf.getUserId()).intValue(); + + UserManager.activateUser(ctx,userId); + + ArrayList list = (ArrayList) request.getSession().getAttribute(Constants.ALL_USERS); + + ArrayList newList = UserManager.updateUserListStatus(list, userId, true); + + request.getSession().setAttribute(Constants.ALL_USERS,newList); + + return mapping.findForward(ACTIVATE_USER); + } + + public static final String INIT_CREATE_USER = "initCreateUser"; + public ActionForward initCreateUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList roles = RoleManager.getAllRoles(ctx); + + ArrayList regions = RegionKeyNamePair.getKeyNamePairs(ctx); + + request.getSession().setAttribute(Constants.ROLES,roles); + + request.getSession().setAttribute(Constants.REGIONS,regions); + + return mapping.findForward(INIT_CREATE_USER); + } + + public static final String INIT_EDIT_USER = "initEditUser"; + public ActionForward initEditUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + UserForm uf = (UserForm) form; + + int userId = Integer.valueOf(uf.getUserId()).intValue(); + + UserBean bean = UserManager.getUser(ctx,userId); + + uf.populate(bean); + + ArrayList roles = RoleManager.getAllRoles(ctx); + + request.getSession().setAttribute(Constants.ROLES,roles); + + request.getSession().setAttribute(Constants.USER_DETAILS,bean); + + return mapping.findForward(INIT_EDIT_USER); + } + + public static final String LIST_USERS = "listUsers"; + public ActionForward listUsers(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + ArrayList users = new ArrayList(); + + if (df.getFirst() != null && df.getFirst().equals("1")) + { + request.getSession().setAttribute(Constants.ALL_USERS,users); + return mapping.findForward(LIST_USERS); + } + else + users = UserManager.getUsers(ctx, df.getName()); + + request.getSession().setAttribute(Constants.ALL_USERS,users); + + return mapping.findForward(LIST_USERS); + } + + public static final String VIEW_USER = "viewUser"; + public ActionForward viewUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + UserForm uf = (UserForm) form; + + int userId = Integer.valueOf(uf.getUserId()).intValue(); + + UserBean userBean = UserManager.getUser(ctx,userId); + + request.getSession().setAttribute(Constants.USER_DETAILS,userBean); + + return mapping.findForward(VIEW_USER); + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/PartialPOSOrderAction.java b/posterita/src/main/org/posterita/struts/pos/PartialPOSOrderAction.java new file mode 100644 index 0000000000..c8521fa167 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/PartialPOSOrderAction.java @@ -0,0 +1,754 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * */ + + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; +import java.math.BigDecimal; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MOrder; +import org.compiere.util.Env; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.ItemBean; +import org.posterita.beans.OrderLineBean; +import org.posterita.beans.ShoppingCartBean; +import org.posterita.beans.WebDocumentBean; +import org.posterita.businesslogic.BPartnerManager; +import org.posterita.businesslogic.OrderReferenceManager; +import org.posterita.businesslogic.OrderManager; +import org.posterita.businesslogic.POSTerminalManager; +import org.posterita.businesslogic.PartialPOSManager; +import org.posterita.businesslogic.RoleManager; +import org.posterita.businesslogic.StockManager; +import org.posterita.businesslogic.UserManager; +import org.posterita.core.SessionStorage; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BPartnerNoLocationException; +import org.posterita.exceptions.BPartnerOverCreditLimitException; +import org.posterita.exceptions.DiscountLimitException; +import org.posterita.exceptions.InputQuantityLessThanZeroException; +import org.posterita.exceptions.InsufficientQtyException; +import org.posterita.exceptions.InvalidInvokeOrderStatusException; +import org.posterita.exceptions.InvalidOrderIDException; +import org.posterita.exceptions.InvalidOrderTypeException; +import org.posterita.exceptions.InvalidTenderedAmountException; +import org.posterita.exceptions.NoOrderLineFoundException; +import org.posterita.exceptions.NoOrderLineSelectedException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ProductNotFoundException; +import org.posterita.exceptions.ProductNotOnPriceListException; +import org.posterita.exceptions.QuantityNotAvailableException; +import org.posterita.form.InvokeOrderForm; +import org.posterita.lib.UdiConstants; +import org.posterita.struts.core.DefaultForm; + + +public class PartialPOSOrderAction extends POSDispatchAction +{ + public static final String CREATE_POS_ORDER="createPOSOrder"; + public ActionForward createPOSOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, DiscountLimitException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + //validate payment type + + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + + if(cartBean==null ||cartBean.getItems() == null||cartBean.getItems().size()==0) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + + MOrder posOrder = null; + + Integer bPartnerId = bean.getBpartnerId(); + + if(bPartnerId==null) + bPartnerId = (Integer) request.getSession().getAttribute(Constants.BPARTNER); + + if(bPartnerId==null) + { + bPartnerId=Integer.valueOf(POSTerminalManager.getPOSDefaultBpartner(ctx).get_ID()); + } + else + { + boolean isBPartnerPresent = BPartnerManager.isBPartnerPresent(ctx,bPartnerId.intValue(),null); + + if( !isBPartnerPresent ) + { + postGlobalError("error.pos.invalid.customerID",request); + return mapping.getInputForward(); + } + } + + request.getSession().setAttribute(Constants.BPARTNER, bPartnerId); + + bean.setBpartnerId(bPartnerId); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + posOrder= PartialPOSManager.createPOSOrder(ctx,bean,cartBean.getItems(),null/*trx.getTrxName()*/); + trx.commit(); + } + catch(BPartnerOverCreditLimitException e1) + { + trx.rollback(); + postGlobalError("error.bpartner.over.credit.limit",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(BPartnerNoLocationException ex) + { + trx.rollback(); + postGlobalError("error.bpartner.nolocation", request); + return mapping.getInputForward(); + } + catch(InvalidTenderedAmountException e) + { + trx.rollback(); + postGlobalError("error.pos.incorrect.tendered.amount",request); + return mapping.getInputForward(); + } + catch(InsufficientQtyException e3) + { + trx.rollback(); + postGlobalError("error.insufficient.qty",e3.getMessage(),request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + bean.setOrderId(Integer.valueOf(posOrder.get_ID())); + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx, posOrder); + if(posOrder.getPaymentRule().equals(UdiConstants.PAYMENTRULE_MIXED)) + { + if(bean.getPaymentByCash()!=null) + webBean.setPaymentByCash(bean.getPaymentByCash()); + if(bean.getPaymentByCard()!=null) + webBean.setPaymentByCard(bean.getPaymentByCard()); + if(bean.getPaymentByChq()!=null) + webBean.setPaymentbyCheque(bean.getPaymentByChq()); + } + + + ArrayList list = PartialPOSManager.populateOrderLines(ctx,posOrder); + WebDocumentBean documentBean=PartialPOSManager.calculateOrderTotals(list); + request.getSession().setAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID,posOrder.get_ID()); + request.getSession().setAttribute(Constants.ORDER_LINE_BEAN,bean); + request.setAttribute(Constants.PARTIAL_POS_ORDER_LINES,list); + /*request.removeAttribute(Constants.POS_ORDER_LINES);*/ + + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + + return mapping.findForward(CREATE_POS_ORDER); + + + + } + + public static final String COMPLETE_POS_ORDER="completePOSOrder"; + public ActionForward completePOSOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + OrderLineBean bean=(OrderLineBean) request.getSession().getAttribute(Constants.ORDER_LINE_BEAN); + Integer orderId = (Integer)request.getSession().getAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID); + MOrder completedPOSOrder=null; + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + completedPOSOrder=PartialPOSManager.completePOSOrder(ctx,orderId.intValue(),bean,trx.getTrxName()); + trx.commit(); + } + catch(NoOrderLineFoundException e) + { + trx.rollback(); + postGlobalError("error.pos.no.orderline",request); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS); + + return mapping.getInputForward(); + } + catch(OperationException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + } + + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx, completedPOSOrder); + + if(completedPOSOrder.getPaymentRule().equals(UdiConstants.PAYMENTRULE_MIXED)) + { + PartialPOSManager.getAmountForMixedPayment(ctx,completedPOSOrder,webBean); + } + + ArrayList list = PartialPOSManager.populateOrderLines(ctx,completedPOSOrder); + WebDocumentBean documentBean=PartialPOSManager.calculateOrderTotals(list); + request.setAttribute(Constants.POS_ORDER_LINES,list); + + /*request.removeAttribute(Constants.POS_ORDER_LINES);*/ + request.getSession().removeAttribute(Constants.BPARTNER); + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID); + request.setAttribute(Constants.ORDER_NAME,"POS ORDER"); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + + return mapping.findForward(COMPLETE_POS_ORDER); + } + + + public static final String GET_POS_PAYMENT_DETAILS="getPOSPaymentDetails"; + public ActionForward getPOSPaymentDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + // Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + df.populate(new OrderLineBean()); + request.getSession().setAttribute(Constants.BPARTNER, bean.getBpartnerId()); + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + + if(cartBean==null ||cartBean.getItems() == null||cartBean.getItems().size()==0) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + + request.getSession().setAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART, cartBean); + request.getSession().setAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS, cartBean.getItems()); + return mapping.findForward(GET_POS_PAYMENT_DETAILS); + + + } + + public static final String DELETE_POS_ORDERLINE = "deletePOSOrderLine"; + public ActionForward deletePOSOrderLine(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + String forward = DELETE_POS_ORDERLINE; + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + forward = PartialPOSManager.deleteOrderLines(ctx,bean.getPosOrderLineIds(),trx.getTrxName()); + trx.commit(); + } + catch (NoOrderLineSelectedException e) + { + trx.rollback(); + SessionStorage.putPOSOrderInfo(ctx,bean,request,forward); + + postGlobalError("error.order.noOrderline.selected",request); + return mapping.getInputForward(); + } + catch (OperationException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + } + + Integer orderId = (Integer)request.getSession().getAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID); + //validating order + //if lines == 0 goto createpartialOrder + + if(OrderManager.isOrderEmpty(ctx,orderId.intValue(),null)) + { + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS); + return new ActionForward("/CreatePartialPOSOrder.do"); + } + + //reload shopping cart + ShoppingCartBean cart = PartialPOSManager.getShoppingCartForOrder(ctx,orderId.intValue(),null); + request.getSession().setAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART,cart); + request.getSession().setAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS,cart.getItems()); + + + + SessionStorage.putPOSOrderInfo(ctx,bean,request,forward); + df.populate(new OrderLineBean()); + + return mapping.findForward(DELETE_POS_ORDERLINE); + } + + + public static final String ADD_TO_SHOPPING_CART = "addToShoppingCart"; + public ActionForward addToShoppingCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + OrderLineBean bean = (OrderLineBean) df.getBean(); + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + + + try + { + // PartialPOSManager.getQtyAndItem(bean); + if(bean.getProductId()==null && bean.getBarCode()==null) + { + postGlobalError("error.barcode.required", request); + return mapping.getInputForward(); + } + + cartBean = StockManager.addToPOSCart(ctx, bean, cartBean,true,Boolean.parseBoolean(bean.getIfAdd())); + } + catch (InputQuantityLessThanZeroException e1) + { + postGlobalError("error.invalid.inputQty", request); + return mapping.getInputForward(); + } + catch (ProductNotFoundException e2) + { + postGlobalError("error.product.not.found", e2.getMessage(), request); + return mapping.getInputForward(); + } + catch(QuantityNotAvailableException e3) + { + postGlobalError("error.quantity.notAvailable", e3.getMessage(), request); + return mapping.getInputForward(); + } + + catch(ProductNotOnPriceListException e4) + { + postGlobalError("error.product.price.not.found", e4.getMessage(), request); + return mapping.getInputForward(); + } + + + request.getSession().setAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART, cartBean); + request.getSession().setAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS, cartBean.getItems()); + + df.setQtyAndItem(""); + + return mapping.findForward(ADD_TO_SHOPPING_CART); + } + + + + public static final String COMPLETE_PARTIAL_POS_ORDER="completePartialPOSOrder"; + public ActionForward completePartialPOSOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + Integer orderId = (Integer)request.getSession().getAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID); + + //MOrder posOrder=(MOrder) request.getSession().getAttribute(Constants.CURRENT_POS_ORDER); + //MOrder completedPOSOrder=null; + //boolean error = false; + + + if(OrderManager.isOrderEmpty(ctx,orderId.intValue(),null)) + { + postGlobalError("error.pos.no.orderline",request); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS); + return mapping.getInputForward(); + } + + //completedPOSOrder=PartialPOSManager.completePOSOrder(ctx,posOrder,bean); + MOrder completedPOSOrder = OrderManager.prepareOrder(ctx,orderId.intValue(),null); + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx, completedPOSOrder); + + if(completedPOSOrder.getPaymentRule().equals(UdiConstants.PAYMENTRULE_MIXED)) + { + PartialPOSManager.getAmountForMixedPayment(ctx,completedPOSOrder,webBean); + } + + ArrayList list = PartialPOSManager.populateOrderLines(ctx,completedPOSOrder); + WebDocumentBean documentBean=PartialPOSManager.calculateOrderTotals(list); + request.getSession().setAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID,orderId); + request.setAttribute(Constants.POS_ORDER_LINES,list); + + /*request.removeAttribute(Constants.POS_ORDER_LINES);*/ + request.getSession().removeAttribute(Constants.BPARTNER); + request.getSession().removeAttribute(Constants.ALL_CUSTOMERS); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + request.getSession().removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS); + request.getSession().removeAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID); + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + request.setAttribute(Constants.ORDER_NAME,"POS ORDER"); + + return mapping.findForward(COMPLETE_PARTIAL_POS_ORDER); + } + + + public static final String INVOKE_PARTIAL_ORDER = "invokePartialOrder"; + public ActionForward invokePartialOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + InvokeOrderForm f = (InvokeOrderForm) form; + OrderLineBean bean = (OrderLineBean) f.getBean(); + + String documentNo = bean.getDocumentNo(); + + MOrder order = null; + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + order = PartialPOSManager.invokePartialOrder(ctx,documentNo,trx.getTrxName()); + trx.commit(); + } + catch (InvalidOrderIDException e) + { + trx.rollback(); + postGlobalError("error.invalid.orderId",request); + return mapping.getInputForward(); + } + catch (InvalidOrderTypeException e) + { + trx.rollback(); + postGlobalError("error.invalid.orderType",request); + return mapping.getInputForward(); + } + catch (NoOrderLineFoundException e) + { + trx.rollback(); + postGlobalError("error.pos.invoke.no.orderline",request); + return mapping.getInputForward(); + } + catch (InvalidInvokeOrderStatusException e) + { + trx.rollback(); + postGlobalError("error.invoke.status",e.getStatus(),request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + int bPartnerId = order.getC_BPartner_ID(); + ShoppingCartBean cart = PartialPOSManager.getShoppingCartForOrder(ctx,order.get_ID(),null); + ArrayList cartItems = cart.getItems(); + + BigDecimal discountAllowed = RoleManager.getDiscountAllowed(ctx, Env.getAD_Role_ID(ctx),null); + + //putting cart & other info in session + request.getSession().setAttribute(Constants.BPARTNER, Integer.valueOf(bPartnerId)); + request.getSession().setAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART, cart); + request.getSession().setAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS, cartItems); + request.getSession().setAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID,Integer.valueOf(order.get_ID())); + request.getSession().setAttribute(Constants.DISCOUNT_ALLOWED, discountAllowed); + + return mapping.findForward(INVOKE_PARTIAL_ORDER); + + } + + public static final String SET_POS_PAYMENT_DETAILS = "setPOSPaymentDetails"; + public ActionForward setPOSPaymentDetails(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + //mapping.setInput("/GetPartialPOSPaymentDetails.do"); + + Properties ctx=TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + OrderLineBean bean=(OrderLineBean) df.getBean(); + + ShoppingCartBean cartBean = (ShoppingCartBean) request.getSession().getAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + + if(cartBean==null) + { + postGlobalError("error.pos.shoppingcart.empty",request); + return mapping.getInputForward(); + } + + //validate discount entered + String[] discountPercentage = df.getDiscountPercent(); + String[] actualPrice = df.getActualPrice(); + + for(String s : discountPercentage) + { + if(s == null || s == "") + { + continue; + } + + try + { + Double.parseDouble(s); + } + catch (NumberFormatException e) + { + postGlobalError("errors.double","Discount(s)",request); + return mapping.getInputForward(); + } + } + + for(String s : actualPrice) + { + if(s == null || s == "") + { + continue; + } + + try + { + Double.parseDouble(s); + } + catch (NumberFormatException e) + { + postGlobalError("errors.double","Price(s)",request); + return mapping.getInputForward(); + } + } + + Integer orderId = (Integer) request.getSession().getAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID); + Integer bPartnerId = bean.getBpartnerId(); + + if(bPartnerId==null) + bPartnerId = (Integer) request.getSession().getAttribute(Constants.BPARTNER); + if(bPartnerId==null) + bPartnerId=Integer.valueOf(POSTerminalManager.getPOSDefaultBpartner(ctx).get_ID()); + + bean.setBpartnerId(bPartnerId); + MOrder posOrder = null; + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + try + { + trx.start(); + posOrder= PartialPOSManager.setOrderPaymentDetails(ctx,orderId,bean,cartBean.getItems(), trx.getTrxName()); + trx.commit(); + } + catch(InvalidTenderedAmountException e) + { + trx.rollback(); + postGlobalError("error.pos.incorrect.tendered.amount",request); + return mapping.getInputForward(); + } + catch (OperationException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + } + + bean.setOrderId(Integer.valueOf(posOrder.get_ID())); + + df.populate(new OrderLineBean()); + WebDocumentBean webBean = OrderReferenceManager.getWebOrderBean(ctx, posOrder); + if(posOrder.getPaymentRule().equals(UdiConstants.PAYMENTRULE_MIXED)) + { + if(bean.getPaymentByCash()!=null) + webBean.setPaymentByCash(bean.getPaymentByCash()); + if(bean.getPaymentByCard()!=null) + webBean.setPaymentByCard(bean.getPaymentByCard()); + if(bean.getPaymentByChq()!=null) + webBean.setPaymentbyCheque(bean.getPaymentByChq()); + } + + + ArrayList list = PartialPOSManager.populateOrderLines(ctx,posOrder); + WebDocumentBean documentBean=PartialPOSManager.calculateOrderTotals(list); + //TODO put id only + request.getSession().setAttribute(Constants.CURRENT_POS_ORDER_ID,Integer.valueOf(orderId)); + request.getSession().setAttribute(Constants.ORDER_LINE_BEAN,bean); + request.setAttribute(Constants.POS_ORDER_LINES,list); + request.setAttribute(Constants.PARTIAL_POS_OREDR,"partialPOSOrder"); + + SessionStorage.putCompleteOrderInfo(ctx,request,webBean,documentBean); + + + return mapping.findForward(SET_POS_PAYMENT_DETAILS); + } + + public static final String DELETE_PARTIAL_ORDER = "deletePartialOrder"; + public ActionForward deletePartialOrder(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + InvokeOrderForm f = (InvokeOrderForm) form; + OrderLineBean bean = (OrderLineBean) f.getBean(); + + int orderId = bean.getOrderId().intValue(); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + OrderManager.deleteDraftedOrder(ctx,orderId,trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + } + + return mapping.findForward(DELETE_PARTIAL_ORDER); + } + + //methods called using AJAX + public static final String INCREMENT_QTY = "incrementQty"; + public ActionForward incrementQty(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + addToShoppingCart(mapping,form,request,response); + return new ActionForward("/jsp/pos/partialPOSOrderShoppingCart.jsp"); + } + + public static final String DECREMENT_QTY = "decrementQty"; + public ActionForward decrementQty(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + addToShoppingCart(mapping,form,request,response); + return new ActionForward("/jsp/pos/partialPOSOrderShoppingCart.jsp"); + } + + public static final String DELETE_FROM_POS_CART = "deleteFromPOSCart"; + public ActionForward deleteFromPOSCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + OrderLineBean bean = (OrderLineBean) df.getBean(); + ArrayList items = (ArrayList) request.getSession().getAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS); + ArrayList itemsInCart = StockManager.deleteItemFromPOSList(ctx,items, bean.getProductId(),true); + request.getSession().setAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS, itemsInCart); + + return new ActionForward("/jsp/pos/partialPOSOrderShoppingCart.jsp"); + } + + public static final String DELETE_ORDER = "deleteOrder"; + public ActionForward deleteOrder(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + OrderLineBean bean = (OrderLineBean) df.getBean(); + + int orderId = bean.getOrderId().intValue(); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + OrderManager.deleteDraftedOrder(ctx,orderId,trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + } + + //removing cart & other info in session + HttpSession session = request.getSession(); + + session.removeAttribute(Constants.BPARTNER); + session.removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART); + session.removeAttribute(Constants.PARTIAL_ORDER_SHOPPING_CART_ITEMS); + session.removeAttribute(Constants.CURRENT_PARTIAL_POS_ORDER_ID); + + return mapping.getInputForward(); + } + +} diff --git a/posterita/src/main/org/posterita/struts/pos/PaymentAction.java b/posterita/src/main/org/posterita/struts/pos/PaymentAction.java new file mode 100644 index 0000000000..ca82eac298 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/PaymentAction.java @@ -0,0 +1,132 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 08-Dec-2006 14:01:58 by praveen + * + */ + +package org.posterita.struts.pos; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MPayment; +import org.compiere.util.Trx; +import org.posterita.beans.PaymentBean; +import org.posterita.businesslogic.PaymentAllocationManager; +import org.posterita.businesslogic.PaymentManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.AllocatedAmtMoreThanOpenAmtException; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.BPartnerNotFoundException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.PayAmtNotEqualToAllocateAmtException; +import org.posterita.form.GeneralPaymentForm; +import org.posterita.form.PaymentForm; + +public class PaymentAction extends POSDispatchAction +{ + public static String CREATE_PAYMENT = "createPayment"; + public ActionForward createPayment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + GeneralPaymentForm pf = (GeneralPaymentForm) form; + PaymentBean bean = (PaymentBean) pf.getBean(); + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + MPayment payment; + try + { + trx.start(); + payment= PaymentManager.createPayment(ctx,bean,trx.getTrxName()); + trx.commit(); + } + catch(BPartnerNotFoundException e) + { + trx.rollback(); + postGlobalError("error.required.bpartnerId",request); + return mapping.getInputForward(); + } + catch(OperationException e) + { + trx.rollback(); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return new ActionForward("/ViewWebstorePaymentAction.do?action=viewOrder&documentId="+payment.get_ID()); + } + + + + public static String CREATE_PAYMENT_FOR_MULTIPLE_INVOICE = "createPaymentForMultipleInvoice"; + public ActionForward createPaymentForMultipleInvoice(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + PaymentForm pf = (PaymentForm) form; + PaymentBean bean = (PaymentBean) pf.getBean(); + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + MPayment payment=null; + try + { + trx.start(); + payment= PaymentManager.createPayment(ctx,bean,null); + PaymentAllocationManager.allocatepaymentWithInvoices(ctx,bean.getInvoiceIds(),bean.getAllocateAmount(),payment.get_ID(),null); + trx.commit(); + } + catch(AllocatedAmtMoreThanOpenAmtException e1) + { + trx.rollback(); + postGlobalError("error.allocate.amt.exceeds",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(PayAmtNotEqualToAllocateAmtException e2) + { + trx.rollback(); + postGlobalError("error.allocate.amt.payamt.notequal",e2.getMessage(),request); + return mapping.getInputForward(); + } + catch(OperationException e) + { + trx.rollback(); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return new ActionForward("/ViewWebstorePaymentAction.do?action=viewOrder&documentId="+payment.get_ID()); + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/PaymentTermAction.java b/posterita/src/main/org/posterita/struts/pos/PaymentTermAction.java new file mode 100644 index 0000000000..aa75b82edc --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/PaymentTermAction.java @@ -0,0 +1,237 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 31, 2006 + */ + + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Trx; +import org.posterita.Constants; +import org.posterita.beans.PaymentTermBean; +import org.posterita.businesslogic.PaymentTermManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.CannotDeactivatePaymentTermException; +import org.posterita.exceptions.InvalidNetDaysException; +import org.posterita.exceptions.MandatoryNameException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.PaymentTermAlreadyExistsException; +import org.posterita.form.PaymentTermForm; +import org.posterita.form.PaymentTermForm2; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + + +public class PaymentTermAction extends BaseDispatchAction +{ + public static final String VIEW_ALL_PAYMENT_TERMS = "viewAllPaymentTerms"; + public ActionForward viewAllPaymentTerms(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + ArrayList paymentTermList = PaymentTermManager.getAllPaymentTerm(ctx,false); + request.setAttribute(Constants.ALL_PAYMENT_TERMS,paymentTermList); + return mapping.findForward(VIEW_ALL_PAYMENT_TERMS); + } + + public static final String CREATE_PAYMENT_TERM = "createPaymentTerm"; + public ActionForward createPaymentTerm(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + DefaultForm df= (DefaultForm) form; + PaymentTermBean bean=(PaymentTermBean) df.getBean(); + Properties ctx=TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + PaymentTermManager.createEditPaymentTerm(ctx,bean,trx.getTrxName()); + trx.commit(); + } + catch(MandatoryNameException e) + { + trx.rollback(); + postGlobalError("error.name.mandatory",request); + return mapping.getInputForward(); + } + catch(InvalidNetDaysException e1) + { + trx.rollback(); + postGlobalError("error.net.days.cannot.be.negative",request); + return mapping.getInputForward(); + } + catch(PaymentTermAlreadyExistsException e2) + { + trx.rollback(); + postGlobalError("error.paymentTermName.duplicate",request); + return mapping.getInputForward(); + } + catch(CannotDeactivatePaymentTermException e3) + { + trx.rollback(); + postGlobalError("error.cannot.deactivate.paymentTermName",request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + ArrayList paymentTermList = PaymentTermManager.getAllPaymentTerm(ctx,false); + request.setAttribute(Constants.ALL_PAYMENT_TERMS,paymentTermList); + return mapping.findForward(CREATE_PAYMENT_TERM); + } + + public static final String DEACTIVATE_PAYMENT_TERM = "deActivatePaymentTerm"; + public ActionForward deActivatePaymentTerm(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + PaymentTermForm2 df= (PaymentTermForm2) form; + PaymentTermBean bean=(PaymentTermBean) df.getBean(); + Properties ctx=TmkJSPEnv.getCtx(request); + ArrayList paymentTermList = PaymentTermManager.getAllPaymentTerm(ctx,false); + request.setAttribute(Constants.ALL_PAYMENT_TERMS,paymentTermList); + try + { + PaymentTermManager.activatePaymentTerm(ctx,bean.getPaymentTermId(),false); + } + catch(CannotDeactivatePaymentTermException e3) + { + + postGlobalError("error.cannot.deactivate.paymentTermName",request); + return mapping.getInputForward(); + } + + + return mapping.findForward(DEACTIVATE_PAYMENT_TERM); + } + + + public static final String ACTIVATE_PAYMENT_TERM = "activatePaymentTerm"; + public ActionForward activatePaymentTerm(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + PaymentTermForm2 df= (PaymentTermForm2) form; + PaymentTermBean bean=(PaymentTermBean) df.getBean(); + Properties ctx=TmkJSPEnv.getCtx(request); + + PaymentTermManager.activatePaymentTerm(ctx,bean.getPaymentTermId(),true); + ArrayList paymentTermList = PaymentTermManager.getAllPaymentTerm(ctx,false); + request.setAttribute(Constants.ALL_PAYMENT_TERMS,paymentTermList); + return mapping.findForward(ACTIVATE_PAYMENT_TERM); + } + + public static final String INIT_EDIT_PAYMENT_TERM = "initEditPaymentTerm"; + public ActionForward initEditPaymentTerm(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + PaymentTermForm ptf = (PaymentTermForm) form; + int paymentTermId = new Integer (ptf.getPaymentTermId()).intValue(); + Properties ctx=TmkJSPEnv.getCtx(request); + PaymentTermBean bean= PaymentTermManager.getPaymentTerm(ctx,paymentTermId); + ptf.populate(bean); + request.setAttribute(Constants.EDIT_PAYMENT_TERM,bean); + return mapping.findForward(INIT_EDIT_PAYMENT_TERM); + } + + public static final String EDIT_PAYMENT_TERM = "editPaymentTerm"; + public ActionForward editPaymentTerm(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + DefaultForm df= (DefaultForm) form; + PaymentTermBean bean=(PaymentTermBean) df.getBean(); + Properties ctx=TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + PaymentTermManager.createEditPaymentTerm(ctx,bean,trx.getTrxName()); + trx.commit(); + } + catch(MandatoryNameException e) + { + trx.rollback(); + postGlobalError("error.name.mandatory",request); + return mapping.getInputForward(); + } + catch(InvalidNetDaysException e1) + { + trx.rollback(); + postGlobalError("error.net.days.cannot.be.negative",request); + return mapping.getInputForward(); + } + + catch(PaymentTermAlreadyExistsException e) + { + trx.rollback(); + postGlobalError("error.paymentTermName.duplicate",request); + return mapping.getInputForward(); + } + catch(CannotDeactivatePaymentTermException e3) + { + trx.rollback(); + postGlobalError("error.cannot.deactivate.paymentTermName",request); + return mapping.getInputForward(); + } + catch(OperationException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + } + ArrayList paymentTermList = PaymentTermManager.getAllPaymentTerm(ctx,false); + request.setAttribute(Constants.ALL_PAYMENT_TERMS,paymentTermList); + return mapping.findForward(EDIT_PAYMENT_TERM); + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/SalesAnalysisReportAction.java b/posterita/src/main/org/posterita/struts/pos/SalesAnalysisReportAction.java new file mode 100644 index 0000000000..be70eaf31b --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/SalesAnalysisReportAction.java @@ -0,0 +1,173 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + + +package org.posterita.struts.pos; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.posterita.beans.ReportBean; +import org.posterita.businesslogic.POSReportManager; +import org.posterita.businesslogic.ReportDateManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.core.PieChart; +import org.posterita.core.RandomStringGenerator; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + +public class SalesAnalysisReportAction extends POSDispatchAction +{ + public static final String GET_CURRENT_DAY_REPORT = "getCurrentDayReport"; + public ActionForward getCurrentDayReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String toDate = sdf.format(new Date(cal.getTimeInMillis())); + + cal.set(Calendar.HOUR_OF_DAY,0); + cal.set(Calendar.MINUTE,0); + cal.set(Calendar.SECOND,0); + cal.set(Calendar.MILLISECOND,0); + + String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + + ArrayList list=POSReportManager.getSalesAnalysisReport(ctx,fromDate,toDate); + request.getSession().setAttribute(org.posterita.Constants.SALES_ANALYSIS,list); + + return mapping.findForward(GET_CURRENT_DAY_REPORT); + } + + public static final String GET_CURRENT_MONTH_REPORT = "getCurrentMonthReport"; + public ActionForward getCurrentMonthReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String toDate = sdf.format(new Date(cal.getTimeInMillis())); + + cal.set(Calendar.DATE,1); + cal.set(Calendar.HOUR_OF_DAY,0); + cal.set(Calendar.MINUTE,0); + cal.set(Calendar.SECOND,0); + cal.set(Calendar.MILLISECOND,0); + + String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + + //String report = SalesAnalysisReportManager.getPDFReport(ctx,fromDate,toDate); + + ArrayList list=POSReportManager.getSalesAnalysisReport(ctx,fromDate,toDate); + request.getSession().setAttribute(org.posterita.Constants.SALES_ANALYSIS,list); + + return mapping.findForward(GET_CURRENT_MONTH_REPORT); + } + + public static final String GET_CUSTOM_REPORT = "getCustomReport"; + public ActionForward getCustomReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + ReportBean bean = (ReportBean) df.getBean(); + String fromDate = ReportDateManager.getFromDate(bean); + String toDate = ReportDateManager.getToDate(bean); + + ArrayList list=POSReportManager.getSalesAnalysisReport(ctx,fromDate,toDate); + request.getSession().setAttribute(org.posterita.Constants.SALES_ANALYSIS,list); + + return mapping.findForward(GET_CUSTOM_REPORT); + } + + public static final String GET_JPEG_REPORT = "getJpegReport"; + public ActionForward getJpegReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException + { + try + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + String reportDir = ReportManager.getReportDirectoryFromServletContext(this.servlet); + + String filename = RandomStringGenerator.randomstring(); + + PieChart pieChart = new PieChart(); + pieChart.getDataSetFromSQL("" + + " select t.ATTR_MODEL \"Model\"," + + " sum(AMTACCTCR) \"Sum\"" + + " from FACT_ACCT f,M_PRODUCT p,U_TSHIRT_V t" + + " where f.AD_CLIENT_ID = 1016840" + + " and f.M_PRODUCT_ID = p.M_PRODUCT_ID" + + " and f.AMTACCTCR > 0" + + " and t.M_PRODUCT_ID = p.M_PRODUCT_ID" + + " having sum(AMTACCTCR) < 1000" + + " group by t.ATTR_MODEL"); + + pieChart.saveChartAsJPEG(reportDir+filename+".jpg",700,600); + + String imgSrc = request.getContextPath() + "/config/reports/"+filename+".jpg"; + String imagemaptag = pieChart.getImageMap(filename); + String imagetag = ""; + + request.getSession().setAttribute("CHART",imagemaptag+imagetag); + + } + catch (Exception e) + { + e.printStackTrace(); + } + + return mapping.findForward(GET_JPEG_REPORT); + } + + +} diff --git a/posterita/src/main/org/posterita/struts/pos/SearchCustomerAction.java b/posterita/src/main/org/posterita/struts/pos/SearchCustomerAction.java new file mode 100644 index 0000000000..794c6de960 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/SearchCustomerAction.java @@ -0,0 +1,123 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 12-Dec-2006 10:00:02 by praveen + * + */ + +package org.posterita.struts.pos; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.beans.CustomerBean; +import org.posterita.businesslogic.CustomerManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.bean.ElementBean; +import org.posterita.core.businesslogic.ElementManager; + +/** + * This action is called using AJAX form the vendor panel + */ +public class SearchCustomerAction extends Action +{ + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + Properties ctx = TmkJSPEnv.getCtx(request); + String customerName = request.getParameter("customerQuery"); + + ArrayList customerList = CustomerManager.searchCustomers(ctx,customerName,false); + CustomerBean bean = null; + + ElementBean elementBean = null; + elementBean = ElementManager.getMsg(ctx, "not.found"); + + StringWriter sw = new StringWriter(); + PrintWriter out = new PrintWriter(sw); + + if (customerList == null || customerList.size() == 0) + { + out.print("

    "); + out.print("
  • "); + out.print("
"); + out.print("
"); + } + else + { + int size = 15; + size = (size > customerList.size())? customerList.size() : size; + + out.print("
    "); + + for(int i=0;i"); + out.print(vendorName); + out.print(""); + } + + out.print("
"); + + elementBean = ElementManager.getMsg(ctx, "search.result.displaying"); + String msg = elementBean.getName(); + + out.print("
"); + } + + response.getOutputStream().print(sw.toString()); + response.getOutputStream().flush(); + response.getOutputStream().close(); + + return null; + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/SearchPOSProductAction.java b/posterita/src/main/org/posterita/struts/pos/SearchPOSProductAction.java new file mode 100644 index 0000000000..e3f11e4949 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/SearchPOSProductAction.java @@ -0,0 +1,57 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.Constants; +import org.posterita.businesslogic.ProductManager; +import org.posterita.core.TmkJSPEnv; + +public class SearchPOSProductAction extends POSDispatchAction +{ + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + String productName = request.getParameter("productName"); + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList productList = ProductManager.getProductList(ctx,productName,true,true); + + request.getSession().setAttribute(Constants.PRODUCT_LIST,productList); + + return mapping.findForward("displayProducts"); + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/SearchProductAction.java b/posterita/src/main/org/posterita/struts/pos/SearchProductAction.java new file mode 100644 index 0000000000..99d391dd00 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/SearchProductAction.java @@ -0,0 +1,97 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 12-Dec-2006 10:00:02 by praveen + * + */ + +package org.posterita.struts.pos; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.beans.ProductStatusBean; +import org.posterita.businesslogic.ProductManager; +import org.posterita.core.TmkJSPEnv; + +/** + * This action is called using AJAX form the product panel + */ +public class SearchProductAction extends Action +{ + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + + String productName = request.getParameter("productName"); + + productName = productName.replaceAll("#", "&#"); + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList productList =ProductManager.searchProductsByName(ctx,productName); + ProductStatusBean bean = null; + StringWriter sw = new StringWriter(); + PrintWriter out = new PrintWriter(sw); + + if(productList == null || productList.size() == 0) + { + out.print("
"); + } + else + { + int size = 15; + + size = (size > productList.size())? productList.size() : size; + + if(size > 0) + { + out.print("
    "); + + for(int i=0;i< size;i++) + { + bean = (ProductStatusBean)productList.get(i); + + out.print("
  • "); + out.print(bean.getProductName()); + out.print("
  • "); + } + + out.print("
"); + } + + out.print("
"); + + } + + response.getOutputStream().print(sw.toString()); + response.getOutputStream().flush(); + response.getOutputStream().close(); + + return null; + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/SearchVendorAction.java b/posterita/src/main/org/posterita/struts/pos/SearchVendorAction.java new file mode 100644 index 0000000000..78ce372255 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/SearchVendorAction.java @@ -0,0 +1,123 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 12-Dec-2006 10:00:02 by praveen + * + */ + +package org.posterita.struts.pos; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.posterita.beans.CustomerBean; +import org.posterita.businesslogic.VendorManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.bean.ElementBean; +import org.posterita.core.businesslogic.ElementManager; + +/** + * This action is called using AJAX form the vendor panel + */ +public class SearchVendorAction extends Action +{ + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception + { + Properties ctx = TmkJSPEnv.getCtx(request); + String customerName = request.getParameter("customerQuery"); + + ArrayList customerList = VendorManager.searchVendors(TmkJSPEnv.getCtx(request),customerName,true); + CustomerBean bean = null; + + ElementBean elementBean = null; + elementBean = ElementManager.getMsg(ctx, "not.found"); + + StringWriter sw = new StringWriter(); + PrintWriter out = new PrintWriter(sw); + + if (customerList == null || customerList.size() == 0) + { + out.print("
    "); + out.print("
  • "); + out.print("
"); + out.print("
"); + } + else + { + int size = 15; + size = (size > customerList.size())? customerList.size() : size; + + out.print("
    "); + + for(int i=0;i"); + out.print(vendorName); + out.print(""); + } + + out.print("
"); + + elementBean = ElementManager.getMsg(ctx, "search.result.displaying"); + String msg = elementBean.getName(); + + out.print("
"); + } + + response.getOutputStream().print(sw.toString()); + response.getOutputStream().flush(); + response.getOutputStream().close(); + + return null; + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/SlowMovingItemReportAction.java b/posterita/src/main/org/posterita/struts/pos/SlowMovingItemReportAction.java new file mode 100644 index 0000000000..2122bd20c3 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/SlowMovingItemReportAction.java @@ -0,0 +1,125 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.pos; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.posterita.Constants; +import org.posterita.beans.ReportBean; +import org.posterita.businesslogic.POSReportManager; +import org.posterita.businesslogic.ReportDateManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + +public class SlowMovingItemReportAction extends POSDispatchAction +{ + public static final String GET_CURRENT_DAY_REPORT = "getCurrentDayReport"; + public ActionForward getCurrentDayReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String toDate = sdf.format(new Date(cal.getTimeInMillis())); + + cal.set(Calendar.HOUR_OF_DAY,0); + cal.set(Calendar.MINUTE,0); + cal.set(Calendar.SECOND,0); + cal.set(Calendar.MILLISECOND,0); + + String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + + ArrayList list=POSReportManager.getMaxMinSoldProducts(ctx,"asc",fromDate,toDate); + request.getSession().setAttribute(Constants.MIN_SOLD_ITEMS,list); + + return mapping.findForward(GET_CURRENT_DAY_REPORT); + } + + public static final String GET_CURRENT_MONTH_REPORT = "getCurrentMonthReport"; + public ActionForward getCurrentMonthReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String toDate = sdf.format(new Date(cal.getTimeInMillis())); + + cal.set(Calendar.DATE,1); + cal.set(Calendar.HOUR_OF_DAY,0); + cal.set(Calendar.MINUTE,0); + cal.set(Calendar.SECOND,0); + cal.set(Calendar.MILLISECOND,0); + + String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + + ArrayList list=POSReportManager.getMaxMinSoldProducts(ctx,"asc",fromDate,toDate); + request.getSession().setAttribute(Constants.MIN_SOLD_ITEMS,list); + + return mapping.findForward(GET_CURRENT_MONTH_REPORT); + } + + public static final String GET_CUSTOM_REPORT = "getCustomReport"; + public ActionForward getCustomReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + + ReportBean bean = (ReportBean) df.getBean(); + String fromDate = ReportDateManager.getFromDate(bean); + String toDate = ReportDateManager.getToDate(bean); + + ArrayList list=POSReportManager.getMaxMinSoldProducts(ctx,"asc",fromDate,toDate); + request.getSession().setAttribute(Constants.MIN_SOLD_ITEMS,list); + + return mapping.findForward(GET_CUSTOM_REPORT); + } + + +} diff --git a/posterita/src/main/org/posterita/struts/pos/StockMovementReportAction.java b/posterita/src/main/org/posterita/struts/pos/StockMovementReportAction.java new file mode 100644 index 0000000000..8b4d197ac4 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/StockMovementReportAction.java @@ -0,0 +1,205 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.pos; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; + +import org.posterita.Constants; +import org.posterita.beans.ReportBean; +import org.posterita.businesslogic.CSVReportManager; +import org.posterita.businesslogic.POSReportManager; +import org.posterita.businesslogic.ReportDateManager; +import org.posterita.businesslogic.ReportManager; +import org.posterita.core.TabularReport; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; + +public class StockMovementReportAction extends POSDispatchAction +{ + public static final String GET_CURRENT_DAY_REPORT = "getCurrentDayReport"; + public ActionForward getCurrentDayReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String toDate = sdf.format(new Date(cal.getTimeInMillis())); + + cal.set(Calendar.HOUR_OF_DAY,0); + cal.set(Calendar.MINUTE,0); + cal.set(Calendar.SECOND,0); + cal.set(Calendar.MILLISECOND,0); + + String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + + ArrayList list=POSReportManager.getStockMovementReport(ctx,fromDate,toDate); + request.getSession().setAttribute(Constants.STOCK_MOVEMENT,list); + + return mapping.findForward(GET_CURRENT_DAY_REPORT); + } + + public static final String GET_CURRENT_MONTH_REPORT = "getCurrentMonthReport"; + public ActionForward getCurrentMonthReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + + String toDate = sdf.format(new Date(cal.getTimeInMillis())); + + cal.set(Calendar.DATE,1); + cal.set(Calendar.HOUR_OF_DAY,0); + cal.set(Calendar.MINUTE,0); + cal.set(Calendar.SECOND,0); + cal.set(Calendar.MILLISECOND,0); + + String fromDate = sdf.format(new Date(cal.getTimeInMillis())); + + ArrayList list=POSReportManager.getStockMovementReport(ctx,fromDate,toDate); + request.getSession().setAttribute(Constants.STOCK_MOVEMENT,list); + + return mapping.findForward(GET_CURRENT_MONTH_REPORT); + } + + public static final String GET_CUSTOM_REPORT = "getCustomReport"; + public ActionForward getCustomReport(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df= (DefaultForm) form; + ReportBean bean = (ReportBean) df.getBean(); + + String title = "Stock Movement Report"; + String subtitle = ""; + + String dateRange = bean.getDateRange(); + String timePeriod = bean.getTimePeriod(); + + String fromDate = null; + String toDate = null; + + //setting from and to dates + if(dateRange.endsWith(Constants.FIXED_DATE_RANGE)) + { + if(timePeriod==null) + { + throw new OperationException("Invalid Parameter for timePeriod : Time period is null "); + } + + Date startDate = ReportDateManager.getStartDateForPeriod(timePeriod); + Date endDate = ReportDateManager.getEndDateForPeriod(timePeriod); + + SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); + fromDate = sdf.format(startDate); + toDate = sdf.format(endDate); + + subtitle = "For " + timePeriod; + } + else if(dateRange.endsWith(Constants.CUSTOM_DATE_RANGE)) + { + boolean error = false; + ActionMessages messages = new ActionMessages(); + ActionMessage message = null; + + if((bean.getFromDate()==null)||(bean.getFromDate()=="")) + { + message = new ActionMessage("error.required.fromDate"); + messages.add(ActionMessages.GLOBAL_MESSAGE, message); + error = true; + } + + if((bean.getToDate()==null)||(bean.getToDate()=="")) + { + message = new ActionMessage("error.required.toDate"); + messages.add(ActionMessages.GLOBAL_MESSAGE, message); + error = true; + } + + if(error) + { + saveErrors(request, messages); + return mapping.getInputForward(); + } + else + { + fromDate = ReportDateManager.getFromDate(bean); + toDate = ReportDateManager.getToDate(bean); + + } + + + subtitle = "For period:"+fromDate+" to "+toDate; + } + else + { + throw new OperationException("Invalid Parameter for dateRange :" + dateRange); + } + + ArrayList reportData = POSReportManager.getStockMovementReportData(ctx,fromDate,toDate); + + //constructing the table + TabularReport tReport = new TabularReport(reportData); + tReport.setSortable(false); + tReport.setStyle("display"); + tReport.setTitle(title); + tReport.setSubtitle(subtitle); + tReport.createReport(); + + String csvReport = CSVReportManager.generateCSVReport(ctx,reportData); + String csvURI = ReportManager.getReportURI(csvReport,request); + + request.getSession().setAttribute(Constants.TABULAR_REPORT_DATA,tReport.toString()); + request.getSession().setAttribute(Constants.CSV_FILE,csvURI); + + return mapping.findForward(GET_CUSTOM_REPORT); + + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/TaxAction.java b/posterita/src/main/org/posterita/struts/pos/TaxAction.java new file mode 100644 index 0000000000..7afef8ab7a --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/TaxAction.java @@ -0,0 +1,247 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Nov 28, 2006 + */ + + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Trx; +import org.posterita.Constants; +import org.posterita.beans.TaxBean; +import org.posterita.businesslogic.TaxManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.CannotInactivateTaxException; +import org.posterita.exceptions.InvalidNetDaysException; +import org.posterita.exceptions.MandatoryException; +import org.posterita.exceptions.MandatoryNameException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.TaxNameAlreadyExistsException; +import org.posterita.exceptions.TaxRateAlreadyExistsException; +import org.posterita.form.TaxForm; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + + +public class TaxAction extends BaseDispatchAction +{ + public static final String VIEW_ALL_TAX = "viewAllTax"; + + public ActionForward viewAllTax(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx=TmkJSPEnv.getCtx(request); + + ArrayList taxList = TaxManager.getAllTaxRates(ctx,false); + request.setAttribute(Constants.ALL_TAX_RATE,taxList); + return mapping.findForward(VIEW_ALL_TAX); + } + + public static final String CREATE_TAX = "createTax"; + public ActionForward createTax(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + DefaultForm df= (DefaultForm) form; + TaxBean bean=(TaxBean) df.getBean(); + Properties ctx=TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + TaxManager.createEditTaxCategoryAndTax(ctx,bean,trx.getTrxName()); + trx.commit(); + } + catch(MandatoryNameException e) + { + trx.rollback(); + postGlobalError("error.name.mandatory",request); + return mapping.getInputForward(); + } + catch(MandatoryException e1) + { + trx.rollback(); + postGlobalError("error.required.field",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(TaxNameAlreadyExistsException e3) + { + trx.rollback(); + postGlobalError("error.taxname.duplicate",request); + return mapping.getInputForward(); + } + catch(TaxRateAlreadyExistsException e4) + { + trx.rollback(); + postGlobalError("error.taxrate.duplicate",request); + return mapping.getInputForward(); + } + catch(InvalidNetDaysException e5) + { + trx.rollback(); + postGlobalError("error.tax.rate.nagative",request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + ArrayList taxList = TaxManager.getAllTaxRates(ctx,false); + request.setAttribute(Constants.ALL_TAX_RATE,taxList); + return mapping.findForward(CREATE_TAX); + } + + public static final String DEACTIVATE_TAX = "deActivateTax"; + public ActionForward deActivateTax(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + DefaultForm df= (DefaultForm) form; + TaxBean bean=(TaxBean) df.getBean(); + Properties ctx=TmkJSPEnv.getCtx(request); + + try + { + TaxManager.activateTax(ctx,bean.getTaxId(),false); + } + + catch(CannotInactivateTaxException e) + { + ArrayList taxList = TaxManager.getAllTaxRates(ctx,false); + request.setAttribute(Constants.ALL_TAX_RATE,taxList); + postGlobalError("cannot.inactivate.tax",request); + return mapping.getInputForward(); + } + ArrayList taxList = TaxManager.getAllTaxRates(ctx,false); + request.setAttribute(Constants.ALL_TAX_RATE,taxList); + + return mapping.findForward(DEACTIVATE_TAX); + } + + + public static final String ACTIVATE_TAX = "activateTax"; + public ActionForward activateTax(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + DefaultForm df= (DefaultForm) form; + TaxBean bean=(TaxBean) df.getBean(); + Properties ctx=TmkJSPEnv.getCtx(request); + + TaxManager.activateTax(ctx,bean.getTaxId(),true); + ArrayList taxList = TaxManager.getAllTaxRates(ctx,false); + request.setAttribute(Constants.ALL_TAX_RATE,taxList); + return mapping.findForward(ACTIVATE_TAX); + } + + public static final String INIT_EDIT_TAX = "initEditTax"; + public ActionForward initEditTax(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + TaxForm tf = (TaxForm) form; + int taxId = new Integer (tf.getTaxId()).intValue(); + Properties ctx=TmkJSPEnv.getCtx(request); + TaxBean bean= TaxManager.getTaxRate(ctx,taxId); + tf.populate(bean); + request.setAttribute(Constants.EDIT_TAX,bean); + return mapping.findForward(INIT_EDIT_TAX); + } + + public static final String EDIT_TAX = "editTax"; + public ActionForward editTax(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd= init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + DefaultForm df= (DefaultForm) form; + TaxBean bean=(TaxBean) df.getBean(); + Properties ctx=TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(),true); + + try + { + trx.start(); + TaxManager.createEditTaxCategoryAndTax(ctx,bean,trx.getTrxName()); + trx.commit(); + } + catch(MandatoryException e1) + { + trx.rollback(); + postGlobalError("error.required.field",e1.getMessage(),request); + return mapping.getInputForward(); + } + catch(MandatoryNameException e2) + { + trx.rollback(); + postGlobalError("error.name.required",request); + return mapping.getInputForward(); + } + catch(InvalidNetDaysException e3) + { + trx.rollback(); + postGlobalError("error.tax.rate.nagative",request); + return mapping.getInputForward(); + } + catch(TaxNameAlreadyExistsException e) + { + trx.rollback(); + postGlobalError("error.taxname.duplicate",request); + return mapping.getInputForward(); + } + catch(TaxRateAlreadyExistsException e) + { + trx.rollback(); + postGlobalError("error.taxrate.duplicate",request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + ArrayList taxList = TaxManager.getAllTaxRates(ctx,false); + request.setAttribute(Constants.ALL_TAX_RATE,taxList); + return mapping.findForward(EDIT_TAX); + } +} diff --git a/posterita/src/main/org/posterita/struts/pos/VendorAction.java b/posterita/src/main/org/posterita/struts/pos/VendorAction.java new file mode 100644 index 0000000000..57051fd9c1 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/pos/VendorAction.java @@ -0,0 +1,275 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on 25-Jul-2005 by alok + * + */ + +package org.posterita.struts.pos; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.VendorBean; +import org.posterita.businesslogic.VendorManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.form.VendorForm; +import org.posterita.struts.core.DefaultForm; + +public class VendorAction extends POSDispatchAction +{ + public static final String SAVE_VENDOR = "saveVendor"; + public ActionForward saveVendor(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + VendorBean bean = (VendorBean) df.getBean(); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + Integer partnerId = 0; + + if (bean.getBpartnerId() != null) + partnerId = bean.getBpartnerId(); + + try + { + trx.start(); + VendorManager.saveVendor(ctx, partnerId, bean, trx.getTrxName()); + trx.commit(); + } + catch(OperationException ex) + { + trx.rollback(); + throw ex; + } + finally + { + trx.close(); + } + request.setAttribute(Constants.VENDOR_DETAILS,bean); + + return mapping.findForward(SAVE_VENDOR); + } + + public static final String VIEW_VENDOR = "viewVendorDetails"; + public ActionForward viewVendorDetails1(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + VendorForm uf = (VendorForm) form; + + int vendorId = Integer.valueOf(uf.getBpartnerId()).intValue(); + + VendorBean vendorBean = VendorManager.getVendor(ctx,vendorId); + + request.getSession().setAttribute(Constants.VENDOR_DETAILS,vendorBean); + + return mapping.findForward(VIEW_VENDOR); + } + + + public static final String INIT_SEARCH_VENDOR = "initSearchVendors"; + public ActionForward initSearchVendors(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + request.getSession().removeAttribute(Constants.VENDOR_LIST); + + return mapping.findForward(INIT_SEARCH_VENDOR); + } + + + public static final String SEARCH_VENDOR = "searchVendors"; + public ActionForward searchVendors(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd=init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + ArrayList vendorList = VendorManager.searchVendors(ctx, df.getName()); + + request.getSession().setAttribute(Constants.VENDOR_LIST,vendorList); + + return mapping.findForward(SEARCH_VENDOR); + } + + + public static final String INIT_EDIT_VENDOR = "initEditVendor"; + public ActionForward initEditVendor(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + + VendorForm f = (VendorForm) form; + f.validate(mapping,request); + + VendorBean bean = (VendorBean) f.getBean(); + + Integer bpartnerId = bean.getBpartnerId(); + if(bpartnerId==null) + { + throw new OperationException("Cannot edit vendor. Cause vendor id cannot be null!"); + } + + bean = VendorManager.getVendor(ctx,bpartnerId.intValue()); + f.populate(bean); + + return mapping.findForward(INIT_EDIT_VENDOR); + } + + + public static final String ACTIVATE_VENDOR = "activateVendor"; + @SuppressWarnings("unchecked") + public ActionForward activateVendor(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + + VendorForm f = (VendorForm) form; + f.validate(mapping,request); //copying the value from the form to the bean + + VendorBean bean = (VendorBean) f.getBean(); + + Integer bpartnerId = bean.getBpartnerId(); + + if(bpartnerId==null) + { + throw new OperationException("Cannot edit vendor. Cause: Vendor id cannot be null!"); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + + try + { + trx.start(); + VendorManager.activateVendor(ctx,bpartnerId.intValue(), trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.activate.vendor", request); + mapping.getInputForward(); + } + finally + { + trx.close(); + } + + ArrayList list = (ArrayList) request.getSession().getAttribute(Constants.VENDOR_LIST); + ArrayList vendorBeanList = list; + + ArrayList newList = VendorManager.updateVendorListStatus(vendorBeanList, bpartnerId, true); + + request.getSession().setAttribute(Constants.VENDOR_LIST, newList); + + + return mapping.findForward(SEARCH_VENDOR); + } + + public static final String DEACTIVATE_VENDOR = "deactivateVendor"; + @SuppressWarnings("unchecked") + public ActionForward deactivateVendor(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd=init(mapping,form,request,response); + if (fwd!=null) + return fwd; + Properties ctx = TmkJSPEnv.getCtx(request); + + VendorForm f = (VendorForm) form; + f.validate(mapping,request); //copying the value from the form to the bean + + VendorBean bean = (VendorBean) f.getBean(); + + Integer bpartnerId = bean.getBpartnerId(); + if(bpartnerId==null) + { + throw new OperationException("Cannot edit vendor. Cause vendor id cannot be null!"); + } + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + try + { + trx.start(); + VendorManager.deactivateVendor(ctx,bpartnerId.intValue(), trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.deactivate.vendor", request); + mapping.getInputForward(); + } + finally + { + trx.close(); + } + + ArrayList list = (ArrayList) request.getSession().getAttribute(Constants.VENDOR_LIST); + ArrayList vendorBeanList = list; + + ArrayList newList = VendorManager.updateVendorListStatus(vendorBeanList, bpartnerId, false); + + request.getSession().setAttribute(Constants.VENDOR_LIST, newList); + + return mapping.findForward(SEARCH_VENDOR); + } + + + +} diff --git a/posterita/src/main/org/posterita/struts/product/PriceListAction.java b/posterita/src/main/org/posterita/struts/product/PriceListAction.java new file mode 100644 index 0000000000..5ce08ecc70 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/product/PriceListAction.java @@ -0,0 +1,241 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 19, 2005 by praveen + * + */ +package org.posterita.struts.product; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.util.Env; +import org.compiere.util.Trx; +import org.posterita.Constants; +import org.posterita.beans.EditPriceBean; +import org.posterita.beans.PriceListBean; +import org.posterita.beans.ProductBean; +import org.posterita.beans.ProductPriceBean; +import org.posterita.businesslogic.ApplicationManager; +import org.posterita.businesslogic.PriceListManager; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.SystemException; +import org.posterita.form.PriceListForm; +import org.posterita.lib.UdiConstants; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + +public class PriceListAction extends BaseDispatchAction +{ + public static final String INIT_PRICE_LIST = "initPriceList"; + private Properties webstoreCtx = new Properties(); + + + private Properties getWebstoreContext(HttpServletRequest request) + { + ApplicationManager.setApplicationParametersInContext(webstoreCtx, "webstore"); + + return webstoreCtx; + } + + + public static final String INIT_WEBSTORE_PRICE_LIST = "initWebstorePriceList"; + public ActionForward initWebstorePriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping, form, request, response); + + if(fwd!=null) + return fwd; + + webstoreCtx = getWebstoreContext(request); + + DefaultForm df = (DefaultForm) form; + ProductBean bean = (ProductBean) df.getBean(); + + df.setIsWebstoreFeatured("true"); + + int priceListId = Env.getContextAsInt(webstoreCtx, UdiConstants.PRICELIST_CTX_PARAM); + int priceListVersionId = PriceListManager.getPriceListVersionID(webstoreCtx, priceListId, null); + + ArrayList productPriceList = new ArrayList (); + + //if (bean.getSearchText() != null) + productPriceList = PriceListManager.getProductPriceList(webstoreCtx, priceListVersionId, bean.getSearchText(), bean.getIsSelfService(), bean.getProductClassification()); + + request.getSession().setAttribute(Constants.PRICE_LIST, productPriceList); + + return mapping.findForward(INIT_WEBSTORE_PRICE_LIST); + } + + + + + + public static final String INIT_EDIT_PRICE_LIST = "initEditPriceList"; + + public ActionForward initEditPriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception + { + ActionForward fwd = init(mapping, form, request, response); + + if(fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + + PriceListBean bean = (PriceListBean) df.getBean(); + + request.getSession().setAttribute(Constants.PRODUCT_IDS, bean.getProductIds()); + + return mapping.findForward(INIT_EDIT_PRICE_LIST); + } + + public static final String INIT_EDIT_WSTORE_PRICE_LIST = "initWebstoreEditPriceList"; + public ActionForward initWebstoreEditPriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + + if(fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + + PriceListBean bean = (PriceListBean) df.getBean(); + + if(bean.getProductIds() == null || bean.getProductIds().length == 0) + { + postGlobalError("error.product.not.selected", request); + return mapping.getInputForward(); + } + + request.getSession().setAttribute(Constants.PRODUCT_IDS, bean.getProductIds()); + + return mapping.findForward(INIT_EDIT_WSTORE_PRICE_LIST); + } + + + public static final String EDIT_PRICE_LIST = "editPriceList"; + public ActionForward editPriceLists(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, SystemException + { + ActionForward fwd = init(mapping, form, request, response); + + if(fwd!=null) + return fwd; + + webstoreCtx = getWebstoreContext(request); + + DefaultForm df = (DefaultForm) form; + + EditPriceBean bean = (EditPriceBean) df.getBean(); + + BigDecimal priceEntered = new BigDecimal(bean.getPrice().toString()); + + Integer productIds[] = (Integer[]) request.getSession().getAttribute(Constants.PRODUCT_IDS); + Integer priceListVersionId = (Integer) request.getSession().getAttribute(Constants.PRICE_LIST_VERSION_ID); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + try + { + trx.start(); + PriceListManager.editProductPrices(webstoreCtx,productIds, priceListVersionId.intValue(), priceEntered, trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + throw e; + } + catch (SystemException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + } + + PriceListForm plf = (PriceListForm) getForm(Constants.PriceListForm, Constants.InitPriceListAction, request); + + PriceListBean plBean = new PriceListBean(); + plBean.setPriceListVersionId(priceListVersionId); + plf.populate(plBean); + + return mapping.findForward(EDIT_PRICE_LIST); + } + + public static final String EDIT_WEBSTORE_PRICELIST = "editWebstorePriceList"; + public ActionForward editWebstorePriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException, SystemException + { + ActionForward fwd = init(mapping, form, request, response); + + if(fwd!=null) + return fwd; + + webstoreCtx = getWebstoreContext(request); + + DefaultForm df = (DefaultForm) form; + + EditPriceBean bean = (EditPriceBean) df.getBean(); + + Integer productIds[] = (Integer[])request.getSession().getAttribute(Constants.PRODUCT_IDS); + + int priceListId = Env.getContextAsInt(webstoreCtx, UdiConstants.PRICELIST_CTX_PARAM); + int priceListVersionId = PriceListManager.getPriceListVersionID(webstoreCtx, priceListId, null); + + BigDecimal priceEntered = new BigDecimal(bean.getPrice().toString()); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + try + { + trx.start(); + PriceListManager.editProductPrices(webstoreCtx,productIds, priceListVersionId, priceEntered, trx.getTrxName()); + trx.commit(); + } + catch (OperationException e) + { + trx.rollback(); + throw e; + } + catch (SystemException e) + { + trx.rollback(); + throw e; + } + finally + { + trx.close(); + } + + + return mapping.findForward(EDIT_WEBSTORE_PRICELIST); + } + + + +} diff --git a/posterita/src/main/org/posterita/struts/stock/StockAction.java b/posterita/src/main/org/posterita/struts/stock/StockAction.java new file mode 100644 index 0000000000..7f480a6c4e --- /dev/null +++ b/posterita/src/main/org/posterita/struts/stock/StockAction.java @@ -0,0 +1,237 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.posterita.struts.stock; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.posterita.Constants; +import org.posterita.beans.ItemBean; +import org.posterita.beans.ShoppingCartBean; +import org.posterita.businesslogic.StockManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.ProductNotOnPriceListException; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; +import org.posterita.struts.pos.POSGoodsAction; + + +public class StockAction extends BaseDispatchAction +{ + + + + public static final String DELETE_FROM_CART = "deleteFromCart"; + public ActionForward deleteFromCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + + ItemBean bean = (ItemBean) df.getBean(); + + ArrayList cartItems = (ArrayList) request.getSession().getAttribute(Constants.SHOPPING_CART_ITEMS); + ShoppingCartBean cartBeans = (ShoppingCartBean) request.getSession().getAttribute(Constants.SHOPPING_CART); + + if (cartItems == null || cartItems.size() == 0) + return mapping.findForward(DELETE_FROM_CART); + + cartItems = StockManager.deleteItemFromList(cartItems, bean.getProductId()); + BigDecimal grandTotal = StockManager.setGrandTotal(cartItems); + cartBeans.setTotalPrice(grandTotal); + + request.getSession().setAttribute(Constants.SHOPPING_CART_ITEMS, cartItems); + request.getSession().setAttribute(Constants.SHOPPING_CART, cartBeans); + + return mapping.findForward(DELETE_FROM_CART); + } + + public static final String DELETE_FROM_POS_CART = "deleteFromPOSCart"; + public ActionForward deleteFromPOSCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + String orderType = df.getOrderType(); + ItemBean bean = (ItemBean) df.getBean(); + + if(orderType==null) + { + orderType=(String)request.getSession().getAttribute(Constants.ORDER_TYPE); + } + + String shoppingCartItem = null; + String path=null; + if(orderType.equalsIgnoreCase(Constants.CREDIT_ORDER)) + { + shoppingCartItem = Constants.CREDIT_ORDER_SHOPPING_CART_ITEMS; + path="/jsp/pos/creditOrderShoppingCart.jsp"; + } + else + { + shoppingCartItem = Constants.SHOPPING_ORDER_CART_ITEMS; + path="/jsp/pos/posShoppingCartFirstPage.jsp"; + + } + ArrayList items = (ArrayList) request.getSession().getAttribute(shoppingCartItem); + ArrayList itemsInCart = StockManager.deleteItemFromPOSList(ctx,items, bean.getProductId(),true); + request.getSession().setAttribute(shoppingCartItem, itemsInCart); + return new ActionForward(path); + } + + + + public static final String DELETE_FROM_CREDIT_ORDER_CART = "deleteFromCreditOrderCart"; + public ActionForward deleteFromCreditOrderCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + //String orderType = df.getOrderType(); + ItemBean bean = (ItemBean) df.getBean(); + + + ArrayList items = (ArrayList) request.getSession().getAttribute(Constants.CREDIT_ORDER_SHOPPING_CART_ITEMS); + + ArrayList itemsInCart = StockManager.deleteItemFromPOSList(ctx,items, bean.getProductId(),true); + + + request.getSession().setAttribute(Constants.CREDIT_ORDER_SHOPPING_CART_ITEMS, itemsInCart); + + return new ActionForward("/jsp/pos/creditOrderShoppingCart.jsp"); + } + + public static final String DELETE_FROM_POS_GRN_CART = "deleteFromPOSGRNCart"; + public ActionForward deleteFromPOSGRNCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + DefaultForm df = (DefaultForm) form; + ItemBean bean = (ItemBean) df.getBean(); + + String orderType = df.getOrderType(); + //String shoppingCart = null; + String shoppingCartItem = null; + + if(orderType.equals(Constants.GOODS_RECEIVE_NOTE)) + { + //shoppingCart = Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART; + shoppingCartItem = Constants.GOODS_RECEIVE_NOTE_SHOPPING_CART_ITEMS; + } + else if(orderType.equals(Constants.GOODS_RETURN_NOTE)) + { + //shoppingCart = Constants.GOODS_RETURN_NOTE_SHOPPING_CART; + shoppingCartItem = Constants.GOODS_RETURN_NOTE_SHOPPING_CART_ITEMS; + } + else if(orderType.equals(Constants.CUSTOMER_RETURN_ORDER)) + { + //shoppingCart = Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART; + shoppingCartItem = Constants.CUSTOMER_RETURN_ORDER_SHOPPING_CART_ITEMS; + } + + + ArrayList items = (ArrayList) request.getSession().getAttribute(shoppingCartItem); + + ArrayList itemsInCart = StockManager.deleteItemFromPOSList(ctx,items, bean.getProductId(),false); + + request.getSession().setAttribute(shoppingCartItem, itemsInCart); + + POSGoodsAction action = new POSGoodsAction(); + ActionForward forward = action.getShoppingCart(mapping,form,request,response); + + return forward; + } + + public static final String DELETE_FROM_POS_RET_CART = "deleteFromPOSRetCart"; + public ActionForward deleteFromPOSRetCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, ProductNotOnPriceListException, OperationException + { + + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + ItemBean bean = (ItemBean) df.getBean(); + + ArrayList items = (ArrayList) request.getSession().getAttribute(Constants.SHOPPING_GRN_CART_ITEMS); + + ArrayList itemsInCart = StockManager.deleteItemFromPOSList(ctx,items, bean.getProductId(),false); + + request.getSession().setAttribute(Constants.SHOPPING_GRN_CART_ITEMS, itemsInCart); + + return mapping.findForward(DELETE_FROM_POS_RET_CART); + } + + + public static final String DELETE_FROM_CUST_RET_CART = "deleteFromCustRetCart"; + public ActionForward deleteFromCustRetCart(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, ProductNotOnPriceListException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + if(fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + + ItemBean bean = (ItemBean) df.getBean(); + + ArrayList items = (ArrayList) request.getSession().getAttribute(Constants.SHOPPING_GRN_CART_ITEMS); + + ArrayList itemsInCart = StockManager.deleteItemFromPOSList(ctx,items, bean.getProductId(),true); + + request.getSession().setAttribute(Constants.SHOPPING_GRN_CART_ITEMS, itemsInCart); + + return mapping.findForward(DELETE_FROM_CUST_RET_CART); + } + + + + +} diff --git a/posterita/src/main/org/posterita/struts/user/CreateUserAction.java b/posterita/src/main/org/posterita/struts/user/CreateUserAction.java new file mode 100644 index 0000000000..5604df2d28 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/user/CreateUserAction.java @@ -0,0 +1,116 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Jul 29, 2005 by din + */ + +package org.posterita.struts.user; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MCountry; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.UserBean; +import org.posterita.businesslogic.RoleManager; +import org.posterita.businesslogic.UserManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.DuplicateUserPinException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.UserAlreadyExistsException; +import org.posterita.keyname.RegionKeyNamePair; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + +public class CreateUserAction extends BaseDispatchAction +{ + public static final String CREATE_USERS = "createUser"; + public ActionForward createUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, FileNotFoundException, OperationException, IOException + { + + DefaultForm df = (DefaultForm) form; + + UserBean bean = (UserBean) df.getBean(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + trx.start(); + try + { + MCountry country = MCountry.getDefault(ctx); + UserManager.createUser(ctx,bean.getUsername(),"",bean.getIsSalesRep().booleanValue(),bean.getAddress1(),bean.getPostalAddress(),bean.getCity(),bean.getPassword(),bean.getEmail(),bean.getIsActive().booleanValue(),bean.getPhone(),bean.getRegionId().intValue(), bean.getRoleId().intValue(),country.get_ID(),bean.getUserPIN(),bean.getUserDiscount(),bean.getDocBasisType(),bean.getAmtMultiplier(),bean.getFrequencyType(),bean.getSubtractAmt(),bean.getIsFullAccess(),trx.getTrxName()); + trx.commit(); + } + catch(DuplicateUserPinException e) + { + trx.rollback(); + postGlobalError("error.duplicate.userpin", request); + return mapping.getInputForward(); + } + catch(UserAlreadyExistsException e) + { + trx.rollback(); + postGlobalError("error.usernameAlreadyUsed", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + request.getSession().setAttribute(Constants.USER_DETAILS,bean); + + return mapping.findForward(CREATE_USERS); + + } + + public static final String INIT_USERS = "initUser"; + public ActionForward initUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ApplicationException, FileNotFoundException, OperationException, IOException + { + ActionForward fwd = init(mapping,form,request,response); + if (fwd!=null) + return fwd; + + //DefaultForm df = (DefaultForm) form; + + // UDIBean bean = (UDIBean) df.getBean(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList roles = RoleManager.getAllRoles(ctx); + ArrayList regions = RegionKeyNamePair.getKeyNamePairs(ctx); + + request.getSession().setAttribute(Constants.ROLES, roles); + request.getSession().setAttribute(Constants.REGIONS, regions); + + return mapping.findForward(INIT_USERS); + } +} diff --git a/posterita/src/main/org/posterita/struts/user/UserAction.java b/posterita/src/main/org/posterita/struts/user/UserAction.java new file mode 100644 index 0000000000..cdb5765118 --- /dev/null +++ b/posterita/src/main/org/posterita/struts/user/UserAction.java @@ -0,0 +1,262 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 29, 2005 by praveen + * + */ +package org.posterita.struts.user; + +import java.util.ArrayList; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MCountry; +import org.compiere.util.Trx; + +import org.posterita.Constants; +import org.posterita.beans.UserBean; +import org.posterita.businesslogic.RoleManager; +import org.posterita.businesslogic.UserManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.core.TrxPrefix; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.DuplicateUserPinException; +import org.posterita.exceptions.OperationException; +import org.posterita.exceptions.UserAlreadyExistsException; +import org.posterita.form.UserForm; +import org.posterita.keyname.RegionKeyNamePair; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.struts.core.DefaultForm; + +public class UserAction extends BaseDispatchAction +{ + + public static final String CREATE_USER = "createUser"; + public ActionForward createUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + + UserBean bean = (UserBean) df.getBean(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + trx.start(); + try + { + MCountry country = MCountry.getDefault(ctx); + UserManager.createUser(ctx,bean.getUsername(),bean.getUsername(), bean.getIsSalesRep().booleanValue(),bean.getAddress1(),bean.getPostalAddress(),bean.getCity(),bean.getPassword(),bean.getEmail(),bean.getIsActive().booleanValue(),bean.getPhone(),bean.getRegionId().intValue(), bean.getRoleId().intValue(), country.get_ID(),bean.getUserPIN(),bean.getUserDiscount(),bean.getDocBasisType(),bean.getAmtMultiplier(),bean.getFrequencyType(),bean.getSubtractAmt(),bean.getIsFullAccess(),trx.getTrxName()); + trx.commit(); + } + catch(DuplicateUserPinException e) + { + trx.rollback(); + postGlobalError("error.duplicate.userpin", request); + return mapping.getInputForward(); + } + catch(UserAlreadyExistsException e) + { + trx.rollback(); + postGlobalError("error.usernameAlreadyUsed", request); + return mapping.getInputForward(); + } + finally + { + trx.close(); + } + + return mapping.findForward(CREATE_USER); + } + + public static final String EDIT_USER = "editUser"; + public ActionForward editUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + DefaultForm df = (DefaultForm) form; + + UserBean bean = (UserBean) df.getBean(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + Trx trx = Trx.get(TrxPrefix.getPrefix(), true); + + try + { + trx.start(); + UserManager.editUser(ctx,bean.getUserId().intValue(),bean.getRoleId().intValue(),bean.getPassword(),bean.getEmail(),bean.getPhone(),bean.getAddress1(),bean.getPostalAddress(),bean.getCity(),bean.getIsSalesRep().booleanValue(),bean.getIsActive().booleanValue(),bean.getUserPIN(),bean.getUserDiscount(),bean.getDocBasisType(),bean.getAmtMultiplier(),bean.getFrequencyType(),bean.getSubtractAmt(),bean.getIsFullAccess(),trx.getTrxName()); + trx.commit(); + } + catch(DuplicateUserPinException e) + { + trx.rollback(); + postGlobalError("error.duplicate.userpin", request); + return mapping.getInputForward(); + } + catch (OperationException e) + { + trx.rollback(); + postGlobalError("error.editing.user", request); + mapping.getInputForward(); + } + finally + { + trx.rollback(); + } + + return mapping.findForward(EDIT_USER); + } + + public static final String DELETE_USER = "deleteUser"; + public ActionForward deleteUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + UserForm uf = (UserForm) form; + + Properties ctx = TmkJSPEnv.getCtx(request); + + int userId = Integer.valueOf(uf.getUserId()).intValue(); + + UserManager.deleteUser(ctx,userId); + + return mapping.findForward(DELETE_USER); + } + + public static final String ACTIVATE_USER = "activateUser"; + public ActionForward activateUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + UserForm uf = (UserForm) form; + + Properties ctx = TmkJSPEnv.getCtx(request); + + int userId = Integer.valueOf(uf.getUserId()).intValue(); + + UserManager.activateUser(ctx,userId); + + return mapping.findForward(ACTIVATE_USER); + } + + public static final String INIT_CREATE_USER = "initCreateUser"; + public ActionForward initCreateUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList roles = RoleManager.getAllRoles(ctx); + + ArrayList regions = RegionKeyNamePair.getKeyNamePairs(ctx); + + request.getSession().setAttribute(Constants.ROLES,roles); + + request.getSession().setAttribute(Constants.REGIONS,regions); + + return mapping.findForward(INIT_CREATE_USER); + } + + public static final String INIT_EDIT_USER = "initEditUser"; + public ActionForward initEditUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + UserForm uf = (UserForm) form; + + int userId = Integer.valueOf(uf.getUserId()).intValue(); + + UserBean bean = UserManager.getUser(ctx,userId); + + uf.populate(bean); + + ArrayList roles = RoleManager.getAllRoles(ctx); + + request.getSession().setAttribute(Constants.ROLES,roles); + + request.getSession().setAttribute(Constants.USER_DETAILS,bean); + + return mapping.findForward(INIT_EDIT_USER); + } + + public static final String LIST_USERS = "listUsers"; + public ActionForward listUsers(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + ArrayList users = UserManager.getAllUsers(ctx); + + request.getSession().setAttribute(Constants.ALL_USERS,users); + + return mapping.findForward(LIST_USERS); + } + + public static final String VIEW_USER = "viewUser"; + public ActionForward viewUser(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException + { + ActionForward fwd = init(mapping,form,request,response); + + if (fwd!=null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + UserForm uf = (UserForm) form; + + int userId = Integer.valueOf(uf.getUserId()).intValue(); + + UserBean userBean = UserManager.getUser(ctx,userId); + + request.getSession().setAttribute(Constants.USER_DETAILS,userBean); + + return mapping.findForward(VIEW_USER); + } + +} diff --git a/posterita/src/main/org/posterita/taglib/BankName.java b/posterita/src/main/org/posterita/taglib/BankName.java new file mode 100644 index 0000000000..4db36852c9 --- /dev/null +++ b/posterita/src/main/org/posterita/taglib/BankName.java @@ -0,0 +1,92 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 11, 2005 by Praveen + */ + +package org.posterita.taglib; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.jsp.JspException; + +import org.apache.struts.taglib.bean.WriteTag; +import org.apache.struts.util.RequestUtils; + +import org.posterita.core.TmkJSPEnv; +import org.posterita.model.MBank; + +public class BankName extends WriteTag +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + + + public String formatValue(Object valueToFormat) throws JspException + { + if (valueToFormat instanceof Integer == false) + throw new JspException("Expected java.lang.Integer, obtained" + valueToFormat.getClass().getName()); + + Integer id = (Integer) valueToFormat; + + return format(id); + } + + private String format(Integer integerValueToFormat) + { + + if (integerValueToFormat == null) + return ""; + + HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + MBank bankName = new MBank(ctx, integerValueToFormat.intValue(),null); + + return bankName.getName(); + } + + + + @SuppressWarnings("deprecation") + public int doStartTag() throws JspException + { + + if (ignore) + { + if (RequestUtils.lookup(pageContext, name, scope) == null) + return (SKIP_BODY); + } + + Object value = RequestUtils.lookup(pageContext, name, property, scope); + if (value == null) + return (SKIP_BODY); + + String output = formatValue(value); + + org.apache.struts.util.ResponseUtils.write(pageContext, output); + + return (SKIP_BODY); + } + +} diff --git a/posterita/src/main/org/posterita/taglib/LinkAccess.java b/posterita/src/main/org/posterita/taglib/LinkAccess.java new file mode 100644 index 0000000000..6c299a5e94 --- /dev/null +++ b/posterita/src/main/org/posterita/taglib/LinkAccess.java @@ -0,0 +1,40 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.taglib; + +import javax.servlet.jsp.JspException; + +import org.apache.struts.taglib.logic.CompareTagBase; + + +public class LinkAccess extends CompareTagBase +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + protected boolean condition() throws JspException + { + return condition(0,0); + } + +} diff --git a/posterita/src/main/org/posterita/taglib/OrderStatus.java b/posterita/src/main/org/posterita/taglib/OrderStatus.java new file mode 100644 index 0000000000..62ad5a9074 --- /dev/null +++ b/posterita/src/main/org/posterita/taglib/OrderStatus.java @@ -0,0 +1,128 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on Mar 3, 2005 +*/ + +package org.posterita.taglib; + +import java.util.LinkedHashMap; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.jsp.JspException; + +import org.apache.struts.taglib.bean.WriteTag; +import org.apache.struts.util.RequestUtils; +import org.compiere.process.DocumentEngine; + +import org.posterita.core.UDIMap; +import org.posterita.user.WebUserInfo; + + + +public class OrderStatus extends WriteTag +{ + + /** + * + */ + private static final long serialVersionUID = 1L; + static LinkedHashMap webDocStatusMap; + static LinkedHashMap docStatusMap; + + static + { + webDocStatusMap = new LinkedHashMap(); + webDocStatusMap.putAll(UDIMap.docStatusMap); + } + + static + { + docStatusMap = new LinkedHashMap(); + docStatusMap.putAll(webDocStatusMap); + docStatusMap.put(DocumentEngine.STATUS_Approved,"Approved"); + docStatusMap.put(DocumentEngine.STATUS_NotApproved,"Not Approved"); + docStatusMap.put(DocumentEngine.STATUS_Reversed,"Reversed"); + docStatusMap.put(DocumentEngine.STATUS_Unknown,"??"); + docStatusMap.put(DocumentEngine.STATUS_WaitingPayment,"Waiting Payment"); + docStatusMap.put(DocumentEngine.STATUS_WaitingConfirmation,"Waiting Confirmation"); + docStatusMap.put(DocumentEngine.STATUS_Invalid,"Invalid"); + } + + + + public static LinkedHashMap getWebDocStatusMap() + { + return webDocStatusMap; + } + + public static void setWebDocStatusMap(LinkedHashMap webDocStatusMap) + { + OrderStatus.webDocStatusMap = webDocStatusMap; + } + + public String formatValue(Object valueToFormat) throws JspException + { + if (valueToFormat instanceof String == false) + throw new JspException("Expected java.lang.String, obtained" + valueToFormat.getClass().getName()); + + String strValueToFormat = (String) valueToFormat; + + return format(strValueToFormat); + } + + + + + + private String format(String strValueToFormat) + { + if (docStatusMap.containsKey(strValueToFormat)) + return (String) docStatusMap.get(strValueToFormat); + + + return (String) docStatusMap.get(DocumentEngine.STATUS_Unknown); + } + + + @SuppressWarnings("deprecation") + public int doStartTag() throws JspException + { + + HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); + + request.getSession().getAttribute(WebUserInfo.NAME); + + if (ignore) + { + if (RequestUtils.lookup(pageContext, name, scope) == null) + return (SKIP_BODY); + } + + Object value = RequestUtils.lookup(pageContext, name, property, scope); + if (value == null) + return (SKIP_BODY); + + String output = formatValue(value); + + org.apache.struts.util.ResponseUtils.write(pageContext, output); + + return (SKIP_BODY); + } + +} diff --git a/posterita/src/main/org/posterita/taglib/ProductName.java b/posterita/src/main/org/posterita/taglib/ProductName.java new file mode 100644 index 0000000000..7a7fc036bb --- /dev/null +++ b/posterita/src/main/org/posterita/taglib/ProductName.java @@ -0,0 +1,94 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 11, 2005 by Alok + */ + +package org.posterita.taglib; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.jsp.JspException; + +import org.apache.struts.taglib.bean.WriteTag; +import org.apache.struts.util.RequestUtils; +import org.compiere.model.MAttributeValue; + +import org.posterita.core.TmkJSPEnv; + +public class ProductName extends WriteTag +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + + + + public String formatValue(Object valueToFormat) throws JspException + { + if (valueToFormat instanceof Integer == false) + throw new JspException("Expected java.lang.Integer, obtained" + valueToFormat.getClass().getName()); + + Integer id = (Integer) valueToFormat; + + return format(id); + } + + private String format(Integer integerValueToFormat) + { + + if (integerValueToFormat == null) + return ""; + + HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); + + Properties ctx = TmkJSPEnv.getCtx(request); + + MAttributeValue attributeValue = new MAttributeValue(ctx, integerValueToFormat.intValue(),null); + + + return attributeValue.getName(); + } + + + + + @SuppressWarnings("deprecation") + public int doStartTag() throws JspException + { + + if (ignore) + { + if (RequestUtils.lookup(pageContext, name, scope) == null) + return (SKIP_BODY); + } + + Object value = RequestUtils.lookup(pageContext, name, property, scope); + if (value == null) + return (SKIP_BODY); + + String output = formatValue(value); + + org.apache.struts.util.ResponseUtils.write(pageContext, output); + + return (SKIP_BODY); + } +} diff --git a/posterita/src/main/org/posterita/user/WebUserInfo.java b/posterita/src/main/org/posterita/user/WebUserInfo.java new file mode 100644 index 0000000000..1fd630b930 --- /dev/null +++ b/posterita/src/main/org/posterita/user/WebUserInfo.java @@ -0,0 +1,318 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 11, 2005 by Alok + */ + +package org.posterita.user; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.model.MLocation; +import org.compiere.model.MOrg; +import org.compiere.model.MRole; +import org.compiere.model.MUser; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.KeyNamePair; +import org.compiere.util.Secure; +import org.compiere.util.WebInfo; +import org.compiere.util.WebUser; + +import org.posterita.exceptions.DataException; +import org.posterita.exceptions.OperationException; + + +/** + * @author fred + * + *This Info is breaking convention because it is using Info that calls some business logic when + *invoking it in the jsp. But should be fine for now. + * + */ +public class WebUserInfo +{ + + public static final String NAME = "webUserInfo"; + protected WebUser user; + protected WebInfo info; + protected Properties ctx; + protected String orgName; + protected String roleName; + protected Integer roleId; + protected Integer orgId; + protected ArrayList menuItem; + protected Integer unreadMessageCount; + protected Boolean canAlterOrder; + protected Boolean canCreateOrder; + protected Boolean canViewOrder; + + + + public Boolean getCanAlterOrder() { + return canAlterOrder; + } + public void setCanAlterOrder(Boolean canAlterOrder) { + this.canAlterOrder = canAlterOrder; + } + public Boolean getCanCreateOrder() { + return canCreateOrder; + } + public void setCanCreateOrder(Boolean canCreateOrder) { + this.canCreateOrder = canCreateOrder; + } + public Boolean getCanViewOrder() { + return canViewOrder; + } + public void setCanViewOrder(Boolean canViewOrder) { + this.canViewOrder = canViewOrder; + } + + public Integer getUnreadMessageCount() + { + return unreadMessageCount; + } + + public void setUnreadMessageCount(Integer unreadMessageCount) + { + this.unreadMessageCount = unreadMessageCount; + } + + public ArrayList getMenuItem() + { + return menuItem; + } + + public void setMenuItem(ArrayList menuItem) + { + this.menuItem = menuItem; + } + + public Integer getOrgId() + { + return orgId; + } + + public void setOrgId(Integer orgId) + { + this.orgId = orgId; + } + + + public Integer getRoleId() + { + return roleId; + } + + public void setRoleId(Integer roleId) + { + this.roleId = roleId; + Env.setContext(ctx,"#AD_Role_ID",roleId.intValue()); + } + public WebUserInfo(Properties ctx, WebUser user, WebInfo info) throws DataException, OperationException + { + this.user = user; + this.ctx =ctx; + this.info = info; + + MUser muser = new MUser(ctx, user.getAD_User_ID(), null); + + // TODO think about this Little hack +// Env.setContext(ctx, "#AD_Org_ID", muser.getAD_Org_ID()); + +// setOriginalUserID(ctx, muser); + + orgId = Integer.valueOf(muser.getAD_Org_ID()); + + KeyNamePair[] roles = getRoles(muser.getName(),muser.getPassword()); + + + if (roles == null || roles.length == 0) + throw new DataException("No role has been set for your user, Please check with your administrator to assign one for you."); + + /* + if (roles.length > 1 ) + throw new DataException("You have been assigned many roles. You are permitted to have one role only. Please check with your administrator"); + */ + + System.out.println("Role:" + roles[0].getName()); + setRoleId( Integer.valueOf(roles[0].getKey())); + setRoleName(); + + } + + /*public void setOriginalUserID(Properties ctx, MUser originalUser) + { + int originalUserID = Env.getContextAsInt(ctx, "#AD_OriginalUser_ID"); + + if (originalUserID == 0) + Env.setContext(ctx, "#AD_OriginalUser_ID", originalUser.getAD_User_ID()); + }*/ + + private KeyNamePair[] getRoles (String app_user, String app_pwd) throws OperationException + { + + if (app_user == null) + return null; + + KeyNamePair[] retValue = null; + ArrayList list = new ArrayList(); + // + String sql = "SELECT AD_User.AD_User_ID, AD_User.Description," + + " AD_Role.AD_Role_ID, AD_Role.Name " + + "FROM AD_User, AD_User_Roles, AD_Role " + + "WHERE AD_User.AD_User_ID=AD_User_Roles.AD_User_ID" + + " AND AD_User_Roles.AD_Role_ID=AD_Role.AD_Role_ID" + + " AND AD_User.Name=? AND AD_User.AD_CLIENT_ID=" + Env.getAD_Client_ID(ctx) // #1 + + " AND AD_User.IsActive='Y' AND AD_Role.IsActive='Y' AND AD_User_Roles.IsActive='Y'"; + if (app_pwd != null) + sql += " AND (AD_User.Password=? OR AD_User.Password=?)"; // #2/3 + sql += " ORDER BY AD_Role.Name"; + System.out.println(sql); + PreparedStatement pstmt = null; + try + { + pstmt = DB.prepareStatement(sql, null); + pstmt.setString(1, app_user); + if (app_pwd != null) + { + pstmt.setString(2, app_pwd); + pstmt.setString(3, new Secure().getDigest(app_pwd)); + } + // execute a query + ResultSet rs = pstmt.executeQuery(); + System.out.println(pstmt.toString()); + + while (rs.next()) + { + + int AD_Role_ID = rs.getInt("AD_Role_ID"); + String Name = rs.getString("Name"); + KeyNamePair p = new KeyNamePair(AD_Role_ID, Name); + list.add(p); + } + + rs.close(); + pstmt.close(); + pstmt = null; + // + retValue = new KeyNamePair[list.size()]; + list.toArray(retValue); + } + catch (SQLException ex) + { + ex.printStackTrace(); + retValue = null; + } + // + try + { + if (pstmt != null) + pstmt.close(); + pstmt = null; + } + catch (Exception e) + { + pstmt = null; + } + return retValue; + } // getRoles + + + /** + * @return Returns the info. + */ + public WebInfo getInfo() + { + return info; + } + /** + * @param info The info to set. + */ + public void setInfo(WebInfo info) + { + this.info = info; + } + /** + * @return Returns the user. + */ + public WebUser getUser() + { + return user; + } + /** + * @param user The user to set. + */ + public void setUser(WebUser user) + { + this.user = user; + } + + public String getOrgName() + { + if (orgName ==null) + { + MUser muser = new MUser(ctx,user.getAD_User_ID(),null); + MOrg org = new MOrg (ctx,muser.getAD_Org_ID(),null); + orgName = org.getName(); + } + + return orgName; + + } + + public String getRoleName() + { + MRole role = new MRole(ctx, getRoleId().intValue(),null); + return role.getName(); + } + + + public MLocation getLocation() + { + + MUser muser = new MUser(ctx, user.getAD_User_ID(),null); + MOrg org = new MOrg(ctx,muser.getAD_Org_ID(),null); + //UDIMOrg udiMorg = new UDIMOrg(org); + /*ZZMOrg org =new ZZMOrg(ctx, muser.getAD_Org_ID()); + + MBPartnerLocation location = org.getLinkedPartner().getLocation(org.getLinkedPartner().getPrimaryC_BPartner_Location_ID()); + MLocation mlocation = location.getLocation(true);*/ + + int locationId = org.getInfo().getC_Location_ID(); + MLocation mlocation = MLocation.get(ctx, locationId, null); + return mlocation; + } + + +/* public boolean isMotorcycle() + { + ZZMOrg org = new ZZMOrg(ctx,getOrgId().intValue()); + return org.isMotorCycle(); + }*/ + + + + public void setRoleName() { + this.roleName = getRoleName(); + } +} diff --git a/posterita/src/main/org/posterita/util/AbstractPrintFormatter.java b/posterita/src/main/org/posterita/util/AbstractPrintFormatter.java new file mode 100644 index 0000000000..8d2fe6a446 --- /dev/null +++ b/posterita/src/main/org/posterita/util/AbstractPrintFormatter.java @@ -0,0 +1,176 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ +package org.posterita.util; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.StringTokenizer; + +import org.posterita.exceptions.OperationException; + + +/** + * @author alok + */ + +public abstract class AbstractPrintFormatter implements IPrintFormatter +{ + private Map arguments; + + protected int _lineWidth = 60; + protected int _halfLineWidth = 30; + protected String _lineTop= ""; + protected String _lineBottom = ""; + protected boolean _showLogo = false; + protected boolean _showBarcode = false; + protected boolean _showDiscount = false; + protected boolean _showFooter = false; + protected boolean _priceWithVat = false; + protected String _footerMessage = ""; + + protected String trxName = null; + + public AbstractPrintFormatter(String args) + { + parseArguments(args); + initFormatter(); + } + + private void parseArguments(String args) + { + arguments = new HashMap(); + + if( args == null || args.length() == 0) + { + return; + } + + StringTokenizer params = new StringTokenizer(args,";"); + StringTokenizer s = null; + + while(params.hasMoreTokens()) + { + s = new StringTokenizer(params.nextToken(), "="); + + if(s.hasMoreTokens()) + { + String key = s.nextToken(); + + if(s.hasMoreTokens()) + { + String value = s.nextToken(); + + arguments.put(key, value); + } + } + }//while + + } + + public String getArgumentValue(String argumentName) + { + if(arguments != null) + { + return arguments.get(argumentName); + } + + return null; + } + + protected void setArgumentValue(String argumentName, String value) throws OperationException + { + try + { + Field field = getClass().getField(argumentName); + Class c = field.getType().getClass(); + + Constructor con = c.getConstructor(new Class[]{String.class}); + Object obj = con.newInstance(new Object[]{value}); + + field.set(this,obj); + } + catch (Exception e) + { + throw new OperationException(e); + } + } + + public void initFormatter() + { + String value; + + value = getArgumentValue("showBarcode"); + if(value != null) + { + _showBarcode = Boolean.parseBoolean(value); + } + + value = getArgumentValue("showLogo"); + if(value != null) + { + _showLogo = Boolean.parseBoolean(value); + } + + value = getArgumentValue("LINE_LENGTH"); + if(value != null) + { + _lineWidth = Integer.parseInt(value); + } + + value = getArgumentValue("footer"); + if(value != null) + { + _footerMessage = value; + } + + value = getArgumentValue("showDiscount"); + if(value != null) + { + _showDiscount = Boolean.parseBoolean(value); + } + + value = getArgumentValue("showFooter"); + if(value != null) + { + _showFooter = Boolean.parseBoolean(value); + } + + value = getArgumentValue("priceWithVat"); + if(value != null) + { + _priceWithVat = Boolean.parseBoolean(value); + } + + String lineSeparator = ""; + + for(int i = 0; i < _lineWidth; i++) + { + lineSeparator = lineSeparator + "-"; + } + + _lineTop = lineSeparator; + _lineBottom = lineSeparator; + + _halfLineWidth = _lineWidth/2; + } +} diff --git a/posterita/src/main/org/posterita/util/BarcodeFormatter.java b/posterita/src/main/org/posterita/util/BarcodeFormatter.java new file mode 100644 index 0000000000..d0ad551976 --- /dev/null +++ b/posterita/src/main/org/posterita/util/BarcodeFormatter.java @@ -0,0 +1,154 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 04-Oct-2006 09:52:44 by praveen + * + */ + +package org.posterita.util; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.posterita.beans.PrintBarcodeBean; +import org.posterita.exceptions.FormattingException; +import org.posterita.formatter.Formatter; + +public class BarcodeFormatter extends Formatter +{ + boolean showPrice = true; + boolean showTitle = true; + boolean showSubtitle = true; + + public Object format(Object target) throws FormattingException + { + + PrintBarcodeBean bean = null; + bean = (PrintBarcodeBean) target; + + int qty = 0; + String title = null; + String barcode = null; + String price = null; + String subtitle = null; + + title = bean.getTitle(); + barcode = bean.getBarcode(); + price = bean.getPrice(); + subtitle = bean.getSubtitle(); + qty = bean.getQty(); + + //setting defaults if params are null + title = ( title == null ) ? "" : title; + barcode = ( barcode == null ) ? "" : barcode; + price = ( price == null ) ? "" : price; + subtitle = ( subtitle == null ) ? "" : subtitle; + qty = ( qty == 0 ) ? 1 : qty; + + StringWriter sw = new StringWriter(); + PrintWriter w = new PrintWriter(sw); + + w.println("^Q24,3"); + w.println("^W75"); + w.println("^H10"); + w.println("^P1"); + w.println("^S4"); + w.println("^AD"); + w.println("^C$qty"); //<-- qty + w.println("^R2"); + w.println("~Q+3"); + w.println("^O0"); + w.println("^D0"); + w.println("^E10"); + w.println("~R200"); + w.println("^L"); + w.println("Dy2-me-dd"); + w.println("Th:m:s"); + + if( showTitle ) + { + w.println("AA,22,12,1,1,0,0,$title"); //<--title1 + w.println("AA,22,12,1,1,0,0,$title"); //<--title1 + } + + w.println("BE,42,62,2,5,100,0,1,$barcode"); //<--barcode + w.println("BE,42,62,2,5,100,0,1,$barcode"); //<--barcode + + if( showPrice ) + { + w.println("AC,222,27,1,1,0,0,$price"); //<-- price + w.println("AC,222,27,1,1,0,0,$price"); //<-- price + } + + if( showSubtitle ) + { + w.println("AA,22,32,1,1,0,0,$subtitle"); //<-- title2 + w.println("AA,22,32,1,1,0,0,$subtitle"); //<-- title2 + } + + w.println("E"); + w.flush(); + + String printData = sw.getBuffer().toString(); + + printData = printData.replace("$qty", qty+""); + printData = printData.replace("$title", title); + printData = printData.replace("$subtitle", subtitle); + printData = printData.replace("$barcode", barcode); + printData = printData.replace("$price", price); + + return printData; + } + + + public Object unformat(Object target) throws FormattingException + { + throw new FormattingException("Operartion not supported"); + } + + + public boolean isShowPrice() { + return showPrice; + } + + + public void setShowPrice(boolean showPrice) { + this.showPrice = showPrice; + } + + + public boolean isShowSubtitle() { + return showSubtitle; + } + + + public void setShowSubtitle(boolean showSubtitle) { + this.showSubtitle = showSubtitle; + } + + + public boolean isShowTitle() { + return showTitle; + } + + + public void setShowTitle(boolean showTitle) { + this.showTitle = showTitle; + } + +} diff --git a/posterita/src/main/org/posterita/util/IPrintFormatter.java b/posterita/src/main/org/posterita/util/IPrintFormatter.java new file mode 100644 index 0000000000..cc328ab18c --- /dev/null +++ b/posterita/src/main/org/posterita/util/IPrintFormatter.java @@ -0,0 +1,33 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ +package org.posterita.util; + +import java.util.Properties; + +/** + * @author alok + */ + +public interface IPrintFormatter +{ + public String format(Properties ctx,int recordId, Object ...args) throws Exception; +} + diff --git a/posterita/src/main/org/posterita/util/InvoiceFormatter.java b/posterita/src/main/org/posterita/util/InvoiceFormatter.java new file mode 100644 index 0000000000..c0fcc30236 --- /dev/null +++ b/posterita/src/main/org/posterita/util/InvoiceFormatter.java @@ -0,0 +1,308 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Sep 26, 2006 + */ + + +package org.posterita.util; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; + +import org.compiere.model.MDocType; +import org.compiere.model.MInvoice; +import org.compiere.model.MLocation; +import org.compiere.model.MOrder; +import org.compiere.model.MOrg; +import org.compiere.model.MUser; + +import org.posterita.Constants; +import org.posterita.beans.BPartnerBean; +import org.posterita.beans.WebOrderLineBean; +import org.posterita.businesslogic.BPartnerManager; +import org.posterita.businesslogic.InvoiceManager; +import org.posterita.core.ContextId; +import org.posterita.exceptions.FormattingException; +import org.posterita.formatter.Formatter; +import org.posterita.lib.UdiConstants; + + +public class InvoiceFormatter extends Formatter +{ + + @Override + public Object format(Object target) throws FormattingException + { + + ContextId ctxId = (ContextId) target; + + Properties ctx = ctxId.getCtx(); + int recordId = ctxId.getId(); + + String title = null; + String customerName = null; + String salesRep = null; + String docStatus = null; + String payment = null; + String customerAddress = null; + String orderType=null; + //String dateOrdered = null; + String refNo = null; + + //load the order + MInvoice invoice = new MInvoice(ctx, recordId, null); + + String paymentRule = null; + + //setting payment + paymentRule = invoice.getPaymentRule(); + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_Cash)) + { + payment = Constants.PAYMENT_RULE_CASH; + } + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_CreditCard)) + { + payment = Constants.PAYMENT_RULE_CARD; + } + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_Check)) + { + payment = Constants.PAYMENT_RULE_CHEQUE; + } + + if(paymentRule.equalsIgnoreCase(UdiConstants.PAYMENTRULE_MIXED)) + { + payment = Constants.PAYMENT_RULE_MIXED; + } + //setting ref no + refNo = invoice.getDocumentNo(); + + //getting orgInfo + MOrg org = new MOrg(ctx,invoice.getAD_Org_ID(),null); + int location_id = org.getInfo().getC_Location_ID(); + MLocation location = new MLocation(ctx,location_id,null); + + + String address1 = (location.getAddress1() == null)? " " : location.getAddress1(); + String address2 = (location.getAddress2() == null)? " " : location.getAddress2(); + + //getting order type + int docTypeId = invoice.getC_DocType_ID(); + MDocType docType = new MDocType(ctx, docTypeId, null); + + orderType = docType.getName(); + + //getting orderInfo + docStatus = invoice.getDocStatusName(); + + + //getting salesrep + int saleRep_id = invoice.getSalesRep_ID(); + MUser user = new MUser(ctx,saleRep_id,null); + salesRep = user.getName(); + + //getting customer info + int bpartner_id = invoice.getC_BPartner_ID(); + BPartnerBean bean; + try + { + bean = BPartnerManager.getBpartner(ctx,bpartner_id,null); + } + catch(Exception e) + { + throw new FormattingException("Formatting",e); + } + + + String name1 = (bean.getPartnerName() == null)? " " : bean.getPartnerName(); + String name2 = (bean.getName2() == null)? " " : bean.getName2(); + customerName = (name1 + " " + name2).trim(); + + address1 = (bean.getAddress1() == null)? " " : bean.getAddress1(); + address2 = (bean.getAddress2() == null)? " " : bean.getAddress2(); + customerAddress = (address1 + " " + address2).trim(); + + + ///////////////////////////////drawing the order//////////////////////////////// + StringBuffer reportData = new StringBuffer(TmkPrinterConstants.LOGO1); + //adding title + title = orderType; + reportData.append(TmkPrinterConstants.BIG_FONT) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(title) + .append(TmkPrinterConstants.LINE_FEED); + + //setting small font + reportData.append(TmkPrinterConstants.SMALL_FONT); + reportData.append(TmkPrinterConstants.LEFT_ALIGN); + + //adding customer name + customerName = String.format("%1$-30s",customerName); + reportData.append(customerName); + + //adding sales rep + salesRep = "Sales Rep:" + salesRep; + salesRep = String.format("%1$30s",salesRep); + reportData.append(salesRep) + .append(TmkPrinterConstants.LINE_FEED); + + //adding customer address + customerAddress = String.format("%1$-60s",customerAddress); + reportData.append(customerAddress) + .append(TmkPrinterConstants.LINE_FEED); + + //adding status + docStatus = "Status:" + docStatus; + docStatus = String.format("%1$-60s",docStatus); + reportData.append(docStatus) + .append(TmkPrinterConstants.LINE_FEED); + + //adding payment + payment = "Payment:" + payment; + payment = String.format("%1$-60s",payment); + reportData.append(payment) + .append(TmkPrinterConstants.LINE_FEED); + + //adding reference no + refNo = "Ref No:" + refNo; + refNo = String.format("%1$-60s",refNo); + reportData.append(refNo) + .append(TmkPrinterConstants.LINE_FEED); + + //adding date + Calendar c = Calendar.getInstance(); + c.setTime(new Date(invoice.getCreated().getTime())); + String date = String.format("%1$te %1$tb,%1$tY %1$tH:%1$tM:%1$tS",c); + date = String.format("%1$-60s",date); + reportData.append(date) + .append(TmkPrinterConstants.LINE_FEED); + + //adding orderlines + //1.header + reportData.append(TmkPrinterConstants.H_FULL_LINE_TOP).append("\n"); + + String headerFormat = "" + + "%1$-40s" + + "%2$5s" + + "%3$5s" + + "%4$10s"; + + String header = String.format(headerFormat,"Name","Qty","","Total"); + reportData.append(header).append("\n"); + + reportData.append(TmkPrinterConstants.H_FULL_LINE_BOTTOM) + .append(TmkPrinterConstants.LINE_FEED); + + ArrayList invoiceLineList; + + //2.body + try + { + invoiceLineList = InvoiceManager.populateInvoiceLines(ctx,invoice,false); + } + catch(Exception e) + { + throw new FormattingException("Formatting Error", e); + } + + + String name = null; + int qty; + + BigDecimal taxAmt = null; + BigDecimal total; + + int totalQty = 0; + double grandTotal = 0.0d; + double totalTax = 0.0d; + String orderline = ""; + + String orderlineFormat = "" + + "%1$-40s" + + "%2$5d" + + "%3$5s" + + "%4$10.2f"; + + for(WebOrderLineBean wbean : invoiceLineList) + { + taxAmt = wbean.getTaxAmt(); + name = wbean.getDescription(); + qty = wbean.getQtyOrdered().intValue(); + total = wbean.getLineTotalAmt(); + + taxAmt = (taxAmt==null)? new BigDecimal(0.0) : taxAmt; + + totalQty += qty; + grandTotal += total.doubleValue(); + totalTax += taxAmt.doubleValue(); + + if(taxAmt.intValue() == 0) + { + name = name + "*"; + } + + orderline = String.format(orderlineFormat,name,qty,"",total); + reportData.append(orderline) + .append(TmkPrinterConstants.LINE_FEED); + } + + //3.footer + reportData.append(TmkPrinterConstants.H_FULL_LINE_BOTTOM) + .append(TmkPrinterConstants.LINE_FEED); + + String footerFormat = "" + + "%1$-40s" + + "%2$5d" + + "%3$5s" + + "%4$10.2f"; + + String footer = String.format(footerFormat,"Grand Total",totalQty,"Rs",grandTotal); + reportData.append(footer) + .append(TmkPrinterConstants.LINE_FEED); + + reportData.append(TmkPrinterConstants.H_FULL_LINE_TOP) + .append(TmkPrinterConstants.LINE_FEED); + + + String totalVAT = String.format("%1$.2f",totalTax); + String vat = String.format("%1$-60s","Total VAT:Rs"+totalVAT); + reportData.append(vat) + .append(TmkPrinterConstants.LINE_FEED); + + String noVAT = String.format("%1$-60s","* NO VAT"); + reportData.append(noVAT) + .append(TmkPrinterConstants.LINE_FEED) + .append(TmkPrinterConstants.PAPER_CUT); + + + return reportData.toString(); + } + + @Override + public Object unformat(Object target) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/posterita/src/main/org/posterita/util/ListUtil.java b/posterita/src/main/org/posterita/util/ListUtil.java new file mode 100644 index 0000000000..2f36dce1a1 --- /dev/null +++ b/posterita/src/main/org/posterita/util/ListUtil.java @@ -0,0 +1,44 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Created on Oct 3, 2006 by ashley +* +*/ + +/** + @author ashley + */ + +package org.posterita.util; + +import java.util.ArrayList; + +public class ListUtil +{ + public static ArrayList getListFromArray(T[] a) + { + ArrayList retList = new ArrayList(); + if(a != null) + { + for(T t : a) + retList.add(t); + } + return retList; + } +} diff --git a/posterita/src/main/org/posterita/util/MinOutFormatter.java b/posterita/src/main/org/posterita/util/MinOutFormatter.java new file mode 100644 index 0000000000..79d0122ed2 --- /dev/null +++ b/posterita/src/main/org/posterita/util/MinOutFormatter.java @@ -0,0 +1,44 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Sep 26, 2006 + */ + + +package org.posterita.util; + +import org.posterita.formatter.Formatter; + + +public class MinOutFormatter extends Formatter +{ + + @Override + public Object format(Object target) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object unformat(Object target) { + // TODO Auto-generated method stub + return null; + } + + +} diff --git a/posterita/src/main/org/posterita/util/OrderFormatter.java b/posterita/src/main/org/posterita/util/OrderFormatter.java new file mode 100644 index 0000000000..002bb98d87 --- /dev/null +++ b/posterita/src/main/org/posterita/util/OrderFormatter.java @@ -0,0 +1,524 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Sep 26, 2006 + */ + + +package org.posterita.util; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; +import java.util.ResourceBundle; + +import org.compiere.model.MBPartner; +import org.compiere.model.MLocation; +import org.compiere.model.MOrder; +import org.compiere.model.MOrg; +import org.compiere.model.MPayment; +import org.compiere.model.MUser; + +import org.posterita.Constants; +import org.posterita.beans.BPartnerBean; +import org.posterita.beans.OrderLineBean; +import org.posterita.beans.WebOrderLineBean; +import org.posterita.businesslogic.BPartnerManager; +import org.posterita.businesslogic.OrganisationManager; +import org.posterita.businesslogic.POSManager; +import org.posterita.core.ContextId; +import org.posterita.exceptions.FormattingException; +import org.posterita.exceptions.OperationException; +import org.posterita.formatter.Formatter; +import org.posterita.lib.UdiConstants; +import org.posterita.order.UDIOrderTypes; + +import org.posterita.util.TmkPrinterConstants; + + +public class OrderFormatter extends Formatter +{ + private boolean isVatIncluded = true; + + @Override + public Object format(Object target) throws FormattingException + { + ResourceBundle messageResource = ResourceBundle.getBundle("MessageResources"); + + String vatRegNumber = "VAT Reg No:" + messageResource.getString("receipt.VATRegNo"); + String companyName1 = messageResource.getString("receipt.company.name1"); + String companyName2 = messageResource.getString("receipt.company.name2"); + String companyPhone = messageResource.getString("receipt.company.phone"); + String companyAddress = messageResource.getString("receipt.company.address"); + + ContextId ctxId = (ContextId) target; + + Properties ctx = ctxId.getCtx(); + int id = ctxId.getId(); + + //setting receipt header + try + { + MOrg myorg = OrganisationManager.getMyOrg(ctx); + int bpartnerId = myorg.getLinkedC_BPartner_ID(null); + + + MBPartner bpartner = BPartnerManager.loadBPartner(ctx,bpartnerId,null); + BPartnerBean bean = BPartnerManager.getBpartner(ctx, bpartnerId, null); + + vatRegNumber = bpartner.getTaxID(); + companyName1 = bean.getPartnerName(); + companyName2 = bean.getName2(); + companyPhone = bean.getPhone(); + + String add = bean.getAddress1(); + add = (add==null) ? "" : add; + + companyAddress = add; + + add = bean.getAddress2(); + + if(add!=null){ + companyAddress = companyAddress + " " + add; + } + + add = bean.getCity(); + add = (add==null) ? "" : add; + + companyAddress = companyAddress + ", " + add; + + + } catch (OperationException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + String title = null; + String customerName = null; + String salesRep = null; + String docStatus = null; + String payment = null; + String customerAddress = null; + String orderType=null; + //String dateOrdered = null; + String refNo = null; + + //load the order + MOrder order = new MOrder(ctx, id, null); + + String paymentRule = null; + + //setting payment + paymentRule = order.getPaymentRule(); + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_Cash)) + { + payment = Constants.PAYMENT_RULE_CASH; + } + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_CreditCard)) + { + payment = Constants.PAYMENT_RULE_CARD; + } + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_Check)) + { + payment = Constants.PAYMENT_RULE_CHEQUE; + } + + if(paymentRule.equalsIgnoreCase(UdiConstants.PAYMENTRULE_MIXED)) + { + payment = Constants.PAYMENT_RULE_MIXED; + } + //setting ref no + refNo = order.getDocumentNo(); + + //getting orgInfo + MOrg org = new MOrg(ctx,order.getAD_Org_ID(),null); + int location_id = org.getInfo().getC_Location_ID(); + MLocation location = new MLocation(ctx,location_id,null); + + // orgName = org.getName(); + + String address1 = (location.getAddress1() == null)? " " : location.getAddress1(); + String address2 = (location.getAddress2() == null)? " " : location.getAddress2(); + // orgAddress = (address1 + " " + address2).trim(); + + //getting order type + orderType = order.getOrderType(); + + //getting orderInfo + docStatus = order.getDocStatusName(); + + + //getting salesrep + int saleRep_id = order.getSalesRep_ID(); + MUser user = new MUser(ctx,saleRep_id,null); + salesRep = user.getName(); + + //getting customer info + int bpartner_id = order.getBill_BPartner_ID(); + BPartnerBean bean; + try + { + bean = BPartnerManager.getBpartner(ctx,bpartner_id,null); + } + catch(Exception e) + { + throw new FormattingException("Formatting Error", e); + } + + + String name1 = (bean.getPartnerName() == null)? " " : bean.getPartnerName(); + String name2 = (bean.getName2() == null)? " " : bean.getName2(); + customerName = (name1 + " " + name2).trim(); + + address1 = (bean.getAddress1() == null)? " " : bean.getAddress1(); + address2 = (bean.getAddress2() == null)? " " : bean.getAddress2(); + customerAddress = (address1 + " " + address2).trim(); + + + ///////////////////////////////drawing the order//////////////////////////////// + StringBuffer reportData = new StringBuffer(TmkPrinterConstants.LOGO1); + //adding header + reportData.append(TmkPrinterConstants.SMALL_FONT) + .append(TmkPrinterConstants.H_FULL_LINE_TOP) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(TmkPrinterConstants.LINE_FEED); + + if(companyName1!=null) + reportData.append(TmkPrinterConstants.FONT_DOUBLE) + .append(companyName1) + .append(TmkPrinterConstants.LINE_FEED); + + if(companyName2!=null) + reportData.append(TmkPrinterConstants.CENTER_ALIGN) + .append(TmkPrinterConstants.BIG_FONT) + .append("(" + companyName2 + ")") + .append(TmkPrinterConstants.LINE_FEED); + + if(companyAddress!=null) + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append(companyAddress) + .append(TmkPrinterConstants.LINE_FEED); + + if(companyPhone!=null) + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append("Tel:" + companyPhone) + .append(TmkPrinterConstants.LINE_FEED); + + if(vatRegNumber!=null) + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append("VAT Reg No:" + vatRegNumber) + .append(TmkPrinterConstants.LINE_FEED); + + reportData.append(TmkPrinterConstants.SMALL_FONT) + .append(TmkPrinterConstants.H_FULL_LINE_TOP) + .append(TmkPrinterConstants.LINE_FEED); + + //adding title + title = orderType; + reportData.append(TmkPrinterConstants.BIG_FONT) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(title) + .append(TmkPrinterConstants.LINE_FEED); + + //setting small font + reportData.append(TmkPrinterConstants.SMALL_FONT); + reportData.append(TmkPrinterConstants.LEFT_ALIGN); + + //adding customer name + customerName = String.format("%1$-30s",customerName); + reportData.append(customerName); + + //adding sales rep + salesRep = "Sales Rep:" + salesRep; + salesRep = String.format("%1$30s",salesRep); + reportData.append(salesRep) + .append(TmkPrinterConstants.LINE_FEED); + + //adding customer address + customerAddress = String.format("%1$-60s",customerAddress); + reportData.append(customerAddress) + .append(TmkPrinterConstants.LINE_FEED); + + //adding status + docStatus = "Status:" + docStatus; + docStatus = String.format("%1$-60s",docStatus); + reportData.append(docStatus) + .append(TmkPrinterConstants.LINE_FEED); + + //adding payment + payment = "Payment:" + payment; + payment = String.format("%1$-60s",payment); + reportData.append(payment) + .append(TmkPrinterConstants.LINE_FEED); + + //adding reference no + refNo = "Ref No:" + refNo; + refNo = String.format("%1$-60s",refNo); + reportData.append(refNo) + .append(TmkPrinterConstants.LINE_FEED); + + //adding date + Calendar c = Calendar.getInstance(); + c.setTime(new Date(order.getCreated().getTime())); + String date = String.format("%1$te %1$tb,%1$tY %1$tH:%1$tM:%1$tS",c); + date = String.format("%1$-60s",date); + reportData.append(date) + .append(TmkPrinterConstants.LINE_FEED); + + //adding orderlines + //1.header + reportData.append(TmkPrinterConstants.H_FULL_LINE_TOP).append("\n"); + + String headerFormat = "" + + "%1$-30s" + + "%2$7s" + + "%3$5s" + + "%4$8s" + + "%5$10s"; + + String header = String.format(headerFormat,"Name","Unit","Qty","Dis","Total"); + reportData.append(header).append("\n"); + + reportData.append(TmkPrinterConstants.H_FULL_LINE_BOTTOM) + .append(TmkPrinterConstants.LINE_FEED); + + //2.body + ArrayList orderLineList; + try + { + orderLineList = POSManager.populateOrderLines(ctx,order); + } + catch(Exception e) + { + throw new FormattingException("Formatting Error", e); + } + + String name = null; + int qty; + BigDecimal discount = null; + BigDecimal taxAmt = null; + BigDecimal total; + BigDecimal unitPrice; + + int totalQty = 0; + double grandTotal = 0.0d; + double totalTax = 0.0d; + String orderline = ""; + + String orderlineFormat = "" + + "%1$-30s" + //1.product name OR description + "%2$7.2f" + //2.unit price + "%3$5d" + //3.quantity + "%4$8.2f" + //4.discount amount + "%5$10.2f"; //5.total price + + for(WebOrderLineBean wbean : orderLineList) + { + taxAmt = wbean.getTaxAmt(); + name = wbean.getDescription(); + qty = wbean.getQtyOrdered().intValue(); + discount = wbean.getDiscountPercentage(); + total = wbean.getLineTotalAmt(); + unitPrice = wbean.getUnitPrice(); + + if(isVatIncluded) + { + unitPrice = total.divide(new BigDecimal(qty)); + } + + + discount = (discount==null)? new BigDecimal(0.0) : discount; + taxAmt = (taxAmt==null)? new BigDecimal(0.0) : taxAmt; + + double discountAmt = 0.0; + discountAmt = (total.doubleValue() * 100.0)/(100.0 - discount.doubleValue()) - total.doubleValue(); + + totalQty += qty; + grandTotal += total.doubleValue(); + totalTax += taxAmt.doubleValue(); + + if(taxAmt.intValue() == 0) + { + name = name + "*"; + } + + orderline = String.format(orderlineFormat,name,unitPrice,qty,discountAmt,total); + reportData.append(orderline) + .append(TmkPrinterConstants.LINE_FEED); + } + + //3.footer + reportData.append(TmkPrinterConstants.H_FULL_LINE_BOTTOM) + .append(TmkPrinterConstants.LINE_FEED); + + String footerFormat = "" + + "%1$-37s" + + "%2$5d" + + "%3$8s" + + "%4$10.2f"; + + String footer = String.format(footerFormat,"Grand Total",totalQty,"Rs",grandTotal); + reportData.append(footer) + .append(TmkPrinterConstants.LINE_FEED); + + reportData.append(TmkPrinterConstants.H_FULL_LINE_TOP) + .append(TmkPrinterConstants.LINE_FEED); + + + //4.amount tendered & refunded + BigDecimal cashAmountTendered = order.getAmountTendered(); + if(cashAmountTendered == null) + { + cashAmountTendered = new BigDecimal(0.0); + } + + BigDecimal cashAmountRefunded = order.getAmountRefunded(); + if(cashAmountRefunded == null) + { + cashAmountRefunded = new BigDecimal(0.0); + } + + BigDecimal cardAmountTendered = null; + BigDecimal chequeAmountTendered = null; + + OrderLineBean orderLineBean = null; + if(ctxId.getBean() != null) + { + orderLineBean = (OrderLineBean) ctxId.getBean(); + Double cardAmt = orderLineBean.getPaymentByCard(); + Double chequeAmt = orderLineBean.getPaymentByChq(); + + if(cardAmt == null) + { + cardAmountTendered = new BigDecimal(0.0d); + } + else + { + cardAmountTendered = new BigDecimal(cardAmt.doubleValue()); + } + + if(chequeAmt == null) + { + chequeAmountTendered = new BigDecimal(0.0d); + } + else + { + chequeAmountTendered = new BigDecimal(chequeAmt.doubleValue()); + } + } + else + { + + if(order.getOrderType().equalsIgnoreCase(UDIOrderTypes.POS_ORDER.getOrderType())) + { + try + { + cardAmountTendered = POSManager.getPayment(ctx, order.get_ID(),MPayment.TENDERTYPE_CreditCard,null); + chequeAmountTendered = POSManager.getPayment(ctx, order.get_ID(),MPayment.TENDERTYPE_Check,null); + } + catch (OperationException e) + { + throw new FormattingException("Cannot get payment",e); + } + } + else + { + cardAmountTendered = new BigDecimal(0.0d); + chequeAmountTendered = new BigDecimal(0.0d); + } + + } + + String amountTendered = String.format("%1$45s%2$4s:%3$10.2f","Cash Tendered","Rs",cashAmountTendered); + String amountRefunded = String.format("%1$45s%2$4s:%3$10.2f","Cash Refunded","Rs",cashAmountRefunded); + + String seperator = String.format("%1$45s%2$15s","","------------"); + + String cardTendered = String.format("%1$45s%2$4s:%3$10.2f","Card Tendered","Rs",cardAmountTendered); + String chequeTendered = String.format("%1$45s%2$4s:%3$10.2f","Cheque Tendered","Rs",chequeAmountTendered); + + if(cashAmountTendered.doubleValue() > 0.0d) + { + reportData.append(amountTendered).append(TmkPrinterConstants.LINE_FEED); + } + + if(cardAmountTendered.doubleValue() > 0.0d) + { + reportData.append(cardTendered).append(TmkPrinterConstants.LINE_FEED); + } + + if(chequeAmountTendered.doubleValue() > 0.0d) + { + reportData.append(chequeTendered).append(TmkPrinterConstants.LINE_FEED); + } + + if(cashAmountTendered.doubleValue() > 0.0d) + { + reportData.append(seperator).append(TmkPrinterConstants.LINE_FEED); + reportData.append(amountRefunded).append(TmkPrinterConstants.LINE_FEED); + } + + + String totalVAT = String.format("%1$.2f",totalTax); + String vat = String.format("%1$-60s","Total VAT:Rs"+totalVAT); + reportData.append(vat) + .append(TmkPrinterConstants.LINE_FEED); + + String noVAT = String.format("%1$-60s","* NO VAT"); + + //barcode + String barcode = ((char)0x1d ) + "H" + (char)2 + ((char)0x1d ) + "k" + (char)4 + order.getDocumentNo() + (char)0; + String barcodeDim = ((char)0x1d) + "h" + (char)50 + ((char)0x1d) + "w" + (char)3; + + reportData.append(noVAT) + .append(TmkPrinterConstants.LINE_FEED) + .append(TmkPrinterConstants.LINE_FEED) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(barcodeDim) + .append(barcode) + .append(TmkPrinterConstants.LINE_FEED) + .append(TmkPrinterConstants.FONT_NORMAL) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append("*** Thank you ***") + .append(TmkPrinterConstants.LINE_FEED); + + if( order.getOrderType().equalsIgnoreCase(UDIOrderTypes.POS_ORDER.getOrderType()) ) + { + reportData.append(TmkPrinterConstants.LINE_FEED) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(TmkPrinterConstants.FONT_SMALL) + .append("*Goods once sold cannot be returned."); + } + + reportData.append(TmkPrinterConstants.PAPER_CUT) + .append(TmkPrinterConstants.LINE_FEED); + + + return reportData.toString(); + } + + @Override + public Object unformat(Object target) { + throw new RuntimeException("Method not implemented"); + } +} diff --git a/posterita/src/main/org/posterita/util/PathInfo.java b/posterita/src/main/org/posterita/util/PathInfo.java new file mode 100644 index 0000000000..8905bd31a4 --- /dev/null +++ b/posterita/src/main/org/posterita/util/PathInfo.java @@ -0,0 +1,50 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* Created on Mar 15, 2006 by ashley +* +*/ + +package org.posterita.util; + +import javax.servlet.Servlet; +import javax.servlet.ServletContext; + +public class PathInfo +{ + + public static String PROJECT_HOME = ""; + public static final String FILE_SEPARATOR = System.getProperty("file.separator"); + static + { + PROJECT_HOME = System.getProperty("user.dir"); + } + + public static void setPathInfo(Servlet servlet) + { + ServletContext serCtx = servlet.getServletConfig().getServletContext(); + + try + { + PROJECT_HOME = serCtx.getRealPath("") + FILE_SEPARATOR; + } + catch(Exception ex) + {} + + } +} diff --git a/posterita/src/main/org/posterita/util/PaymentFormatter.java b/posterita/src/main/org/posterita/util/PaymentFormatter.java new file mode 100644 index 0000000000..1f46bdea1a --- /dev/null +++ b/posterita/src/main/org/posterita/util/PaymentFormatter.java @@ -0,0 +1,43 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Sep 26, 2006 + */ + + +package org.posterita.util; + +import org.posterita.formatter.Formatter; + + +public class PaymentFormatter extends Formatter +{ + + @Override + public Object format(Object target) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object unformat(Object target) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/posterita/src/main/org/posterita/util/PoManager.java b/posterita/src/main/org/posterita/util/PoManager.java new file mode 100644 index 0000000000..3bde03ab0c --- /dev/null +++ b/posterita/src/main/org/posterita/util/PoManager.java @@ -0,0 +1,72 @@ +/** + * + * Copyright (c) 2007 Posterita. All Rights Reserved. + * + * This software is the confidential and proprietary information of + * Posterita. ("Confidential Information"). You shall not + * disclose such Confidential Information and shall use it only in + * accordance with the terms of the license agreement you entered into + * with Posterita. + * + * POSTERITA MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE + * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR + * A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. Posterita SHALL NOT + * BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, + * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + * + * May 22, 2007 11:46:27 AM by praveen + * + */ + +package org.posterita.util; + +import org.compiere.model.PO; +import org.compiere.util.CLogger; +import org.compiere.util.ValueNamePair; +import org.posterita.exceptions.OperationException; + +public class PoManager +{ + public static void save(PO po) throws OperationException + { + boolean saved = po.save(); + if(! saved ) + { + handleError(po); + } + } + + public static void save(PO po, String trxName) throws OperationException + { + boolean saved = po.save(trxName); + if(! saved ) + { + handleError(po); + } + + } + + private static void handleError(PO po) throws OperationException + { + Exception ex = CLogger.retrieveException(); + ValueNamePair error = CLogger.retrieveError(); + String msg = null; + if(error != null) + { + msg = error.getName(); + } + + if(ex != null) + { + throw new OperationException("Cannot save PO object. " + po.getClass().getName() + " Cause: " + ex.getMessage()); + } + + if(msg != null) + { + throw new OperationException("Cannot save PO object. " + po.getClass().getName() + " Cause: " + msg); + } + + throw new OperationException("Cannot save PO object. " + po.getClass().getName()); + } +} diff --git a/posterita/src/main/org/posterita/util/RegenerateModels.java b/posterita/src/main/org/posterita/util/RegenerateModels.java new file mode 100644 index 0000000000..281b99ab88 --- /dev/null +++ b/posterita/src/main/org/posterita/util/RegenerateModels.java @@ -0,0 +1,119 @@ +/* +* +* Copyright (c) 2007 Tamak ICT Ltd. All Rights Reserved. +* +* This software is the confidential and proprietary information of +* Tamak ICT Ltd. ("Confidential Information"). You shall not +* disclose such Confidential Information and shall use it only in +* accordance with the terms of the license agreement you entered into +* with Tamak ICT. +* +* Tamak ICT MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE +* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT +* NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR +* A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. Tamak ICT SHALL NOT +* BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, +* MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. +* +* Created on Feb 6, 2007 by ashley +* +*/ + +/** + @author ashley + */ + +package org.posterita.util; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.logging.Level; + +import org.adempiere.util.ModelClassGenerator; +import org.adempiere.util.ModelInterfaceGenerator; +import org.compiere.Adempiere; +import org.compiere.util.CLogMgt; +import org.compiere.util.DB; + +public class RegenerateModels +{ + + private static final ArrayList tables = new ArrayList(); + private static final String PACKAGE_NAME = "org.compiere.model"; + private static final String DIRECTORY = PathInfo.PROJECT_HOME + "/base/src/org/compiere/model/"; + + static + { + tables.add("U_MENU"); + tables.add("U_ROLE_MENU"); + tables.add("U_WEB_PROPERTIES"); + tables.add("U_BlackListCheque"); + tables.add("C_ORDER"); + tables.add("AD_USER"); + tables.add("AD_ROLE"); + tables.add("M_PRODUCT"); + tables.add("AD_PRINTFORMAT"); + } + + public static void main(String args[]) throws Exception + { + Adempiere.startupEnvironment(true); + CLogMgt.setLevel(Level.FINE); + + StringBuffer sqlStmt = new StringBuffer(); + + StringBuffer tableNames = new StringBuffer(); + + for (String tblName : tables) + { + tableNames.append(", '").append(tblName).append("'"); + } + + if (tableNames.length() > 0 && tables.size() > 0) + { + String tableInStmt = tableNames.substring(1); + tableInStmt = tableInStmt.toUpperCase(); + + String entityType = "'U','A','D','EXT'"; + sqlStmt.append("SELECT AD_Table_ID from AD_Table where "); + sqlStmt.append(" (TableName IN ('RV_WarehousePrice','RV_BPartner')"); + sqlStmt.append(" OR IsView='N')"); + sqlStmt.append(" AND Upper(TableName) in (").append(tableInStmt).append(") and"); + sqlStmt.append(" EntityType in (").append(entityType).append(")"); + sqlStmt.append(" ORDER BY TableName"); + + PreparedStatement pstmt = null; + try + { + pstmt = DB.prepareStatement(sqlStmt.toString(), null); + ResultSet rs = pstmt.executeQuery(); + while (rs.next()) + { + int tableId = rs.getInt(1); + new ModelInterfaceGenerator(tableId, DIRECTORY, PACKAGE_NAME); + new ModelClassGenerator(tableId, DIRECTORY, PACKAGE_NAME); + } + rs.close(); + } + catch (SQLException ex) + { + throw ex; + } + finally + { + if (pstmt != null) + { + try + { + pstmt.close(); + } + catch (Exception ex){} + } + } + + } + + } +} diff --git a/posterita/src/main/org/posterita/util/TMKInvoicePrintFormatter.java b/posterita/src/main/org/posterita/util/TMKInvoicePrintFormatter.java new file mode 100644 index 0000000000..e13f796288 --- /dev/null +++ b/posterita/src/main/org/posterita/util/TMKInvoicePrintFormatter.java @@ -0,0 +1,439 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 23, 2006 + */ + + +package org.posterita.util; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; + +import org.compiere.model.MBPartner; +import org.compiere.model.MDocType; +import org.compiere.model.MInvoice; +import org.compiere.model.MLocation; +import org.compiere.model.MOrder; +import org.compiere.model.MOrg; +import org.compiere.model.MUser; + +import org.posterita.Constants; +import org.posterita.beans.BPartnerBean; +import org.posterita.beans.WebOrderLineBean; +import org.posterita.businesslogic.BPartnerManager; +import org.posterita.businesslogic.InvoiceManager; +import org.posterita.businesslogic.OrganisationManager; +import org.posterita.exceptions.FormattingException; +import org.posterita.exceptions.OperationException; +import org.posterita.lib.UdiConstants; + + + +public class TMKInvoicePrintFormatter extends AbstractPrintFormatter +{ + public TMKInvoicePrintFormatter(String args) + { + super(args); + } + + public String format(Properties ctx, int recordId, Object... args) throws Exception + { + //----------------------------------------------------------------------------------------------------------------------------- + + //set some default values + String vatRegNumber = ""; + String companyName1 = ""; + String companyName2 = ""; + String companyPhone = ""; + String companyAddress = ""; + + //setting receipt header + try + { + MOrg myorg = OrganisationManager.getMyOrg(ctx); + int bpartnerId = myorg.getLinkedC_BPartner_ID(null); + + + MBPartner bpartner = BPartnerManager.loadBPartner(ctx,bpartnerId,null); + BPartnerBean bean = BPartnerManager.getBpartner(ctx, bpartnerId, null); + + vatRegNumber = bpartner.getTaxID(); + companyName1 = bean.getPartnerName(); + companyName2 = bean.getName2(); + companyPhone = bean.getPhone(); + + String add = bean.getAddress1(); + add = (add==null) ? "" : add; + + companyAddress = add; + + add = bean.getAddress2(); + + if(add!=null){ + companyAddress = companyAddress + " " + add; + } + + add = bean.getCity(); + add = (add==null) ? "" : add; + + companyAddress = companyAddress + ", " + add; + + + } catch (OperationException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + String title = null; + String customerName = null; + String salesRep = null; + String docStatus = null; + String payment = null; + String customerAddress = null; + String orderType=null; + //String dateOrdered = null; + String refNo = null; + + //load the order + MInvoice invoice = new MInvoice(ctx, recordId, null); + + String paymentRule = null; + + //setting payment + paymentRule = invoice.getPaymentRule(); + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_Cash)) + { + payment = Constants.PAYMENT_RULE_CASH; + } + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_CreditCard)) + { + payment = Constants.PAYMENT_RULE_CARD; + } + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_Check)) + { + payment = Constants.PAYMENT_RULE_CHEQUE; + } + + if(paymentRule.equalsIgnoreCase(UdiConstants.PAYMENTRULE_MIXED)) + { + payment = Constants.PAYMENT_RULE_MIXED; + } + //setting ref no + refNo = invoice.getDocumentNo(); + + //getting orgInfo + MOrg org = new MOrg(ctx,invoice.getAD_Org_ID(),null); + int location_id = org.getInfo().getC_Location_ID(); + MLocation location = new MLocation(ctx,location_id,null); + + + String address1 = (location.getAddress1() == null)? " " : location.getAddress1(); + String address2 = (location.getAddress2() == null)? " " : location.getAddress2(); + + //getting order type + int docTypeId = invoice.getC_DocType_ID(); + MDocType docType = new MDocType(ctx, docTypeId, null); + + orderType = docType.getName(); + + //getting orderInfo + docStatus = invoice.getDocStatusName(); + + + //getting salesrep + int saleRep_id = invoice.getSalesRep_ID(); + MUser user = new MUser(ctx,saleRep_id,null); + salesRep = user.getName(); + + //getting customer info + int bpartner_id = invoice.getC_BPartner_ID(); + BPartnerBean bean; + try + { + bean = BPartnerManager.getBpartner(ctx,bpartner_id,null); + } + catch(Exception e) + { + throw new FormattingException("Formatting",e); + } + + + String name1 = (bean.getPartnerName() == null)? " " : bean.getPartnerName(); + String name2 = (bean.getName2() == null)? " " : bean.getName2(); + customerName = (name1 + " " + name2).trim(); + + address1 = (bean.getAddress1() == null)? " " : bean.getAddress1(); + address2 = (bean.getAddress2() == null)? " " : bean.getAddress2(); + customerAddress = (address1 + " " + address2).trim(); + + + ///////////////////////////////drawing the order//////////////////////////////// + StringBuffer reportData = new StringBuffer();//TmkPrinterConstants.LOGO1); + + if(_showLogo) + { + reportData.append(TmkPrinterConstants.LOGO1); + } + + //adding header + reportData.append(TmkPrinterConstants.FONT_SMALL) + .append(_lineTop) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(TmkPrinterConstants.LINE_FEED); + + if(companyName1!=null) + reportData.append(TmkPrinterConstants.FONT_DOUBLE) + .append(companyName1) + .append(TmkPrinterConstants.LINE_FEED); + + if(companyName2.trim().length() > 0) + if(companyName2!=null) + reportData.append(TmkPrinterConstants.CENTER_ALIGN) + .append(TmkPrinterConstants.BIG_FONT) + .append("(" + companyName2 + ")") + .append(TmkPrinterConstants.LINE_FEED); + + if(companyAddress!=null) + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append(companyAddress) + .append(TmkPrinterConstants.LINE_FEED); + + if(companyPhone!=null) + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append("Tel:" + companyPhone) + .append(TmkPrinterConstants.LINE_FEED); + + if(vatRegNumber!=null) + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append("VAT Reg No:" + vatRegNumber) + .append(TmkPrinterConstants.LINE_FEED); + + reportData.append(TmkPrinterConstants.FONT_SMALL) + .append(_lineTop) + .append(TmkPrinterConstants.LINE_FEED); + + //adding title + title = "Invoice"; + reportData.append(TmkPrinterConstants.BIG_FONT) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(title) + .append(TmkPrinterConstants.LINE_FEED); + + //setting small font + reportData.append(TmkPrinterConstants.FONT_SMALL); + reportData.append(TmkPrinterConstants.LEFT_ALIGN); + + //adding customer name + customerName = String.format("%1$-" + _halfLineWidth + "s", customerName); + reportData.append(customerName); + + //adding sales rep + salesRep = "Sales Rep:" + salesRep; + salesRep = String.format("%1$"+ _halfLineWidth + "s", salesRep); + reportData.append(salesRep) + .append(TmkPrinterConstants.LINE_FEED); + + //adding customer address + customerAddress = String.format("%1$-" + _lineWidth + "s",customerAddress); + reportData.append(customerAddress) + .append(TmkPrinterConstants.LINE_FEED); + + //adding status + docStatus = "Status:" + docStatus; + docStatus = String.format("%1$-" + _lineWidth + "s",docStatus); + reportData.append(docStatus) + .append(TmkPrinterConstants.LINE_FEED); + + //adding payment + payment = "Payment:" + payment; + payment = String.format("%1$-" + _lineWidth + "s",payment); + reportData.append(payment) + .append(TmkPrinterConstants.LINE_FEED); + + //adding reference no + refNo = "Ref No:" + refNo; + refNo = String.format("%1$-" + _lineWidth + "s",refNo); + reportData.append(refNo) + .append(TmkPrinterConstants.LINE_FEED); + + //adding date + Calendar c = Calendar.getInstance(); + c.setTime(new Date(invoice.getCreated().getTime())); + String date = String.format("%1$te %1$tb,%1$tY %1$tH:%1$tM:%1$tS",c); + date = String.format("%1$-" + _lineWidth + "s",date); + reportData.append(date) + .append(TmkPrinterConstants.LINE_FEED); + + //adding orderlines + //1.header + reportData.append(_lineTop).append("\n"); + + String headerFormat = "%1$-" + (_lineWidth - ( 7 + 5 + 13 )) + "s" + + "%2$7s" + + "%3$5s" + + "%4$13s"; + + String header = String.format(headerFormat,"Name","Unit","Qty","Total"); + reportData.append(header).append("\n"); + + reportData.append(_lineBottom) + .append(TmkPrinterConstants.LINE_FEED); + + //2.body + ArrayList invoiceLineList; + try + { + invoiceLineList = InvoiceManager.populateInvoiceLines(ctx,invoice,false); + } + catch(Exception e) + { + throw new FormattingException("Formatting Error", e); + } + + String name = null; + int qty; + + BigDecimal taxAmt = null; + BigDecimal total; + BigDecimal unitPrice; + + int totalQty = 0; + double grandTotal = 0.0d; + double totalTax = 0.0d; + String orderline = ""; + + String orderlineFormat = "" + + "%1$-" + (_lineWidth - ( 7 + 5 + 13 )) + "s" + //1.product name OR description + "%2$7.2f" + //2.unit price + "%3$5d" + //3.quantity + "%4$13.2f"; //5.total price + + for(WebOrderLineBean wbean : invoiceLineList) + { + taxAmt = wbean.getTaxAmt(); + name = wbean.getDescription(); + qty = wbean.getQtyOrdered().intValue(); + total = wbean.getLineTotalAmt(); + unitPrice = wbean.getUnitPrice(); + + if( _priceWithVat ) + { + unitPrice = total.divide(wbean.getQtyOrdered()); + } + + if(name.length() > 10) + { + if(name.length() > 40) + name = name.substring(0,39); + + orderline = String.format("%1$-" + _lineWidth + "s", name); + reportData.append(orderline) + .append(TmkPrinterConstants.LINE_FEED); + + name = ""; + + } + + taxAmt = (taxAmt==null)? new BigDecimal(0.0) : taxAmt; + + totalQty += qty; + grandTotal += total.doubleValue(); + totalTax += taxAmt.doubleValue(); + + if(taxAmt.intValue() == 0) + { + name = name + "*"; + } + + orderline = String.format(orderlineFormat,name,unitPrice,qty,total); + reportData.append(orderline) + .append(TmkPrinterConstants.LINE_FEED); + } + + //3.footer + reportData.append(_lineBottom) + .append(TmkPrinterConstants.LINE_FEED); + + String footerFormat = "" + + "%1$-" + (_lineWidth - ( 5 + 3 + 10 )) + "s" + + "%2$5d" + + "%3$3s" + + "%4$10.2f"; + + String footer = String.format(footerFormat,"Grand Total",totalQty,"Rs",grandTotal); + reportData.append(footer) + .append(TmkPrinterConstants.LINE_FEED); + + reportData.append(_lineTop) + .append(TmkPrinterConstants.LINE_FEED); + + + String totalVAT = String.format("%1$.2f",totalTax); + String vat = String.format("%1$-" + _lineWidth + "s","Total VAT:Rs"+totalVAT); + reportData.append(vat) + .append(TmkPrinterConstants.LINE_FEED); + + String noVAT = String.format("%1$-" + _lineWidth + "s","* NO VAT"); + reportData.append(noVAT) + .append(TmkPrinterConstants.LINE_FEED) + .append(TmkPrinterConstants.LINE_FEED); + + if(_showBarcode) + { + String barcode = ((char)0x1d ) + "H" + (char)2 + ((char)0x1d ) + "k" + (char)4 + invoice.getDocumentNo() + (char)0; + String barcodeDim = ((char)0x1d) + "h" + (char)50 + ((char)0x1d) + "w" + (char)3; + reportData.append(TmkPrinterConstants.CENTER_ALIGN) + .append(barcodeDim) + .append(barcode) + .append(TmkPrinterConstants.LINE_FEED); + } + + + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append("*** Thank you ***") + .append(TmkPrinterConstants.LINE_FEED); + + + if(_showFooter) + if( _footerMessage.length() > 0 ) + { + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append(TmkPrinterConstants.LINE_FEED) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(_footerMessage) + .append(TmkPrinterConstants.LINE_FEED); + } + + reportData.append(TmkPrinterConstants.PAPER_CUT) + .append(TmkPrinterConstants.LINE_FEED); + + + return reportData.toString(); + + } + + +} diff --git a/posterita/src/main/org/posterita/util/TMKOrderPrintFormatter.java b/posterita/src/main/org/posterita/util/TMKOrderPrintFormatter.java new file mode 100755 index 0000000000..893337f747 --- /dev/null +++ b/posterita/src/main/org/posterita/util/TMKOrderPrintFormatter.java @@ -0,0 +1,641 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 23, 2006 + */ + + +package org.posterita.util; + +import java.io.OutputStream; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.http.HttpServletResponse; + +import org.compiere.model.MBPartner; +import org.compiere.model.MLocation; +import org.compiere.model.MOrder; +import org.compiere.model.MOrg; +import org.compiere.model.MPayment; +import org.compiere.model.MUser; + +import org.posterita.Constants; +import org.posterita.beans.BPartnerBean; +import org.posterita.beans.OrderLineBean; +import org.posterita.beans.WebOrderLineBean; +import org.posterita.businesslogic.BPartnerManager; +import org.posterita.businesslogic.OrganisationManager; +import org.posterita.businesslogic.POSManager; +import org.posterita.businesslogic.PrintManager; +import org.posterita.exceptions.FormattingException; +import org.posterita.exceptions.OperationException; +import org.posterita.lib.UdiConstants; +import org.posterita.order.UDIOrderTypes; + +import org.posterita.util.AbstractPrintFormatter; +import org.posterita.util.TmkPrinterConstants; + + + +public class TMKOrderPrintFormatter extends AbstractPrintFormatter +{ + public TMKOrderPrintFormatter(String args) + { + super(args); + } + + public TMKOrderPrintFormatter(String args, String trxName) + { + super(args); + this.trxName = trxName; + } + + public String format(Properties ctx, int recordId, Object... args) throws Exception + { + //require UDIBean + OrderLineBean orderLineBean = null; + if( args != null && args.length > 0) + { + orderLineBean = (OrderLineBean) args[0]; + } + + //----------------------------------------------------------------------------------------------------------------------------- + + //set some default values + String vatRegNumber = ""; + String companyName1 = ""; + String companyName2 = ""; + String companyPhone = ""; + String companyAddress = ""; + + //setting receipt header + try + { + MOrg myorg = OrganisationManager.getMyOrg(ctx); + int bpartnerId = myorg.getLinkedC_BPartner_ID(trxName); + + + MBPartner bpartner = BPartnerManager.loadBPartner(ctx,bpartnerId,trxName); + BPartnerBean bean = BPartnerManager.getBpartner(ctx, bpartnerId, trxName); + + vatRegNumber = bpartner.getTaxID(); + companyName1 = bean.getPartnerName(); + companyName2 = bean.getName2(); + companyPhone = bean.getPhone(); + + String add = bean.getAddress1(); + add = (add==null) ? "" : add; + + companyAddress = add; + + add = bean.getAddress2(); + + if(add!=null){ + companyAddress = companyAddress + " " + add; + } + + add = bean.getCity(); + add = (add==null) ? "" : add; + + companyAddress = companyAddress + ", " + add; + + + } catch (OperationException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + String title = null; + String customerName = null; + String salesRep = null; + String docStatus = null; + String payment = null; + String customerAddress = null; + String refNo = null; + + //load the order + MOrder order = new MOrder(ctx, recordId, trxName); + + String paymentRule = null; + + //setting payment + paymentRule = order.getPaymentRule(); + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_Cash)) + { + payment = Constants.PAYMENT_RULE_CASH; + } + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_CreditCard)) + { + payment = Constants.PAYMENT_RULE_CARD; + } + + if(paymentRule.equalsIgnoreCase(MOrder.PAYMENTRULE_Check)) + { + payment = Constants.PAYMENT_RULE_CHEQUE; + } + + if(paymentRule.equalsIgnoreCase(UdiConstants.PAYMENTRULE_MIXED)) + { + payment = Constants.PAYMENT_RULE_MIXED; + } + //setting ref no + refNo = order.getDocumentNo(); + + //getting orgInfo + MOrg org = new MOrg(ctx,order.getAD_Org_ID(),trxName); + int location_id = org.getInfo().getC_Location_ID(); + MLocation location = new MLocation(ctx,location_id,trxName); + + // orgName = org.getName(); + + String address1 = (location.getAddress1() == null)? " " : location.getAddress1(); + String address2 = (location.getAddress2() == null)? " " : location.getAddress2(); + // orgAddress = (address1 + " " + address2).trim(); + + + //getting orderInfo + docStatus = order.getDocStatusName(); + + //getting salesrep + int saleRep_id = order.getSalesRep_ID(); + MUser user = new MUser(ctx,saleRep_id,null); + salesRep = user.getName(); + + //getting customer info + int bpartner_id = order.getBill_BPartner_ID(); + BPartnerBean bean; + try + { + bean = BPartnerManager.getBpartner(ctx,bpartner_id,trxName); + } + catch(Exception e) + { + throw new FormattingException("Formatting Error", e); + } + + + String name1 = (bean.getPartnerName() == null)? " " : bean.getPartnerName(); + String name2 = (bean.getName2() == null)? " " : bean.getName2(); + customerName = (name1 + " " + name2).trim(); + + address1 = (bean.getAddress1() == null)? " " : bean.getAddress1(); + address2 = (bean.getAddress2() == null)? " " : bean.getAddress2(); + customerAddress = (address1 + " " + address2).trim(); + + + ///////////////////////////////drawing the order//////////////////////////////// + StringBuffer reportData = new StringBuffer();//TmkPrinterConstants.LOGO1); + + if(_showLogo) + { + reportData.append(TmkPrinterConstants.LOGO1); + } + + //adding header + reportData.append(TmkPrinterConstants.FONT_SMALL) + .append(_lineTop) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(TmkPrinterConstants.LINE_FEED); + + if(companyName1!=null) + reportData.append(TmkPrinterConstants.FONT_DOUBLE) + .append(companyName1) + .append(TmkPrinterConstants.LINE_FEED); + + if(companyName2.trim().length() > 0) + if(companyName2!=null) + reportData.append(TmkPrinterConstants.CENTER_ALIGN) + .append(TmkPrinterConstants.BIG_FONT) + .append("(" + companyName2 + ")") + .append(TmkPrinterConstants.LINE_FEED); + + if(companyAddress!=null) + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append(companyAddress) + .append(TmkPrinterConstants.LINE_FEED); + + if(companyPhone!=null) + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append("Tel:" + companyPhone) + .append(TmkPrinterConstants.LINE_FEED); + + if(vatRegNumber!=null) + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append("VAT Reg No:" + vatRegNumber) + .append(TmkPrinterConstants.LINE_FEED); + + reportData.append(TmkPrinterConstants.FONT_SMALL) + .append(_lineTop) + .append(TmkPrinterConstants.LINE_FEED); + + //adding title + + if ( UDIOrderTypes.POS_ORDER.getOrderType().equals(order.getOrderType()) || order.getOrderType().equals(null)) + { + title = "Receipt"; + } + if ( UDIOrderTypes.POS_GOODS_RECEIVE_NOTE.getOrderType().equals(order.getOrderType())) + { + title = "Goods Receive Note"; + } + if ( UDIOrderTypes.POS_GOODS_RETURN_NOTE.getOrderType().equals(order.getOrderType())) + { + title = "Goods Return Note"; + } + if ( UDIOrderTypes.CUSTOMER_RETURN_ORDER.getOrderType().equals(order.getOrderType())) + { + title = "Customer Return Order"; + } + if ( UDIOrderTypes.CREDIT_ORDER.getOrderType().equals(order.getOrderType())) + { + title = "Credit Order"; + } + + reportData.append(TmkPrinterConstants.BIG_FONT) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(title) + .append(TmkPrinterConstants.LINE_FEED); + + //setting small font + reportData.append(TmkPrinterConstants.FONT_SMALL); + reportData.append(TmkPrinterConstants.LEFT_ALIGN); + + //adding customer name + customerName = String.format("%1$-" + _halfLineWidth + "s", customerName); + reportData.append(customerName); + + //adding sales rep + salesRep = "Sales Rep:" + salesRep; + salesRep = String.format("%1$"+ _halfLineWidth + "s", salesRep); + reportData.append(salesRep) + .append(TmkPrinterConstants.LINE_FEED); + + //adding customer address + customerAddress = String.format("%1$-" + _lineWidth + "s",customerAddress); + reportData.append(customerAddress) + .append(TmkPrinterConstants.LINE_FEED); + + //adding status + docStatus = "Status:" + docStatus; + docStatus = String.format("%1$-" + _lineWidth + "s",docStatus); + reportData.append(docStatus) + .append(TmkPrinterConstants.LINE_FEED); + + //adding payment + payment = "Payment:" + payment; + payment = String.format("%1$-" + _lineWidth + "s",payment); + reportData.append(payment) + .append(TmkPrinterConstants.LINE_FEED); + + //adding reference no + refNo = "Ref No:" + refNo; + refNo = String.format("%1$-" + _lineWidth + "s",refNo); + reportData.append(refNo) + .append(TmkPrinterConstants.LINE_FEED); + + //adding date + Calendar c = Calendar.getInstance(); + c.setTime(new Date(order.getCreated().getTime())); + String date = String.format("%1$te %1$tb,%1$tY %1$tH:%1$tM:%1$tS",c); + date = String.format("%1$-" + _lineWidth + "s",date); + reportData.append(date) + .append(TmkPrinterConstants.LINE_FEED); + + //adding orderlines + //1.header + reportData.append(_lineTop).append("\n"); + + String headerFormat; + if(_showDiscount) + { + headerFormat = "%1$-" + (_lineWidth - ( 7 + 5 + 8 + 10 )) + "s" + + "%2$7s" + + "%3$5s" + + "%4$8s" + + "%5$10s"; + } + else + { + headerFormat = "%1$-" + (_lineWidth - ( 7 + 5 + 13 )) + "s" + + "%2$7s" + + "%3$5s" + + //"%4$8s" + + "%5$13s"; + } + + String header = String.format(headerFormat,"Name","Unit","Qty","Dis","Total"); + reportData.append(header).append("\n"); + + reportData.append(_lineBottom) + .append(TmkPrinterConstants.LINE_FEED); + + //2.body + ArrayList orderLineList; + try + { + orderLineList = POSManager.populateOrderLines(ctx,order); + } + catch(Exception e) + { + throw new FormattingException("Formatting Error", e); + } + + String name = null; + int qty; + BigDecimal discount = null; + BigDecimal taxAmt = null; + BigDecimal total; + BigDecimal unitPrice; + + int totalQty = 0; + double grandTotal = 0.0d; + double totalTax = 0.0d; + String orderline = ""; + String orderlineFormat = null; + + int nameWidth = 0; + + + if(_showDiscount) + { + orderlineFormat = "" + + "%1$-" + (_lineWidth - ( 7 + 5 + 8 + 10 )) + "s" + //1.product name OR description + "%2$7.2f" + //2.unit price + "%3$5d" + //3.quantity + "%4$8.2f" + //4.discount amount + "%5$10.2f"; //5.total price + + nameWidth = _lineWidth - ( 7 + 5 + 8 + 10 ); + } + else + { + orderlineFormat = "" + + "%1$-" + (_lineWidth - ( 7 + 5 + 13 )) + "s" + //1.product name OR description + "%2$7.2f" + //2.unit price + "%3$5d" + //3.quantity + //"%4$8.2f" + //4.discount amount + "%5$13.2f"; //5.total price + + nameWidth = _lineWidth - ( 7 + 5 + 13 ); + } + + + + for(WebOrderLineBean wbean : orderLineList) + { + taxAmt = wbean.getTaxAmt(); + name = wbean.getDescription(); + qty = wbean.getQtyOrdered().intValue(); + discount = wbean.getDiscountPercentage(); + total = wbean.getLineTotalAmt(); + unitPrice = wbean.getUnitPrice(); + + if( _priceWithVat ) + { + unitPrice = total.divide(wbean.getQtyOrdered(),BigDecimal.ROUND_UP); + } + + + if(name.length() > nameWidth) + { + // print on multiple lines + int beginIndex = 0; + int endIndex = 0; + endIndex = nameWidth; + + while(endIndex < name.length()) + { + String s = name.substring(beginIndex, endIndex); + beginIndex = endIndex; + endIndex = endIndex + nameWidth; + + orderline = String.format("%1$-" + _lineWidth + "s", s); + reportData.append(orderline) + .append(TmkPrinterConstants.LINE_FEED); + } + + name = name.substring(beginIndex); + } + + discount = (discount==null)? new BigDecimal(0.0) : discount; + taxAmt = (taxAmt==null)? new BigDecimal(0.0) : taxAmt; + + double discountAmt = 0.0; + discountAmt = (total.doubleValue() * 100.0)/(100.0 - discount.doubleValue()) - total.doubleValue(); + + totalQty += qty; + grandTotal += total.doubleValue(); + totalTax += taxAmt.doubleValue(); + + if(taxAmt.intValue() == 0) + { + name = name + "*"; + } + + unitPrice = unitPrice.add(BigDecimal.valueOf(discountAmt)); + + orderline = String.format(orderlineFormat,name,unitPrice,qty,discountAmt,total); + reportData.append(orderline) + .append(TmkPrinterConstants.LINE_FEED); + } + + //3.footer + reportData.append(_lineBottom) + .append(TmkPrinterConstants.LINE_FEED); + + String footerFormat = null; + if(_showDiscount) + { + footerFormat = "" + + "%1$-" + (_lineWidth - ( 5 + 8 + 10 )) + "s" + + "%2$5d" + + "%3$8.2s" + + "%4$10.2f"; + } + else + { + footerFormat = "" + + "%1$-" + (_lineWidth - ( 5 + 3 + 10 )) + "s" + + "%2$5d" + + "%3$3s" + + "%4$10.2f"; + } + + String orderFooter = String.format(footerFormat,"Grand Total",totalQty,"Rs",grandTotal); + reportData.append(orderFooter) + .append(TmkPrinterConstants.LINE_FEED); + + reportData.append(_lineTop) + .append(TmkPrinterConstants.LINE_FEED); + + + //4.amount tendered & refunded + BigDecimal cashAmountTendered = order.getAmountTendered(); + if(cashAmountTendered == null) + { + cashAmountTendered = new BigDecimal(0.0); + } + + BigDecimal cashAmountRefunded = order.getAmountRefunded(); + if(cashAmountRefunded == null) + { + cashAmountRefunded = new BigDecimal(0.0); + } + + BigDecimal cardAmountTendered = null; + BigDecimal chequeAmountTendered = null; + + + if(orderLineBean != null) + { + Double cardAmt = orderLineBean.getPaymentByCard(); + Double chequeAmt = orderLineBean.getPaymentByChq(); + + if(cardAmt == null) + { + cardAmountTendered = new BigDecimal(0.0d); + } + else + { + cardAmountTendered = new BigDecimal(cardAmt.doubleValue()); + } + + if(chequeAmt == null) + { + chequeAmountTendered = new BigDecimal(0.0d); + } + else + { + chequeAmountTendered = new BigDecimal(chequeAmt.doubleValue()); + } + } + else + { + + if(MOrder.STATUS_Completed.equalsIgnoreCase(order.getDocStatus())) + if(order.getOrderType().equalsIgnoreCase(UDIOrderTypes.POS_ORDER.getOrderType())) + { + try + { + cardAmountTendered = POSManager.getPayment(ctx, order.get_ID(), MPayment.TENDERTYPE_CreditCard, trxName); + chequeAmountTendered = POSManager.getPayment(ctx, order.get_ID(), MPayment.TENDERTYPE_Check, trxName); + } + catch (OperationException e) + { + throw new FormattingException("Cannot get payment",e); + } + } + else + { + cardAmountTendered = new BigDecimal(0.0d); + chequeAmountTendered = new BigDecimal(0.0d); + } + + } + + String amountTendered = String.format("%1$25s%2$4s:%3$10.2f","Cash Tendered","Rs",cashAmountTendered); + String amountRefunded = String.format("%1$25s%2$4s:%3$10.2f","Cash Refunded","Rs",cashAmountRefunded); + + String seperator = String.format("%1$25s%2$15s","","------------"); + + String cardTendered = String.format("%1$25s%2$4s:%3$10.2f","Card Tendered","Rs",cardAmountTendered); + String chequeTendered = String.format("%1$25s%2$4s:%3$10.2f","Cheque Tendered","Rs",chequeAmountTendered); + + if(cashAmountTendered.doubleValue() > 0.0d) + { + reportData.append(amountTendered).append(TmkPrinterConstants.LINE_FEED); + } + + if(cardAmountTendered.doubleValue() > 0.0d) + { + reportData.append(cardTendered).append(TmkPrinterConstants.LINE_FEED); + } + + if(chequeAmountTendered.doubleValue() > 0.0d) + { + reportData.append(chequeTendered).append(TmkPrinterConstants.LINE_FEED); + } + + if(cashAmountTendered.doubleValue() > 0.0d) + { + reportData.append(seperator).append(TmkPrinterConstants.LINE_FEED); + reportData.append(amountRefunded).append(TmkPrinterConstants.LINE_FEED); + } + + + String totalVAT = String.format("%1$.2f",totalTax); + String vat = String.format("%1$-" + _lineWidth + "s","Total VAT:Rs"+totalVAT); + reportData.append(vat) + .append(TmkPrinterConstants.LINE_FEED); + + String noVAT = String.format("%1$-" + _lineWidth + "s","* NO VAT"); + + + + reportData.append(noVAT) + .append(TmkPrinterConstants.LINE_FEED) + .append(TmkPrinterConstants.LINE_FEED); + + if(_showBarcode) + { + String barcode = ((char)0x1d ) + "H" + (char)2 + ((char)0x1d ) + "k" + (char)4 + order.getDocumentNo() + (char)0; + String barcodeDim = ((char)0x1d) + "h" + (char)50 + ((char)0x1d) + "w" + (char)3; + reportData.append(TmkPrinterConstants.CENTER_ALIGN) + .append(barcodeDim) + .append(barcode) + .append(TmkPrinterConstants.LINE_FEED); + } + + + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append("*** Thank you ***") + .append(TmkPrinterConstants.LINE_FEED); + + + if(_showFooter) + if( _footerMessage.length() > 0 ) + { + reportData.append(TmkPrinterConstants.FONT_NORMAL) + .append(TmkPrinterConstants.LINE_FEED) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(_footerMessage) + .append(TmkPrinterConstants.LINE_FEED); + } + + if( order.getOrderType().equalsIgnoreCase(UDIOrderTypes.POS_ORDER.getOrderType()) ) + { + reportData.append(TmkPrinterConstants.LINE_FEED) + .append(TmkPrinterConstants.CENTER_ALIGN) + .append(TmkPrinterConstants.FONT_SMALL) + .append("*Goods once sold cannot be returned."); + } + + reportData.append(TmkPrinterConstants.PAPER_CUT) + .append(TmkPrinterConstants.LINE_FEED); + + return reportData.toString(); + + } +} diff --git a/posterita/src/main/org/posterita/util/TmkPrintUtil.java b/posterita/src/main/org/posterita/util/TmkPrintUtil.java new file mode 100644 index 0000000000..90cb9a64ca --- /dev/null +++ b/posterita/src/main/org/posterita/util/TmkPrintUtil.java @@ -0,0 +1,71 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 23, 2006 + */ + + +package org.posterita.util; + + +public class TmkPrintUtil +{ + + private static final int TOTAL_PAGE_LENGTH=40; + private static final int MAX_ALLOWED_FOR_FIELD=15; + public static String alignRight(String data) + { + int dataLength=data.length(); + String padding=" "; + for( int i=0;i14) + { + finaldata=finaldata+"\n"+initData.substring(0,MAX_ALLOWED_FOR_FIELD); + initData=initData.substring(MAX_ALLOWED_FOR_FIELD,initData.length()-1); + } + + } + + finaldata=finaldata+"\n"+initData; + + return finaldata.trim(); + + + } + + + public static String alignInCorners(String data1,String data2) + { + + + return null; + } +} diff --git a/posterita/src/main/org/posterita/util/TmkPrinterConstants.java b/posterita/src/main/org/posterita/util/TmkPrinterConstants.java new file mode 100644 index 0000000000..5d15501cd5 --- /dev/null +++ b/posterita/src/main/org/posterita/util/TmkPrinterConstants.java @@ -0,0 +1,79 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Aug 24, 2006 + */ + + +package org.posterita.util; + + +public class TmkPrinterConstants +{ + public static final String PAPER_CUT = new String(new byte[]{10,29,86,66}); + // public static final String PAPER_CUT= new String (new byte[]{10,29,56,66}); + public static final String PAGE_MODE = new String (new byte[]{27,76}); + public static final String LOGO1= new String(new byte[]{28,112,1,48}); + public static final String STANDARD_MODE = new String (new byte[]{27,83}); + public static final String LINE_FEED= new String (new byte []{10}); + public static final String H_TAB = new String (new byte[]{9}); + public static final String SOUND_BUZZER=new String (new byte[]{27,30}); + public static final String ABS_POSITION=new String (new byte[]{}); + public static final String LEFT_ALIGN=new String (new byte[]{27,97,2}); + public static final String CENTER_ALIGN=new String (new byte[]{27,97,1}); + public static final String RIGHT_ALIGN=new String (new byte[]{27,97,2,80}); + public static final String MULTIPLE_LINE_FEED= new String (new byte []{27,100,2});//5 lines + public static final String SETTING_LEFT_MARGIN=new String (new byte[]{29,76,5,0}); + public static final String BIG_FONT=new String (new byte[]{27,33,8}); + public static final String SMALL_FONT=new String (new byte[]{27,33,1}); + public static final String ABS_POS_LOC1=new String (new byte[]{27,36,0,0}); + public static final String ABS_POS_LOC2=new String (new byte[]{27,36,100,1}); + public static final String ABS_POS_LOC3=new String (new byte[]{27,36,(byte)145,1}); + public static final String ABS_POS_LOC4=new String (new byte[]{27,36,(byte)200,1}); + public static final String ABS_POS_LOC5=new String (new byte[]{27,36,1,1}); + public static final String CHARACTER_SPACING=new String (new byte[]{27,32,0}); + public static final String H_FULL_LINE_TOP; + + public static final String FONT_NORMAL = ((char)0x1b) + "!" + ((char)0x00); + public static final String FONT_SMALL = ((char)0x1b) + "!" + ((char)0x01); + public static final String FONT_NORMAL_BOLD = ((char)0x1b) + "!" + ((char)0x08); + public static final String FONT_DOUBLE_HEIGHT = ((char)0x1b) + "!" + ((char)0x10); + public static final String FONT_DOUBLE_WIDTH = ((char)0x1b) + "!" + ((char)0x20); + public static final String FONT_DOUBLE = ((char)0x1b) + "!" + ((char)0x30); + + public static final String H_FULL_LINE_BOTTOM; + + static + { + int length = 60; + byte hFullLineTop[] = new byte[length]; + + for(int i = 0; i < length; i++) + hFullLineTop[i] = (byte)223; + + H_FULL_LINE_TOP = new String(hFullLineTop); + + byte hFullLineBottom[] = new byte[length]; + + for(int i = 0; i < length; i++) + hFullLineBottom[i] = (byte)220; + + H_FULL_LINE_BOTTOM = new String(hFullLineBottom); + } + +} diff --git a/posterita/src/main/org/posterita/webstore/action/DocumentHistoryAction.java b/posterita/src/main/org/posterita/webstore/action/DocumentHistoryAction.java new file mode 100644 index 0000000000..b7b3738506 --- /dev/null +++ b/posterita/src/main/org/posterita/webstore/action/DocumentHistoryAction.java @@ -0,0 +1,136 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ +package org.posterita.webstore.action; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Properties; +import java.util.TreeSet; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.compiere.model.MBPartner; +import org.compiere.process.DocAction; +import org.compiere.util.Env; +import org.posterita.Constants; +import org.posterita.beans.DocumentHistortFilterBean; +import org.posterita.beans.DocumentHistoryBean; +import org.posterita.beans.FilterBean; +import org.posterita.businesslogic.POSReportManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.form.DocumentHistoryForm; +import org.posterita.order.UDIOrderTypes; +import org.posterita.struts.core.BaseDispatchAction; +import org.posterita.user.WebUserInfo; +import org.posterita.webstore.businesslogic.DocumentHistoryManager; + +public class DocumentHistoryAction extends BaseDispatchAction +{ + + public static final String INIT_HISTORY = "initHistory"; + public ActionForward initHistory(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DocumentHistoryForm dhf = (DocumentHistoryForm) form; + DocumentHistoryBean bean = (DocumentHistoryBean) dhf.getBean(); + + Calendar calendar = Calendar.getInstance(); + int month = calendar.get(Calendar.MONTH) + 1 ; + int year = calendar.get(Calendar.YEAR); + + bean.setMonth( Integer.valueOf(month) ); + bean.setYear( Integer.valueOf(year) ); + bean.setOrderType( UDIOrderTypes.POS_ORDER .getOrderType()); + bean.setDocStatus( DocAction.STATUS_Completed ); + + dhf.populate( bean ); + + //TODO OrderType should be taken from the bean + ArrayList list = DocumentHistoryManager.getHistory(ctx, bean.getBpartnerId(), bean.getDocStatus(), bean.getMonth(), bean.getYear(), bean.getOrderType()); + + getWebstoreFilterBean(ctx, request, list); + + request.getSession().setAttribute(Constants.DOCUMENT_HISTORY, list); + + return mapping.findForward(GET_HISTORY); + } + + public static final String GET_HISTORY = "getHistory"; + public ActionForward getHistory(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + Properties ctx = TmkJSPEnv.getCtx(request); + + DocumentHistoryForm dhf = (DocumentHistoryForm) form; + DocumentHistoryBean bean = (DocumentHistoryBean) dhf.getBean(); + + //TODO OrderType should be taken from the bean + ArrayList list = DocumentHistoryManager.getHistory(ctx, bean.getBpartnerId(), bean.getDocStatus(), bean.getMonth(), bean.getYear(), bean.getOrderType()); + + getWebstoreFilterBean(ctx, request, list); + + request.getSession().setAttribute(Constants.DOCUMENT_HISTORY, list); + + return mapping.findForward(GET_HISTORY); + + } + + public static void getWebstoreFilterBean(Properties ctx, HttpServletRequest request, ArrayList orderHistory) throws OperationException + { + + DocumentHistortFilterBean filterBean = new DocumentHistortFilterBean(orderHistory); + + TreeSet docStatus = filterBean.getDocStatusList(); + request.getSession().setAttribute(Constants.DOC_STATUS, docStatus); + ArrayList orderTypeList=POSReportManager.getAllOrderTypes(ctx); + + request.getSession().setAttribute(Constants.ORDER_TYPES,orderTypeList); + + WebUserInfo wuInfo = (WebUserInfo) request.getSession().getAttribute(WebUserInfo.NAME); + int partnerId = wuInfo.getInfo().getC_BPartner_ID(); + MBPartner partner = new MBPartner(ctx, partnerId, null); + + + if (partner.getAD_Org_ID() != Env.getAD_Org_ID(ctx)) + { + TreeSet bPartners = (TreeSet)filterBean.getBPartnerList(); + request.getSession().setAttribute(Constants.BPARTNERS, bPartners); + + } + } + +} diff --git a/posterita/src/main/org/posterita/webstore/action/ViewCashPaymentAction.java b/posterita/src/main/org/posterita/webstore/action/ViewCashPaymentAction.java new file mode 100644 index 0000000000..cde8b771c3 --- /dev/null +++ b/posterita/src/main/org/posterita/webstore/action/ViewCashPaymentAction.java @@ -0,0 +1,101 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Created on Oct 25, 2006 + */ + + +package org.posterita.webstore.action; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.Globals; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.config.ActionConfig; +import org.apache.struts.config.ForwardConfig; +import org.apache.struts.util.MessageResources; + +import org.posterita.Constants; +import org.posterita.beans.DocumentBean; +import org.posterita.beans.WebDocumentBean; +import org.posterita.businesslogic.CashManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; +import org.posterita.struts.pos.POSDispatchAction; + + +public class ViewCashPaymentAction extends POSDispatchAction +{ + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + MessageResources resources = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); + + String operationException = resources.getMessage("error.operationException"); + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + DocumentBean bean = (DocumentBean) df.getBean(); + Integer paymentId = bean.getDocumentId(); + + // retrieve from cache + WebDocumentBean webBean = null; + webBean = CashManager.getWebCashPaymentBean(ctx, paymentId); + + request.getSession().setAttribute(Constants.WEB_PAYMENT_BEAN, webBean); + if (webBean == null) + webBean = (WebDocumentBean) request.getSession().getAttribute(Constants.WEB_PAYMENT_BEAN); + + if (webBean == null) + throw new OperationException(operationException); + + request.getSession().setAttribute(Constants.ME_LOCATION, webBean.getMeLocation()); + request.getSession().setAttribute(Constants.YOU_LOCATION, webBean.getYouLocation()); + request.getSession().setAttribute(Constants.YOU_BP_LOCATION, webBean.getYoubpLocation()); + request.getSession().setAttribute(Constants.ME, webBean.getMe()); + request.getSession().setAttribute(Constants.YOU,webBean.getYou()); + request.getSession().setAttribute(Constants.MCASHLINE, webBean.getCashLine()); + request.getSession().setAttribute(Constants.WEB_DOCUMENT_HEADER_BEAN, webBean.getHeaderBean()); + request.setAttribute(Constants.CURRENCY_SYMBOLE,webBean.getCurrencySymbole()); + request.getSession().setAttribute(Constants.CASH_PAYMENT_MADE,bean); + ForwardConfig forwardConfig = getForward(ctx,webBean,mapping,form); + + ActionForward forward = new ActionForward(forwardConfig.getPath()); + + return forward; + } + + private ForwardConfig getForward(Properties ctx, WebDocumentBean webBean, ActionMapping mapping, ActionForm form) throws OperationException + { + ActionConfig config = mapping.getModuleConfig().findActionConfig("/ViewWebstoreCashPaymentAction"); + + return config.findForwardConfig(Constants.VIEW_PAYMENT); + } +} \ No newline at end of file diff --git a/posterita/src/main/org/posterita/webstore/action/ViewPaymentAction.java b/posterita/src/main/org/posterita/webstore/action/ViewPaymentAction.java new file mode 100644 index 0000000000..f03ec967a4 --- /dev/null +++ b/posterita/src/main/org/posterita/webstore/action/ViewPaymentAction.java @@ -0,0 +1,109 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +package org.posterita.webstore.action; + +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.Globals; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.config.ActionConfig; +import org.apache.struts.config.ForwardConfig; +import org.apache.struts.util.MessageResources; +import org.compiere.model.MPayment; + +import org.posterita.Constants; +import org.posterita.beans.DocumentBean; +import org.posterita.beans.WebDocumentBean; +import org.posterita.businesslogic.PaymentManager; +import org.posterita.core.TmkJSPEnv; +import org.posterita.exceptions.ApplicationException; +import org.posterita.exceptions.OperationException; +import org.posterita.struts.core.DefaultForm; +import org.posterita.struts.pos.POSDispatchAction; + + +public class ViewPaymentAction extends POSDispatchAction +{ + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws OperationException, ApplicationException + { + ActionForward fwd = init(mapping, form, request, response); + + if (fwd != null) + return fwd; + + MessageResources resources = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); + + String operationException = resources.getMessage("error.operationException"); + + Properties ctx = TmkJSPEnv.getCtx(request); + + DefaultForm df = (DefaultForm) form; + DocumentBean bean = (DocumentBean) df.getBean(); + Integer paymentId = bean.getDocumentId(); + + // retrieve from cache + WebDocumentBean webBean = null; + + MPayment payment = null; + if (paymentId!= null) + { + payment = new MPayment(ctx, paymentId.intValue(), null); + webBean = PaymentManager.getWebPaymentBean(ctx, payment); + request.getSession().setAttribute(Constants.WEB_PAYMENT_BEAN, webBean); + } + + if (webBean == null) + webBean = (WebDocumentBean) request.getSession().getAttribute(Constants.WEB_PAYMENT_BEAN); + + if (webBean == null) + throw new OperationException(operationException); + + request.getSession().setAttribute(Constants.ME_LOCATION, webBean.getMeLocation()); + request.getSession().setAttribute(Constants.YOU_LOCATION, webBean.getYouLocation()); + request.getSession().setAttribute(Constants.YOU_BP_LOCATION, webBean.getYoubpLocation()); + request.getSession().setAttribute(Constants.ME, webBean.getMe()); + request.getSession().setAttribute(Constants.MORDER, webBean.getOrder()); + request.getSession().setAttribute(Constants.YOU,webBean.getYou()); + request.getSession().setAttribute(Constants.MPAYMENT, webBean.getPayment()); + request.getSession().setAttribute(Constants.PAYMENT_TYPE, webBean.getTenderType()); + request.getSession().setAttribute(Constants.MINVOICE, webBean.getInvoice()); + request.getSession().setAttribute(Constants.SIMPLE_COMMAND,webBean.getSimpleCommand()); + request.getSession().setAttribute(Constants.COMPLEX_COMMAND,webBean.getComplexCommand()); + request.getSession().setAttribute(Constants.WEB_DOCUMENT_HEADER_BEAN, webBean.getHeaderBean()); + request.setAttribute(Constants.CURRENCY_SYMBOLE,webBean.getCurrencySymbole()); + ForwardConfig forwardConfig = getForward(ctx,webBean,mapping,form); + + ActionForward forward = new ActionForward(forwardConfig.getPath()); + + return forward; + } + + private ForwardConfig getForward(Properties ctx, WebDocumentBean webBean, ActionMapping mapping, ActionForm form) throws OperationException + { + ActionConfig config = mapping.getModuleConfig().findActionConfig("/ViewWebstorePaymentAction"); + + return config.findForwardConfig(Constants.VIEW_PAYMENT); + } +} diff --git a/posterita/src/main/org/posterita/webstore/businesslogic/DocumentHistoryManager.java b/posterita/src/main/org/posterita/webstore/businesslogic/DocumentHistoryManager.java new file mode 100644 index 0000000000..0443a59cdf --- /dev/null +++ b/posterita/src/main/org/posterita/webstore/businesslogic/DocumentHistoryManager.java @@ -0,0 +1,184 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ +package org.posterita.webstore.businesslogic; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; + +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.posterita.beans.DocumentHistoryBean; +import org.posterita.core.UDIMap; +import org.posterita.exceptions.OperationException; + +public class DocumentHistoryManager +{ + + private static Integer getIntegerValue(int value) + { + if (value == 0) + return null; + else + return Integer.valueOf(value); + } + + + public static ArrayList getHistory(Properties ctx, Integer bpartnerId, String docStatus, Integer month, Integer year, String orderType) throws OperationException + { + StringBuffer sql = new StringBuffer(); + sql.append(" select"); + sql.append(" ord.c_order_id, "); //1.orderID + sql.append(" pay.c_payment_id, "); //2.paymentID + sql.append(" inv.c_invoice_id, "); //3.invoiceID + sql.append(" ship.m_inout_id, "); //4.shipmentID + sql.append(" partner.c_bpartner_id, "); //5.partnerID + sql.append(" partner.name, "); //6.partnerName + sql.append(" partner.name2, "); //7.partnerName2 + sql.append(" ord.created, "); //8.dateCreated + sql.append(" ship.docstatus,"); //9/docStatus + sql.append(" DECODE(pay.docstatus, 'CO', 'Paid', 'Awaiting Payment') paymentStatus,"); + sql.append(" DECODE (ship.docstatus, 'CO', 'Shipped', 'Not Shipped') shipmentStatus,"); + sql.append(" ord.documentNo,"); + sql.append(" inv.documentNo,"); + sql.append(" pay.documentNo,"); + sql.append(" ship.documentNo,"); + sql.append(" partner.isCustomer,"); + sql.append(" partner.isVendor from "); + sql.append("(((c_order ord left outer join c_invoice inv on ord.C_Order_ID=inv.C_Order_ID) left outer join M_InOut ship on ord.C_Order_ID=ship.C_Order_ID) left outer join c_payment pay on inv.c_invoice_id = pay.c_invoice_id)"); + sql.append(", c_bpartner partner"); + sql.append(" where ord.ad_client_id=" + Env.getAD_Client_ID(ctx)); + sql.append(" and ord.ad_org_id=" + Env.getAD_Org_ID(ctx)); + sql.append(" and partner.c_bpartner_id=ord.c_bpartner_id"); + sql.append(" and ord.isactive='Y'"); + + + if(orderType!=null) + { + sql.append(" and ord.ordertype='" + orderType + "'"); + } + + if (month != null) + { + String mm = String.valueOf(month); + if (mm.length() == 1) + { + mm = "0" + mm; + } + sql.append(" and to_char(ord.dateOrdered, 'mm') ='" + mm + "'"); + } + + if (year != null) + { + sql.append(" and to_char(ord.dateOrdered, 'yyyy') ='" + year+"'"); + } + + if (bpartnerId != null) + { + sql.append(" and ord.c_bpartner_id=" + bpartnerId); + } + + sql.append(" order by ord.c_order_id desc"); + + + + PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); + + ResultSet rs = null; + DocumentHistoryBean bean; + ArrayList list = new ArrayList(); + + try + { + rs = pstmt.executeQuery(); + + while(rs.next()) + { + bean = new DocumentHistoryBean(); + bean.setOrderId(getIntegerValue(rs.getInt(1))); + bean.setPaymentId(getIntegerValue(rs.getInt(2))); + bean.setInvoiceId(getIntegerValue(rs.getInt(3))); + bean.setMinOutId(getIntegerValue(rs.getInt(4))); + bean.setBpartnerId(getIntegerValue(rs.getInt(5))); + bean.setPartnerName(rs.getString(6) + " " + rs.getString(7)); + bean.setDateOrdered(rs.getTimestamp(8)); + + if (rs.getString(9) != null) + { + bean.setDocStatus(UDIMap.docStatusMap.get(rs.getString(9))); + bean.setDocStatusCode(rs.getString(9)); + } + + bean.setPaymentStatus(rs.getString(10)); + bean.setShipmentStatus(rs.getString(11)); + bean.setDocumentNo(rs.getString(12)); + bean.setInvoiceNo(rs.getString(13)); + bean.setPaymentNo(rs.getString(14)); + bean.setShipmentNo(rs.getString(15)); + + if(rs.getString(16).equals("Y")) + { + bean.setIsCustomer(Boolean.valueOf(true)); + } + else + { + bean.setIsCustomer(Boolean.valueOf(false)); + } + + if(rs.getString(17).equals("Y")) + { + bean.setIsVendor(Boolean.valueOf(true)); + } + else + { + bean.setIsVendor(Boolean.valueOf(false)); + } + + + list.add(bean); + } + + } + catch (SQLException e) + { + throw new OperationException(e.getMessage()); + } + finally + { + try + { + rs.close(); + pstmt.close(); + } + catch (Exception ex) + { + } + rs = null; + pstmt = null; + } + + return list; + } + + +} diff --git a/posterita/src/main/org/posterita/webstore/businesslogic/PaymentManager.java b/posterita/src/main/org/posterita/webstore/businesslogic/PaymentManager.java new file mode 100644 index 0000000000..d219317c96 --- /dev/null +++ b/posterita/src/main/org/posterita/webstore/businesslogic/PaymentManager.java @@ -0,0 +1,258 @@ +/** + * Product: Posterita Web-Based POS and Adempiere Plugin + * Copyright (C) 2007 Posterita Ltd + * This file is part of POSterita + * + * POSterita is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + **/ +package org.posterita.webstore.businesslogic; + +import java.util.Properties; + +import org.compiere.model.MBankAccount; +import org.compiere.model.MDocType; +import org.compiere.model.MInOut; +import org.compiere.model.MOrder; +import org.compiere.model.MPayment; +import org.compiere.model.MPaymentValidate; +import org.compiere.process.DocumentEngine; +import org.posterita.Constants; +import org.posterita.beans.CreditCardBean; +import org.posterita.exceptions.CreditCardExpiryInvalidException; +import org.posterita.exceptions.CreditCardNumberException; +import org.posterita.exceptions.CreditCardTypeNotSupportedException; +import org.posterita.exceptions.CreditCardVVInvalidException; +import org.posterita.exceptions.OperationException; +import org.posterita.model.UDIMPayment; +import org.posterita.order.UDIOrderTypes; + +import org.compiere.util.Env; + +public class PaymentManager +{ + + public static MPayment createARReceipt(Properties ctx, int salesOrderId, String deliveryViaRule, String trxName) throws OperationException + { + return createPayment(ctx, salesOrderId, deliveryViaRule, MDocType.DOCBASETYPE_ARReceipt, null, null, null, null, null, trxName); + } + + + public static MPayment createARReceipt(Properties ctx, int salesOrderId, String deliveryViaRule, String creditCardType, String creditCardNumber, String cvv2, Integer expMonth, Integer expYear, String trxName) throws OperationException + { + return createPayment(ctx, salesOrderId, deliveryViaRule, MDocType.DOCBASETYPE_ARReceipt, creditCardType, creditCardNumber, cvv2, expMonth, expYear, trxName); + } + + + public static MPayment createPayment(Properties ctx, int orderId, String deliveryViaRule, String docBaseType, String creditCardType, String creditCardNumber, String cvv2, Integer expMonth, Integer expYear, String trxName) throws OperationException + { + MPayment payment; + MOrder order = new MOrder(ctx, orderId, trxName); + + try + { + int orgID = Env.getAD_Org_ID(ctx); + //get org's default bank Account + int bankAccIds[] = MBankAccount.getAllIDs(MBankAccount.Table_Name, " ad_org_id=" + orgID + " and ad_client_id=" + Env.getAD_Client_ID(ctx) + " and isDefault='Y'", trxName); + + if (bankAccIds.length == 0) + throw new OperationException("No default bank account found for org"); + + MBankAccount orgBankAc = new MBankAccount(ctx, bankAccIds[0], trxName); + + payment = new MPayment(ctx,0, trxName); + payment.setC_BankAccount_ID(bankAccIds[0]); + payment.setC_BPartner_ID(order.getC_BPartner_ID()); + payment.setC_Currency_ID(order.getC_Currency_ID()); + payment.setC_Order_ID(orderId); + + if (deliveryViaRule != null && deliveryViaRule.equals(MInOut.DELIVERYVIARULE_Shipper)) + { + payment.setTenderType(MPayment.TENDERTYPE_CreditCard); + + boolean creditcardDetailsValid = payment.setCreditCard(MPayment.TRXTYPE_Sales, creditCardType, creditCardNumber, cvv2,expMonth.intValue(), expYear.intValue()); + + if (!creditcardDetailsValid) + throw new OperationException("Credit Card Details Missing!!!"); + } + else + payment.setTenderType(MPayment.TENDERTYPE_Check); + + MDocType[] docTypes = MDocType.getOfDocBaseType(ctx, docBaseType); + + if (docTypes.length == 0) + throw new OperationException("not document type found for payment"); + + payment.setC_DocType_ID(docTypes[0].get_ID()); + + payment.setAccountNo(orgBankAc.getAccountNo()); + + payment.setPayAmt(order.getGrandTotal()); + + + if (docBaseType.equals(MDocType.DOCBASETYPE_APPayment)) + { + payment.setIsReceipt(false); + payment.setDescription("(AP Payment) Payment Made"); + } + + else + { + payment.setIsReceipt(true); + payment.setDescription("(AR Receipt) Payment Received"); + } + + UDIMPayment udiPayment = new UDIMPayment(payment); + udiPayment.save(); + + } + catch(OperationException e) + { + throw e; + } + + return payment; + } + + + public static MPayment completePayment(Properties ctx, int paymentId, String trxName) throws OperationException + { + MPayment payment; + + try + { + payment = new MPayment(ctx, paymentId, trxName); + + + if (payment.getDocStatus().equals(DocumentEngine.STATUS_Completed)) + throw new OperationException("Cannot complete a payment which is already completed"); + + if (payment.getDocStatus().equals(DocumentEngine.STATUS_Voided)) + throw new OperationException("Cannot complete a payment which has been voided"); + UDIMPayment udipayment = new UDIMPayment(payment); + udipayment.processIt(DocumentEngine.ACTION_Complete); + } + catch(OperationException e) + { + throw e; + } + + return payment; + } + + public static MPayment loadPayment(Properties ctx, MOrder order, String trxName) throws OperationException + { + if (!order.getOrderType().equals(UDIOrderTypes.WEBSTORE_ORDER.getOrderType())) + throw new OperationException("This method only loads payment for a webstore order!!"); + + int[] paymentIds = MPayment.getAllIDs(MPayment.Table_Name, "c_order_id=" + order.get_ID(), null); + + if (paymentIds.length > 1) + throw new OperationException("Error loading payment. Webstore does not support multiple payment for one order.Order Id is " + order.get_ID()); + + if (paymentIds.length < 0) + throw new OperationException("Error loading payment. No payment found for this order: " + order.get_ID()); + + //Assuming that there will be only one payment for this order + MPayment payment = new MPayment(ctx, paymentIds[0], trxName); + + return payment; + } + + + public static String isPaid(Properties ctx, int orderId, String trxName) + { + int[] paymentIds = MPayment.getAllIDs(MPayment.Table_Name, "c_order_id=" + orderId, trxName); + + if (paymentIds.length == 0) + return Constants.NO_CHAR; + + MPayment payment = new MPayment(ctx, paymentIds[0], trxName); + + if (payment.getDocStatus().equals(MPayment.DOCSTATUS_Completed)) + return Constants.YES_CHAR; + else + return Constants.NO_CHAR; + } + + + public static void validateCreditCardDetails(CreditCardBean cardBean) throws CreditCardTypeNotSupportedException, CreditCardNumberException, CreditCardExpiryInvalidException, CreditCardVVInvalidException + { + if(cardBean == null) + throw new IllegalArgumentException("CardBean cannot be null"); + + String creditCardNum = cardBean.getCreditCardNumber(); + String creditCardType = cardBean.getCreditCardType(); + + if(!(creditCardType != null + && (creditCardType.equals(MPayment.CREDITCARDTYPE_Amex) + || creditCardType.equals(MPayment.CREDITCARDTYPE_Discover) + || creditCardType.equals(MPayment.CREDITCARDTYPE_MasterCard) + || creditCardType.equals(MPayment.CREDITCARDTYPE_Visa)))) + { + throw new CreditCardTypeNotSupportedException("Credit Card type: " + creditCardType + " is not supported"); + } + + String numValResult = MPaymentValidate.validateCreditCardNumber(creditCardNum, creditCardType); + if(numValResult != "") + throw new CreditCardNumberException("Credit Card number is not valid, Reason: " + numValResult); + + Integer expMonth = cardBean.getCreditCardExpMonth(); + Integer expYear = cardBean.getCreditCardExpYear(); + + if(expMonth == null) + throw new CreditCardExpiryInvalidException("Expiry month cannot be null"); + if(expYear == null) + throw new CreditCardExpiryInvalidException("Expiry year cannot be null"); + + String expiryValResult = MPaymentValidate.validateCreditCardExp(expMonth.intValue(), expYear.intValue()); + + if(expiryValResult != "") + throw new CreditCardExpiryInvalidException("Credit Card Expiry date invalid"); + + String cvv = cardBean.getCvv(); + if(cvv == null) + throw new CreditCardVVInvalidException("Credit Card VV cannot be null"); + + String cvvValResult = MPaymentValidate.validateCreditCardVV(cvv, creditCardType); + if(cvvValResult != "") + throw new CreditCardVVInvalidException("Credit Card VV is not valid"); + } + + + public static String loadCreditCardTypeName(String creditCardType) throws OperationException + { + if(creditCardType == null) + throw new OperationException("Credit Card Type not present!!"); + + String creditCardTypeName = ""; + + if (creditCardType.equals(MPayment.CREDITCARDTYPE_Amex)) + creditCardTypeName = Constants.CREDITCARDTYPE_AMEX; + else + if (creditCardType.equals(MPayment.CREDITCARDTYPE_Discover)) + creditCardTypeName = Constants.CREDITCARDTYPE_DISCOVER; + else + if (creditCardType.equals(MPayment.CREDITCARDTYPE_MasterCard)) + creditCardTypeName = Constants.CREDITCARDTYPE_MASTERCARD; + else + if (creditCardType.equals(MPayment.CREDITCARDTYPE_Visa)) + creditCardTypeName = Constants.CREDITCARDTYPE_VISA; + + return creditCardTypeName; + + } + +}