Skip to content

Commit

Permalink
Add permission by user from POS
Browse files Browse the repository at this point in the history
  • Loading branch information
yamelsenih committed Nov 18, 2021
1 parent b67c84f commit aed86e8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -3820,17 +3821,46 @@ private PointOfSales.Builder convertPointOfSales(MPOS pos) {
// Special values
builder
.setDefaultCampaignUuid(ValueUtil.validateNull(RecordUtil.getUuidFromId(I_C_Campaign.Table_Name, pos.get_ValueAsInt("DefaultCampaign_ID"))))
.setMaximumRefundAllowed(ValueUtil.getDecimalFromBigDecimal((BigDecimal) pos.get_Value("MaximumRefundAllowed")))
.setMaximumDailyRefundAllowed(ValueUtil.getDecimalFromBigDecimal((BigDecimal) pos.get_Value("MaximumDailyRefundAllowed")))
.setMaximumDiscountAllowed(ValueUtil.getDecimalFromBigDecimal((BigDecimal) pos.get_Value("MaximumDiscountAllowed")))
.setWriteOffAmountTolerance(ValueUtil.getDecimalFromBigDecimal((BigDecimal) pos.get_Value("WriteOffAmtTolerance")));
if(!pos.get_ValueAsBoolean("IsAllowsAllocateSeller")) {
builder
.setIsAllowsModifyQuantity(pos.get_ValueAsBoolean("IsAllowsModifyQuantity"))
.setIsAllowsReturnOrder(pos.get_ValueAsBoolean("IsAllowsReturnOrder"))
.setIsAllowsCollectOrder(pos.get_ValueAsBoolean("IsAllowsCollectOrder"))
.setIsAllowsCreateOrder(pos.get_ValueAsBoolean("IsAllowsCreateOrder"))
.setIsDisplayTaxAmount(pos.get_ValueAsBoolean("IsDisplayTaxAmount"))
.setIsDisplayDiscount(pos.get_ValueAsBoolean("IsDisplayDiscount"))
.setIsAllowsConfirmShipment(pos.get_ValueAsBoolean("IsAllowsConfirmShipment"))
.setMaximumRefundAllowed(ValueUtil.getDecimalFromBigDecimal((BigDecimal) pos.get_Value("MaximumRefundAllowed")))
.setMaximumDailyRefundAllowed(ValueUtil.getDecimalFromBigDecimal((BigDecimal) pos.get_Value("MaximumDailyRefundAllowed")))
.setMaximumDiscountAllowed(ValueUtil.getDecimalFromBigDecimal((BigDecimal) pos.get_Value("MaximumDiscountAllowed")))
.setWriteOffAmountTolerance(ValueUtil.getDecimalFromBigDecimal((BigDecimal) pos.get_Value("WriteOffAmtTolerance")));
.setIsConfirmCompleteShipment(pos.get_ValueAsBoolean("IsConfirmCompleteShipment"))
.setIsAllowsAllocateSeller(pos.get_ValueAsBoolean("IsAllowsAllocateSeller"))
.setIsAllowsConcurrentUse(pos.get_ValueAsBoolean("IsAllowsConcurrentUse"))
.setIsAllowsCashOpening(pos.get_ValueAsBoolean("IsAllowsCashOpening"))
.setIsAllowsCashClosing(pos.get_ValueAsBoolean("IsAllowsCashClosing"))
.setIsAllowsCashWithdrawal(pos.get_ValueAsBoolean("IsAllowsCashWithdrawal"));
} else { // Get from user
PO userAllocated = getUserAllowed(pos.getCtx(), pos.getC_POS_ID(), Env.getAD_User_ID(pos.getCtx()), null);
if(userAllocated != null
&& userAllocated.get_ID() > 0) {
// Get from user access
builder
.setIsAllowsModifyQuantity(userAllocated.get_ValueAsBoolean("IsAllowsModifyQuantity"))
.setIsAllowsReturnOrder(userAllocated.get_ValueAsBoolean("IsAllowsReturnOrder"))
.setIsAllowsCollectOrder(userAllocated.get_ValueAsBoolean("IsAllowsCollectOrder"))
.setIsAllowsCreateOrder(userAllocated.get_ValueAsBoolean("IsAllowsCreateOrder"))
.setIsDisplayTaxAmount(userAllocated.get_ValueAsBoolean("IsDisplayTaxAmount"))
.setIsDisplayDiscount(userAllocated.get_ValueAsBoolean("IsDisplayDiscount"))
.setIsAllowsConfirmShipment(userAllocated.get_ValueAsBoolean("IsAllowsConfirmShipment"))
.setIsConfirmCompleteShipment(userAllocated.get_ValueAsBoolean("IsConfirmCompleteShipment"))
.setIsAllowsAllocateSeller(userAllocated.get_ValueAsBoolean("IsAllowsAllocateSeller"))
.setIsAllowsConcurrentUse(userAllocated.get_ValueAsBoolean("IsAllowsConcurrentUse"))
.setIsAllowsCashOpening(userAllocated.get_ValueAsBoolean("IsAllowsCashOpening"))
.setIsAllowsCashClosing(userAllocated.get_ValueAsBoolean("IsAllowsCashClosing"))
.setIsAllowsCashWithdrawal(userAllocated.get_ValueAsBoolean("IsAllowsCashWithdrawal"));
}
}
if(pos.get_ValueAsInt("RefundReferenceCurrency_ID") > 0) {
builder.setRefundReferenceCurrency(ConvertUtil.convertCurrency(MCurrency.get(Env.getCtx(), pos.get_ValueAsInt("RefundReferenceCurrency_ID"))));
}
Expand Down Expand Up @@ -3871,6 +3901,21 @@ private PointOfSales.Builder convertPointOfSales(MPOS pos) {
return builder;
}

/**
* Validate if is allowed user
* @param context
* @param userId
* @param transactionName
* @return
*/
public static PO getUserAllowed(Properties context, int posId, int userId, String transactionName) {
return new Query(context, "C_POSSellerAllocation", "C_POS_ID = ? AND SalesRep_ID = ?", transactionName)
.setParameters(posId, userId)
.setOnlyActiveRecords(true)
.setClient_ID()
.first();
}

/**
* Create Order from request
* @param context
Expand Down
4 changes: 4 additions & 0 deletions src/main/proto/point_of_sales.proto
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,10 @@ message PointOfSales {
Decimal write_off_amount_tolerance = 35;
bool is_allows_allocate_seller = 36;
bool is_allows_concurrent_use = 37;
bool is_confirm_complete_shipment = 38;
bool is_allows_cash_closing = 39;
bool is_allows_cash_opening = 40;
bool is_allows_cash_withdrawal = 41;
}

// Request for create a order
Expand Down

0 comments on commit aed86e8

Please sign in to comment.