All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.beigesoft.acc.srv.RvPuGdLn Maven / Gradle / Ivy

Go to download

It consists of double entry accounting and trading (web-store) business logic. It's based on previous beigesoft-accounting and beigesoft-webstore projects.

The newest version!
/*
BSD 2-Clause License

Copyright (c) 2019, Beigesoft™
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.beigesoft.acc.srv;

import java.util.List;
import java.util.Map;
import java.util.Arrays;
import java.math.BigDecimal;

import org.beigesoft.exc.ExcCode;
import org.beigesoft.mdl.CmnPrf;
import org.beigesoft.hld.HldUvd;
import org.beigesoft.rdb.IOrm;
import org.beigesoft.rdb.IRdb;
import org.beigesoft.srv.II18n;
import org.beigesoft.acc.mdlb.APrep;
import org.beigesoft.acc.mdlb.APaym;
import org.beigesoft.acc.mdlp.PaymTo;
import org.beigesoft.acc.mdlp.PrepTo;
import org.beigesoft.acc.mdlp.PurInv;
import org.beigesoft.acc.mdlp.PuInGdLn;

/**
 * 

Reverser for purchase good invoice line.

* * @param platform dependent record set type * @author Yury Demidenko */ public class RvPuGdLn implements IRvInvLn { /** *

Database service.

**/ private IRdb rdb; /** *

ORM service.

**/ private IOrm orm; /** *

Warehouse entries service.

**/ private ISrWrhEnr srWrhEnr; /** *

Holder UVD settings, vars.

*/ private HldUvd hldUvd; /** *

I18N service.

*/ private II18n i18n; /** *

Retrieves and checks lines for reversing, * e.g. for purchase goods lines it checks for withdrawals.

* @param pRvs Request scoped variables, not null * @param pVs Invoker scoped variables, not null * @param pEnt reversed invoice, not null * @return checked lines * @throws Exception - an exception **/ @Override public final List retChkLns(final Map pRvs, final Map pVs, final PurInv pEnt) throws Exception { String[] lstFds = this.hldUvd.lazLstFds(PuInGdLn.class); String[] ndFds = Arrays.copyOf(lstFds, lstFds.length); Arrays.sort(ndFds); pVs.put("PuInGdLnndFds", ndFds); pVs.put("PuInGdLndpLv", 1); List lst = this.orm.retLstCnd(pRvs, pVs, PuInGdLn.class, "where PUINGDLN.RVID is null and PUINGDLN.OWNR=" + pEnt.getIid()); pVs.clear(); for (PuInGdLn gl : lst) { if (gl.getQuan().compareTo(gl.getItLf()) == 1) { throw new ExcCode(ExcCode.WRPR, "where_is_withdraw"); } } return lst; } /** *

Reverses lines. * it also inserts reversing and updates reversed * for good it also makes warehouse reversing. * It removes line tax lines.

* @param pRvs Request scoped variables, not null * @param pVs Invoker scoped variables, not null * @param pEnt reversed invoice, not null * @param pRvng reversing line, not null * @param pRved reversed line, not null * @throws Exception - an exception **/ @Override public final void revLns(final Map pRvs, final Map pVs, final PurInv pEnt, final PuInGdLn pRvng, final PuInGdLn pRved) throws Exception { this.rdb.delete("PUINGDTXLN", "OWNR=" + pRved.getIid()); CmnPrf cpf = (CmnPrf) pRvs.get("cpf"); pRvng.setWrhp(pRved.getWrhp()); StringBuffer sb = new StringBuffer(); if (pRvng.getDscr() != null) { sb.append(pRvng.getDscr() + " !"); } sb.append(getI18n().getMsg("reversed", cpf.getLngDef().getIid())); sb.append(" #" + pRved.getDbOr() + "-" + pRved.getIid()); pRvng.setDscr(sb.toString()); this.orm.insIdLn(pRvs, pVs, pRvng); this.srWrhEnr.revLoad(pRvs, pRvng); sb.delete(0, sb.length()); if (pRved.getDscr() != null) { sb.append(pRved.getDscr() + " !"); } sb.append(getI18n().getMsg("reversing", cpf.getLngDef().getIid())); sb.append(" #" + pRvng.getDbOr() + "-" + pRvng.getIid()); pRved.setDscr(sb.toString()); pRved.setRvId(pRvng.getIid()); pRved.setItLf(BigDecimal.ZERO); pRved.setToLf(BigDecimal.ZERO); String[] ndFds = new String[] {"dscr", "itLf", "rvId", "toLf", "ver"}; Arrays.sort(ndFds); pVs.put("ndFds", ndFds); this.orm.update(pRvs, pVs, pRved); pVs.clear(); } /** *

Getter for prepayment class.

* @return Prepayment class **/ @Override public final Class getPrepCls() { return PrepTo.class; } /** *

Getter for payment class.

* @return payment class **/ @Override public final Class> getPaymCls() { return PaymTo.class; } //Simple getters and setters: /** *

Getter for orm.

* @return IOrm **/ public final IOrm getOrm() { return this.orm; } /** *

Setter for orm.

* @param pOrm reference **/ public final void setOrm(final IOrm pOrm) { this.orm = pOrm; } /** *

Getter for srWrhEnr.

* @return ISrWrhEnr **/ public final ISrWrhEnr getSrWrhEnr() { return this.srWrhEnr; } /** *

Setter for srWrhEnr.

* @param pSrWrhEnr reference **/ public final void setSrWrhEnr(final ISrWrhEnr pSrWrhEnr) { this.srWrhEnr = pSrWrhEnr; } /** *

Getter for hldUvd.

* @return HldUvd **/ public final HldUvd getHldUvd() { return this.hldUvd; } /** *

Setter for hldUvd.

* @param pHldUvd reference **/ public final void setHldUvd(final HldUvd pHldUvd) { this.hldUvd = pHldUvd; } /** *

Geter for rdb.

* @return IRdb **/ public final IRdb getRdb() { return this.rdb; } /** *

Setter for rdb.

* @param pRdb reference **/ public final void setRdb( final IRdb pRdb) { this.rdb = pRdb; } /** *

Getter for i18n.

* @return II18n **/ public final II18n getI18n() { return this.i18n; } /** *

Setter for i18n.

* @param pI18n reference **/ public final void setI18n(final II18n pI18n) { this.i18n = pI18n; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy