├── .classpath
├── .gitignore
├── .project
├── .settings
└── org.eclipse.jdt.core.prefs
├── AndroidManifest.xml
├── BBAF-Key-pass=bbafii
├── README.md
├── dist
└── BBAF-MPOS.apk
├── docs
├── DCD POS.png
├── DCD.violet
├── FullyDressedUC
│ ├── UC_AddItem.doc
│ └── UC_RemoveItem.doc
├── IterationPlan
│ ├── IterationPlan1.doc
│ └── IterationPlan2.doc
├── Mockup
│ ├── Ledger.jpg
│ ├── Menu.jpg
│ ├── Overall.jpg
│ ├── PageFlow.jpg
│ ├── ProductDescription.jpg
│ └── SaleAndInventory.jpg
├── POS Domain Model.class.violet
├── POS Domain Model.png
├── SAD.doc
├── SCD.class .violet
├── SRS.doc
├── User_Guide_POS-BBAF.pdf
├── VisionScopeGROUP.docx
├── brief_uc.docx
├── class diagram.class.violet
├── interation diagram.png
├── interation diagram.seq.violet
└── userstories.txt
├── gen
└── com
│ └── bbaf
│ └── mpos
│ └── BuildConfig.java
├── ic_launcher-web.png
├── libs
└── android-support-v4.jar
├── proguard-project.txt
├── project.properties
├── res
├── .DS_Store
├── drawable-hdpi
│ ├── homebg.jpg
│ ├── ic_action_accept.png
│ ├── ic_action_camera.png
│ ├── ic_action_cancel.png
│ ├── ic_action_discard.png
│ ├── ic_action_download.png
│ ├── ic_action_labels.png
│ ├── ic_action_new_label.png
│ ├── ic_action_overflow.png
│ ├── ic_action_search.png
│ ├── ic_launcher.png
│ ├── logo.png
│ └── testbackground.jpg
├── drawable-mdpi
│ ├── homebg.jpg
│ ├── ic_action_accept.png
│ ├── ic_action_camera.png
│ ├── ic_action_cancel.png
│ ├── ic_action_discard.png
│ ├── ic_action_download.png
│ ├── ic_action_labels.png
│ ├── ic_action_new_label.png
│ ├── ic_action_overflow.png
│ ├── ic_action_search.png
│ ├── ic_launcher.png
│ ├── logo.png
│ └── testbackground.jpg
├── drawable-xhdpi
│ ├── homebg.jpg
│ ├── ic_action_accept.png
│ ├── ic_action_camera.png
│ ├── ic_action_cancel.png
│ ├── ic_action_discard.png
│ ├── ic_action_download.png
│ ├── ic_action_labels.png
│ ├── ic_action_new_label.png
│ ├── ic_action_overflow.png
│ ├── ic_action_search.png
│ ├── ic_launcher.png
│ ├── logo.png
│ └── testbackground.jpg
├── drawable-xxhdpi
│ ├── homebg.jpg
│ ├── ic_action_accept.png
│ ├── ic_action_camera.png
│ ├── ic_action_cancel.png
│ ├── ic_action_discard.png
│ ├── ic_action_download.png
│ ├── ic_action_labels.png
│ ├── ic_action_new_label.png
│ ├── ic_action_overflow.png
│ ├── ic_action_search.png
│ ├── ic_launcher.png
│ ├── logo.png
│ └── testbackground.jpg
├── drawable
│ ├── homebg.jpg
│ ├── light_blue_btn.xml
│ ├── light_green_btn.xml
│ ├── light_red_btn.xml
│ ├── light_yellow_btn.xml
│ ├── logo.png
│ ├── testbackground.jpg
│ ├── testbg.xml
│ └── testtab.xml
├── layout
│ ├── .DS_Store
│ ├── activity_add_product.xml
│ ├── activity_description.xml
│ ├── activity_edit_product.xml
│ ├── activity_inventory_activity2.xml
│ ├── activity_ledger_ui.xml
│ ├── activity_menu.xml
│ ├── activity_payment.xml
│ ├── activity_sale_edit.xml
│ ├── activity_sale_ledger_product_list.xml
│ ├── activity_success_payment.xml
│ ├── inventory_list_row.xml
│ ├── product_ledger_list_row.xml
│ ├── sale_ledger_list_row.xml
│ └── sale_list_row.xml
├── menu
│ ├── add_product.xml
│ ├── description.xml
│ ├── edit_product.xml
│ ├── inventory_activity2.xml
│ ├── ledger_ui.xml
│ ├── menu.xml
│ ├── payment.xml
│ ├── sale_edit.xml
│ ├── sale_ledger_list.xml
│ └── success_payment.xml
├── values-sw600dp
│ └── dimens.xml
├── values-sw720dp-land
│ └── dimens.xml
├── values-v11
│ └── styles.xml
├── values-v14
│ └── styles.xml
└── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── src
└── com
├── bbaf
└── mpos
│ ├── DAO
│ ├── InventoryDBHelper.java
│ └── SaleLedgerDBHelper.java
│ ├── FacadeController
│ └── Register.java
│ ├── ProductDescription
│ ├── ProductDescription.java
│ └── ProductQuantity.java
│ ├── inventory
│ ├── Inventory.java
│ └── description
│ │ └── ui
│ │ └── DescriptionActivity.java
│ ├── inventoryAndSale
│ └── ui
│ │ ├── ATSOnClickListener.java
│ │ ├── AddOnClickListener.java
│ │ ├── AddProductActivity.java
│ │ ├── CancelSaleDialogOnClickListener.java
│ │ ├── CancelSaleOnClickListener.java
│ │ ├── ClearOnClickListener.java
│ │ ├── EditProductActivity.java
│ │ ├── InventoryListRow.java
│ │ ├── InventoryListViewAdapter.java
│ │ ├── InventoryandSaleActivity.java
│ │ ├── RemovableListRow.java
│ │ ├── RemoveDialogOnClickListener.java
│ │ ├── RemoveOnClickListener.java
│ │ ├── SaleListRow.java
│ │ ├── SaleListViewAdapter.java
│ │ └── ScanOnClickListener.java
│ ├── menu
│ └── ui
│ │ └── MenuActivity.java
│ ├── sale
│ ├── Sale.java
│ ├── SaleLineItem.java
│ └── payment
│ │ └── ui
│ │ ├── PaymentActivity.java
│ │ ├── PaymentCancelOnClickListener.java
│ │ ├── PaymentConfirmOnClickListener.java
│ │ ├── PaymentOnClickListener.java
│ │ ├── SaleEditActivity.java
│ │ └── SuccessPaymentActivity.java
│ └── saleledger
│ ├── Ledger.java
│ ├── ProductLedger.java
│ ├── SaleLedger.java
│ └── ui
│ ├── LedgerActivity.java
│ ├── ProductLedgerListRow.java
│ ├── ProductLedgerListViewAdapter.java
│ ├── SaleLedgerListRow.java
│ ├── SaleLedgerListViewAdapter.java
│ └── SaleLedgerProductListActivity.java
└── google
└── zxing
└── integration
└── android
├── IntentIntegrator.java
└── IntentResult.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /bin
2 | .DS_Store
3 |
4 | gen/com/bbaf/mpos/R.java
5 |
6 | gen/com/bbaf/mpos/R.java
7 |
8 | gen/com/bbaf/mpos/R.java
9 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | MPOS
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
16 |
19 |
20 |
26 |
27 |
32 |
33 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
49 |
50 |
56 |
57 |
63 |
64 |
70 |
71 |
77 |
78 |
83 |
84 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/BBAF-Key-pass=bbafii:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/BBAF-Key-pass=bbafii
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | MPOS
2 | ====
3 |
4 | Mobile POS for Android
5 |
--------------------------------------------------------------------------------
/dist/BBAF-MPOS.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/dist/BBAF-MPOS.apk
--------------------------------------------------------------------------------
/docs/DCD POS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/DCD POS.png
--------------------------------------------------------------------------------
/docs/FullyDressedUC/UC_AddItem.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/FullyDressedUC/UC_AddItem.doc
--------------------------------------------------------------------------------
/docs/FullyDressedUC/UC_RemoveItem.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/FullyDressedUC/UC_RemoveItem.doc
--------------------------------------------------------------------------------
/docs/IterationPlan/IterationPlan1.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/IterationPlan/IterationPlan1.doc
--------------------------------------------------------------------------------
/docs/IterationPlan/IterationPlan2.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/IterationPlan/IterationPlan2.doc
--------------------------------------------------------------------------------
/docs/Mockup/Ledger.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/Mockup/Ledger.jpg
--------------------------------------------------------------------------------
/docs/Mockup/Menu.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/Mockup/Menu.jpg
--------------------------------------------------------------------------------
/docs/Mockup/Overall.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/Mockup/Overall.jpg
--------------------------------------------------------------------------------
/docs/Mockup/PageFlow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/Mockup/PageFlow.jpg
--------------------------------------------------------------------------------
/docs/Mockup/ProductDescription.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/Mockup/ProductDescription.jpg
--------------------------------------------------------------------------------
/docs/Mockup/SaleAndInventory.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/Mockup/SaleAndInventory.jpg
--------------------------------------------------------------------------------
/docs/POS Domain Model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/POS Domain Model.png
--------------------------------------------------------------------------------
/docs/SAD.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/SAD.doc
--------------------------------------------------------------------------------
/docs/SRS.doc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/SRS.doc
--------------------------------------------------------------------------------
/docs/User_Guide_POS-BBAF.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/User_Guide_POS-BBAF.pdf
--------------------------------------------------------------------------------
/docs/VisionScopeGROUP.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/VisionScopeGROUP.docx
--------------------------------------------------------------------------------
/docs/brief_uc.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/brief_uc.docx
--------------------------------------------------------------------------------
/docs/interation diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/docs/interation diagram.png
--------------------------------------------------------------------------------
/docs/userstories.txt:
--------------------------------------------------------------------------------
1 | Inventory System
2 |
3 |
4 | - As an owner , I want to add a product so I can have my product in my inventory.
5 | - As an owner , I want to remove a product so I can delete my product that I don’t want to sell from inventory.
6 | - As an owner, I want to edit description so I can change the description of the product.
7 | - As a seller , I want to make sale so that I can sell the product.
8 | - As a cashier I want to record a receipt so that I can record sale to ledger.
9 | - As a seller , I want to check product quantity so that I can know the product availability.
10 |
11 |
12 | Sales System
13 |
14 |
15 | - As an owner, I want to make sale of this product by pressing the button related to this product.
16 | - As an owner, I want to make a receipt of the recent sale so I can give it to the customer.
17 | - As a customer, I want the sale to show my total price so I can pay accordingly.
18 | - As a customer, I want the sale to show the change.
19 |
20 |
21 | Basic User Management System
22 |
23 |
24 | - As an owner, I want to identify my employee so that I can know who sells the product.
25 |
26 |
27 | Basic Customer Management System
28 |
29 |
30 | - As an owner, I want to record the sale that customer make so that I can know what customer interest.
--------------------------------------------------------------------------------
/gen/com/bbaf/mpos/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.bbaf.mpos;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/ic_launcher-web.png
--------------------------------------------------------------------------------
/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-14
15 |
--------------------------------------------------------------------------------
/res/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/.DS_Store
--------------------------------------------------------------------------------
/res/drawable-hdpi/homebg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/homebg.jpg
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_action_accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/ic_action_accept.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_action_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/ic_action_camera.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_action_cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/ic_action_cancel.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_action_discard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/ic_action_discard.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_action_download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/ic_action_download.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_action_labels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/ic_action_labels.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_action_new_label.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/ic_action_new_label.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_action_overflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/ic_action_overflow.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/ic_action_search.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/logo.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/testbackground.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-hdpi/testbackground.jpg
--------------------------------------------------------------------------------
/res/drawable-mdpi/homebg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/homebg.jpg
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_action_accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/ic_action_accept.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_action_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/ic_action_camera.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_action_cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/ic_action_cancel.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_action_discard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/ic_action_discard.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_action_download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/ic_action_download.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_action_labels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/ic_action_labels.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_action_new_label.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/ic_action_new_label.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_action_overflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/ic_action_overflow.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/ic_action_search.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/logo.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/testbackground.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-mdpi/testbackground.jpg
--------------------------------------------------------------------------------
/res/drawable-xhdpi/homebg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/homebg.jpg
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_action_accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/ic_action_accept.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_action_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/ic_action_camera.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_action_cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/ic_action_cancel.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_action_discard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/ic_action_discard.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_action_download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/ic_action_download.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_action_labels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/ic_action_labels.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_action_new_label.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/ic_action_new_label.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_action_overflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/ic_action_overflow.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/logo.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/testbackground.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xhdpi/testbackground.jpg
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/homebg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/homebg.jpg
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_action_accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/ic_action_accept.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_action_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/ic_action_camera.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_action_cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/ic_action_cancel.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_action_discard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/ic_action_discard.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_action_download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/ic_action_download.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_action_labels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/ic_action_labels.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_action_new_label.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/ic_action_new_label.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_action_overflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/ic_action_overflow.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/logo.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/testbackground.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable-xxhdpi/testbackground.jpg
--------------------------------------------------------------------------------
/res/drawable/homebg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable/homebg.jpg
--------------------------------------------------------------------------------
/res/drawable/light_blue_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/res/drawable/light_green_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/res/drawable/light_red_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/res/drawable/light_yellow_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/res/drawable/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable/logo.png
--------------------------------------------------------------------------------
/res/drawable/testbackground.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/drawable/testbackground.jpg
--------------------------------------------------------------------------------
/res/drawable/testbg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/drawable/testtab.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/res/layout/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/batmaster/MPOS/d7a00cebfb6e3d2ad0a942b047072bd0b8651a6c/res/layout/.DS_Store
--------------------------------------------------------------------------------
/res/layout/activity_add_product.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
17 |
18 |
26 |
27 |
35 |
36 |
37 |
38 |
39 |
40 |
43 |
44 |
52 |
53 |
61 |
62 |
63 |
64 |
67 |
68 |
76 |
77 |
86 |
87 |
88 |
89 |
92 |
93 |
101 |
102 |
111 |
112 |
113 |
114 |
118 |
119 |
127 |
128 |
137 |
138 |
139 |
140 |
144 |
145 |
163 |
164 |
183 |
184 |
202 |
203 |
204 |
--------------------------------------------------------------------------------
/res/layout/activity_description.xml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
17 |
18 |
21 |
22 |
30 |
31 |
32 |
36 |
37 |
45 |
46 |
53 |
54 |
55 |
59 |
60 |
68 |
69 |
76 |
77 |
78 |
82 |
83 |
91 |
92 |
99 |
100 |
101 |
105 |
106 |
114 |
115 |
122 |
123 |
124 |
128 |
129 |
137 |
138 |
145 |
146 |
147 |
153 |
154 |
155 |
158 |
159 |
179 |
180 |
197 |
198 |
199 |
200 |
--------------------------------------------------------------------------------
/res/layout/activity_edit_product.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
18 |
19 |
22 |
23 |
31 |
32 |
40 |
41 |
42 |
43 |
46 |
47 |
55 |
56 |
63 |
64 |
65 |
68 |
69 |
77 |
78 |
86 |
87 |
88 |
89 |
92 |
93 |
101 |
102 |
110 |
111 |
112 |
113 |
116 |
117 |
125 |
126 |
134 |
135 |
136 |
137 |
138 |
142 |
143 |
162 |
163 |
183 |
184 |
203 |
204 |
205 |
--------------------------------------------------------------------------------
/res/layout/activity_menu.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
28 |
29 |
43 |
44 |
57 |
58 |
--------------------------------------------------------------------------------
/res/layout/activity_payment.xml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
17 |
18 |
21 |
22 |
30 |
31 |
38 |
39 |
40 |
44 |
45 |
53 |
54 |
63 |
64 |
65 |
66 |
67 |
68 |
73 |
74 |
92 |
93 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/res/layout/activity_sale_edit.xml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
17 |
18 |
21 |
22 |
30 |
31 |
38 |
39 |
40 |
43 |
44 |
52 |
53 |
60 |
61 |
62 |
65 |
66 |
74 |
75 |
83 |
84 |
85 |
86 |
87 |
88 |
91 |
92 |
100 |
101 |
109 |
110 |
111 |
112 |
113 |
117 |
118 |
136 |
137 |
155 |
156 |
157 |
158 |
159 |
--------------------------------------------------------------------------------
/res/layout/activity_sale_ledger_product_list.xml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
17 |
18 |
22 |
23 |
29 |
30 |
37 |
38 |
39 |
40 |
45 |
46 |
47 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/res/layout/activity_success_payment.xml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
17 |
18 |
26 |
27 |
36 |
37 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/res/layout/inventory_list_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
24 |
25 |
32 |
33 |
40 |
41 |
49 |
50 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/res/layout/product_ledger_list_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
22 |
23 |
29 |
30 |
37 |
38 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/res/layout/sale_ledger_list_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
22 |
23 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/res/layout/sale_list_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
24 |
25 |
33 |
34 |
41 |
42 |
49 |
50 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/res/menu/add_product.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/menu/description.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/menu/edit_product.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/menu/inventory_activity2.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/menu/ledger_ui.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/menu/payment.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/menu/sale_edit.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/menu/sale_ledger_list.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/menu/success_payment.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/values-sw600dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/res/values-sw720dp-land/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | 128dp
8 |
9 |
10 |
--------------------------------------------------------------------------------
/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | MPOS
5 | Settings
6 | Hello world!
7 | EditProductActivity
8 | SaleActivity
9 |
10 |
11 | - Sale
12 | - Inventory
13 |
14 |
15 | InventoryActivity2
16 | MenuActivity
17 | LedgerUIActivity
18 | AddProductActivity
19 | PaymentActivity
20 | SuccessPaymentActivity
21 | DescriptionActivity
22 | SaleEditActivity
23 | SaleLedgerListActivity
24 |
25 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/DAO/SaleLedgerDBHelper.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.DAO;
2 |
3 | import java.io.Serializable;
4 | import java.text.SimpleDateFormat;
5 | import java.util.ArrayList;
6 | import java.util.Calendar;
7 | import java.util.Date;
8 |
9 | import com.bbaf.mpos.FacadeController.Register;
10 | import com.bbaf.mpos.ProductDescription.ProductDescription;
11 | import com.bbaf.mpos.sale.Sale;
12 | import com.bbaf.mpos.sale.SaleLineItem;
13 | import com.bbaf.mpos.saleledger.ProductLedger;
14 | import com.bbaf.mpos.saleledger.SaleLedger;
15 |
16 | import android.content.ContentValues;
17 | import android.content.Context;
18 | import android.database.Cursor;
19 | import android.database.sqlite.SQLiteDatabase;
20 | import android.database.sqlite.SQLiteOpenHelper;
21 | import android.util.Log;
22 | import android.widget.Toast;
23 |
24 | /**
25 | * SaleLedger DAO, for contact between java object and database.
26 | * @author Poramet Homprakob 5510546077
27 | */
28 | public class SaleLedgerDBHelper extends SQLiteOpenHelper {
29 |
30 | private static final String DATABASE_NAME = "bbafmpos2.db";
31 | private static final String TABLE_SALE_LEDGER = "saleledger";
32 | private static final String TABLE_PRODUCT_LEDGER = "productledger";
33 | private static final int DATABASE_VERSION = 1;
34 | private static SaleLedgerDBHelper dao;
35 |
36 | private SaleLedgerDBHelper(Context context) {
37 | super(context, DATABASE_NAME, null, DATABASE_VERSION);
38 | }
39 |
40 | /**
41 | * Get SaleLedgerDBHelper object by initializing context.
42 | * Only for first using SaleLedgerDBHelper.
43 | * @param context context of calling activity
44 | * @return SaleLedgerDBHelper object
45 | */
46 | public static SaleLedgerDBHelper getInstance(Context context) {
47 | if (dao == null)
48 | dao = new SaleLedgerDBHelper(context);
49 | return dao;
50 | }
51 |
52 | /**
53 | * Get SaleLedgerDBHelper object.
54 | * @return SaleLedgerDBHelper object
55 | */
56 | public static SaleLedgerDBHelper getInstance() {
57 | return dao;
58 | }
59 |
60 | @Override
61 | public void onCreate(SQLiteDatabase db) {
62 | // date text yyyy-MM-dd HH:mm:ss
63 | String sql = String
64 | .format("CREATE TABLE %s (_key INTEGER PRIMARY KEY, Date TEXT, TotalPrice DOUBLE);",
65 | TABLE_SALE_LEDGER);
66 | db.execSQL(sql);
67 | sql = String
68 | .format("CREATE TABLE %s (_key INTEGER PRIMARY KEY, Date TEXT, ProductId TEXT, ProductName TEXT, UnitPrice DOUBLE, Price DOUBLE, Quantity INTEGER);",
69 | TABLE_PRODUCT_LEDGER);
70 | db.execSQL(sql);
71 | }
72 |
73 | @Override
74 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
75 | String sql = "USE TABLE IF EXISTS " + TABLE_SALE_LEDGER;
76 | db.execSQL(sql);
77 | sql = "USE TABLE IF EXISTS " + TABLE_PRODUCT_LEDGER;
78 | db.execSQL(sql);
79 | }
80 |
81 | /**
82 | * Add Sale description to database.
83 | * @param sale Sale object
84 | * @return row of added sale description in database, -1 if failed
85 | */
86 | public long addSale(Sale sale) {
87 |
88 | ArrayList lines = sale.getAllList();
89 |
90 | // date text yyyy MM dd HH mm ss
91 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy MM dd HH mm ss");
92 | Date a = sale.getDate();
93 | String current = sdf.format(a);
94 |
95 | /** add Sale Ledger **/
96 | try {
97 | SQLiteDatabase db = this.getWritableDatabase();
98 | ContentValues value = new ContentValues();
99 | value.put("Date", current);
100 | value.put("TotalPrice", sale.getTotal());
101 | long row = db.insert(TABLE_SALE_LEDGER, null, value);
102 |
103 | db.close();
104 | Log.d("add sale", "add SL r:" + row + " " + value.toString());
105 |
106 | } catch (Exception e) {
107 | return -1;
108 | }
109 |
110 | /** looping add Product Ledger **/
111 | try {
112 | SQLiteDatabase db = this.getWritableDatabase();
113 |
114 | for (int i = 0; i < lines.size(); i++) {
115 | SaleLineItem line = lines.get(i);
116 |
117 | ContentValues value = new ContentValues();
118 | value.put("Date", current);
119 | value.put("ProductId",line.getProductDescription().getId());
120 | value.put("ProductName", line.getProductDescription().getName());
121 | value.put("UnitPrice", line.getUnitPrice());
122 | value.put("Price", line.getTotal());
123 | value.put("Quantity", line.getQuantity());
124 | long row = db.insert(TABLE_PRODUCT_LEDGER, null, value);
125 |
126 | Log.d("add sale", "add PL r:" + row + " " + i + "/" + lines.size() + " " + value.toString());
127 | }
128 |
129 | db.close();
130 |
131 | } catch (Exception e) {
132 | return -2;
133 | }
134 |
135 | return 0;
136 | }
137 |
138 | /**
139 | * Get all Sale in database.
140 | * @return list of all sale in database
141 | */
142 | public ArrayList getAllSale() {
143 | ArrayList saleList = new ArrayList();
144 | try {
145 | SQLiteDatabase db = this.getReadableDatabase();
146 |
147 | /** Get all Sale Ledger **/
148 | String strSQL = "SELECT * FROM " + TABLE_SALE_LEDGER;
149 | Cursor cursorSL = db.rawQuery(strSQL, null);
150 | if (cursorSL != null) {
151 | if (cursorSL.moveToFirst()) {
152 | do {
153 | /**
154 | * 0 = _key 1 = Date 2 = Total
155 | */
156 | SaleLedger sl = new SaleLedger(cursorSL.getString(1), cursorSL.getDouble(2));
157 | String date = cursorSL.getString(0);
158 |
159 | /** Get all SaleLineItem for that Sale Ledger **/
160 | Cursor cursorPL = db.query(TABLE_PRODUCT_LEDGER, new String[] { "*" },
161 | "Date=?", new String[] { date }, null,
162 | null, null, null);
163 |
164 | if (cursorPL != null) {
165 | if (cursorPL.moveToFirst()) {
166 | do {
167 | /**
168 | * 0 = _key 1 = Date 2 = ProductId 3 = ProductName 4 = UnitPrice
169 | * 5 = Price 6 = Quantity
170 | */
171 | sl.addProductLedger(new ProductLedger(cursorPL.getString(2), cursorPL.getString(3), cursorPL.getDouble(4), cursorPL.getInt(6)));
172 | } while(cursorPL.moveToNext());
173 | }
174 | }
175 | cursorPL.close();
176 | saleList.add(sl);
177 | } while (cursorSL.moveToNext());
178 | }
179 | }
180 | cursorSL.close();
181 | db.close();
182 | return saleList;
183 | } catch (Exception e) {
184 | return saleList;
185 | }
186 | }
187 |
188 | /**
189 | * Get Sale by using start and end date string
190 | * @param from start date string
191 | * @param to end date string
192 | * @return list of found sales
193 | */
194 | public ArrayList getSale(String from, String to) {
195 | ArrayList saleList = new ArrayList();
196 | try {
197 | SQLiteDatabase db = this.getReadableDatabase();
198 |
199 | /** Get Sale Ledger **/
200 | String strSQL = String.format("SELECT * FROM %s WHERE Date BETWEEN '%s' AND '%s'", TABLE_SALE_LEDGER, from, to);
201 | Log.d("getSale", strSQL);
202 | Cursor cursorSL = db.rawQuery(strSQL, null);
203 | if (cursorSL != null) {
204 | if (cursorSL.moveToFirst()) {
205 | do {
206 | /**
207 | * 0 = _key 1 = Date 2 = Total
208 | */
209 | SaleLedger sl = new SaleLedger(cursorSL.getString(1), cursorSL.getDouble(2));
210 | String date = cursorSL.getString(1);
211 |
212 | /** Get SaleLineItem for that Sale Ledger **/
213 | strSQL = String.format("SELECT * FROM %s WHERE Date = '%s'", TABLE_PRODUCT_LEDGER, date);
214 | Cursor cursorPL = db.rawQuery(strSQL, null);
215 |
216 | if (cursorPL != null) {
217 | if (cursorPL.moveToFirst()) {
218 | do {
219 | /**
220 | * 0 = _key 1 = Date 2 = ProductId 3 = ProductName 4 = UnitPrice
221 | * 5 = Price 6 = Quantity
222 | */
223 | sl.addProductLedger(new ProductLedger(cursorPL.getString(2), cursorPL.getString(3), cursorPL.getDouble(4), cursorPL.getInt(6)));
224 | } while (cursorPL.moveToNext());
225 | }
226 | }
227 | cursorPL.close();
228 | saleList.add(sl);
229 | } while (cursorSL.moveToNext());
230 | }
231 | }
232 | cursorSL.close();
233 | db.close();
234 | return saleList;
235 | } catch (Exception e) {
236 | return saleList;
237 | }
238 | }
239 |
240 | /**
241 | * Remove sale in database by using date Calendar
242 | * @param calendar date as Calendar
243 | * @return row of deleted sale, -1 if failed
244 | */
245 | public long removeSale(Calendar calendar) {
246 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy MM dd HH mm ss");
247 | String current = sdf.format(calendar);
248 | try {
249 |
250 | SQLiteDatabase db = this.getWritableDatabase();
251 |
252 | long rows = db.delete(TABLE_SALE_LEDGER, "Date=?",
253 | new String[] {current});
254 | db.delete(TABLE_PRODUCT_LEDGER, "Date=?",
255 | new String[] { current});
256 |
257 | db.close();
258 | return rows; // return rows delete.
259 |
260 | } catch (Exception e) {
261 | return -1;
262 | }
263 | }
264 | }
265 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/FacadeController/Register.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.FacadeController;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 |
6 | import android.util.Log;
7 | import android.widget.Toast;
8 |
9 | import com.bbaf.mpos.ProductDescription.ProductDescription;
10 | import com.bbaf.mpos.inventory.Inventory;
11 | import com.bbaf.mpos.sale.Sale;
12 | import com.bbaf.mpos.sale.SaleLineItem;
13 | import com.bbaf.mpos.saleledger.Ledger;
14 |
15 | /**
16 | * Register is a controller for sale.
17 | * @author Atit Leelasuksan 5510546221 , Rungroj Maipradit 5510546654
18 | * @version Oct 29, 2013
19 | */
20 | public class Register implements Serializable {
21 |
22 | /** sale for register. */
23 | private Sale sale;
24 |
25 | /** Inventory for register. */
26 | private Inventory inventory;
27 | /** Ledger for register. */
28 | private Ledger ledger;
29 |
30 | /** instance of register to be singleton. */
31 | private static Register register;
32 |
33 | /**
34 | * initialize.
35 | */
36 | private Register(Inventory inventory) {
37 | this.inventory = inventory;
38 | }
39 |
40 | /**
41 | * get register if null create new one
42 | * @param inventory set Inventory
43 | * @return register
44 | */
45 | public static Register getInstance(Inventory inventory) {
46 | if(register==null) register = new Register(inventory);
47 | return register;
48 | }
49 |
50 | /**
51 | * get register if null create new one
52 | * @return register
53 | */
54 | public static Register getInstance() {
55 | if(register==null) register = new Register(new Inventory());
56 | return register;
57 | }
58 |
59 | /**
60 | * create new sale.
61 | */
62 | public void startSale() {
63 | if(sale==null)
64 | sale = new Sale(inventory);
65 | }
66 |
67 | /**
68 | * get total of sale.
69 | * @return total of current sale.
70 | */
71 | public double getTotal() {
72 | if(!sale.equals(null)) return sale.getTotal();
73 | return 0;
74 | }
75 |
76 | /**
77 | * add item to sale.
78 | * @param productDesc is item to add.
79 | * @param quantity of item to add.
80 | * @return true if add complete otherwise false.
81 | */
82 | public boolean addItem(ProductDescription productDesc,int quantity) {
83 | if(!sale.equals(null)) {
84 | sale.addSaleLineItem(productDesc,quantity);
85 | return true;
86 | }
87 | return false;
88 | }
89 |
90 | /**
91 | * remove item in sale.
92 | * @param productDesc is item to add.
93 | * @return true if remove complete otherwise false.
94 | */
95 | public boolean removeItem(ProductDescription productDesc) {
96 | if(!sale.equals(null)) {
97 | sale.removeSaleLineItem(productDesc);
98 | return true;
99 | }
100 | return false;
101 | }
102 |
103 | /**
104 | * remove all item in sale.
105 | * @param productDesc is item to add.
106 | * @return true if remove complete otherwise false.
107 | */
108 | public boolean removeAllItem() {
109 | if(!sale.equals(null)) {
110 | sale.removeAllSaleLineItem();
111 | return true;
112 | }
113 | return false;
114 | }
115 |
116 | /**
117 | * get all list of item in sale.
118 | * @return all list of item in current sale.
119 | */
120 | public ArrayList getAllSaleLineItemList() {
121 | if(!sale.equals(null))
122 | return sale.getAllList();
123 | return null;
124 | }
125 |
126 | /**
127 | * get list of item in sale.
128 | * @return list of item in current sale.
129 | */
130 | public SaleLineItem getSaleLineItemList(ProductDescription product) {
131 | if(!sale.equals(null))
132 | return sale.getList(product);
133 | return null;
134 | }
135 |
136 | /**
137 | * remove current sale.
138 | */
139 | public void endSale() {
140 | if(!sale.equals(null)) sale = null;
141 | }
142 |
143 | /**
144 | * get sale status.
145 | * @return true if sale not null otherwise false.
146 | */
147 | public boolean isSale() {
148 | return !(sale==null);
149 | }
150 |
151 | /**
152 | * get inventory.
153 | * @return inventory
154 | */
155 | public Inventory getInventory() {
156 | return inventory;
157 | }
158 |
159 | /**
160 | * Decrease amount of item that match with this id.
161 | * @param id key that match with item
162 | * @param quantity amount of item
163 | */
164 | public void decrease(String id,int quantity) {
165 | inventory.setQuantity(inventory.getProduct(id), inventory.getQuantity(id) - quantity);
166 | }
167 |
168 | /**
169 | * get sale
170 | * @return sale
171 | */
172 | public Sale getSale() {
173 | return sale;
174 | }
175 |
176 | /**
177 | * set ledger
178 | * @param ledger set Ledger
179 | */
180 | public void setLedger(Ledger ledger) {
181 | this.ledger = ledger;
182 | }
183 |
184 | /**
185 | * get ledger
186 | * @return ledger
187 | */
188 | public Ledger getLedger() {
189 | return ledger;
190 | }
191 |
192 | /**
193 | * return change
194 | * @param input amount of money that get paid
195 | * @return change
196 | */
197 | public double change(double input){
198 | return input - getTotal();
199 | }
200 | }
201 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/ProductDescription/ProductDescription.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.ProductDescription;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.bbaf.mpos.sale.SaleLineItem;
6 |
7 | import android.util.Log;
8 |
9 | /**
10 | * Class for product detail.
11 | * @author Atit Leelasuksan 5510546221
12 | * @version Dec 9, 2013
13 | */
14 | public class ProductDescription implements Serializable {
15 |
16 | @Override
17 | public int hashCode() {
18 | final int prime = 31;
19 | int result = 1;
20 | result = prime * result + ((id == null) ? 0 : id.hashCode());
21 | return result;
22 | }
23 |
24 | @Override
25 | public boolean equals(Object obj) {
26 | if (obj == null)
27 | return false;
28 | if (this.getClass() == obj.getClass()) {
29 | ProductDescription product = (ProductDescription)obj;
30 | return id.equals(product.getId());
31 | }
32 | else if (SaleLineItem.class == obj.getClass()) {
33 | SaleLineItem line = (SaleLineItem)obj;
34 | return id.equals(line.getProductDescription().getId());
35 | }
36 |
37 | return false;
38 | }
39 |
40 | private int key;
41 | /** id of product. */
42 | private String id;
43 | /** name of product. */
44 | private String name;
45 | /** price of product. */
46 | private double price;
47 | /** cost of product. */
48 | private double cost;
49 | /** last date modified of product. */
50 | private String dateModified;
51 |
52 | /**
53 | * Constructor of this class
54 | * @param key refer to key
55 | * @param id refer to id
56 | * @param name refer to name
57 | * @param price refer to price
58 | * @param cost refer to cost
59 | * @param dateModified refer to dateModified
60 | */
61 | public ProductDescription(int key, String id, String name, double price, double cost, String dateModified) {
62 | this.key = key;
63 | this.id = id;
64 | this.name = name;
65 | this.price = price;
66 | this.cost = cost;
67 | this.dateModified = dateModified;
68 | }
69 |
70 | /**
71 | * Constructor of this class
72 | * @param id refer to id
73 | * @param name refer to name
74 | * @param price refer to price
75 | * @param cost refer to cost
76 | */
77 | public ProductDescription(String id, String name, double price, double cost) {
78 | this(0, id, name, price, cost, "");
79 | }
80 |
81 | /**
82 | * return key
83 | * @return key
84 | */
85 | public int getKey() {
86 | return key;
87 | }
88 |
89 | /**
90 | * return id
91 | * @return id
92 | */
93 | public String getId() {
94 | return id;
95 | }
96 |
97 | /**
98 | * return name
99 | * @return name
100 | */
101 | public String getName() {
102 | return name;
103 | }
104 |
105 | /**
106 | * return price
107 | * @return price
108 | */
109 | public double getPrice() {
110 | return price;
111 | }
112 |
113 | /**
114 | * return cost
115 | * @return cost
116 | */
117 | public double getCost() {
118 | return cost;
119 | }
120 |
121 | /**
122 | * return date type string
123 | * @return date
124 | */
125 | public String getDateModified() {
126 | return dateModified;
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/ProductDescription/ProductQuantity.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.ProductDescription;
2 |
3 | /**
4 | * Class to represent quantity of product that have same id.
5 | * @author Atit Leelasuksan 5510546221
6 | *
7 | */
8 | public class ProductQuantity {
9 |
10 | /** id of product. */
11 | private String id;
12 |
13 | /** quantity of product. */
14 | private int quantity;
15 |
16 | /**
17 | * Constructor to initialize with id and quantity.
18 | * @param id of product.
19 | * @param quan quantity of product.
20 | */
21 | public ProductQuantity(String id,int quan) {
22 | this.id = id;
23 | quantity = quan;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventory/Inventory.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventory;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 |
6 | import android.content.ContentValues;
7 | import android.database.sqlite.SQLiteDatabase;
8 |
9 | import com.bbaf.mpos.DAO.InventoryDBHelper;
10 | import com.bbaf.mpos.ProductDescription.ProductDescription;
11 |
12 | /**
13 | * Inventory class to delegate duty to inventory database access object.
14 | * @author Atit Leelasuksan 5510546221
15 | * @version Dec 9, 2013
16 | */
17 | public class Inventory implements Serializable {
18 | /** database access object for inventory. */
19 | private InventoryDBHelper dbDAO;
20 |
21 | /**
22 | * Constructor of inventory.
23 | * Initialize attribute of this class.
24 | */
25 | public Inventory(){
26 | dbDAO = InventoryDBHelper.getInstance();
27 | }
28 |
29 | /**
30 | * Set Inventory database connector
31 | * @param db set Inventory database connector
32 | */
33 | public void setDB(InventoryDBHelper db) {
34 | dbDAO = db;
35 | }
36 |
37 | /**
38 | * Add productDescription
39 | * @param product is item to add.
40 | * @param quantity of item to add.
41 | * @return
42 | */
43 | public long addProduct(ProductDescription product,int quantity){
44 | return dbDAO.addProduct(product,quantity);
45 | }
46 |
47 | /**
48 | * increase quantity.
49 | * @param product is item to add.
50 | * @param quantity of item to add.
51 | */
52 | public void addQuantity(ProductDescription product, int quantity) {
53 | dbDAO.addQuantity(product, quantity);
54 | }
55 |
56 | /**
57 | * set quantity
58 | * @param product is item to add.
59 | * @param quantity of item to add.
60 | * @return
61 | */
62 | public long setQuantity(ProductDescription product, int quantity) {
63 | return dbDAO.setQuantity(product, quantity);
64 | }
65 |
66 | /**
67 | * get productDescription that match with id.
68 | * @param id of that item
69 | * @return productDescription
70 | */
71 | public ProductDescription getProduct(String id) {
72 | return dbDAO.getProduct(id);
73 | }
74 |
75 | /**
76 | * get quantity.
77 | * @param id of that item
78 | * @return quantity
79 | */
80 | public int getQuantity(String id) {
81 | return dbDAO.getQuantity(id);
82 | }
83 |
84 | /**
85 | * edit productDescription
86 | * @param oldProduct the old one
87 | * @param newProduct the new one
88 | */
89 | public void editProduct(ProductDescription oldProduct,
90 | ProductDescription newProduct) {
91 | dbDAO.editProduct(oldProduct, newProduct);
92 | }
93 |
94 | /**
95 | * edit quantity
96 | * @param oldProduct the old one
97 | * @param newProduct the new one
98 | * @param quantity amount of item
99 | */
100 | public void editQuantity(ProductDescription oldProduct,
101 | ProductDescription newProduct, int quantity) {
102 | dbDAO.editQuantity(oldProduct, newProduct, quantity);
103 | }
104 |
105 | /**
106 | * test method.
107 | * @param something to test.
108 | * @return all product.
109 | */
110 | public ArrayList getProductBySomething(String something) {
111 | return dbDAO.getProductBySomething(something);
112 | }
113 |
114 | /**
115 | * remove productDescription
116 | * @param product that want to remove
117 | */
118 | public void removeProduct(ProductDescription product) {
119 | dbDAO.removeProduct(product);
120 | }
121 |
122 | /**
123 | * return all productDescription
124 | * @return all productDescription
125 | */
126 | public ArrayList getAllProduct() {
127 | return dbDAO.getAllProduct();
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventory/description/ui/DescriptionActivity.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventory.description.ui;
2 |
3 | import com.bbaf.mpos.R;
4 | import com.bbaf.mpos.FacadeController.Register;
5 | import com.bbaf.mpos.ProductDescription.ProductDescription;
6 | import com.bbaf.mpos.R.layout;
7 | import com.bbaf.mpos.R.menu;
8 | import com.bbaf.mpos.inventoryAndSale.ui.EditProductActivity;
9 | import com.google.zxing.integration.android.IntentIntegrator;
10 | import com.google.zxing.integration.android.IntentResult;
11 |
12 | import android.os.Bundle;
13 | import android.app.Activity;
14 | import android.content.Intent;
15 | import android.view.Menu;
16 | import android.view.View;
17 | import android.view.View.OnClickListener;
18 | import android.widget.Button;
19 | import android.widget.TextView;
20 | import android.widget.Toast;
21 | /**
22 | * Description Activity for showing the product description.
23 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
24 | */
25 | public class DescriptionActivity extends Activity {
26 |
27 | /** Description */
28 | private TextView textViewDescriptionID;
29 | private TextView textViewDescriptionName;
30 | private TextView textViewDescriptionPrice;
31 | private TextView textViewDescriptionCost;
32 | private TextView textViewDescriptionQuantity;
33 | private Button buttonDescriptionEdit;
34 | //private Button buttonDescriptionBack;
35 |
36 | private static final int EDIT_ACTIVITY_REQUESTCODE = 1;
37 |
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.activity_description);
42 |
43 | final ProductDescription oldProduct = (ProductDescription) getIntent()
44 | .getSerializableExtra("ProductDescription");
45 | final Activity activity = (Activity) getIntent()
46 | .getSerializableExtra("Activity");
47 | final int oldQuantity = getIntent()
48 | .getIntExtra("ProductQuantity", 0);
49 |
50 | textViewDescriptionID = (TextView)findViewById(R.id.textViewDescriptionID);
51 | textViewDescriptionID.setText(oldProduct.getId());
52 |
53 | textViewDescriptionName = (TextView)findViewById(R.id.textViewDescriptionName);
54 | textViewDescriptionName.setText(oldProduct.getName());
55 |
56 | textViewDescriptionPrice = (TextView)findViewById(R.id.textViewDescriptionPrice);
57 | textViewDescriptionPrice.setText(String.format("%.2f", oldProduct.getPrice()));
58 |
59 | textViewDescriptionCost = (TextView)findViewById(R.id.textViewDescriptionCost);
60 | textViewDescriptionCost.setText(String.format("%.2f", oldProduct.getCost()));
61 |
62 | textViewDescriptionQuantity = (TextView)findViewById(R.id.textViewDescriptionQuantity);
63 | textViewDescriptionQuantity.setText(String.valueOf(oldQuantity));
64 |
65 | buttonDescriptionEdit = (Button)findViewById(R.id.buttonDescriptionEdit);
66 | buttonDescriptionEdit.setOnClickListener(new OnClickListener() {
67 |
68 | @Override
69 | public void onClick(View arg0) {
70 | Intent editActivity = new Intent(getApplicationContext(), EditProductActivity.class);
71 |
72 | editActivity.putExtra("ProductDescription", oldProduct);
73 | editActivity.putExtra("ProductQuantity", oldQuantity);
74 |
75 | startActivityForResult(editActivity, EDIT_ACTIVITY_REQUESTCODE);
76 | }
77 | });
78 | }
79 |
80 | @Override
81 | public boolean onCreateOptionsMenu(Menu menu) {
82 | // Inflate the menu; this adds items to the action bar if it is present.
83 | getMenuInflater().inflate(R.menu.description, menu);
84 | return true;
85 | }
86 |
87 | @Override
88 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
89 | super.onActivityResult(requestCode, resultCode, data);
90 |
91 | if (requestCode == EDIT_ACTIVITY_REQUESTCODE) {
92 | setResult(resultCode);
93 | finish();
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/ATSOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.view.View;
4 | import android.view.View.OnClickListener;
5 | import android.widget.ListView;
6 | import android.widget.TabHost;
7 | import android.widget.Toast;
8 |
9 | import com.bbaf.mpos.R;
10 | import com.bbaf.mpos.FacadeController.Register;
11 | import com.bbaf.mpos.ProductDescription.ProductDescription;
12 | /**
13 | * ActionListener of AddToSale button in Sale view.
14 | * @author Poramet Homprakob 5510546077
15 | */
16 | public class ATSOnClickListener implements OnClickListener {
17 |
18 | private ListView listViewInventory;
19 | private InventoryandSaleActivity activity;
20 |
21 | /**
22 | * Constructor, use calling activity as a context.
23 | * @param listViewInventory ListView of items in Inventory
24 | * @param activity calling activity
25 | */
26 | public ATSOnClickListener(ListView listViewInventory, InventoryandSaleActivity activity) {
27 | this.listViewInventory = listViewInventory;
28 | this.activity = activity;
29 | }
30 |
31 | @Override
32 | public void onClick(View v) {
33 | int count = 0;
34 | for (int i = 0; i < listViewInventory.getChildCount(); i++) {
35 | try {
36 | InventoryListRow row = (InventoryListRow)listViewInventory.getChildAt(i);
37 |
38 | if (row.isChecked()) {
39 | ProductDescription product = row.getProduct();
40 | Register.getInstance().addItem(product, 1);
41 | count++;
42 | }
43 | } catch (ClassCastException e) {
44 | }
45 | }
46 | TabHost tabHost = (TabHost)activity.findViewById(R.id.tabhost2);
47 | tabHost.setCurrentTab(0);
48 | activity.refreshSaleListView();
49 | activity.refreshIntenvoryListView();
50 | Toast.makeText(activity, count + " items are added.", Toast.LENGTH_SHORT).show();
51 | }
52 | }
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/AddOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.view.View;
4 | import android.view.View.OnClickListener;
5 | import android.widget.EditText;
6 | import android.widget.Toast;
7 |
8 | import com.bbaf.mpos.FacadeController.Register;
9 | import com.bbaf.mpos.ProductDescription.ProductDescription;
10 |
11 | /**
12 | * ActionListener of Add button in Inventory view.
13 | * @author Poramet Homprakob 5510546077
14 | */
15 | public class AddOnClickListener implements OnClickListener {
16 |
17 | private AddProductActivity activity;
18 |
19 | private static final int ADD_SUCCESS = 1;
20 |
21 | /**
22 | * Constructor, use calling activity as a context.
23 | * @param activity calling activity
24 | */
25 | public AddOnClickListener(AddProductActivity activity) {
26 | this.activity = activity;
27 | }
28 |
29 | @Override
30 | public void onClick(View v) {
31 | EditText[] text = activity.getAllEditText();
32 | EditText editTextProductId = text[0];
33 | EditText editTextProductName = text[1];
34 | EditText editTextPrice = text[2];
35 | EditText editTextCost = text[3];
36 | EditText editTextQuantity = text[4];
37 | String id = editTextProductId.getText().toString();
38 | if (!id.equals("")) {
39 | if (Register.getInstance().getInventory().getProduct(id) == null) {
40 | String name = editTextProductName.getText().toString();
41 | String priceText = editTextPrice.getText().toString();
42 | String costText = editTextCost.getText().toString();
43 | String quantityText = editTextQuantity.getText()
44 | .toString();
45 |
46 | double price = Double.parseDouble(priceText.equals("") ? "0"
47 | : priceText);
48 | double cost = Double.parseDouble(costText.equals("") ? "0"
49 | : costText);
50 | int quantity = Integer.parseInt(quantityText.equals("") ? "1"
51 | : quantityText);
52 | ProductDescription product = new ProductDescription(id,
53 | name, price, cost);
54 | long row = Register.getInstance().getInventory().addProduct(product,quantity);
55 | Toast.makeText(
56 | activity.getApplicationContext(),
57 | String.format(
58 | "Product add to row %d successfully.",
59 | row), Toast.LENGTH_SHORT).show();
60 | activity.setResult(ADD_SUCCESS);
61 |
62 | editTextProductId.setText("");
63 | editTextProductName.setText("");
64 | editTextPrice.setText("");
65 | editTextCost.setText("");
66 | editTextQuantity.setText("");
67 | editTextProductId.requestFocus();
68 | //
69 | }
70 | else {
71 | Toast.makeText(activity.getApplicationContext(), String.format("Product ID %s is already added", id), Toast.LENGTH_SHORT).show();
72 | }
73 | } else {
74 | Toast.makeText(activity.getApplicationContext(),
75 | "Product ID must not be empty.", Toast.LENGTH_SHORT)
76 | .show();
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/AddProductActivity.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.Menu;
8 | import android.view.View;
9 | import android.view.View.OnClickListener;
10 | import android.widget.Button;
11 | import android.widget.EditText;
12 | import android.widget.Toast;
13 |
14 | import com.bbaf.mpos.R;
15 | import com.bbaf.mpos.FacadeController.Register;
16 | import com.google.zxing.integration.android.IntentIntegrator;
17 | import com.google.zxing.integration.android.IntentResult;
18 |
19 | /**
20 | * Controller of AddProductActivity.
21 | * @author Poramet Homprakob 5510546077
22 | */
23 | public class AddProductActivity extends Activity {
24 |
25 | private EditText editTextProductId;
26 | private EditText editTextProductName;
27 | private EditText editTextCost;
28 | private EditText editTextPrice;
29 | private EditText editTextQuantity;
30 | private Button buttonAddX;
31 | private Button buttonScanX;
32 | private Button buttonCancelX;
33 |
34 | private static final int ADD_CANCEL = 0;
35 | private static final int SCANNER_ACTIVITY_REQUESTCODE = 49374;
36 |
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.activity_add_product);
41 |
42 | editTextProductId = (EditText)findViewById(R.id.editTextProductId2);
43 | editTextProductName = (EditText)findViewById(R.id.editTextProductName2);
44 | editTextPrice = (EditText)findViewById(R.id.editTextPrice2);
45 | editTextCost = (EditText)findViewById(R.id.editTextCost2);
46 | editTextQuantity = (EditText)findViewById(R.id.editTextQuantity3);
47 |
48 | buttonAddX = (Button)findViewById(R.id.buttonAddX);
49 | buttonAddX.setOnClickListener(new AddOnClickListener(this));
50 |
51 | buttonScanX = (Button)findViewById(R.id.buttonScanX);
52 | buttonScanX.setOnClickListener(new ScanOnClickListener(this));
53 |
54 | buttonCancelX = (Button)findViewById(R.id.buttonCancelX);
55 | buttonCancelX.setOnClickListener(new OnClickListener() {
56 |
57 | @Override
58 | public void onClick(View v) {
59 | finish();
60 |
61 | }
62 | });
63 |
64 | setResult(ADD_CANCEL);
65 | }
66 |
67 | @Override
68 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
69 | super.onActivityResult(requestCode, resultCode, data);
70 | // bat: for tracking whether from which Activity and what is the result
71 | Log.d("result", "requestCode " + requestCode);
72 | Log.d("result", "resultCode " + resultCode);
73 | //
74 | if (requestCode == SCANNER_ACTIVITY_REQUESTCODE) {
75 | IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
76 | if (scanningResult != null) {
77 | if (Register.getInstance().getInventory().getProduct(scanningResult.getContents()) == null) {
78 | editTextProductId.setText(scanningResult.getContents());
79 | editTextQuantity.requestFocus();
80 | }
81 | else {
82 | Toast.makeText(getApplicationContext(),"ID has been registered already.", Toast.LENGTH_SHORT).show();
83 | }
84 | }
85 | else {
86 | Toast.makeText(getApplicationContext(),"No scanned data received!", Toast.LENGTH_SHORT).show();
87 | }
88 | }
89 | }
90 |
91 | /**
92 | * Return all EditText in activity.
93 | * @return all EditText in activity
94 | */
95 | public EditText[] getAllEditText() {
96 | return new EditText[] {editTextProductId, editTextProductName, editTextPrice, editTextCost, editTextQuantity};
97 | }
98 |
99 | @Override
100 | public boolean onCreateOptionsMenu(Menu menu) {
101 | // Inflate the menu; this adds items to the action bar if it is present.
102 | getMenuInflater().inflate(R.menu.add_product, menu);
103 | return true;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/CancelSaleDialogOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.content.DialogInterface;
4 | import android.content.DialogInterface.OnClickListener;
5 |
6 | import com.bbaf.mpos.FacadeController.Register;
7 |
8 | /**
9 | * ActionListener of CancelSale button in Sale view.
10 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
11 | */
12 | public class CancelSaleDialogOnClickListener implements OnClickListener {
13 |
14 | private InventoryandSaleActivity activity;
15 |
16 | /**
17 | * Constructor, use calling activity as a context.
18 | * @param activity calling activity
19 | */
20 | public CancelSaleDialogOnClickListener(InventoryandSaleActivity activity) {
21 | this.activity = activity;
22 | }
23 |
24 | @Override
25 | public void onClick(DialogInterface dialog, int which) {
26 | Register.getInstance().removeAllItem();
27 | activity.clearSaleTab();
28 | activity.refreshSaleListView();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/CancelSaleOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.app.AlertDialog;
4 | import android.view.View;
5 | import android.view.View.OnClickListener;
6 | import android.widget.ListView;
7 |
8 | import com.bbaf.mpos.FacadeController.Register;
9 |
10 | /**
11 | * ActionListener of Cancel button in confirm dialog in Sale view.
12 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
13 | */
14 | public class CancelSaleOnClickListener implements OnClickListener {
15 |
16 | private ListView listView;
17 | private InventoryandSaleActivity activity;
18 |
19 | public CancelSaleOnClickListener(InventoryandSaleActivity activity) {
20 | this.listView = listView;
21 | this.activity = activity;
22 | }
23 |
24 | @Override
25 | public void onClick(View v) {
26 | if (Register.getInstance().getSale().getAllList().size() == 0) {
27 |
28 | }
29 | else {
30 | final AlertDialog.Builder adb = new AlertDialog.Builder(
31 | activity);
32 | adb.setTitle("Confirm?");
33 | adb.setMessage("Cancel Sale?");
34 | adb.setPositiveButton("Cancel", null);
35 | adb.setNegativeButton("Confirm", new CancelSaleDialogOnClickListener(activity));
36 | adb.show();
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/ClearOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.view.View;
4 | import android.view.View.OnClickListener;
5 | import android.widget.EditText;
6 |
7 | /**
8 | * ActionListener of Clear button in Inventory view.
9 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
10 | */
11 | public class ClearOnClickListener implements OnClickListener {
12 |
13 | private AddProductActivity activity;
14 |
15 | /**
16 | * Constructor, use calling activity as a context.
17 | * @param activity calling activity
18 | */
19 | public ClearOnClickListener(AddProductActivity activity) {
20 | this.activity = activity;
21 | }
22 |
23 | @Override
24 | public void onClick(View v) {
25 | clear();
26 | }
27 |
28 | /**
29 | * Clear text in EditTexts
30 | */
31 | private void clear() {
32 | EditText[] text = activity.getAllEditText();
33 | EditText editTextProductId = text[0];
34 | EditText editTextProductName = text[1];
35 | EditText editTextPrice = text[2];
36 | EditText editTextCost = text[3];
37 | EditText editTextQuantity = text[4];
38 | editTextProductId.setText("");
39 | editTextProductName.setText("");
40 | editTextPrice.setText("");
41 | editTextCost.setText("");
42 | editTextQuantity.setText("");
43 | editTextProductId.requestFocus();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/EditProductActivity.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.Menu;
7 | import android.view.View;
8 | import android.view.View.OnClickListener;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 | import android.widget.Toast;
12 |
13 | import com.bbaf.mpos.R;
14 | import com.bbaf.mpos.FacadeController.Register;
15 | import com.bbaf.mpos.ProductDescription.ProductDescription;
16 | import com.google.zxing.integration.android.IntentIntegrator;
17 | import com.google.zxing.integration.android.IntentResult;
18 |
19 | /**
20 | * Controller of EditProductActivity.
21 | * @author Poramet Homprakob 5510546077
22 | */
23 | public class EditProductActivity extends Activity {
24 |
25 | private EditText editTextProductId;
26 | private EditText editTextProductName;
27 | private EditText editTextPrice;
28 | private EditText editTextCost;
29 | private EditText editTextQuantity;
30 | private Button buttonScan;
31 | private Button buttonSave;
32 | private Button buttonCancel;
33 |
34 | private static final int SCANNER_ACTIVITY_REQUESTCODE = 49374;
35 | private static final int EDIT_CANCEL = 0;
36 | private static final int EDIT_SUCCESS = 1;
37 |
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.activity_edit_product);
42 | final ProductDescription oldProduct = (ProductDescription) getIntent()
43 | .getSerializableExtra("ProductDescription");
44 | final int oldQuantity = getIntent()
45 | .getIntExtra("ProductQuantity", 0);
46 |
47 | editTextProductId = (EditText) findViewById(R.id.edit_editTextProductId);
48 | editTextProductId.setText(String.valueOf(oldProduct.getId()));
49 | editTextProductName = (EditText) findViewById(R.id.edit_editTextProductName);
50 | editTextProductName.setText(String.valueOf(oldProduct.getName()));
51 | editTextPrice = (EditText) findViewById(R.id.edit_editTextPrice);
52 | editTextPrice.setText(String.format("%.2f", oldProduct.getPrice()));
53 | editTextCost = (EditText) findViewById(R.id.edit_editTextCost);
54 | editTextCost.setText(String.format("%.2f", oldProduct.getCost()));
55 | editTextQuantity = (EditText) findViewById(R.id.edit_editTextQuantity);
56 | editTextQuantity.setText(String.valueOf(oldQuantity));
57 | buttonScan = (Button) findViewById(R.id.buttonScan);
58 | buttonScan.setOnClickListener(new OnClickListener() {
59 |
60 | @Override
61 | public void onClick(View v) {
62 | IntentIntegrator scanIntegrator = new IntentIntegrator(
63 | EditProductActivity.this);
64 | scanIntegrator.initiateScan();
65 | }
66 | });
67 |
68 | buttonSave = (Button) findViewById(R.id.buttonSave);
69 | buttonSave.setOnClickListener(new OnClickListener() {
70 |
71 | @Override
72 | public void onClick(View arg0) {
73 | String id = editTextProductId.getText().toString();
74 | if (id.equals("")) {
75 | Toast.makeText(getApplicationContext(),
76 | "Product ID must not be empty.", Toast.LENGTH_SHORT)
77 | .show();
78 | }
79 | else {
80 | if (Register.getInstance().getInventory().getProduct(id) != null && !id.equals(oldProduct.getId())) {
81 | Toast.makeText(
82 | getApplicationContext(),
83 | String.format("Product : %s is already added.",
84 | id), Toast.LENGTH_SHORT).show();
85 | }
86 | else {
87 | String name = editTextProductName.getText().toString();
88 | double price = Double.parseDouble(editTextPrice
89 | .getText().toString());
90 | double cost = Double.parseDouble(editTextCost.getText()
91 | .toString());
92 | ProductDescription newProduct = new ProductDescription(
93 | id, name, price, cost);
94 | Register.getInstance().getInventory().editProduct(oldProduct, newProduct);
95 | int quantity = Integer.parseInt(editTextQuantity
96 | .getText().toString());
97 | Register.getInstance().getInventory().editQuantity(oldProduct, newProduct, quantity);
98 | setResult(EDIT_SUCCESS);
99 | finish();
100 | }
101 | }
102 | }
103 | });
104 |
105 | buttonCancel = (Button) findViewById(R.id.buttonCancel);
106 | buttonCancel.setOnClickListener(new OnClickListener() {
107 |
108 | @Override
109 | public void onClick(View v) {
110 | setResult(EDIT_SUCCESS);
111 | finish();
112 | }
113 | });
114 | }
115 |
116 | @Override
117 | public boolean onCreateOptionsMenu(Menu menu) {
118 | getMenuInflater().inflate(R.menu.edit_product, menu);
119 | return true;
120 | }
121 |
122 | @Override
123 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
124 | super.onActivityResult(requestCode, resultCode, data);
125 |
126 | if (requestCode == SCANNER_ACTIVITY_REQUESTCODE) {
127 | IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
128 |
129 | // bat: although scanner is canceled, scanningResult is not null but scanningResult.getContents()
130 | if (scanningResult != null) {
131 | editTextProductId.setText(scanningResult.getContents());
132 | editTextProductName.requestFocus();
133 | }
134 | else {
135 | Toast.makeText(getApplicationContext(),"No scanned data received!", Toast.LENGTH_SHORT).show();
136 | }
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/InventoryListRow.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.graphics.Color;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.CheckBox;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import com.bbaf.mpos.R;
14 | import com.bbaf.mpos.FacadeController.Register;
15 | import com.bbaf.mpos.ProductDescription.ProductDescription;
16 | import com.bbaf.mpos.inventory.description.ui.DescriptionActivity;
17 |
18 | /**
19 | * Prototype of ListRow in Inventory.
20 | * @author Poramet Homprakob 5510546077
21 | */
22 | class InventoryListRow extends RemovableListRow {
23 |
24 | private ProductDescription product;
25 |
26 | private CheckBox checkBoxRowInventory;
27 | private TextView textViewRowIdInventory;
28 | private TextView textViewRowNameInventory;
29 | private TextView textViewRowQuantityInventory;
30 | private TextView textViewRowPriceInventory;
31 | private ImageView imageViewDetailRowInventory;
32 |
33 | private static final int EDIT_ACTIVITY_REQUESTCODE = 1;
34 |
35 | /**
36 | * Constructor.
37 | * @param activity creating activity
38 | * @param product ProductDescription to be shown
39 | */
40 | public InventoryListRow(final Activity activity, ProductDescription product) {
41 | super(activity.getApplicationContext());
42 | LayoutInflater inflater = (LayoutInflater)activity.getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
43 | inflater.inflate(R.layout.inventory_list_row, this, true);
44 |
45 | this.product = product;
46 |
47 | checkBoxRowInventory = (CheckBox)findViewById(R.id.checkBoxRowInventory);
48 |
49 | textViewRowIdInventory = (TextView)findViewById(R.id.textViewRowIdInventory);
50 | textViewRowIdInventory.setText(product.getId());
51 | textViewRowIdInventory.setTextColor(Color.GRAY);
52 |
53 | textViewRowNameInventory = (TextView)findViewById(R.id.textViewRowNameInventory);
54 | textViewRowNameInventory.setText(product.getName());
55 | textViewRowNameInventory.setTextColor(Color.BLACK);
56 |
57 | textViewRowQuantityInventory = (TextView)findViewById(R.id.textViewRowQuantityInventory);
58 | int quantity = Register.getInstance().getInventory().getQuantity(product.getId());
59 | textViewRowQuantityInventory.setText(String.valueOf(quantity));
60 | textViewRowQuantityInventory.setTextColor(quantity < 0 ? Color.RED : Color.BLACK);
61 |
62 | textViewRowPriceInventory = (TextView)findViewById(R.id.textViewRowPriceInventory);
63 | textViewRowPriceInventory.setText(String.format("%.2f", product.getPrice()));
64 | textViewRowPriceInventory.setTextColor(Color.BLACK);
65 |
66 | imageViewDetailRowInventory = (ImageView)findViewById(R.id.imageViewDetailRowInventory);
67 | imageViewDetailRowInventory.setOnClickListener(new OnClickListener() {
68 |
69 | @Override
70 | public void onClick(View v) {
71 | Intent descActivity = new Intent(activity.getApplicationContext(), DescriptionActivity.class);
72 |
73 | descActivity.putExtra("ProductDescription", getProduct());
74 | int quantity = Register.getInstance().getInventory().getQuantity(getProduct().getId());
75 | descActivity.putExtra("ProductQuantity", quantity);
76 |
77 | activity.startActivityForResult(descActivity, EDIT_ACTIVITY_REQUESTCODE);
78 | }
79 | });
80 | }
81 |
82 | /**
83 | * @see RemovableListRow#isChecked()
84 | */
85 | @Override
86 | public boolean isChecked() {
87 | return checkBoxRowInventory.isChecked();
88 | }
89 |
90 | /**
91 | * @see RemovableListRow#getProduct()
92 | */
93 | @Override
94 | public ProductDescription getProduct() {
95 | return product;
96 | }
97 |
98 | /**
99 | * @see RemovableListRow#remove()
100 | */
101 | @Override
102 | public void remove() {
103 | Register.getInstance().getInventory().removeProduct(product);
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/InventoryListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import java.util.ArrayList;
4 |
5 | import android.app.Activity;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.BaseAdapter;
9 |
10 | import com.bbaf.mpos.FacadeController.Register;
11 | import com.bbaf.mpos.ProductDescription.ProductDescription;
12 |
13 | /**
14 | * A class adapt ArrayList to be ListView shown in Inventory view.
15 | * @author Poramet Homprakob 5510546077
16 | */
17 | public class InventoryListViewAdapter extends BaseAdapter {
18 |
19 | private Activity activity;
20 | private ArrayList productList;
21 |
22 | /**
23 | * Constructor, using calling activity.
24 | * @param activity calling activity
25 | */
26 | public InventoryListViewAdapter(Activity activity) {
27 | this.activity = activity;
28 | this.productList = Register.getInstance().getInventory().getAllProduct();
29 | }
30 |
31 | @Override
32 | public int getCount() {
33 | return productList.size();
34 | }
35 |
36 | @Override
37 | public Object getItem(int position) {
38 | return productList.get(position);
39 | }
40 |
41 | @Override
42 | public long getItemId(int position) {
43 | return position;
44 | }
45 |
46 | @Override
47 | public View getView(int position, View convertView, ViewGroup parent) {
48 | return new InventoryListRow(activity, productList.get(position));
49 | }
50 |
51 | /**
52 | * Notify ListView to show new row lists
53 | */
54 | public void notifyDataSetChanged() {
55 | productList = Register.getInstance().getInventory().getAllProduct();
56 | super.notifyDataSetChanged();
57 | }
58 |
59 | /**
60 | * Notify ListView to show new row lists by using list of ProductDescription lists
61 | * @param productList list of ProductDescription
62 | */
63 | public void notifyDataSetChanged(ArrayList productList) {
64 | this.productList = productList;
65 | super.notifyDataSetChanged();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/RemovableListRow.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.content.Context;
4 | import android.widget.RelativeLayout;
5 |
6 | import com.bbaf.mpos.ProductDescription.ProductDescription;
7 |
8 | /**
9 | * Abstract of ListRow which has CheckBox and can use
10 | * description in itself to remove data in database.
11 | * @author Poramet Homprakob 5510546077
12 | */
13 | public abstract class RemovableListRow extends RelativeLayout {
14 |
15 | /**
16 | * Constructor, use activity context to create ListRow.
17 | * @param context context of calling activity
18 | */
19 | public RemovableListRow(Context context) {
20 | super(context);
21 | }
22 |
23 | /**
24 | * Return is the CheckBox in itself checked.
25 | * @return true if CheckBox is check, otherwise false
26 | */
27 | public abstract boolean isChecked();
28 |
29 | /**
30 | * Return ProductDescription which is stored in itself
31 | * @return ProductDesCription object
32 | */
33 | public abstract ProductDescription getProduct();
34 |
35 | /**
36 | * Remove data in database by using information from attribute
37 | */
38 | public abstract void remove();
39 | }
40 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/RemoveDialogOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.content.DialogInterface;
4 | import android.content.DialogInterface.OnClickListener;
5 | import android.widget.ListView;
6 |
7 | /**
8 | * ActionListener of Remove button.
9 | * @author Poramet Homprakob 5510546077
10 | */
11 | public class RemoveDialogOnClickListener implements OnClickListener {
12 |
13 | private ListView listView;
14 | private InventoryandSaleActivity activity;
15 |
16 | /**
17 | * Constructor, use calling activity as a context.
18 | * @param listView ListView of removing list row
19 | * @param activity calling activity
20 | */
21 | public RemoveDialogOnClickListener(ListView listView, InventoryandSaleActivity activity) {
22 | this.listView = listView;
23 | this.activity = activity;
24 | }
25 |
26 | @Override
27 | public void onClick(DialogInterface dialog, int which) {
28 | for (int i = 0; i < listView.getChildCount(); i++) {
29 | RemovableListRow row = (RemovableListRow)listView.getChildAt(i);
30 |
31 | if (row.isChecked()) {
32 | row.remove();
33 | }
34 | }
35 | activity.refreshIntenvoryListView();
36 | activity.refreshSaleListView();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/RemoveOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 |
4 | import android.app.AlertDialog;
5 | import android.view.View;
6 | import android.view.View.OnClickListener;
7 | import android.widget.ListView;
8 |
9 | /**
10 | * ActionListener of Remove button in confirm dialog.
11 | * @author Poramet Homprakob 5510546077
12 | */
13 | public class RemoveOnClickListener implements OnClickListener {
14 |
15 | private ListView listView;
16 | private InventoryandSaleActivity activity;
17 |
18 | public RemoveOnClickListener(ListView listView, InventoryandSaleActivity activity) {
19 | this.listView = listView;
20 | this.activity = activity;
21 | }
22 |
23 | @Override
24 | public void onClick(View v) {
25 | boolean hasChecked = false;
26 | for (int i = 0; i < listView.getChildCount(); i++) {
27 | RemovableListRow row = (RemovableListRow)listView.getChildAt(i);
28 |
29 | if (row.isChecked()) {
30 | hasChecked = true;
31 | break;
32 | }
33 | }
34 |
35 | if (hasChecked) {
36 | final AlertDialog.Builder adb = new AlertDialog.Builder(
37 | activity);
38 | adb.setTitle("Confirm?");
39 | adb.setMessage("Remove item(s)?");
40 | adb.setPositiveButton("Cancel", null);
41 | adb.setNegativeButton("Confirm", new RemoveDialogOnClickListener(listView, activity));
42 | adb.show();
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/SaleListRow.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.graphics.Color;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.CheckBox;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import com.bbaf.mpos.R;
14 | import com.bbaf.mpos.FacadeController.Register;
15 | import com.bbaf.mpos.ProductDescription.ProductDescription;
16 | import com.bbaf.mpos.sale.SaleLineItem;
17 | import com.bbaf.mpos.sale.payment.ui.SaleEditActivity;
18 |
19 | /**
20 | * Prototype of ListRow in Sale.
21 | * @author Poramet Homprakob 5510546077
22 | */
23 | class SaleListRow extends RemovableListRow {
24 |
25 | private SaleLineItem line;
26 |
27 | private CheckBox checkBoxRowSale;
28 | private TextView textViewRowIdSale;
29 | private TextView textViewRowNameSale;
30 | private TextView textViewRowUnitPriceSale;
31 | private TextView textViewRowQuantitySale;
32 | private ImageView imageViewEditRowSale;
33 |
34 | private boolean unitPriceChanged = false;
35 |
36 | private static final int EDIT_UNITPRICE_ACTIVITY_REQUESTCODE = 3;
37 |
38 | /**
39 | * Constructor.
40 | * @param activity creating activity
41 | * @param SaleLineItem SaleLineItem to be shown
42 | */
43 | public SaleListRow(final Activity activity, SaleLineItem line) {
44 | super(activity.getApplicationContext());
45 | LayoutInflater inflater = (LayoutInflater)activity.getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
46 | inflater.inflate(R.layout.sale_list_row, this, true);
47 |
48 | this.line = line;
49 |
50 | checkBoxRowSale = (CheckBox)findViewById(R.id.checkBoxRowSale);
51 |
52 | textViewRowIdSale = (TextView)findViewById(R.id.textViewRowIdSale);
53 | textViewRowIdSale.setText(line.getProductDescription().getId());
54 | textViewRowIdSale.setTextColor(Color.GRAY);
55 |
56 | textViewRowNameSale = (TextView)findViewById(R.id.textViewRowTotalSaleLedger);
57 | textViewRowNameSale.setText(line.getProductDescription().getName());
58 | textViewRowNameSale.setTextColor(Color.BLACK);
59 |
60 | textViewRowUnitPriceSale = (TextView)findViewById(R.id.textViewRowUnitPriceSale);
61 | textViewRowUnitPriceSale.setText(String.format("%.2f", line.getUnitPrice()));
62 | textViewRowUnitPriceSale.setTextColor(line.getUnitPrice() == Register.getInstance().getInventory().getProduct(line.getProductDescription().getId()).getPrice() ? Color.GRAY : Color.BLUE);
63 |
64 | textViewRowQuantitySale = (TextView)findViewById(R.id.textViewRowDateSaleLedger);
65 | textViewRowQuantitySale.setText(String.valueOf(line.getQuantity()));
66 | textViewRowQuantitySale.setTextColor(Color.BLACK);
67 |
68 | imageViewEditRowSale = (ImageView)findViewById(R.id.imageViewEditRowSale);
69 | imageViewEditRowSale.setOnClickListener(new OnClickListener() {
70 |
71 | @Override
72 | public void onClick(View v) {
73 | Intent editActivity = new Intent(activity.getApplicationContext(), SaleEditActivity.class);
74 |
75 | editActivity.putExtra("ProductDescription", getProduct());
76 |
77 | activity.startActivityForResult(editActivity, EDIT_UNITPRICE_ACTIVITY_REQUESTCODE);
78 | }
79 | });
80 | }
81 |
82 | /**
83 | * @see RemovableListRow#isChecked()
84 | */
85 | @Override
86 | public boolean isChecked() {
87 | return checkBoxRowSale.isChecked();
88 | }
89 |
90 | /**
91 | * @see RemovableListRow#getProduct()
92 | */
93 | @Override
94 | public ProductDescription getProduct() {
95 | return line.getProductDescription();
96 | }
97 |
98 | /**
99 | * @see RemovableListRow#remove()
100 | */
101 | @Override
102 | public void remove() {
103 | Register.getInstance().getSale().removeSaleLineItem(line.getProductDescription());
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/SaleListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import java.util.ArrayList;
4 |
5 | import android.app.Activity;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.BaseAdapter;
9 |
10 | import com.bbaf.mpos.FacadeController.Register;
11 | import com.bbaf.mpos.sale.SaleLineItem;
12 |
13 | /**
14 | * A class adapt ArrayList to be ListView shown in Sale view.
15 | * @author Poramet Homprakob 5510546077
16 | */
17 | public class SaleListViewAdapter extends BaseAdapter {
18 |
19 | private Activity activity;
20 | private ArrayList lineList;
21 |
22 | /**
23 | * Constructor, using calling activity.
24 | * @param activity calling activity
25 | */
26 | public SaleListViewAdapter(Activity activity) {
27 | this.activity = activity;
28 | this.lineList = Register.getInstance().getSale().getAllList();
29 | }
30 |
31 | @Override
32 | public int getCount() {
33 | return lineList.size();
34 | }
35 |
36 | @Override
37 | public Object getItem(int position) {
38 | return lineList.get(position);
39 | }
40 |
41 | @Override
42 | public long getItemId(int position) {
43 | return position;
44 | }
45 |
46 | @Override
47 | public View getView(int position, View convertView, ViewGroup parent) {
48 | return new SaleListRow(activity, lineList.get(position));
49 | }
50 |
51 | /**
52 | * Notify ListView to show new row lists
53 | */
54 | public void notifyDataSetChanged() {
55 | lineList = Register.getInstance().getSale().getAllList();
56 | super.notifyDataSetChanged();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/inventoryAndSale/ui/ScanOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.inventoryAndSale.ui;
2 |
3 | import android.app.Activity;
4 | import android.view.View;
5 | import android.view.View.OnClickListener;
6 |
7 | import com.google.zxing.integration.android.IntentIntegrator;
8 |
9 | /**
10 | * ActionListener of Scan button.
11 | * @author Poramet Homprakob 5510546077
12 | */
13 | public class ScanOnClickListener implements OnClickListener {
14 |
15 | private Activity activity;
16 |
17 | /**
18 | * Constructor, use calling activity.
19 | * @param activity calling activity
20 | */
21 | public ScanOnClickListener(Activity activity) {
22 | this.activity = activity;
23 | }
24 |
25 | @Override
26 | public void onClick(View v) {
27 | IntentIntegrator scanIntegrator = new IntentIntegrator(activity);
28 | scanIntegrator.initiateScan();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/menu/ui/MenuActivity.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.menu.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.Menu;
7 | import android.view.View;
8 | import android.view.View.OnClickListener;
9 | import android.widget.Button;
10 |
11 | import com.bbaf.mpos.R;
12 | import com.bbaf.mpos.DAO.InventoryDBHelper;
13 | import com.bbaf.mpos.FacadeController.Register;
14 | import com.bbaf.mpos.inventoryAndSale.ui.InventoryandSaleActivity;
15 | import com.bbaf.mpos.saleledger.Ledger;
16 | import com.bbaf.mpos.saleledger.ui.LedgerActivity;
17 |
18 | /**
19 | * Menu for choosing the option. Controller of Menu view.
20 | *
21 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
22 | */
23 | public class MenuActivity extends Activity {
24 |
25 | private Button buttonToInvenSale;
26 | private Button buttonToLedger;
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_menu);
32 | Register.getInstance().getInventory().setDB((InventoryDBHelper.getInstance(getApplicationContext())));
33 |
34 | buttonToInvenSale = (Button)findViewById(R.id.buttonToInvenSale);
35 | buttonToLedger = (Button)findViewById(R.id.buttonToLedger);
36 |
37 | Register.getInstance().setLedger(new Ledger(this));
38 |
39 | buttonToInvenSale.setOnClickListener(new OnClickListener() {
40 |
41 | @Override
42 | public void onClick(View arg0) {
43 | Intent toInvenSale = new Intent(getApplicationContext(),
44 | InventoryandSaleActivity.class);
45 | startActivity(toInvenSale);
46 | }
47 | });
48 |
49 | buttonToLedger.setOnClickListener(new OnClickListener() {
50 |
51 | @Override
52 | public void onClick(View arg0) {
53 | Intent toLedger = new Intent(getApplicationContext(),
54 | LedgerActivity.class);
55 | startActivity(toLedger);
56 | }
57 | });
58 | }
59 |
60 | @Override
61 | public boolean onCreateOptionsMenu(Menu menu) {
62 | // Inflate the menu; this adds items to the action bar if it is present.
63 | getMenuInflater().inflate(R.menu.menu, menu);
64 | return true;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/sale/Sale.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.sale;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.Calendar;
6 | import java.util.Date;
7 |
8 | import android.util.Log;
9 | import android.widget.Toast;
10 |
11 | import com.bbaf.mpos.DAO.InventoryDBHelper;
12 | import com.bbaf.mpos.ProductDescription.ProductDescription;
13 | import com.bbaf.mpos.inventory.Inventory;
14 |
15 | /**
16 | * Class for sale function work with SaleLineItem.
17 | * @author Atit Leelasuksan 5510546221 , Rungroj Maipradit 5510546654
18 | * @version Oct 28, 2013
19 | */
20 | public class Sale implements Serializable {
21 |
22 | /** List of SaleLineItem in this sale. */
23 | private ArrayList lineOfItem;
24 |
25 | /** inventory to get or check product. */
26 | private Inventory inventory;
27 |
28 | /** date of sale. */
29 | private Date date;
30 |
31 | /**
32 | * initialize sale with empty List of SaleLineItem.
33 | */
34 | public Sale() {
35 | date = Calendar.getInstance().getTime();
36 | lineOfItem = new ArrayList();
37 | }
38 |
39 | /**
40 | * initialize sale with empty List of SaleLineItem and set date.
41 | * @param sdate date
42 | */
43 | public Sale(String sdate) {
44 | date = Calendar.getInstance().getTime();
45 | setDate(sdate);
46 | lineOfItem = new ArrayList();
47 | }
48 |
49 | /**
50 | * initialize sale with empty List of SaleLineItem and set inventory.
51 | * @param inventory
52 | */
53 | public Sale(Inventory inventory){
54 | this();
55 | this.inventory = inventory;
56 | }
57 |
58 | /**
59 | * Add SaleLineItem to List if SaleLineItem doesn't exist in List.
60 | * Add SaleLineItem instead if it exist in List.
61 | * @param productDesc is product.
62 | * @param quantity is quantity of product to add.
63 | * @return true if add new SaleLineItem.
64 | * false if add quantity instead.
65 | */
66 | public boolean addSaleLineItem(ProductDescription productDesc,int quantity) {
67 | SaleLineItem line = checkItemInLine(new SaleLineItem(productDesc,quantity));
68 | if(!(line == null)) {
69 | line.addQuantity(quantity);
70 | return true;
71 | }
72 | lineOfItem.add(new SaleLineItem(productDesc, quantity));
73 | return true;
74 | }
75 |
76 | /**
77 | * remove saleLineItem that match with productDesc
78 | * @param productDesc productDescription that want to remove
79 | * @return return true if can remove else false
80 | */
81 | public boolean removeSaleLineItem(ProductDescription productDesc) {
82 | try {
83 | boolean canRemove = lineOfItem.remove(productDesc);
84 | Log.d("remove", canRemove + "");
85 | return canRemove;
86 | }
87 | catch (Exception ex) {
88 | return false;
89 | }
90 | }
91 |
92 | /**
93 | * remove all saleLineItem.
94 | * @return return true if can remove else false
95 | */
96 | public boolean removeAllSaleLineItem() {
97 | try {
98 | lineOfItem.clear();
99 | }
100 | catch (Exception ex) {
101 | return false;
102 | }
103 | return true;
104 | }
105 |
106 | /**
107 | * Check SaleLineItem in List.
108 | * @param lineItem is SaleLineItem to check.
109 | * @return SaleLineItem that match with parameter if found
110 | * otherwise return null.
111 | */
112 | private SaleLineItem checkItemInLine(SaleLineItem lineItem) {
113 | for(int i = 0 ; i < lineOfItem.size() ; i++) {
114 | if(lineItem.getProductDescription().equals(lineOfItem.get(i).getProductDescription()))
115 | return lineOfItem.get(i);
116 | }
117 | return null;
118 | }
119 |
120 | /**
121 | * Calculate total price.
122 | * @return total price
123 | */
124 | public double getTotal(){
125 | double total = 0;
126 | for(SaleLineItem sli : lineOfItem){
127 | total += sli.getTotal();
128 | }
129 | return total;
130 | }
131 |
132 | /**
133 | * return change that calculate from money and total price
134 | * @param money customer pay
135 | * @return money minus total price
136 | */
137 | public double change(double money){
138 | return money - getTotal();
139 | }
140 |
141 | /**
142 | * decrease quantity that match which id.
143 | * @param id that match which inventory.
144 | * @param quantity amount of quantity that decrease from total quantity in inventory.
145 | */
146 | public void decrease(String id,int quantity) {
147 | inventory.setQuantity(inventory.getProduct(id), inventory.getQuantity(id)-quantity);
148 | }
149 |
150 | /**
151 | * return all list of sale line item.
152 | * @return all list of sale line item.
153 | */
154 | public ArrayList getAllList() {
155 | return lineOfItem;
156 | }
157 |
158 | /**
159 | * return list of sale line item.
160 | * @return list of sale line item.
161 | */
162 | public SaleLineItem getList(ProductDescription product) {
163 | for (int i = 0; i < lineOfItem.size(); i++) {
164 | if (lineOfItem.get(i).getProductDescription().equals(product))
165 | return lineOfItem.get(i);
166 | }
167 | return null;
168 | }
169 |
170 | /**
171 | * return date
172 | * @return date
173 | */
174 | public Date getDate(){
175 | return date;
176 | }
177 |
178 | /**
179 | * set date
180 | * @param s date
181 | */
182 | private void setDate(String s){
183 | String[] temp = s.split(" ");
184 | date.setYear(Integer.parseInt(temp[0]));
185 | date.setMonth(Integer.parseInt(temp[1]));
186 | date.setDate(Integer.parseInt(temp[2]));
187 | date.setHours(Integer.parseInt(temp[3]));
188 | date.setMinutes(Integer.parseInt(temp[4]));
189 | date.setSeconds(Integer.parseInt(temp[5]));
190 | }
191 | }
192 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/sale/SaleLineItem.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.sale;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.bbaf.mpos.ProductDescription.ProductDescription;
6 |
7 | /**
8 | * SaleLineItem to Show Detail of line item in sale.
9 | * @author Atit Leelasuksan 5510546221 , Rungroj Maipradit 5510546654
10 | * @version Oct 28, 2013
11 | */
12 | public class SaleLineItem implements Serializable {
13 |
14 | @Override
15 | public boolean equals(Object obj) {
16 | if (obj == null)
17 | return false;
18 | if (this.getClass() == obj.getClass()) {
19 | SaleLineItem line = (SaleLineItem)obj;
20 | return productDesc.getId().equals(line.getProductDescription().getId());
21 | }
22 | else if (ProductDescription.class == obj.getClass()) {
23 | ProductDescription product = (ProductDescription)obj;
24 | return productDesc.getId().equals(product.getId());
25 | }
26 |
27 | return false;
28 | }
29 |
30 | /** ProductDescription of this line item. */
31 | private ProductDescription productDesc;
32 | /** Quantity of product in this line item. */
33 | private int quantity;
34 | /** unit price for product in SaleLineItem. */
35 | private double unitPrice;
36 | /**
37 | * initialize SaleLineItem with ProductDescription.
38 | * it will invoke other constructor with quantity of 1 instead.
39 | * @param product is ProductDescription of this line item.
40 | */
41 | public SaleLineItem(ProductDescription product) {
42 | this(product,1);
43 | }
44 |
45 | /**
46 | * initialize SaleLineItem with ProductDescription and Quantity.
47 | * if quantity less than 0 it will use 1 instead.
48 | * @param product is ProductDescription of this line item.
49 | * @param q is quantity of product in this line item.
50 | */
51 | public SaleLineItem(ProductDescription product,int q) {
52 | productDesc = product;
53 | unitPrice = product.getPrice();
54 | if(q>0) quantity = q;
55 | else quantity = 1;
56 | }
57 |
58 | /**
59 | * Get ProductDescription of this line item.
60 | * @return ProductDescription of this line item.
61 | */
62 | public ProductDescription getProductDescription() {
63 | return productDesc;
64 | }
65 |
66 | /**
67 | * Get Quantity of product in this line item.
68 | * @return quantity of product.
69 | */
70 | public int getQuantity() {
71 | return quantity;
72 | }
73 |
74 | /**
75 | * add or subtract quantity of product in this line item.
76 | * it will add if amount>0 otherwise will subtract instead.
77 | * @param amount to add or subtract.
78 | * @return true if add otherwise subtract will return false.
79 | */
80 | public boolean addQuantity(int amount) {
81 | quantity+=amount;
82 | if(amount>0) return true;
83 | else return false;
84 | }
85 |
86 | /**
87 | * Calculate price of this item.
88 | * @return total item price
89 | */
90 | public double getTotal(){
91 | return quantity * unitPrice;
92 | }
93 |
94 | /**
95 | * return unitPrice.
96 | * @return unitPrice
97 | */
98 | public double getUnitPrice() {
99 | return unitPrice;
100 | }
101 |
102 | /**
103 | * set unitPrice
104 | * @param price that use for set unitPrice
105 | */
106 | public void setUnitPrice(double price){
107 | this.unitPrice = price;
108 | }
109 |
110 | /**
111 | * set quantity of product in SaleLineItem.
112 | * @param quantity to set.
113 | */
114 | public void setQuantity(int quantity) {
115 | this.quantity = quantity;
116 | }
117 | }
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/sale/payment/ui/PaymentActivity.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.sale.payment.ui;
2 |
3 | import com.bbaf.mpos.R;
4 | import com.bbaf.mpos.R.layout;
5 | import com.bbaf.mpos.R.menu;
6 | import com.bbaf.mpos.FacadeController.Register;
7 |
8 | import android.os.Bundle;
9 | import android.app.Activity;
10 | import android.view.Menu;
11 | import android.view.View;
12 | import android.view.View.OnClickListener;
13 | import android.widget.Button;
14 | import android.widget.EditText;
15 | import android.widget.TextView;
16 |
17 | /**
18 | * Activity for showing Payment. Controller of Payment view.
19 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
20 | */
21 | public class PaymentActivity extends Activity {
22 |
23 | private TextView textViewPaymentTotal;
24 | private EditText editTextPay;
25 | private Button buttonPaymentConfirm;
26 | private Button buttonPaymentCancel;
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_payment);
32 |
33 | textViewPaymentTotal = (TextView)findViewById(R.id.textViewPaymentTotal);
34 | textViewPaymentTotal.setText(String.format("%.2f", Register.getInstance().getTotal()));
35 |
36 | editTextPay = (EditText)findViewById(R.id.editTextPay);
37 |
38 | buttonPaymentConfirm = (Button)findViewById(R.id.buttonPaymentComfirm);
39 | buttonPaymentConfirm.setOnClickListener(new PaymentConfirmOnClickListener(this));
40 |
41 | buttonPaymentCancel = (Button)findViewById(R.id.buttonPaymentCancel);
42 | buttonPaymentCancel.setOnClickListener(new PaymentCancelOnClickListener(this));
43 | }
44 |
45 | /**
46 | * Return number in EditText.
47 | * @return number in EditText
48 | */
49 | public double getCash() {
50 | return editTextPay.getText().toString().equals("") ? 0 : Double.parseDouble(editTextPay.getText().toString());
51 | }
52 |
53 | @Override
54 | public boolean onCreateOptionsMenu(Menu menu) {
55 | // Inflate the menu; this adds items to the action bar if it is present.
56 | getMenuInflater().inflate(R.menu.payment, menu);
57 | return true;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/sale/payment/ui/PaymentCancelOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.sale.payment.ui;
2 |
3 | import android.view.View;
4 | import android.view.View.OnClickListener;
5 |
6 | /**
7 | * ActionListener of Cancel in Payment view.
8 | * @author Poramet Homprakob 5510546077
9 | */
10 | public class PaymentCancelOnClickListener implements OnClickListener {
11 |
12 | private PaymentActivity activity;
13 |
14 | private final int PAYMENT_CANCEL = 0;
15 |
16 | /**
17 | * Constructor, use calling activity
18 | * @param activity calling activity
19 | */
20 | public PaymentCancelOnClickListener(PaymentActivity activity) {
21 | this.activity = activity;
22 | }
23 |
24 | @Override
25 | public void onClick(View v) {
26 | activity.setResult(PAYMENT_CANCEL);
27 | activity.finish();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/sale/payment/ui/PaymentConfirmOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.sale.payment.ui;
2 |
3 | import java.util.ArrayList;
4 |
5 | import com.bbaf.mpos.FacadeController.Register;
6 | import com.bbaf.mpos.sale.SaleLineItem;
7 |
8 | import android.content.Intent;
9 | import android.view.View;
10 | import android.view.View.OnClickListener;
11 | import android.widget.Toast;
12 |
13 | /**
14 | * ActionListener of Confirm button in Payment view.
15 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
16 | */
17 | public class PaymentConfirmOnClickListener implements OnClickListener {
18 |
19 | private PaymentActivity activity;
20 |
21 | private final int PAYMENT_SUCCESS = 1;
22 |
23 | /**
24 | * Constructor, use calling activity.
25 | * @param activity calling activity
26 | */
27 | public PaymentConfirmOnClickListener(PaymentActivity activity) {
28 | this.activity = activity;
29 | }
30 |
31 | @Override
32 | public void onClick(View arg0) {
33 | if (activity.getCash() >= Register.getInstance().getTotal()) {
34 | ArrayList sli = Register.getInstance().getAllSaleLineItemList();
35 | for(int i = 0 ;i < sli.size();i++){
36 | Register.getInstance().decrease(sli.get(i).getProductDescription().getId(), sli.get(i).getQuantity());
37 | }
38 |
39 | if (sli.size() != 0) {
40 | Register.getInstance().getLedger().record(Register.getInstance().getSale());
41 | Toast.makeText(activity.getApplicationContext(), "Sale ended with " + sli.size() + " line item(s).", Toast.LENGTH_SHORT).show();
42 | }
43 | else {
44 | Toast.makeText(activity.getApplicationContext(), "Sale cancelled ", Toast.LENGTH_SHORT).show();
45 | }
46 |
47 | Intent successPaymentActivity = new Intent(activity, SuccessPaymentActivity.class);
48 | successPaymentActivity.putExtra("Cash", activity.getCash() - Register.getInstance().getTotal());
49 | activity.startActivity(successPaymentActivity);
50 |
51 | Register.getInstance().endSale();
52 | Register.getInstance().startSale();
53 |
54 | activity.setResult(PAYMENT_SUCCESS);
55 | activity.finish();
56 | }
57 | else {
58 | Toast.makeText(activity.getApplicationContext(), String.format("Need more %.2f", Register.getInstance().getTotal() - activity.getCash()), Toast.LENGTH_SHORT).show();
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/sale/payment/ui/PaymentOnClickListener.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.sale.payment.ui;
2 |
3 | import android.content.Intent;
4 | import android.view.View;
5 | import android.view.View.OnClickListener;
6 | import android.widget.Toast;
7 |
8 | import com.bbaf.mpos.FacadeController.Register;
9 | import com.bbaf.mpos.inventoryAndSale.ui.InventoryandSaleActivity;
10 |
11 | /**
12 | * ActionListener of Payment in Sale view.
13 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
14 | */
15 | public class PaymentOnClickListener implements OnClickListener {
16 |
17 | private InventoryandSaleActivity activity;
18 |
19 | private static final int PAYMENT_ACTIVITY_REQUESTCODE = 2;
20 |
21 | /**
22 | * Constructor, use calling activity.
23 | * @param activity calling activity
24 | */
25 | public PaymentOnClickListener(InventoryandSaleActivity activity) {
26 | this.activity = activity;
27 | }
28 |
29 | @Override
30 | public void onClick(View v) {
31 | if (Register.getInstance().getSale().getAllList().size() == 0) {
32 | Toast.makeText(activity.getApplicationContext(), "Add item first.", Toast.LENGTH_SHORT).show();
33 | }
34 | else {
35 | Intent paymentActivity = new Intent(activity.getApplicationContext(), PaymentActivity.class);
36 | activity.startActivityForResult(paymentActivity, PAYMENT_ACTIVITY_REQUESTCODE);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/sale/payment/ui/SaleEditActivity.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.sale.payment.ui;
2 |
3 | import com.bbaf.mpos.R;
4 | import com.bbaf.mpos.FacadeController.Register;
5 | import com.bbaf.mpos.ProductDescription.ProductDescription;
6 |
7 | import android.os.Bundle;
8 | import android.app.Activity;
9 | import android.view.Menu;
10 | import android.view.View;
11 | import android.view.View.OnClickListener;
12 | import android.widget.Button;
13 | import android.widget.EditText;
14 | import android.widget.TextView;
15 |
16 | /**
17 | * Activity for editing the price while in sale process. Controller of EditSale in Sale view.
18 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
19 | */
20 | public class SaleEditActivity extends Activity {
21 |
22 | private TextView textViewEditUnitPriceId;
23 | private TextView textViewEditUnitPriceName;
24 | private EditText editTextUnitPrice;
25 | private EditText editTextEditQuantity;
26 | private Button buttonEditSalePriceConfirm;
27 | private Button buttonEditSalePriceCancel;
28 |
29 | private static final int EDIT_CANCEL = 0;
30 | private static final int EDIT_SUCCESS = 1;
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | setContentView(R.layout.activity_sale_edit);
36 |
37 | final ProductDescription product = (ProductDescription) getIntent().getSerializableExtra("ProductDescription");
38 |
39 | textViewEditUnitPriceId = (TextView)findViewById(R.id.textViewEditUnitPriceId);
40 | textViewEditUnitPriceId.setText(product.getId());
41 |
42 | textViewEditUnitPriceName = (TextView)findViewById(R.id.textViewEditUnitPriceName);
43 | textViewEditUnitPriceName.setText(product.getName());
44 |
45 | editTextUnitPrice = (EditText)findViewById(R.id.editTextUnitPrice);
46 | editTextUnitPrice.setHint(String.valueOf(Register.getInstance().getInventory().getProduct(product.getId()).getPrice()));
47 |
48 | editTextEditQuantity = (EditText)findViewById(R.id.editTextEditQuantity);
49 | editTextEditQuantity.setHint(String.valueOf(Register.getInstance().getSale().getList(Register.getInstance().getInventory().getProduct(product.getId())).getQuantity()));
50 |
51 | buttonEditSalePriceConfirm = (Button)findViewById(R.id.buttonEditSalePriceConfirm);
52 | buttonEditSalePriceConfirm.setOnClickListener(new OnClickListener() {
53 |
54 | @Override
55 | public void onClick(View v) {
56 | if (!editTextUnitPrice.getText().toString().equals(""))
57 | Register.getInstance().getSale().getList(product).setUnitPrice(Double.parseDouble(editTextUnitPrice.getText().toString()));
58 |
59 | if (!editTextEditQuantity.getText().toString().equals(""))
60 | Register.getInstance().getSale().getList(Register.getInstance().getInventory().getProduct(product.getId())).setQuantity(Integer.parseInt(editTextEditQuantity.getText().toString()));
61 |
62 | setResult(EDIT_SUCCESS);
63 | finish();
64 | }
65 | });
66 |
67 | buttonEditSalePriceCancel = (Button)findViewById(R.id.buttonEditSalePriceCancel);
68 | buttonEditSalePriceCancel.setOnClickListener(new OnClickListener() {
69 |
70 | @Override
71 | public void onClick(View v) {
72 | setResult(EDIT_CANCEL);
73 | finish();
74 | }
75 | });
76 | }
77 |
78 | @Override
79 | public boolean onCreateOptionsMenu(Menu menu) {
80 | // Inflate the menu; this adds items to the action bar if it is present.
81 | getMenuInflater().inflate(R.menu.sale_edit, menu);
82 | return true;
83 | }
84 | }
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/sale/payment/ui/SuccessPaymentActivity.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.sale.payment.ui;
2 |
3 | import com.bbaf.mpos.R;
4 | import com.bbaf.mpos.R.layout;
5 | import com.bbaf.mpos.R.menu;
6 |
7 | import android.os.Bundle;
8 | import android.app.Activity;
9 | import android.view.Menu;
10 | import android.view.View;
11 | import android.view.View.OnClickListener;
12 | import android.widget.Button;
13 | import android.widget.TextView;
14 |
15 | /**
16 | * Activity for showing success payment. Controller of SuccessPayment view.
17 | * @author Poramet Homprakob 5510546077
18 | */
19 | public class SuccessPaymentActivity extends Activity {
20 |
21 | private TextView textViewChange;
22 | private Button buttonChangeConfirm;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_success_payment);
28 |
29 | textViewChange = (TextView)findViewById(R.id.textViewChange);
30 | double cash = getIntent().getDoubleExtra("Cash", 0);
31 | textViewChange.setText(String.format("%.2f", cash));
32 |
33 | buttonChangeConfirm = (Button)findViewById(R.id.buttonChangeComfirm);
34 | buttonChangeConfirm.setOnClickListener(new OnClickListener() {
35 |
36 | @Override
37 | public void onClick(View v) {
38 | finish();
39 |
40 | }
41 | });
42 | }
43 |
44 | @Override
45 | public boolean onCreateOptionsMenu(Menu menu) {
46 | // Inflate the menu; this adds items to the action bar if it is present.
47 | getMenuInflater().inflate(R.menu.success_payment, menu);
48 | return true;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/saleledger/Ledger.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.saleledger;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.ArrayList;
5 | import java.util.Calendar;
6 |
7 |
8 | import android.app.Activity;
9 | import android.content.Context;
10 | import android.support.v4.app.ActivityCompat;
11 | import android.util.Log;
12 |
13 | import com.bbaf.mpos.DAO.InventoryDBHelper;
14 | import com.bbaf.mpos.DAO.SaleLedgerDBHelper;
15 | import com.bbaf.mpos.sale.Sale;
16 |
17 | /**
18 | * Ledger to record sale.
19 | * Ledger will record all complete sale detail
20 | * e.g. date, total price, amount of product, list of product.
21 | * @author Atit Leelasuksan 5510546221
22 | * @version Dec 9, 2013
23 | */
24 | public class Ledger {
25 | /** to set format of date. */
26 | private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy MM dd");
27 |
28 | private Calendar dateDaily;
29 | private Calendar dateWeek;
30 | private Calendar dateMonth;
31 | private SaleLedgerDBHelper dbDAO;
32 |
33 | private String date;
34 | private String week;
35 | private String month;
36 |
37 | /**
38 | * if dateDaily,dateWeek,dateMonth are null initialize them.
39 | */
40 | public Ledger() {
41 | dbDAO = SaleLedgerDBHelper.getInstance();
42 | if(dateDaily == null)
43 | dateDaily = Calendar.getInstance();
44 | if(dateWeek == null)
45 | dateWeek = Calendar.getInstance();
46 | if(dateMonth == null)
47 | dateMonth = Calendar.getInstance();
48 | }
49 |
50 | /**
51 | * if dateDaily,dateWeek,dateMonth are null initialize them and set context.
52 | * @param context of calling Activity
53 | */
54 | public Ledger(Context context) {
55 | dbDAO = SaleLedgerDBHelper.getInstance(context);
56 | if(dateDaily == null)
57 | dateDaily = Calendar.getInstance();
58 | if(dateWeek == null)
59 | dateWeek = Calendar.getInstance();
60 | if(dateMonth == null)
61 | dateMonth = Calendar.getInstance();
62 | }
63 |
64 | /**
65 | * Add sale in saleLedger connector.
66 | * @param sale is sale to add.
67 | */
68 | public void record(Sale sale){
69 | dbDAO.addSale(sale);
70 | }
71 |
72 | /**
73 | * return all sale.
74 | * @return all sale
75 | */
76 | public ArrayList getAllSaleLedger() {
77 | return dbDAO.getAllSale();
78 | }
79 |
80 | /**
81 | * return sale that time length equal 1 day.
82 | * @return sale that time length equal 1 day
83 | */
84 | public ArrayList getDaily() {
85 | String current = SDF.format(dateDaily.getTime());
86 | Calendar from = (Calendar) dateDaily.clone();
87 | from.add(Calendar.DATE,1);
88 | String to = SDF.format(from.getTime());
89 | date = String.format("Date : %s/%s/%s", current.split(" ")[2], current.split(" ")[1], current.split(" ")[0]);
90 | return dbDAO.getSale(current,to);
91 | }
92 |
93 | /**
94 | * return sale that time length equal 1 week.
95 | * @return sale that time length equal 1 week
96 | */
97 | public ArrayList getWeek(){
98 | Calendar from = (Calendar) dateWeek.clone();
99 | Calendar temp = (Calendar) dateWeek.clone();
100 | temp.set(Calendar.DAY_OF_WEEK, 0);
101 | if(temp.get(Calendar.DATE) >= from.get(Calendar.DATE))
102 | temp.add(Calendar.DATE, -7);
103 | temp.add(Calendar.DATE,1);
104 | String current = SDF.format(temp.getTime());
105 | from.add(Calendar.DATE,1);
106 | String to = SDF.format(from.getTime());
107 | Calendar temp2 = (Calendar)from.clone();
108 | temp2.add(Calendar.DATE, -1);
109 | String to2 = SDF.format(temp2.getTime());
110 | week = String.format("Week : %s/%s/%s ~ %s/%s/%s", current.split(" ")[2], current.split(" ")[1], current.split(" ")[0], to2.split(" ")[2], to2.split(" ")[1], to2.split(" ")[0]);
111 | return dbDAO.getSale(current,to);
112 | }
113 |
114 | /**
115 | * return sale that time length equal 1 month.
116 | * @return sale that time length equal 1 month
117 | */
118 | public ArrayList getMonth(){
119 | Calendar from = (Calendar) dateMonth.clone();
120 | Calendar temp = (Calendar) dateMonth.clone();
121 | int mtemp = temp.get(Calendar.MONTH);
122 | temp.set(Calendar.DATE,1);
123 | temp.set(Calendar.MONTH, mtemp);
124 | from.add(Calendar.DATE,1);
125 | String current = SDF.format(temp.getTime());
126 | String to = SDF.format(from.getTime());
127 | month = String.format("Month : %s/%s", current.split(" ")[1], current.split(" ")[0]);
128 | return dbDAO.getSale(current,to);
129 | }
130 |
131 | /**
132 | * decrease dateDaily by 1 day.
133 | */
134 | public void prevDaily(){
135 | dateDaily.add(Calendar.DATE, -1);
136 | }
137 |
138 | /**
139 | * increase dateDaily by 1 day.
140 | */
141 | public void nextDaily(){
142 | dateDaily.add(Calendar.DATE, 1);
143 | }
144 |
145 | /**
146 | * decrease dateWeek by 1 week.
147 | */
148 | public void prevWeek(){
149 | dateWeek.set(Calendar.DAY_OF_WEEK, 0);
150 | dateWeek.add(Calendar.WEEK_OF_YEAR, -1);
151 | }
152 |
153 | /**
154 | * decrease dateWeek by 1 week.
155 | */
156 | public void nextWeek(){
157 | dateWeek.set(Calendar.DAY_OF_WEEK, 0);
158 | dateWeek.add(Calendar.WEEK_OF_YEAR, 1);
159 | }
160 |
161 | /**
162 | * decrease dateMonth by 1 month.
163 | */
164 | public void prevMonth(){
165 | int temp = dateMonth.get(Calendar.MONTH);
166 | dateMonth.set(Calendar.DATE, 0);
167 | dateMonth.set(Calendar.MONTH, temp);
168 | }
169 |
170 | /**
171 | * increase dateMonth by 1 month.
172 | */
173 | public void nextMonth(){
174 | int temp = dateMonth.get(Calendar.MONTH);
175 | dateMonth.set(Calendar.DATE, 0);
176 | dateMonth.set(Calendar.MONTH,temp+2);
177 | }
178 | /**
179 | * return date as string format
180 | * @return date as string
181 | */
182 | public String getDateS() {
183 | return date;
184 | }
185 |
186 | /**
187 | * return date range in week as string format
188 | * @return date range in week as string
189 | */
190 | public String getWeekS() {
191 | return week;
192 | }
193 |
194 | /**
195 | * return date range in month as string format
196 | * @return date range in month as string
197 | */
198 | public String getMonthS() {
199 | return month;
200 | }
201 | }
202 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/saleledger/ProductLedger.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.saleledger;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * ProductLedger is class for product that use in SaleLedger.
7 | * @author Atit Leelasuksan 5510546221
8 | * @version Dec 9, 2013
9 | */
10 | public class ProductLedger implements Serializable {
11 |
12 | /** id of product. */
13 | private String id;
14 | /** name of product. */
15 | private String name;
16 | /** unit price of product. */
17 | private double unitPrice;
18 | /** quantity of product. */
19 | private int quantity;
20 |
21 | /**
22 | * Constructor of this class
23 | * @param id set id
24 | * @param name set name
25 | * @param unitPrice set unitPrice
26 | * @param quantity set quantity
27 | */
28 | public ProductLedger(String id, String name, double unitPrice, int quantity) {
29 | this.id = id;
30 | this.name = name;
31 | this.unitPrice = unitPrice;
32 | this.quantity = quantity;
33 | }
34 |
35 | /**
36 | * return id.
37 | * @return id
38 | */
39 | public String getId() {
40 | return id;
41 | }
42 |
43 | /**
44 | * return name.
45 | * @return name
46 | */
47 | public String getName() {
48 | return name;
49 | }
50 |
51 | /**
52 | * return unitPrice.
53 | * @return unitPrice
54 | */
55 | public double getUnitPrice() {
56 | return unitPrice;
57 | }
58 |
59 | /**
60 | * return quantity.
61 | * @return quantity
62 | */
63 | public int getQuantity() {
64 | return quantity;
65 | }
66 |
67 | /**
68 | * set id
69 | * @param id that use to set
70 | */
71 | public void setId(String id) {
72 | this.id = id;
73 | }
74 |
75 | /**
76 | * set name.
77 | * @param name that use to set
78 | */
79 | public void setName(String name) {
80 | this.name = name;
81 | }
82 |
83 | /**
84 | * set unitPrice
85 | * @param unitPrice that use to set
86 | */
87 | public void setUnitPrice(double unitPrice) {
88 | this.unitPrice = unitPrice;
89 | }
90 |
91 | /**
92 | * set quantity
93 | * @param quantity that use to set
94 | */
95 | public void setQuantity(int quantity) {
96 | this.quantity = quantity;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/saleledger/SaleLedger.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.saleledger;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.Date;
6 |
7 | /**
8 | * SaleLedger is class for sale to use in Ledger.
9 | * @author Atit Leelasuksan 5510546221
10 | * @version Dec 9, 2013
11 | */
12 | public class SaleLedger implements Serializable {
13 |
14 | /** date of sale. */
15 | private String date;
16 | /** total price of sale. */
17 | private double total;
18 | /** list of product in sale. */
19 | private ArrayList productLedgerList;
20 |
21 | /**
22 | * Initialize list of productLedger and set date,total.
23 | * @param date that use to set
24 | * @param total that use to set
25 | */
26 | public SaleLedger(String date, double total) {
27 | this.date = date;
28 | this.total = total;
29 | productLedgerList = new ArrayList();
30 | }
31 |
32 | /**
33 | * add productLedger.
34 | * @param productLedger that use to add.
35 | */
36 | public void addProductLedger(ProductLedger productLedger) {
37 | productLedgerList.add(productLedger);
38 | }
39 |
40 | /**
41 | * return all productLedger.
42 | * @return all productLedger.
43 | */
44 | public ArrayList getAllProductLedger() {
45 | return productLedgerList;
46 | }
47 |
48 | /**
49 | * return date type string.
50 | * @return date
51 | */
52 | public String getDate() {
53 | return date;
54 | }
55 |
56 | /**
57 | * return total price.
58 | * @return total price.
59 | */
60 | public double getTotal() {
61 | return total;
62 | }
63 |
64 | /**
65 | * set date
66 | * @param date that use to set.
67 | */
68 | public void setDate(String date) {
69 | this.date = date;
70 | }
71 |
72 | /**
73 | * set total
74 | * @param total that use to set.
75 | */
76 | public void setTotal(double total) {
77 | this.total = total;
78 | }
79 |
80 | /**
81 | * set list of ProductLedger.
82 | * @param productLedgerList list of productLedger that use to set.
83 | */
84 | public void setProductLedgerList(ArrayList productLedgerList) {
85 | this.productLedgerList = productLedgerList;
86 | }
87 |
88 | /**
89 | * return date with new format.
90 | * @return date
91 | */
92 | public String getDateX() {
93 | String[] x = date.split(" ");
94 | return String.format("%s-%s-%s", x[0], x[1], x[2]);
95 | }
96 |
97 | /**
98 | * return time with new format.
99 | * @return time
100 | */
101 | public String getTimeX() {
102 | String[] x = date.split(" ");
103 | return String.format("%s:%s:%s", x[3], x[4], x[5]);
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/saleledger/ui/LedgerActivity.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.saleledger.ui;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Date;
5 |
6 | import com.bbaf.mpos.R;
7 | import com.bbaf.mpos.ProductDescription.ProductDescription;
8 | import com.bbaf.mpos.R.layout;
9 | import com.bbaf.mpos.R.menu;
10 | import com.bbaf.mpos.FacadeController.Register;
11 | import com.bbaf.mpos.sale.Sale;
12 | import com.bbaf.mpos.saleledger.Ledger;
13 | import com.bbaf.mpos.saleledger.SaleLedger;
14 |
15 | import android.os.Bundle;
16 | import android.app.Activity;
17 | import android.util.Log;
18 | import android.view.Menu;
19 | import android.view.View;
20 | import android.view.View.OnClickListener;
21 | import android.widget.Button;
22 | import android.widget.ListView;
23 | import android.widget.TabHost;
24 | import android.widget.TableRow;
25 | import android.widget.TextView;
26 | import android.widget.TabHost.TabSpec;
27 | import android.widget.TableLayout;
28 |
29 | /**
30 | * Activity for showing the ledger. Controller of Ledger view.
31 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
32 | */
33 | public class LedgerActivity extends Activity {
34 |
35 | private TabHost tabLedger;
36 | private TabSpec tabByDate;
37 | private TextView textViewDate;
38 | private ListView listViewSaleLedgerDate;
39 | private SaleLedgerListViewAdapter saleLedgerListViewAdapterDate;
40 | private TextView textViewTotalByDate;
41 | private Button buttonDateNext;
42 | private Button buttonDatePrevious;
43 |
44 | private TabSpec tabByWeek;
45 | private TextView textViewWeek;
46 | private ListView listViewSaleLedgerWeek;
47 | private SaleLedgerListViewAdapter saleLedgerListViewAdapterWeek;
48 | private TextView textViewTotalByWeek;
49 | private Button buttonWeekNext;
50 | private Button buttonWeekPrevious;
51 |
52 | private TabSpec tabByMonth;
53 | private TextView textViewMonth;
54 | private ListView listViewSaleLedgerMonth;
55 | private SaleLedgerListViewAdapter saleLedgerListViewAdapterMonth;
56 | private TextView textViewTotalByMonth;
57 | private Button buttonMonthNext;
58 | private Button buttonMonthPrevious;
59 |
60 | @Override
61 | protected void onCreate(Bundle savedInstanceState) {
62 | super.onCreate(savedInstanceState);
63 | setContentView(R.layout.activity_ledger_ui);
64 |
65 | tabLedger = (TabHost) findViewById(R.id.tabLedger);
66 | tabLedger.setup();
67 |
68 | tabByDate = tabLedger.newTabSpec("tabdate");
69 | tabByDate.setContent(R.id.tabdate);
70 | tabByDate.setIndicator("By Date");
71 | tabLedger.addTab(tabByDate);
72 | textViewDate = (TextView)findViewById(R.id.textViewDate);
73 | listViewSaleLedgerDate = (ListView)findViewById(R.id.listViewSaleLedgerDate);
74 | saleLedgerListViewAdapterDate = new SaleLedgerListViewAdapter(this, Register.getInstance().getLedger().getDaily());
75 | listViewSaleLedgerDate.setAdapter(saleLedgerListViewAdapterDate);
76 | textViewTotalByDate = (TextView)findViewById(R.id.textViewTotalByDate);
77 | buttonDateNext = (Button)findViewById(R.id.buttonDateNext);
78 | buttonDateNext.setOnClickListener(new OnClickListener() {
79 |
80 | @Override
81 | public void onClick(View v) {
82 | Register.getInstance().getLedger().nextDaily();
83 | refreshDateListView();
84 | }
85 | });
86 | buttonDatePrevious = (Button)findViewById(R.id.buttonDatePrevious);
87 | buttonDatePrevious.setOnClickListener(new OnClickListener() {
88 |
89 | @Override
90 | public void onClick(View v) {
91 | Register.getInstance().getLedger().prevDaily();
92 | refreshDateListView();
93 | }
94 | });
95 |
96 | tabByWeek = tabLedger.newTabSpec("tabweek");
97 | tabByWeek.setContent(R.id.tabweek);
98 | tabByWeek.setIndicator("By Week");
99 | tabLedger.addTab(tabByWeek);
100 | textViewWeek = (TextView)findViewById(R.id.textViewWeek);
101 | listViewSaleLedgerWeek = (ListView)findViewById(R.id.listViewSaleLedgerWeek);
102 | saleLedgerListViewAdapterWeek = new SaleLedgerListViewAdapter(this, Register.getInstance().getLedger().getWeek());
103 | listViewSaleLedgerWeek.setAdapter(saleLedgerListViewAdapterWeek);
104 | textViewTotalByWeek = (TextView)findViewById(R.id.textViewTotalByWeek);
105 | buttonWeekNext = (Button)findViewById(R.id.buttonWeekNext);
106 | buttonWeekNext.setOnClickListener(new OnClickListener() {
107 |
108 | @Override
109 | public void onClick(View v) {
110 | Register.getInstance().getLedger().nextWeek();
111 | refreshWeekListView();
112 | }
113 | });
114 | buttonWeekPrevious = (Button)findViewById(R.id.buttonWeekPrevious);
115 | buttonWeekPrevious.setOnClickListener(new OnClickListener() {
116 |
117 | @Override
118 | public void onClick(View v) {
119 | Register.getInstance().getLedger().prevWeek();
120 | refreshWeekListView();
121 | }
122 | });
123 |
124 | tabByMonth = tabLedger.newTabSpec("tabmonth");
125 | tabByMonth.setContent(R.id.tabmonth);
126 | tabByMonth.setIndicator("By Month");
127 | tabLedger.addTab(tabByMonth);
128 | textViewMonth = (TextView)findViewById(R.id.textViewMonth);
129 | listViewSaleLedgerMonth = (ListView)findViewById(R.id.listViewSaleLedgerMonth);
130 | saleLedgerListViewAdapterMonth = new SaleLedgerListViewAdapter(this, Register.getInstance().getLedger().getMonth());
131 | listViewSaleLedgerMonth.setAdapter(saleLedgerListViewAdapterMonth);
132 | textViewTotalByMonth = (TextView)findViewById(R.id.textViewTotalByMonth);
133 | buttonMonthNext = (Button)findViewById(R.id.buttonMonthNext);
134 | buttonMonthNext.setOnClickListener(new OnClickListener() {
135 |
136 | @Override
137 | public void onClick(View v) {
138 | Register.getInstance().getLedger().nextMonth();
139 | refreshMonthListView();
140 | }
141 | });
142 | buttonMonthPrevious = (Button)findViewById(R.id.buttonMonthPrevious);
143 | buttonMonthPrevious.setOnClickListener(new OnClickListener() {
144 |
145 | @Override
146 | public void onClick(View v) {
147 | Register.getInstance().getLedger().prevMonth();
148 | refreshMonthListView();
149 | }
150 | });
151 |
152 | refreshDateListView();
153 | refreshMonthListView();
154 | refreshWeekListView();
155 | }
156 |
157 | /**
158 | * Refresh elements in Date ListView.
159 | */
160 | public void refreshDateListView() {
161 | saleLedgerListViewAdapterDate.notifyDataSetChanged(Register.getInstance().getLedger().getDaily());
162 | textViewDate.setText(Register.getInstance().getLedger().getDateS());
163 | textViewTotalByDate.setText(String.format("Total : %.2f", saleLedgerListViewAdapterDate.getTotal()));
164 | }
165 |
166 | /**
167 | * Refresh elements in Week ListView.
168 | */
169 | public void refreshWeekListView() {
170 | saleLedgerListViewAdapterWeek.notifyDataSetChanged(Register.getInstance().getLedger().getWeek());
171 | textViewWeek.setText(Register.getInstance().getLedger().getWeekS());
172 | textViewTotalByWeek.setText(String.format("Total : %.2f", saleLedgerListViewAdapterWeek.getTotal()));
173 | }
174 |
175 | /**
176 | * Refresh elements in Month ListView.
177 | */
178 | public void refreshMonthListView() {
179 | saleLedgerListViewAdapterMonth.notifyDataSetChanged(Register.getInstance().getLedger().getMonth());
180 | textViewMonth.setText(Register.getInstance().getLedger().getMonthS());
181 | textViewTotalByMonth.setText(String.format("Total : %.2f", saleLedgerListViewAdapterMonth.getTotal()));
182 | }
183 |
184 | @Override
185 | public boolean onCreateOptionsMenu(Menu menu) {
186 | // Inflate the menu; this adds items to the action bar if it is present.
187 | getMenuInflater().inflate(R.menu.ledger_ui, menu);
188 | return true;
189 | }
190 |
191 | }
192 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/saleledger/ui/ProductLedgerListRow.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.saleledger.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.graphics.Color;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.CheckBox;
10 | import android.widget.ImageView;
11 | import android.widget.RelativeLayout;
12 | import android.widget.TextView;
13 | import android.widget.Toast;
14 |
15 | import com.bbaf.mpos.R;
16 | import com.bbaf.mpos.FacadeController.Register;
17 | import com.bbaf.mpos.ProductDescription.ProductDescription;
18 | import com.bbaf.mpos.sale.Sale;
19 | import com.bbaf.mpos.sale.SaleLineItem;
20 | import com.bbaf.mpos.saleledger.ProductLedger;
21 | import com.bbaf.mpos.saleledger.SaleLedger;
22 |
23 | /**
24 | * Prototype of ListRow in ProductLedger.
25 | * @author Poramet Homprakob 5510546077
26 | */
27 | class ProductLedgerListRow extends RelativeLayout {
28 |
29 | private ProductLedger product;
30 |
31 | private TextView textViewRowIdProductLedger;
32 | private TextView textViewRowNameProductLedger;
33 | private TextView textViewRowTotalProductLedger;
34 | private TextView textViewRowQuantityProductLedger;
35 | private TextView textViewRowUnitPriceProductLedger;
36 |
37 | public ProductLedgerListRow(final Activity activity, ProductLedger product) {
38 | super(activity.getApplicationContext());
39 | LayoutInflater inflater = (LayoutInflater)activity.getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
40 | inflater.inflate(R.layout.product_ledger_list_row, this, true);
41 |
42 | this.product = product;
43 |
44 | textViewRowIdProductLedger = (TextView)findViewById(R.id.textViewRowIdProductLedger);
45 | textViewRowIdProductLedger.setText(product.getId());
46 | textViewRowIdProductLedger.setTextColor(Color.GRAY);
47 |
48 | textViewRowNameProductLedger = (TextView)findViewById(R.id.textViewRowNameProductLedger);
49 | textViewRowNameProductLedger.setText(product.getName());
50 | textViewRowNameProductLedger.setTextColor(Color.BLACK);
51 |
52 | textViewRowTotalProductLedger = (TextView)findViewById(R.id.textViewRowTotalProductLedger);
53 | textViewRowTotalProductLedger.setText(String.format("%.2f", product.getQuantity() * product.getUnitPrice()));
54 | textViewRowTotalProductLedger.setTextColor(Color.BLACK);
55 |
56 | textViewRowQuantityProductLedger = (TextView)findViewById(R.id.textViewRowQuantityProductLedger);
57 | textViewRowQuantityProductLedger.setText(String.format("x %d Pcs.", product.getQuantity()));
58 | textViewRowQuantityProductLedger.setTextColor(Color.GRAY);
59 |
60 | textViewRowUnitPriceProductLedger = (TextView)findViewById(R.id.textViewRowUnitPriceProductLedger);
61 | textViewRowUnitPriceProductLedger.setText(String.format("%.2f", product.getUnitPrice()));
62 | textViewRowUnitPriceProductLedger.setTextColor(Color.GRAY);
63 | }
64 |
65 | /**
66 | * Return ProductLedger which is stored in itself
67 | * @return ProductLedger object
68 | */
69 | public ProductLedger getProduct() {
70 | return product;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/saleledger/ui/ProductLedgerListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.saleledger.ui;
2 |
3 | import java.util.ArrayList;
4 | import java.util.zip.Inflater;
5 |
6 | import com.bbaf.mpos.R;
7 | import com.bbaf.mpos.FacadeController.Register;
8 | import com.bbaf.mpos.ProductDescription.ProductDescription;
9 | import com.bbaf.mpos.sale.Sale;
10 | import com.bbaf.mpos.sale.SaleLineItem;
11 | import com.bbaf.mpos.saleledger.ProductLedger;
12 | import com.bbaf.mpos.saleledger.SaleLedger;
13 |
14 | import android.app.Activity;
15 | import android.content.Context;
16 | import android.content.Intent;
17 | import android.graphics.Color;
18 | import android.view.LayoutInflater;
19 | import android.view.View;
20 | import android.view.View.OnClickListener;
21 | import android.view.ViewGroup;
22 | import android.widget.BaseAdapter;
23 | import android.widget.CheckBox;
24 | import android.widget.ImageView;
25 | import android.widget.RelativeLayout;
26 | import android.widget.TextView;
27 | import android.widget.Toast;
28 |
29 | /**
30 | * A class adapt ArrayList to be ListView shown in Sale view.
31 | * @author Poramet Homprakob 5510546077
32 | */
33 | public class ProductLedgerListViewAdapter extends BaseAdapter {
34 |
35 | private Activity activity;
36 | private ArrayList productList;
37 |
38 | /**
39 | * Constructor, using calling activity.
40 | * @param activity calling activity
41 | * @param saleList list of ProductLedger
42 | */
43 | public ProductLedgerListViewAdapter(Activity activity, ArrayList productList) {
44 | this.activity = activity;
45 | this.productList = productList;
46 | }
47 |
48 | @Override
49 | public int getCount() {
50 | return productList.size();
51 | }
52 |
53 | @Override
54 | public Object getItem(int position) {
55 | return productList.get(position);
56 | }
57 |
58 | @Override
59 | public long getItemId(int position) {
60 | return position;
61 | }
62 |
63 | @Override
64 | public View getView(int position, View convertView, ViewGroup parent) {
65 | return new ProductLedgerListRow(activity, productList.get(position));
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/saleledger/ui/SaleLedgerListRow.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.saleledger.ui;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.graphics.Color;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.CheckBox;
10 | import android.widget.ImageView;
11 | import android.widget.RelativeLayout;
12 | import android.widget.TextView;
13 | import android.widget.Toast;
14 |
15 | import com.bbaf.mpos.R;
16 | import com.bbaf.mpos.FacadeController.Register;
17 | import com.bbaf.mpos.ProductDescription.ProductDescription;
18 | import com.bbaf.mpos.sale.Sale;
19 | import com.bbaf.mpos.sale.SaleLineItem;
20 | import com.bbaf.mpos.saleledger.SaleLedger;
21 |
22 | /**
23 | * Prototype of ListRow in SaleLedger.
24 | * @author Poramet Homprakob 5510546077
25 | */
26 | class SaleLedgerListRow extends RelativeLayout {
27 |
28 | private SaleLedger sale;
29 |
30 | private TextView textViewRowDateSaleLedger;
31 | private TextView textViewRowTimeSaleLedger;
32 | private TextView textViewRowTotalSaleLedger;
33 |
34 | public SaleLedgerListRow(final Activity activity, final SaleLedger sale) {
35 | super(activity.getApplicationContext());
36 | LayoutInflater inflater = (LayoutInflater)activity.getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
37 | inflater.inflate(R.layout.sale_ledger_list_row, this, true);
38 |
39 | this.sale = sale;
40 |
41 | textViewRowDateSaleLedger = (TextView)findViewById(R.id.textViewRowDateSaleLedger);
42 | textViewRowDateSaleLedger.setText(sale.getDateX());
43 | textViewRowDateSaleLedger.setTextColor(Color.BLACK);
44 |
45 | textViewRowTimeSaleLedger = (TextView)findViewById(R.id.textViewRowTimeSaleLedger);
46 | textViewRowTimeSaleLedger.setText(sale.getTimeX());
47 | textViewRowTimeSaleLedger.setTextColor(Color.BLACK);
48 |
49 | textViewRowTotalSaleLedger = (TextView)findViewById(R.id.textViewRowTotalSaleLedger);
50 | textViewRowTotalSaleLedger.setText(String.format("%.2f", sale.getTotal()));
51 | textViewRowTotalSaleLedger.setTextColor(Color.BLACK);
52 |
53 | setOnClickListener(new OnClickListener() {
54 |
55 | @Override
56 | public void onClick(View v) {
57 | Intent productListActivity = new Intent(activity, SaleLedgerProductListActivity.class);
58 | productListActivity.putExtra("SaleLedger", sale);
59 | productListActivity.putExtra("ProductLedgerList", sale.getAllProductLedger());
60 | activity.startActivity(productListActivity);
61 | }
62 | });
63 | }
64 |
65 | /**
66 | * Return SaleLedger which is stored in itself
67 | * @return SaleLedger object
68 | */
69 | public SaleLedger getSale() {
70 | return sale;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/saleledger/ui/SaleLedgerListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.saleledger.ui;
2 |
3 | import java.util.ArrayList;
4 | import java.util.zip.Inflater;
5 |
6 | import com.bbaf.mpos.R;
7 | import com.bbaf.mpos.FacadeController.Register;
8 | import com.bbaf.mpos.ProductDescription.ProductDescription;
9 | import com.bbaf.mpos.sale.Sale;
10 | import com.bbaf.mpos.sale.SaleLineItem;
11 | import com.bbaf.mpos.saleledger.SaleLedger;
12 |
13 | import android.app.Activity;
14 | import android.content.Context;
15 | import android.content.Intent;
16 | import android.graphics.Color;
17 | import android.view.LayoutInflater;
18 | import android.view.View;
19 | import android.view.View.OnClickListener;
20 | import android.view.ViewGroup;
21 | import android.widget.BaseAdapter;
22 | import android.widget.CheckBox;
23 | import android.widget.ImageView;
24 | import android.widget.RelativeLayout;
25 | import android.widget.TextView;
26 | import android.widget.Toast;
27 |
28 | /**
29 | * A class adapt ArrayList to be ListView shown in Sale view.
30 | * @author Poramet Homprakob 5510546077
31 | */
32 | public class SaleLedgerListViewAdapter extends BaseAdapter {
33 |
34 | private Activity activity;
35 | private ArrayList saleList;
36 |
37 | /**
38 | * Constructor, using calling activity.
39 | * @param activity calling activity
40 | * @param saleList list of SaleLedger
41 | */
42 | public SaleLedgerListViewAdapter(Activity activity, ArrayList saleList) {
43 | this.activity = activity;
44 | this.saleList = saleList;
45 | }
46 |
47 | @Override
48 | public int getCount() {
49 | return saleList.size();
50 | }
51 |
52 | @Override
53 | public Object getItem(int position) {
54 | return saleList.get(position);
55 | }
56 |
57 | @Override
58 | public long getItemId(int position) {
59 | return position;
60 | }
61 |
62 | @Override
63 | public View getView(int position, View convertView, ViewGroup parent) {
64 | return new SaleLedgerListRow(activity, saleList.get(position));
65 | }
66 |
67 | /**
68 | * Notify ListView to show new row lists by using list of SaleLedger lists
69 | * @param saleList list of SaleLedger
70 | */
71 | public void notifyDataSetChanged(ArrayList saleList) {
72 | this.saleList = saleList;
73 | super.notifyDataSetChanged();
74 | }
75 |
76 | /**
77 | * Return total of Sale lists
78 | * @return total of Sale lists
79 | */
80 | public double getTotal() {
81 | double total = 0;
82 | for (int i = 0; i < saleList.size(); i++) {
83 | total += saleList.get(i).getTotal();
84 | }
85 | return total;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/com/bbaf/mpos/saleledger/ui/SaleLedgerProductListActivity.java:
--------------------------------------------------------------------------------
1 | package com.bbaf.mpos.saleledger.ui;
2 |
3 | import java.util.ArrayList;
4 |
5 | import com.bbaf.mpos.R;
6 | import com.bbaf.mpos.FacadeController.Register;
7 | import com.bbaf.mpos.saleledger.ProductLedger;
8 | import com.bbaf.mpos.saleledger.SaleLedger;
9 | import com.bbaf.mpos.R.layout;
10 | import com.bbaf.mpos.R.menu;
11 |
12 | import android.os.Bundle;
13 | import android.app.Activity;
14 | import android.view.Menu;
15 | import android.view.View;
16 | import android.view.View.OnClickListener;
17 | import android.widget.Button;
18 | import android.widget.ListView;
19 | import android.widget.TextView;
20 |
21 | /**
22 | * Activity for showing the sale list in a ledger. Controller of ProductLedger view.
23 | * @author Sarathit Sangtaweep 5510546182, Poramet Homprakob 5510546077
24 | */
25 | public class SaleLedgerProductListActivity extends Activity {
26 |
27 | private TextView textViewLedgerProductListDate;
28 | private TextView textViewLedgerProductListTotal;
29 | private ListView listViewLedgerProductList;
30 | private ProductLedgerListViewAdapter productLedgerListViewAdapter;
31 | //private Button buttonLedgerProductBack;
32 |
33 | private SaleLedger sale;
34 | private ArrayList productList;
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.activity_sale_ledger_product_list);
40 |
41 | sale = (SaleLedger) getIntent().getSerializableExtra("SaleLedger");
42 |
43 | productList = (ArrayList) getIntent().getSerializableExtra("ProductLedgerList");
44 |
45 | textViewLedgerProductListDate = (TextView)findViewById(R.id.textViewLedgerProductList);
46 | textViewLedgerProductListDate.setText(String.format("%s %s", sale.getDateX(), sale.getTimeX()));
47 |
48 | textViewLedgerProductListTotal = (TextView)findViewById(R.id.textViewLedgerProductListTotal);
49 | textViewLedgerProductListTotal.setText(String.format("Total : %.2f", sale.getTotal()));
50 |
51 | listViewLedgerProductList = (ListView)findViewById(R.id.listViewLedgerProductList);
52 | productLedgerListViewAdapter = new ProductLedgerListViewAdapter(this, productList);
53 | listViewLedgerProductList.setAdapter(productLedgerListViewAdapter);
54 | }
55 |
56 | @Override
57 | public boolean onCreateOptionsMenu(Menu menu) {
58 | // Inflate the menu; this adds items to the action bar if it is present.
59 | getMenuInflater().inflate(R.menu.sale_ledger_list, menu);
60 | return true;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/com/google/zxing/integration/android/IntentResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 ZXing authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.zxing.integration.android;
18 |
19 | /**
20 | * Encapsulates the result of a barcode scan invoked through {@link IntentIntegrator}.
21 | *
22 | * @author Sean Owen
23 | */
24 | public final class IntentResult {
25 |
26 | private final String contents;
27 | private final String formatName;
28 | private final byte[] rawBytes;
29 | private final Integer orientation;
30 | private final String errorCorrectionLevel;
31 |
32 | IntentResult() {
33 | this(null, null, null, null, null);
34 | }
35 |
36 | IntentResult(String contents,
37 | String formatName,
38 | byte[] rawBytes,
39 | Integer orientation,
40 | String errorCorrectionLevel) {
41 | this.contents = contents;
42 | this.formatName = formatName;
43 | this.rawBytes = rawBytes;
44 | this.orientation = orientation;
45 | this.errorCorrectionLevel = errorCorrectionLevel;
46 | }
47 |
48 | /**
49 | * @return raw content of barcode
50 | */
51 | public String getContents() {
52 | return contents;
53 | }
54 |
55 | /**
56 | * @return name of format, like "QR_CODE", "UPC_A". See {@code BarcodeFormat} for more format names.
57 | */
58 | public String getFormatName() {
59 | return formatName;
60 | }
61 |
62 | /**
63 | * @return raw bytes of the barcode content, if applicable, or null otherwise
64 | */
65 | public byte[] getRawBytes() {
66 | return rawBytes;
67 | }
68 |
69 | /**
70 | * @return rotation of the image, in degrees, which resulted in a successful scan. May be null.
71 | */
72 | public Integer getOrientation() {
73 | return orientation;
74 | }
75 |
76 | /**
77 | * @return name of the error correction level used in the barcode, if applicable
78 | */
79 | public String getErrorCorrectionLevel() {
80 | return errorCorrectionLevel;
81 | }
82 |
83 | @Override
84 | public String toString() {
85 | StringBuilder dialogText = new StringBuilder(100);
86 | dialogText.append("Format: ").append(formatName).append('\n');
87 | dialogText.append("Contents: ").append(contents).append('\n');
88 | int rawBytesLength = rawBytes == null ? 0 : rawBytes.length;
89 | dialogText.append("Raw bytes: (").append(rawBytesLength).append(" bytes)\n");
90 | dialogText.append("Orientation: ").append(orientation).append('\n');
91 | dialogText.append("EC level: ").append(errorCorrectionLevel).append('\n');
92 | return dialogText.toString();
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------